com.ergotech.vib.valueobjects.LongValueObject

Description

The Long Value Object (sometimes referred to as “LVO”) is a type of Value Object which is used to hold a whole number (non-floating point). This includes the java types boolean, byte, short, integer, and long, in order of byte size.

Some manipulators will take any numeric input and generate a Long Value Object output. For example, Round, Floor, and Ceiling will all generate a Long Value Object output from either decimal or non-decimal numeric inputs. PLC servers of the Int type will produce LongValueObjects.

If you need Long Value Objects for testing, you can use the Increment Server (IncrementServer), Extreme Server (ExtremeServer), Synchronized Clock Tick (SynchronizedClockTick) or Random Boolean (RandomBoolean) test Data Sources.

JavaScript Notes

Example 1: Create a Long Value Object with value “22”

var LongValueObject = Java.type("com.ergotech.vib.valueobjects.LongValueObject");
myLVO = new LongValueObject(22);

Example 2: Add two integer values from two data sources named “Value1” and “Value2”

var LongValueObject = Java.type("com.ergotech.vib.valueobjects.LongValueObject");
 
value1 = Value1 -> getLongValue();
value2 = Value2 -> getLongValue();
LVO = new LongValueObject(value1+value2);

See also the examples in this article: Creating Value Objects in Scripts

Storing a Specific Data Type

LongValueObject can store java types boolean,byte,short,int, and long. By default when a new LongValueObject is created, the type is long. To force a specific type to be stored (in case you need to return this value as a specific type), create an Long object and get the value as a specific type:

var LongValueObject = Java.type("com.ergotech.vib.valueobjects.LongValueObject");
var Long = Java.type("java.lang.Long");
 
javaLong = new Long(100);
 
//now you can get any java type for this value (if it is in range)
byteValue = javaLong.byteValue(); //java byte
shortValue = javaLong.shortValue(); //java short
longValue = javaLong.intValue(); //java int
intValue = javaLong.longValue(); //java long
 
 
//create the LongValueObject and with a specific type
vo = new LongValueObject(shortValue); //stores the value as a short in the LongValueObject
  • longvalueobjects.txt
  • Last modified: 2021/10/12 16:12
  • by wikiadmin