Working With Properties for UDO (2d and Circuit)

A property is the unit for collecting and using input on the user that is used to influence the UDO’s Compute method. These are initially set up when the UDOs GetInputUDSParams method is called and are retrieved in the compute method.

There are 3 supported property types that could be used in the UDO script:

The IPropertyList type implements a collection for these properties.

IPropertyList Abstract class

IProperty Abstract class

INumberProperty Abstract class

ITextProperty Abstract class

IMenuProperty Abstract class

Related Topics:

user-defined Outputs: Python Script API

IPropertyList Abstract Class (2D and Circuit)

Attributes:

  • AllProperties (IEnumerable<IProperty>)
  • NumProperties (int)

Functions:

  • GetProperty(string propName): Returns a named property as an IProperty.
  • GetMenuProperty (string propName): Returns the named property as an IMenuProperty.
  • GetTextProperty (string propName): Returns the named property as an ITextProperty
  • GetNumberProperty (string propName): Returns the named property as an INumberProperty
  • DeleteProperty (string propName): Deletes an already added named property
  • AddNumberProperty(string name, string numberWithUnits): Adds a new number property. If a property with the same name already exists, it is overwritten.
  • AddTextProperty(string name, string textValue): Adds a new named text property with the supplied value. Any existing property with the same name is overwritten.
  • AddMenuProperty(string name, IList<string> menuChoices): Creates a new named menu property with the supplied list of choices. The default selection is set to item 0 (the first item). Any property with the same name is overwritten.

IProperty Abstract Class (2D and Circuit)

Attributes:

  • Name (string)
  • Description (string)
  • PropType (read-only EPropType – see Constants)

Constructor:

  • IProperty(string name, EPropType type)

The class is used as base class for INumberProperty, IMenuProperty, and ITextProperty.

INumberProperty Abstract Class (2D and Circuit)

Base class:

  • abstract class IProperty

Attributes:

  • ValueSI (read-only double)
  • ValueInUnits (read-only double)
  • Units (read-only string)
  • HasUnits (read-only bool)

Constructor:

  • INumberProperty(string name)

Functions:

  • Set(string numberWithUnits)
  • SetDouble(double number, string unitString)

ITextProperty Abstract Class (2D and Circuit)

Base class:

  • abstract class IProperty

Attributes:

  • Text (string)

Constructor:

  • ITextProperty(string name)

IMenuProperty Abstract Class (2D and Circuit)

Base class:

  • abstract class IProperty

Attributes:

  • MenuSelection (int): This represents the index into the MenuChoices list.
  • SelectedMenuChoice (string): This is the item in the MenuChoices list corresponding to the MenuSelection index
  • MenuChoices (IList<string>)

Constructor:

  • IMenuProperty (string name)

Example:

# adding data to IPropertyList propList; used in Compute function

prop = propList.AddNumberProperty('Offset 1', '0')

prop.Description = 'Trace 1 Offset'

prop = propList.AddNumberProperty(“TRATE”, "800 MHz")

prop.Description = "Frequency"

prop = propList.AddTextProperty(“Text”, “The Text”)

prop.Description = "Text Property"

prop = propList.AddMenuProperty('Operation', ['Add', 'Subtract', 'Max' ,'Min','Mean'])

prop.Description = 'Operation menu’

# reading data from IPropertyList propList; used in Validate function

numOfNumberProperties = 0

if propList != None and propList.AllProperties != None:

for prop in propList.AllProperties:

if prop.PropType == Constants.EPropType.PT_NUMBER:

numOfNumberProperties ++