Forum

BatteryStatus + AvoidNILS Plugins. feedback?

hello
i’m not a programmer or so… but i made these plugins, one might could improve them.

i made the AvoidNILPlugin’s just in order to save some ticks/performance… basically they do the same as kalles AvoidNIL’s but they seem a bit faster.

the idea from the batterystatus plugin i’ve stole from sunep. he had this plugin running on his laptop, i think he said u7angel made it for him. and as gregsn showed at the keynode at the node10, it became very simple to work with any dll, so i just implemented it by myself, because i found this feature very useful. now i put it here. i hope it comes in handy.

i would be happy to have some feedback… whether it works or not…
just drop them into your plugins-folder, the help patch is included.

thanks
aivenhoe

AvoidNILPlugin_ColorStringValue.zip (13.0 kB)
BatteryStatus.zip (4.1 kB)

powerstate(battery) is already part of the addon pack…

oh. well…

as you see, the AvoidNIL code is the same for each type, only the type of the pins is different. the code in Evaluate is not type specific, it just handles the pin data. this is a very nice example for generics. you would create one ‘template’ class with a type parameter which does the data handling and then create the nodes for each type with just 3 lines:

code(csharp):

public class AvoidNILPlugin : IPluginEvaluate
{
#region fields & pins

  [Input("Input")](Input("Input"))
  ISpread<T> FInput;

  [Input("Default")](Input("Default"))
  ISpread<T> FInput2;

  [Output("Output")](Output("Output"))
  ISpread<T> FOutput;

  #endregion fields & pins

  //called when data for any output pin is requested
  public void Evaluate(int SpreadMax)
  {
  	if (FInput.SliceCount > 0) 
  	{
  		FOutput.SliceCount = FInput.SliceCount;
  		for (int i = 0; i < FInput.SliceCount; i++)
  			FOutput[i](i) = FInput[i](i);
  	} 
  	else 
  	{
  		FOutput.SliceCount = FInput2.SliceCount;
  		for (int i = 0; i < FInput2.SliceCount; i++)
  			FOutput[i](i) = FInput2[i](i);
  	}
  }

}

#region PluginInfo
[PluginInfo(Name = “AvoidNILPlugin”, Category = “Value”, Help = “Replaces an empty value spread with a default value”, Tags = “empty”, Author = “aivenhoe”)](PluginInfo(Name = “AvoidNILPlugin”, Category = “Value”, Help = “Replaces an empty value spread with a default value”, Tags = “empty”, Author = “aivenhoe”))
#endregion PluginInfo
public class AvoidNILValue: AvoidNILPlugin
{
}

#region PluginInfo
[PluginInfo(Name = “AvoidNILPlugin”, Category = “Color”, Help = “Replaces an empty color spread with a default color”, Tags = “empty”, Author = “aivenhoe”)](PluginInfo(Name = “AvoidNILPlugin”, Category = “Color”, Help = “Replaces an empty color spread with a default color”, Tags = “empty”, Author = “aivenhoe”))
#endregion PluginInfo
public class AvoidNILColor: AvoidNILPlugin
{
}

#region PluginInfo
[PluginInfo(Name = “AvoidNILPlugin”, Category = “String”, Help = “Replaces an empty string spread with a default string”, Tags = “empty”, Author = “aivenhoe”)](PluginInfo(Name = “AvoidNILPlugin”, Category = “String”, Help = “Replaces an empty string spread with a default string”, Tags = “empty”, Author = “aivenhoe”))
#endregion PluginInfo
public class AvoidNILString: AvoidNILPlugin
{
}

#region PluginInfo
[PluginInfo(Name = “AvoidNILPlugin”, Category = “Transform”, Help = “Replaces an empty transformation spread with a default transformation”, Tags = “empty”, Author = “aivenhoe”)](PluginInfo(Name = “AvoidNILPlugin”, Category = “Transform”, Help = “Replaces an empty transformation spread with a default transformation”, Tags = “empty”, Author = “aivenhoe”))
#endregion PluginInfo
public class AvoidNILTransform: AvoidNILPlugin
{
}

//… and so on