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.
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 (
enum- stores a choice between a set of predetermined string values
Property tags are placed within the
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
All of the above attributes are required for properties.
serialize values must be alphanumeric with no spaces, starting with a letter
Component resistanceis not valid
1Resistanceis not valid
My-property!is not valid
If the property is an enum, the options for the enum are placed within the
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>
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
<formatting> tag contains one or more
<format> tags, which have the
<value> attribute which determines the formatting. The syntax is described below.
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.
the value is $property for some property becomes
the value is 100 for some property.
Unicode characters (e.g. Ω) can be inserted using the syntax
\u0000 where the four zeros are the unicode value for that character.
20\u2126 becomes 20Ω.
Operations can be placed after a property to modify
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:
Other strings are treated as text and are not modified.