BigNumber Type
BigNumber instances can be created to handle properties whose type may require large integers (for example, 64-bit unsigned integers).
Javascript represents numbers using IEEE-754 double precision. Consequently, if the value cannot be handled with double precision it is necessary to use BigNumber instances.
Syntax
It is possible to create BigNumber instances in Desigo CC. See the following syntax:
var bigNumber = new BigNumber(<largeInteger>);
Parameter Usage
Parameter | Type | Default | Use | Annotation |
largeInteger | Integer String | - | Mandatory | A large integer represented by:
|
Error Handling
Errors can occur in case:
- The
<largeInteger>
provided is null, empty or invalid.
Datapoint name or CNS full path does not identify an object in the system.
Examples of Use
How to write and read 64-bit properties using BigNumber instances
var objects = [
"System1.ApplicationView:ApplicationView.Logics.VirtualObjects.integer64",
"System1.ApplicationView:ApplicationView.Logics.VirtualObjects.unsigned64",
"System1.ApplicationView:ApplicationView.Logics.VirtualObjects.bitstring64"];
var propertiesValues = [
new BigNumber("9223372036854775807"), //integer64 - max int64
new BigNumber("18446744073709551615"), /unsigned64 - max uint 64
new BigNumber("18446744073709551615") //bitstring64 - max uint64
];
for (var i = 0; i < objects.length; i++)
{
console("\n---------- {0} -------------", objects[i]);
commandProperty(objects[i], propertiesValues[i]);
readPropertyValue(objects[i]);
}
function commandProperty(obj, val)
{
console("\n--- Commanding {0} ---", obj);
console("Value to write: {0}", val);
var result = executePropertyCommand(obj, "Value", "Write", val);
if (result.error)
{
console("Error commanding {0}, value = {1}: {2}", obj, val, result.error);
return;
}
}
function readPropertyValue(obj)
{
console("\n--- Reading {0} ---", obj);
var objPropertyValue = read(obj, "Value");
if (objPropertyValue.error)
{
console("Error reading {0}: {1}", obj, objPropertyValue.error);
return;
}
console(objPropertyValue.value);
console("Min = {0} - Max = {1}", objPropertyValue.min, objPropertyValue.max);
}