createvalueobjectscripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
createvalueobjectscripts [2020/09/22 09:24]
wikiadmin
createvalueobjectscripts [2021/10/11 19:27] (current)
wikiadmin
Line 1: Line 1:
-==== Creating VIB ValueObjects in Scripts ====+===== Creating VIB ValueObjects in Scripts =====
  
 Value Objects are the most common variable type within MIStudio and TransSECS.  A ValueObject contains not only the value, but also the type, the quality and the timestamp of the value. Value Objects are the most common variable type within MIStudio and TransSECS.  A ValueObject contains not only the value, but also the type, the quality and the timestamp of the value.
Line 43: Line 43:
 </code> </code>
  
-**Booleans**+====Setting Value Object values==== 
 + 
 +To set a value to a server (DataSource) in scripting, use set[ValueObjectType]Value(number or String). Note that the Server must be a "Manipulator" which has an input. 
 + 
 +For example: 
 + 
 + 
 +<code JavaScript> 
 +//set a Double (float) to a named Server 
 +BroadcastServer->setDoubleValue(42.01); 
 +</code> 
 + 
 +Other set methods are for Int,Long,Boolean,Float,String, etc. 
 + 
 +<code JavaScript> 
 +BroadcastServer->setLongValue(655031340); 
 +BroadcastServer->setStringValue("Hello"); 
 +BroadcastServer->setFloatValue(1.3); 
 +BroadcastServer->setBoolValue(true); 
 +</code> 
 + 
 +You can also use variables for the data. 
 + 
 +<code JavaScript> 
 +var pi=java.lang.Math.PI; 
 +BroadcastServer->setDoubleValue(pi); 
 +</code> 
 + 
 +===Booleans===
  
 <code JavaScript> <code JavaScript>
Line 51: Line 79:
 ''**getBoolValue()**'' will return false if the value is zero, otherwise it will return true.  For //StringValueObjects// if the value is numeric, the same rule applies.  If the value is ''"true"'' or ''"yes"'' regardless of the case (upper or lower) then the call will return true.  If the value is ''"false"'' or ''"no"'' the call will return false.  If none of these apply, the method will throw an exception. ''**getBoolValue()**'' will return false if the value is zero, otherwise it will return true.  For //StringValueObjects// if the value is numeric, the same rule applies.  If the value is ''"true"'' or ''"yes"'' regardless of the case (upper or lower) then the call will return true.  If the value is ''"false"'' or ''"no"'' the call will return false.  If none of these apply, the method will throw an exception.
  
-**Value Timestamp**+===Value Timestamp===
  
 <code JavaScript> <code JavaScript>
Line 65: Line 93:
 Will return the time in milliseconds since Jan 01 1970.  This is useful for time arithmetic. Will return the time in milliseconds since Jan 01 1970.  This is useful for time arithmetic.
  
-**Data Quality**+===Data Quality===
  
 ValueObjects always have a quality associated with them.  The quality is an integer value. ValueObjects always have a quality associated with them.  The quality is an integer value.
Line 82: Line 110:
 </code> </code>
  
-**Complex Types - Arrays and Tables**+====Complex Types - Arrays and Tables====
  
 One dimensional arrays are stored in //"ArrayValueObjects"// Two dimensional arrays, such as tables, are stored in //"TwoDimensionalValueObjects"//. One dimensional arrays are stored in //"ArrayValueObjects"// Two dimensional arrays, such as tables, are stored in //"TwoDimensionalValueObjects"//.
Line 104: Line 132:
 </code> </code>
  
 +====Create a TwoDimensionalValueObject====
  
-**Create a TwoDimensionalValueObject**. TwoDVOs are used most often for tables and multi-line graphs.+TwoDVOs are used most often for tables and multi-line graphs.
  
 <code JavaScript> <code JavaScript>
Line 161: Line 190:
 </code> </code>
  
-**JavaScript JSON**+====JavaScript JSON====
  
 TransSECS devices will often use JSON to represent lists.  Here's an example of a recipe list. TransSECS devices will often use JSON to represent lists.  Here's an example of a recipe list.
Line 175: Line 204:
 <code javascript> <code javascript>
 JSON.parse(json); JSON.parse(json);
-<code>+</code>
  
 Examples of converting from a Javascript object to Java types are available [[https://codereview.stackexchange.com/questions/90272/java-json-parsing-with-the-nashorn-api|here]]. Examples of converting from a Javascript object to Java types are available [[https://codereview.stackexchange.com/questions/90272/java-json-parsing-with-the-nashorn-api|here]].
  
  
  • createvalueobjectscripts.1600784656.txt.gz
  • Last modified: 2020/09/22 09:24
  • by wikiadmin