com.apama.cumulocity
Event Util


Cumulocity Utilities.

Various static actions useful for interacting with Cumulocity.
Action summary
 stringstatic ensureSMSLength(string text)

Truncate a string to max length of 160 characters.
 stringstatic formatTime(float t)

Format time into human readable form, as used by Cumulocity.
 booleanstatic inMaintenanceMode(com.apama.cumulocity.ManagedObject device)

Determine if ManagedObject is in maintenance mode.
 booleanstatic isStringInEnabledDisabledLists(string value, sequence<string> enabledList, sequence<string> disabledList)

Check if id is in list of enabled or disabled ids.
 floatstatic max(float a, float b)

Get maximum of two floating point numbers.
 floatstatic min(float a, float b)

Get minimum of two floating point numbers.
 stringstatic replacePlaceholders(string value, any e)

Replace placeholders in string from an Event.
 stringstatic stringify(any value, boolean quoteStrings)

Convert any object to JSON-style form.
 
Action detail

ensureSMSLength

string static ensureSMSLength(string text)
Truncate a string to max length of 160 characters.
Parameters:
text

formatTime

string static formatTime(float t)
Format time into human readable form, as used by Cumulocity.
Parameters:
t

inMaintenanceMode

boolean static inMaintenanceMode(com.apama.cumulocity.ManagedObject device)
Determine if ManagedObject is in maintenance mode.
Parameters:
device
Returns:
true if c8y_Availability.status is MAINTENANCE.

isStringInEnabledDisabledLists

boolean static isStringInEnabledDisabledLists(string value, sequence<string> enabledList, sequence<string> disabledList)
Check if id is in list of enabled or disabled ids.
Parameters:
value
enabledList
disabledList
Returns:
true if in enabledList, or if enabledList is empty, true if not in disabledList.

max

float static max(float a, float b)
Get maximum of two floating point numbers.
Parameters:
a
b

min

float static min(float a, float b)
Get minimum of two floating point numbers.
Parameters:
a
b

replacePlaceholders

string static replacePlaceholders(string value, any e)
Replace placeholders in string from an Event.

For fields named 'time' or 'timestamp', converts the time to a human-readable form. Replace #{field} with field values or entries in params. Sub-objects are printed in JSON form.
Parameters:
value
e

stringify

string static stringify(any value, boolean quoteStrings)
Convert any object to JSON-style form.
Parameters:
value
quoteStrings - Whether strings should be quoted or not; strings within lists or objects will be quoted.