A major source of errors in embedded software is incorrect application of units. Yuhong Xiong and Xiaojun Liu have created a unit system for Ptolemy II that is quite clever. A suite of constants are defined, with names such as "meter", "cm", "feet", "miles", "seconds", "hours", and "days". In each unit category ("length" or "time" for example), there is a primary unit with respect to which all the others are specified. Thus, for example, if the primary unit of length is meters, then the expression "1.0 * cm" will have an internal value of 0.01 * meters. Compound units are specified by just multiplying and dividing, as in for example "1.0 * cm/second".
The way this is realized is that these unit constants are tokens just like other Ptolemy II data, and multiplication and division are overloaded in the base classes for numeric valued tokens. We continue to work on this architecture to enable users to customize the unit system on a per-model basis.
The block diagram for the model was constructed using the Ptolemy II schematic editor called Vergil.