Properties

Component properties are values which can be modified to change the behaviour or appearance of a component. Their values are automatically stored when saving the circuit document. Examples of properties include:

  • Resistance of a resistor
  • Voltage of a supply
  • Type of diode e.g. zener, led etc.

When using configurations (described later), you will often use a property to determine which configuration is in use.

Types

There are different types of properties:

  • string - stores plain text
  • int - stores an integer value
  • decimal - stores a decimal value
  • bool - stores a boolean value (true or false)
  • enum - stores a choice between a set of predetermined string values

Property tags are placed within the <declaration> tag of the XML file, and have the following attributes:

  • name - the name of the property as it is referred to in the component file
  • type - the type of property (int, decimal, bool or enum)
  • default - the value that the property is initialized to when the component is created
  • serialize - the key used when saving the property in a circuit document
  • display - the name that is presented to the user

Attributes

All of the above attributes are required for properties.

The name and serialize values must be alphanumeric with no spaces, starting with a letter

  • Resistance is valid
  • Component resistance is not valid
  • 1Resistance is not valid
  • My-property! is not valid

Enums

If the property is an enum, the options for the enum are placed within the <property> tag inside <option> tags.

For example, the following is the property which is used to determine which type of resistor to display:

<property name="Type" type="enum" default="Standard" serialize="t" display="Type">
<option>Standard</option>
<option>Potentiometer</option>
<option>LDR</option>
<option>Thermistor</option>
<option>Variable</option>
</property>

Formatting

When rendering the component (described later), you will often want to display the value of a property, such as the resistance of a resistor or the voltage of a rail. To determine how the property is displayed, the <formatting> tag is used inside the <property> tag.

The <formatting> tag contains one or more <format> tags, which have the <value> attribute which determines the formatting. The syntax is described below.

Property Values

To display a property value, preceed the property name with a dollar symbol and follow it with a space.

The space is removed, so to show a space in the output after a property value, two spaces are required in the syntax.

Example: the value is $property for some property becomes the value is 100 for some property.

Unicode Characters

Unicode characters (e.g. Ω) can be inserted using the syntax \u0000 where the four zeros are the unicode value for that character.

Example: 20\u2126 becomes 20Ω.

Mathematical Operations

Operations can be placed after a property to modify int and decimal values.

There should not be a space between the property name and the operator which follows it.

  • (div_X) - divide the preceding value by X
  • (round_X) - round the preceding value to X number of decimal places

These operations can be chained so that the following would return the Resistance property divided by 1000 and then rounded to 1 decimal place:

$Resistance(div_1000)(round_1)

Other Strings

Other strings are treated as text and are not modified.