Forum

PinAttributes: NIL as default value?

hi,

a question regarding plugin developement:
is it possible to set a pin to a default value of NIL?

something like that:

[Output("Output", DefaultValue = NIL)](Output("Output", DefaultValue = NIL))
ISpread<double> FOutput;

for now i’m doing it by setting SliceCount = 0 , but this feels a little clumsy…

thanks

hei motzi, setting SliceCount=0 is exactly what NIL is about. NIL is not a special value in slice 0. it actually means that there are 0 slices.

yes, i am aware of that. the question is: can a slicecount of 0 be set via PinAttribute?

no… no text …

allright, thanks for the clarification!

i’d find this a handy feature though :)

just for documentation:
@velcrome)) shows a way how to set an initial slicecount of zero in his ((contribution:teensy3.0octows2811-led-control contribution plugins, which does not clutter the evaluate method. by implementing the IPartImportsSatisfiedNotification interface and the OnImportsSatisfied method, you get a method that is run once at plugin initialisation.

public class ValuetestNode : IPluginEvaluate, IPartImportsSatisfiedNotification
	{
		#region fields & pins
		[Input("Input", DefaultValue = 1.0)](Input("Input", DefaultValue = 1.0))
		public ISpread<double> FInput;

		[Output("Output")](Output("Output"))
		public ISpread<double> FOutput;

		[Import()](Import())
		public ILogger FLogger;
		#endregion fields & pins

		public void OnImportsSatisfied()
		{
			//start with an empty stream output
			FOutput.SliceCount = 0;
		}	
		
		//called when data for any output pin is requested
		public void Evaluate(int SpreadMax)
		{
			
			...
		}
	}

thanks @velcrome!