=====Value Objects===== ValueObjects (Value Objects) are the basic containers of data in MIStudio/MIX and TransSECS applications. Value objects are transferred between servers, manipulators, and graphics in MIStudio through Connections (wired or managed). Value Objects will appear in TransSECS when you configure the Data Items you use for SECS/GEM messages. Value Objects are automatically created by all Data Sources when a new data value is generated. A Value Object contains, at the very minimum these properties: the Data "value", a Quality, a Timestamp, and a Color. In scripts these ValueObjects are generally accessed as the incomingValue and the values you get or send to data sources in the project. More information on using ValueObjects in scripts can be found here: [[incomingvalue_and_server_values|Incoming Values and Server Values in Scripts]] ====Value Object Properties==== ===The Value=== The Data Value of a Value Object is stored in the Value Object a basic type: either as a Double Value Object (integers, longs, booleans), a Double Value Object (floats, double), or a String Value Object. The Array Value Object (AVO) contains an array of Value Objects (of any type). Two Dimensional Value Objects (2DVOs) are array of arrays. These are used in data sources (and graphics in MIStudio/MIX) which read databases for graph data or for tables. More details on different types of ValueObjects is detailed below under Value Object Types. In scripts the value of the ValueObject is accessed using getXXXXValue(), where XXXXX is the data type (Long,Float,Double,Int,Boolean, etc.), and can be set in a similar manner, setXXXXValue(). If you look for articles on using javascript or scripting in this wiki you will find many examples of getting and setting ValueObject values. ===The Quality=== The Value Object also contains a "Quality ". Graphics in MIStudio will be displayed with an overlaid marker if the quality of the incoming value object does not pass its "good" quality metrics. The Property Filter manipulator can be used to wash or change the quality of the Value Object. In a script you can change the quality using setQuality() and obtain the quality using getQuality(). Here is an article which goes into more detail on data quality: [[valueobject_qualities|Value Object Qualities]] ===The Timestamp=== When the value object is created (when a PLC driver reads the data, when a database bean gets the data from the database, etc.) the time is recorded in the Value Object as its Timestamp. Historical log data, from a database, will have a Timestamp assigned to it corresponding to its reading time stored in the database. The Timestamp of the data can be used in the Date/Time manipulator beans to display the time. For example, the Synchronized Clock Tick generates values of alternating 0 and 1, but the Timestamp from the Value Object can be used to display the time using a Generic Date Formatter or to extract a particular date item using the Date Info manipulator. In this case it is not the data value that is used by the Date Info, but its timestamp. ===Color=== The color property of a ValueObject is mainly used in MIStudio/MIX graphics. It can be set when a DataSource generates the ValueObject by setting the server's "Send Colors?" property to true (it defaults to false). If this property is set then the color property of the generated Value Object will be set according to the color ranges set in the expert properties of the bean. For Boolean data sources, this is only two colors (one for true and one for false). For analog data sources the colors and ranges of data values can be set to five specific colors. The color of a ValueObject can be set programmatically in a script using setColor(), and its current value obtained using getColor(). =====Value Object Types==== === Long Value Object (LongValueObject) === The LongValueObject can be created from any integer-type value, including boolean,byte, short, integer, and long. [[longvalueobjects|Long Value Objects]] === Real Types === Real type Value Objects are [[doublevalueobject|Double Value Objects]]. These can store any size floating point numbers. === String Value Object === A StringValueObject contains a String value. Only Strings are stored, so in scripting only getStringValue() can be used to access its value. If you use setXXXXValue() on a StringValueObject you will be converting a numeric data type to a String (and will normally store two decimal places for a real number unless you first convert the real to a string with more decimal places). [[stringvalueobjects|String Value Object]] === Array Types === There are two Array type ValueObjects: ArrayValueObject and TwoDimensionalValueObject. [[ArrayValueObjects|Array Value Objects]] [[TwoDValueObjects|Two Dimensional Value Objects]] ==== Other Types ==== [[daterangevalueobject|Date Range Value Object]] is a ValueObject which contains a date range (two dates, a start date and an end date). [[binaryvalueobjects|Binary Value Object]] is a ValueObject which contains a byte array (byte[])