Expressions
Components that display data values either numerically or graphically can be processed using expressions. These expressions can include simple mathematical expressions, functions to manipulate strings, or more complex functions that deal with the state of a data value over time.
For instance, a temperature reading in degrees Celsius can be processed to display in degrees Fahrenheit using a simple mathematical expression. This is done by first selecting the data value in the Select Data field, and then entering the mathematical expression after the defined data value. Using the above example, if the data value is defined as "Server:CR5000.TempData.Temp1" ("Source:datalogger.table.variable"), you would enter
"Server:CR5000.TempData.Temp1" * 1.8 + 32
to convert the temperature reading from degrees Celsius to degrees Fahrenheit.
Instead of typing the expression directly into the Select Data field, you can press next to that field to bring up the Expression Builder.
Strings
As shown above, double quotes are used in RTMC Pro to enclose the name of a data value (or source, datalogger, or table depending on the component). Therefore, when defining a literal string, a dollar sign is used as a prefix. This indicates to RTMC Pro that you are defining a literal string rather than a data value. For example, to search for the position of the sequence abc in the data value mystring, you would use the following expression:
InStr( 1, "Server:CR1000.hourly.mystring", $"abc")
Statistical Functions
Expressions can also use Statistical Functions, some of which involve the state of a data value over a period of time. For instance, you can return the maximum value of a data value over the past 24 hours using the expression:
MaxRunOverTime("Server:CR1000.QtrHour.Temp",Timestamp("Server:CR1000.QtrHour.Temp"),nsecPerDay)
When RTMC-RT is launched it begins processing with the newest record by default. Therefore, using the above expression, a component will not immediately display the maximum value over the past 24 hours. Rather, it will display the maximum value since RTMC-RT was launched. The 24-hour maximum will only be displayed after it has been running for 24 hours. In order to get a 24 hour maximum immediately, you can use a "Start Option Function" to cause RTMC to begin processing data at an earlier point. For example,
StartRelativeToNewest(nsecPerDay,ordercollected); MaxRunOverTime("Server:CR1000.QtrHour.Temp",Timestamp("Server:CR1000.QtrHour.Temp"),nsecPerDay)
would begin displaying a 24 hour maximum immediately, provided that the data is available in the communications server's data cache.
Aliases
If a data value is used multiple times in an expression, the expression can be simplified by declaring an alias for the data value at the first of the expression, in the form:
Alias(alias_name, data_value)
For example,
can be replaced by:
Alias(X,"Server:CR1000.MyTable.Value");
Synchronizing Variables
The ValueSynch function can be used to synchronize data values coming from multiple data sources so that you can display the results of a calculation on those data values in a single component. The Value Synch function takes the form:
ValueSynch(synchronized_name, data_value)
Where synchronized_name is the name of a new variable that will be used in a calculation at the end of the expression and data_value is the name used within RTMC to access the data value, i.e., Source:datalogger.table.variable.
For example, if you wish to display the average air temperature of two stations on a chart, the following expression can be used to synchronize the timestamps of the stations and then calculate the average air temperature:
ValueSynch(air_temp_1,"Server:CR1000_1.SECOND.air_temp");ValueSynch(air_temp_2,"Server:CR1000_2.SECOND.air_temp"); (air_temp_1 + air_temp_2) / 2
NOTE: Timestamps are truncated to seconds prior to synchronization. Therefore, synchronizing sub-second data is not recommended as the results will be unpredictable.
NOTE: If the timestamps of the stations are not the same (for example, if one datalogger is a few minutes behind the other), the component will display the exclamation point indicating no data, until the data sources have common timestamps and, therefore, can be synchronized.
NOTE: RTMC will buffer up to 100,000 points of a data value while waiting for a common timestamp from the other datalogger(s). Once the buffer reaches 100,000 data points the oldest data value will be removed from the buffer, each time a new data value is collected.
All of the functions available in RTMC Pro are described below. For details on a function,
NOTE: Spaces must be used to delimit the predefined constants and functions. Operators allow but do not require spaces.
NOTE: An expression can include data values from multiple dataloggers.
NOTE:
Operators
|
Description |
( ) |
Prioritizes an expression |
* |
Multiply by |
/ |
Divide by |
^ |
Raised to the power of |
+ |
Add |
- |
Subtract/Unary negation |
= |
Equal |
<> |
Not equal |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal to |
<= |
Less than or equal to |
Order of Precedence
-
Anything inside parentheses ( )
-
Exponentiation ^
-
Negation (unary) -
-
Multiplication *, division /
-
Modulo (remainder) MOD
-
Addition +, subtraction -
When consecutive operators have the same priority, the expression evaluates from left to right. This means that an expression such as a-b-c is evaluated as (a-b)-c.
Predefined Constants
The following constants are defined for convenience within numeric expressions:
Constant |
Description |
e |
2.718282 |
PI |
3.141593 |
True |
-1 |
False |
0 |
NOPLOT |
NAN |
NAN |
NAN (not a number) |
INF |
INF (non-finite number) |
Predefined Time Constants
These predefined time constants can be useful as a parameter for the Statistical Functions, where the interval parameter must be specified in nanoseconds.
Constant |
Description |
nsecPerUSec | Number of nanoseconds in a microsecond |
nsecPerMSec | Number of nanoseconds in a millisecond |
nsecPerSec | Number of nanoseconds in a second |
nsecPerMin | Number of nanoseconds in a minute |
nsecPerHour | Number of nanoseconds in an hour |
nsecPerDay | Number of nanoseconds in a day |
nsecPerWeek | Number of nanoseconds in a week |
Predefined Reset Options
These predefined reset options are used as a parameter for the Statistical Functions with a reset parameter.
Constant |
Description |
RESET_HOURLY |
Reset whenever there is a change in the hour in the value's timestamp |
RESET_DAILY |
Reset whenever there is a change in the day in the value's timestamp |
RESET_WEEKLY |
Reset whenever the day of the week is less than the day of the week of the newest timestamp stored (Sunday marks the beginning of the week) or when the difference between the current timestamp and the newest timestamp stored exceeds seven days. |
RESET_YEARLY |
Reset whenever there is a change in the year in the value's timestamp |
RESET_CUSTOM |
Reset whenever the doReset parameter is set to a non-zero value. |
Math Functions
Function |
Description |
Returns the absolute value of a number. |
|
Returns the arc cosine of a number. |
|
Returns the arc sine of a number. |
|
Returns the arc tangent of a number. |
|
Returns the arctangent of y/x. |
|
Rounds a number up to an integer value. |
|
Returns the cosine of a number. |
|
Returns the hyperbolic cosine of a number. |
|
Changes the sign of a number by multiplying by -1.0. |
|
Returns e raised to a power. |
|
Returns the integer portion of a number. If the number is a negative, the first negative integer greater than or equal to the number is returned. |
|
Rounds a number down to an integer value. |
|
Returns the fraction part of a number. |
|
Converts a floating point value into a string. |
|
Converts a floating point value into a string and applies any rules associated with the locale of the computer running RTMC Pro. |
|
Returns the integer portion of a number. If the number is a negative, the first negative integer less than or equal to the number is returned. |
|
Determines if a value is finite. |
|
Returns the natural log of a number. (Note that LN or LOG may be used to perform the same function.) |
|
Returns the natural log of a number. (Note that LN or LOG may be used to perform the same function.) |
|
Returns the logarithm base 10 of a number. |
|
Performs a modulo divide of two numbers. |
|
Raises a constant to a specified exponent. |
|
Generates a random number. |
|
Rounds a number to a higher or lower number. |
|
Used to find the sign value of a number (-1, 0, or 1). |
|
Returns the sine of an angle. |
|
Returns the hyperbolic sine of a number. |
|
Returns the square root of a number. |
|
Returns the tangent of an angle. |
|
Returns the hyperbolic tangent of a number. |
Logical Functions
Function |
Description |
Performs a logical conjunction on two numbers. |
|
Performs a logical equivalence on two numbers. |
|
Evaluates an expression and returns one value if true, a different value if false. |
|
Performs a logical implication on two numbers. |
|
Performs a logical negation on a number. |
|
Performs a logical disjunction on two numbers. |
|
Iterates through the set of predicates and values in the order in which these are specified in its arguments list. It will return the value associated with the first predicate that specifies a non-zero integer value. If no asserting predicate can be found, the function will return the default_value |
|
Performs a logical exclusion on two numbers. |
String Functions
Function |
Description |
Returns a hexadecimal string representation of an expression. |
|
Converts a hexadecimal string to a float or integer. |
|
Finds the location of a string within a string. |
|
Finds the location of a string within a string. (Differs from InStr in that it searches from the end of the string rather than from the start of the string.) |
|
Returns a substring that is a defined number of characters from the left side of the original string. |
|
Returns the number of bytes in a string. |
|
Returns a copy of a string with no leading spaces. |
|
Returns a substring that is within a string. |
|
Used to search a string for a substring, and replace that substring with a different string. |
|
Returns a substring that is a defined number of characters from the right side of the original string. |
|
Returns a copy of a string with no trailing spaces. |
|
Returns a string value that is filled with a defined number of spaces |
|
Compares two strings by comparing the characters in one string to the characters in another. |
|
Returns a copy of a string with the characters in reverse order. |
|
Returns a copy of a string with no leading or trailing spaces. |
Conversion Functions
Function |
Description |
Converts a value to a date. |
|
Converts a value to a floating point number. |
|
Converts a value to an integer. |
Time Functions
Function |
Description |
Produces a string that formats a timestamp in the manner specified. |
|
Returns the current computer time. |
|
Returns the current GMT (Greenwich Mean Time) system time. |
|
Returns the timestamp associated with the record from which a value is derived. |
|
Returns the value specified and sets its timestamp to the timestamp specified. |
Start Option Functions
NOTE: The majority of Start Option Functions are most useful when used with Statistical Functions. This is because when RTMC-RT is launched it begins processing with the newest record by default. Therefore, a Start Option Function must be used to cause RTMC to begin processing data at an earlier point that provides the history required by some Statistical Functions. For example using MaxRunOverTime to display the maximum value over the past 24 hours will initially display the maximum value since RTMC-RT was launched. The 24-hour maximum will only be displayed after it has been running for 24 hours. In order to get a 24-hour maximum immediately, a Start Option Function must be used.
NOTE: StartAfterNewest and StartAtNewest can be useful with trend components (Time Series Chart, XY Chart, Scope, Table Display, Wind Rose) if you wish to prevent RTMC from backfilling a component with historical data.
NOTE: ReportOffset is the only Start Option Function that works when your RTMC screen contains a Report Range component. This is because RTMC uses the other Start Option Functions in the background to implement the report functionality which will override any other user-entered Start Option Functions.
NOTE: Some Start Option Functions behave differently depending on the type of the data source (i.e., LoggerNet server, database, data file, or http datalogger). Click on the function name for more information.
Function |
Description |
No records are processed until a new record has been collected. |
|
Attempts to start processing at the newest record in the table. |
|
Attempts to start processing with the record at the specified offset back from the newest record in the table. For example, an offset of one starts processing at the newest record, an offset of two starts processing one record back from the newest record, and so forth. |
|
Attempts to start processing at the specified |
|
Attempts to start processing at the specified timestamp. If the specified timestamp cannot be located, it starts processing at the oldest record since the specified timestamp. If the specified timestamp is beyond what is available, it starts processing at the first record that is subsequently written to the data table (i.e., you will have no backfill). |
|
Attempts to start processing with the first record whose timestamp is greater than or equal to the newest record's timestamp minus the specified interval. |
|
For RTMC project pages where a Report Range component is present, this function will specify an offset, in nanoseconds, that will be subtracted from the report's start time. This function will not have an effect in any other context. This function is useful for a report that contains a statistical function that requires data from before the report’s start time. |
Statistical Functions
NOTE:
Function |
Description |
Returns a running average of up to the last specified number of values. |
|
Returns the running average of the specified value over time. |
|
Returns the running average of the specified value since the function was reset. |
|
Returns the average of the specified values. |
|
Stores the specified value and returns the previous value. |
|
Returns the maximum of all values that it has considered. |
|
Returns the maximum of all values whose timestamps are greater than the newest timestamp minus the specified interval. |
|
Returns the maximum of all values since the function was reset. |
|
Returns the maximum of the specified values. |
|
Returns the median value of up to the last specified number of values. |
|
Returns the median value in the set of values whose timestamps are greater than the newest timestamp minus the specified interval. |
|
Returns the minimum of all values that it has considered. |
|
Returns the minimum of all values whose timestamps are greater than the newest timestamp minus the specified interval. |
|
Returns the minimum of all values since the function was reset. |
|
Returns the minimum of the specified values. |
|
Returns the standard deviation of up to the last specified number of values. |
|
Returns the standard deviation of the specified value over time. |
|
Returns the standard deviation of the specified value since the function was reset. |
|
Returns the total of all values that it has considered. |
|
Returns the total of all values whose timestamps are greater than the newest timestamp minus the specified interval. |
|
Returns the total of all values since the function was reset. |
|
Returns the oldest value in a set of values from a specified time interval. |