The following classes will be available by default in each Omnyvore script you write.
Object which acts as a proxy to access Omnyvore's big data. It can be instantiated as follows:
var bdc = new BigDataClient(topic, env);
Instances of BigDataClient expose the following interface:
getAggregatedValue(resourceId, parameterCode, timerange, aggregationOperator) : Double: given a resource id of a thing, retrieve the aggregated value for the measurements which have a given parameter code in the last timerange millisecondsgetAggregatedValue(resourceId, parameterCode, start, end, aggregationOperator) : Double: given a resource id of a thing, retrieve the aggregated value for the measurements which have a given parameter code in the time range starting at start milliseconds from UNIX epoch and ending at end milliseconds from UNIX epochgetLatestMeasurement(resourceId, parameterCode) : Measurement: given a resource id of a thing, retrieve last value for the measurements which have a given parameter codeThe available aggregation operators are
avg,count,value_count,max,min, andsum.
Caution:
topicandenvare variables available only in channel processing, so for nowBigDataClientis not recommended to be used in alarm processing.
Object with the same API as a Java's Boolean.
Object with the same API as a Java's Double.
Data object that is returned when processing alarms. EvaluationResult objects are compliant to the following JSON Schema:
{
"persist" : "boolean", // true iff the alarm has to be raised within the Omnyvore platform
"measurements" : "List<Measurement>" // List (see the class in this page) of Measurements
}
Caution: Additional fields may be found or filled, but their value is likely to be overwritten.
Object with the same API as a Java's Float.
Object which performs HTTP GET calls. It can be instantiated as follows:
var httpGet = new HttpGet(url);
Where url is the URL towards which the call will be made.
HttpGet objects have the following interface:
send: perform the HTTP GET callObject which performs HTTP POST calls. It can be instantiated as follows:
var httpPost = new HttpPost(url);
Where url is the URL towards which the call will be made.
HttpPost objects have the following interface:
addJson(json): add json as the request entityaddParam(name, value): add a name-value pair to be used as the request entitysend(): perform the HTTP POST callObject which performs HTTP PUT calls. It can be instantiated as follows:
var httpPut = new HttpPut(url);
Where url is the URL towards which the call will be made.
HttpPut objects have the following interface:
addJson(json): add json as the request entityaddParam(name, value): add a name-value pair to be used as the request entitysend(): perform the HTTP PUT callObject with the same API as a Java's Integer.
Object with the same API as a Java's ArrayList.
Object with the same API as a Java's Long.
Data object which is compliant to the following JSON Schema:
{
"name" : "string", // name of the parameter which corresponds to the processed data
"value" : "string", // measured value of the parameter
"when" : "integer" // timestamp (milliseconds from UNIX epoch)
}
Object which acts as a proxy to access Omnyvore's MQTT broker. It can be instantiated as follows:
var mqtt = new Mqtt(topic, env);
Instances of Mqtt expose the following interface:
publishOut(channel, data): given the ending part of an MQTT channel, publish a message directed to Omnyvore with data as payloadpublishOut(channel, data, retained): given the ending part of an MQTT channel, publish a message directed to Omnyvore with data as payload. If retained is true, the broker will retain the messagepublishIn(channel, data): given the ending part of an MQTT channel, publish a message directed to the thing with data as payloadpublishIn(channel, data, retained): given the ending part of an MQTT channel, publish a message directed to the thing with data as payload. If retained is true, the broker will retain the messageCaution:
topicandenvare variables available only in channel processing, so for nowMqttis not recommended to be used in alarm processing.
Object with the same API as a Java's Object.
Utils class whose methods can be used to ease several tasks:
byte2int(byte) : int: return the byte converted to an integer (not unsigned)decodeHex(hex) : byte[]: get the byte array corresponding to the decoding of the hexadecimal string hexencodeHex(byteBuffer) : String: get the textual representation of byteBuffer as an hexadecimal stringgetRange(byteBuffer, start, end) : ByteBuffer: byteBuffer is a ByteBuffer from which the bytes from the start index (inclusive) to the end index (exclusive)readBool(byteBuffer, position) : boolean: return true iff the bit at a given position of the byteBuffer is truereadUInt8(byteBuffer) : int: return the byteBuffer converted to a 8-bit integer (with little endianess)readUInt16(byteBuffer) : int: return the byteBuffer converted to a 16-bit integer (with little endianess)readUInt16BE(byteBuffer) : int: return the byteBuffer converted to a 16-bit integer (with big endianess)readUInt24(byteBuffer) : int: return the byteBuffer converted to a 24-bit integer (with little endianess)readUInt32BE(byteBuffer) : long: return the byteBuffer converted to a 32-bit integer (with big endianess)readUInt32(byteBuffer) : long: return the byteBuffer converted to a 32-bit integer (with little endianess)readUInt64(byteBuffer) : long: return the byteBuffer converted to a 64-bit integer (with little endianess)toString(byteBuffer) : String: encode byteBuffer as an UTF-8 stringData object that is returned when processing command replies. Reply objects are compliant to the following JSON Schema:
{
"correlationId" : "string", // identifier used to correlate the reply to the command sent to the thing
"payload" : "string", // text containing the payload of a reply
"measurements" : "List<Measurement>", // List (see the class in this page) of Measurements
"when" : "integer" // timestamp (milliseconds from UNIX epoch)
}
Caution: Additional fields may be found or filled, but their value is likely to be overwritten.
This type of object is injected as env and it comes with the following interface:
getProperties() : Set<String>: retrieves the set of all the properties present in the current environmentgetProperty(key): retrieves the value of a property called keyCaution: SafeEnvironment is currently injected only in alarm processing scripts.
Object with the same API as a Java's Short.
Object with the same API as a Java's String.
Class equivalent to OMV.