is AutoEvaluate on if the plugin only evaluates when an output is requested?
or is it the other way around?
More importantly, what’s the easiest way to make a plugin always evaluate if there are no outputs in PluginInterfaces2? (default behaviour being only evaluate when output requested)
public class test : IPlugin
{
public bool AutoEvaluate
{
get { throw new NotImplementedException(); }
}
public void Configurate(IPluginConfig input)
{
throw new NotImplementedException();
}
public void Evaluate(int SpreadMax)
{
throw new NotImplementedException();
}
public void SetPluginHost(IPluginHost Host)
{
throw new NotImplementedException();
}
}
public class test : IPluginEvaluate
{
public void Evaluate(int SpreadMax)
{
throw new NotImplementedException();
}
}
#region PluginInfo
[PluginInfo(Name = "Beep", Category = "System", Help = "Basic template with one value in/out", Tags = "")](PluginInfo(Name = "Beep", Category = "System", Help = "Basic template with one value in/out", Tags = ""))
#endregion PluginInfo
public class SystemBeepNode : IPlugin
{
#region fields & pins
[Input("Input", IsBang=true, IsSingle=true)](Input("Input", IsBang=true, IsSingle=true))
ISpread<bool> FInput;
[Import()](Import())
ILogger FLogger;
#endregion fields & pins
//called when data for any output pin is requested
public void Evaluate(int SpreadMax)
{
if (FInput[0](0))
System.Media.SystemSounds.Beep.Play();
}
public bool AutoEvaluate
{
get { return true; }
}
public void Configurate(IPluginConfig input)
{
}
public void SetPluginHost(IPluginHost Host)
{
}
}
}
IPlugin is the old interface used in V1, while IPluginEvaluate is the new interface used in V2 which requires you less methods to implement.
AutoEvaluate == true → Evaluate is called every frame.
AutoEvaluate == false → Evaluate is only called if a downstream node requests data.
In V1 auto evaluation] is set explicitly via the interface IPlugin.
In V2 auto evaluation] is set via the PluginInfo attribute. By default auto evaluation is disabled.
So your example can be written like this (shorter as you see):
[PluginInfo(Name = "Beep", Category = "System", AutoEvaluate = true)](PluginInfo(Name = "Beep", Category = "System", AutoEvaluate = true))
public class SystemBeepNode : IPluginEvaluate
{
[Input("Input", IsBang=true, IsSingle=true)](Input("Input", IsBang=true, IsSingle=true))
//called every frame because AutoEvaluate == true (see above)
public void Evaluate(int SpreadMax)
{
if (FInput[0](0))
System.Media.SystemSounds.Beep.Play();
}
}