sosDoubleCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.52.00


sosDoubleCreate will create a new DOUBLE object.

If the object already exists, it will be replaced.

Please note that when using this function in a non-NX32L project, math.inc must be explicitly included by the application.

 

Input:

key : STRING

The key for the object to create. May only contain a-z,A-Z,0-9, "." and "_" (maximum of 250 characters).

 

desc : STRING

The description for the object, to show in the RTCU M2M Studio (maximum of 80 characters).

 

value : DOUBLE default 0

The initial value for the object. The value is not validated, making it possible to use it to e.g. determine unmodified values.

 

min_val : DOUBLE default 0

The minimum allowed value for the object. If both min_val and max_val are 0, there will be no limit. NaN is not a valid value for this parameter.

 

max_val : DOUBLE default 0

The maximum allowed value for the object. If both min_val and max_val are 0, there will be no limit. NaN is not a valid value for this parameter.

 

Returns: INT

0

- The object is created.

-1

- Generic error.

-2

- Invalid parameter.

 

 

Declaration:

FUNCTION sosDoubleCreate : INT;
VAR_INPUT
   key     : STRING;
   desc    : STRING;
   value   : DOUBLE := 0.0;
   min_val : DOUBLE := 0.0;
   max_val : DOUBLE := 0.0;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
INCLUDE math.inc
 
PROGRAM test;
VAR
   rc   : INT;
   temp : DOUBLE;
END_VAR;
BEGIN
   ...
   // Create double object
   rc := sosDoubleCreate(key := "config.max_temperature", value:=24.5desc := "Largest temperature measured");
   DebugFmt(message:="sosDoubleCreate=\1", v1:=rc);
   // Update double object
   rc:= sosDoubleSet(key:="config.max_temperature", value:=26.7);
   DebugFmt(message:="sosDoubleSet=\1", v1:=rc);
   
   // Read double object
   rc:= sosDoubleGet(key:="config.max_temperature", value:=temp);
   DebugFmt(message:="sosDoubleGet=\1 => " + doubleToStr(v:=temp), v1:=rc);
   ...
END;
 
END_PROGRAM;