Skip to main content

Activity counting module "uptime"

Description

The "uptime" module consumes a certain set of input channels, applies a predicate to their channel values and adds up the time periods for which the predicate is fulfilled. The summed time periods are then stored in a corresponding persistent file and additionally produced in the form of channels.

Interfaces and protocols used

NONE

JSON configuration example (demo)

The following section shows a demo configuration of the module.

    {
"module": "uptime",
"factory": "uptime",
"config":{
"fileName": "/sdi/log/uptimes.ini",
"pollingIntervalMs": 1000,
"writeIntervalMs":5000,
"reproductionTimeoutMs":60000,
"triggerChannels":[
{
"inputChannel": "ch_trigger_sawtooth_int64",
"outputChannel": "ch_trigger_sawtooth_int64_and2_ch",
"countIf": "&2"
},
{
"inputChannel": "ch_trigger_sawtooth_int64",
"outputChannel": "ch_trigger_sawtooth_int64_and4_ch",
"countIf": "&4"
},
{
"inputChannel": "ch_trigger_sawtooth_int64",
"outputChannel": "ch_trigger_sawtooth_int64_andoct8_ch",
"countIf": "&010"
},
{
"inputChannel": "ch_trigger_sawtooth_int64",
"outputChannel": "ch_trigger_sawtooth_int64_andhex16_ch",
"countIf": "&0xA"
},
{
"inputChannel": "ch_trigger_sawtooth_int64",
"outputChannel": "ch_trigger_sawtooth_int64_andbinary4_ch",
"countIf": "&0b100"
},
{
"inputChannel": "ch_trigger_sawtooth_int64",
"outputChannel": "ch_trigger_sawtooth_int64_andbinary4or1_ch",
"countIf": "&0b101"
},
{
"inputChannel": "ch_trigger",
"outputChannel": "ch_trigger_outputChannel",
"offset":-10
},
{
"inputChannel": "ch_trigger",
"outputChannel": "ch_trigger_outputChannel_RENAMED_CHANNEL"
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_lessThan_90_channel",
"countIf": "<90,0"
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_lessOrEqual_90_channel",
"countIf": "<=90"
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_greaterThan_130_channel",
"countIf": ">130"
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_greaterOrEqual_130_channel",
"countIf":">=130.0"
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_inRangeExclusive_90_130_channel",
"countIf": "90.0~130"
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_inRangeInclusive_90_130_channel",
"countIf": "90=~=130.0"
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_notInRangeExclusive_90_130_channel",
"countIf": "90.!~130"
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_notInRangeInclusive_90_130_channel",
"countIf": "90=!~=130."
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_equal_110_channel",
"countIf":"==110."
},
{
"inputChannel": "ch_trigger_sawtooth",
"outputChannel": "ch_trigger_sawtooth_notEqual_110_channel",
"countIf":"!=110."
}
]
}
}

Module parameters

Parameter NameRequiredData TypeMeaningful Value RangeDefaultDescription
fileNameNoSTRINGvalid writable file path"/sdi/config/uptimes.ini"path to the persistent file in which the counter readings are saved
pollingIntervalMsNoINT1000 (1 s)Interval [ms] for the periodic evaluation of the counter predicates
writeIntervalMsNoINT60000 (60 s)Interval [ms] for updating the counter readings within the persistent file
reproductionTimeoutMsNoINT60000 (60 s)Timeout [ms] for the unconditional production of the resulting counter channels if no counter update has taken place
triggerChannelsYESJSON Array of JSON objectssee belowConfiguration of the channels to be monitored and their counter channels

Configuration of the "triggerChannels"

Parameter NameRequiredData TypeMeaningful Value RangeDefaultDescription
inputChannelYESSTRINGvalid channel namemonitored channel
outputChannelYESSTRINGcounter channel of the monitored channel
offsetNoINT0an additional offset that is added to the CounterChannel value
countIfNoSTRINGinputChannel value is interpreted as truean optional predicate that converts the value of inputChannel into a Boolean value (see below)

Configuration of the "countIf" predicate

The predicate can be defined with the following notations

predicate typepredicate examplesdescription
Bitwise &"&2", "&010", "&0xf0", "&0b10010"Bitwise conjunction of the value of the monitored (integer) channel, e.g. for status monitoring of bit masks. Decimal, octal, hexadecimal and binary representations are supported (displayed from left to right).
True comparison <, >"<70.0", ">90"True comparison of the value of the monitored channel
Comparison <=, >="<=70.0", ">=90"Comparison of the value of the monitored channel
Comparison for within range ~"7~10", "7=~10", "7~=10", "7=~=10"Comparison for belonging to the range for the ranges 7-10, excluding 7 and 10, excluding 10, excluding 7, including 7 and 10 (shown from left to right)
Comparison for out-of-range !~"7!~10", "7=!~10", "7!~=10", "7=!~=10"Comparison for not belonging to the range 7-10, excluding 7 and 10, excluding 10, excluding 7, including 7 and 10 (shown from left to right)
Equality == and inequality !="==42", "!=7.0"Checking the monitored channel for equality or inequality

Reset the meter readings (Reset) via SCPI

The counter readings can be reset or changed via the SCPI action UPTIME:SET.

Parameters

OptionalParameterData typeValue rangeMeaning
NoNameSTRINGName of counter
NoMeter readingINTNewly assigned meter reading

Returns

OK or ERR

Example

< uptime:set counter,42
> OK

Reset the meter readings (Reset) via RPC

The counter readings can be reset or changed via the remote procedure call [$Module instance]::setCounter in optiCloud.

Parameter

OptionalParameterData typeValue rangeMeaning
NocounterVariableSTRINGThe channel name of the counter to be changed.
NocounterValueINT0 - *The value to which the counter should be set.

Example

RPC method: [uptime0]::setCounter. RPC parameter:

{
"counterVariable": "SawToothExceed70_Time",
"counterValue": 0
}

Module information

InformationValue
AuthoroptiMEAS Measurement and Automation Systems GmbH
since smartCORE0.143
Module typeConsumer / Producer
DependenciesChannels to be monitored