CSVWriter.AddBOOL (METH) ¶ METHOD AddBOOL : ERROR Adds a variable of type BOOL. RESULT: The error Code of type ERROR InOut: Scope Name Type Comment Return AddBOOL ERROR Input xValue BOOL The value to be saved
CSVWriter.AddBYTE (METH) ¶ METHOD AddBYTE : ERROR Adds a variable of type BYTE. InOut: Scope Name Type Comment Return AddBYTE ERROR Input byValue BYTE The value to be saved
CSVWriter.AddDATE (METH) ¶ METHOD AddDATE : ERROR Adds a variable of type DATE. RESULT: The error Code of type ERROR InOut: Scope Name Type Comment Return AddDATE ERROR Input datValue DATE The value to be saved
CSVWriter.AddDATE_AND_TIME (METH) ¶ METHOD AddDATE_AND_TIME : ERROR Adds a variable of type DATE_AND_TIME. RESULT: The error Code of type ERROR InOut: Scope Name Type Comment Return AddDATE_AND_TIME ERROR Input dtValue DT The value to be saved
CSVWriter.AddDINT (METH) ¶ METHOD AddDINT : ERROR Adds a variable of type DINT. RESULT: The error Code of type ERROR InOut: Scope Name Type Comment Return AddDINT ERROR Input diValue DINT The value to be saved
JSONType (ENUM) ¶ TYPE JSONType : Types of JSON elements Attributes: qualified_only InOut: Name Initial Comment KEY 0 The element is a key which is stored as WSTRING WSTRING_VALUE 1 Element is a WSTRING value LINT_VALUE 2 EElement is a LINT value LREAL_VALUE 3 Element is a LREAL value BOOL_VALUE 4 Element is a BOOL value NULL 5 Element is NULL JSON_ARRAY 6 Element is an array JSON_OBJECT 7 Element is an object NONE NO JSON type
Function Blocks ¶ FindFirstValueByKey (FunctionBlock) JSONBuilder (FunctionBlock) Reset (Method) SetKey (Method) SetKeyWithArray (Method) SetKeyWithObject (Method) SetKeyWithValue (Method) SetKeyWithValueNull (Method) SetObject (Method) SetValue (Method) JSONByteArrayReader (FunctionBlock) JSONByteArrayWriter (FunctionBlock) JSONData (FunctionBlock) Clear (Method) FindAllElementsByKey (Method) FindFirstElementByKey (Method) FindFirstValueByKey (Method) GetChildren (Method) GetElementByIndex (Method) SetArray (Method) SetBool (Method) SetEmpty (Method) SetKey (Method) SetLReal (Method) SetLRealRounded (Method) SetLint (Method) SetNull (Method) SetObject (Method) SetString (Method) JSONDataFactory (FunctionBlock) Create (Method) JSONFileReader (FunctionBlock) JSONFileWriter (FunctionBlock)
FindFirstValueByKey (FB) ¶ FUNCTION_BLOCK FindFirstValueByKey EXTENDS CBM.ETrig Finds the corresponding value of a key. InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input wsKey WSTRING The key to search diStartIndex DINT Start index Inout jsonData JSONData JSONData object Output jsonElement JSONElement The corresponding value of the key eError ERROR
JSONBuilder (FB) ¶ FUNCTION_BLOCK JSONBuilder The JSONBuilder is a helper FB for building JSON structures. It simplifies the setting of key-value pairs by setting the key and value in one call and using the value of type ANY. The structure is built using index fields. The root object has the index -1. All methods return the next index. The input diParentIndex is used to set the index of the parent element. Example: JSON String to create: { "Key1" : "Value1" , "Key2" : { "Key3" : 1234 } } VAR factory : JSON.JSONDataFactory ; eDataFactoryError : FBF.ERROR ; pJsonData : POINTER TO JSON.JSONData := factory.Create ( eError => eDataFactoryError ); fb_JBuilder : JSON.JSONBuilder ; wsValue : WSTRING ; diRootIndex , diObject1Index : DINT ; iValue : INT ; jsonArrayWriter : JSON.JSONByteArrayWriter ; wsJsonData : WSTRING ( 1000 ); xFirst : BOOL := TRUE ; END_VAR IF xFirst THEN fb_JBuilder ( pJsonData := pJsonData , diRootObj => diRootIndex ); wsValue := "Value1" ; fb_JBuilder.SetKeyWithValue ( "Key1" , wsValue , diParentIndex := diRootIndex ); diObject1Index := fb_JBuilder.SetKeyWithObject ( "Key2" , diParentIndex := diRootIndex ); iValue := 1234 ; fb_JBuilder.SetKeyWithValue ( "Key3" , iValue , diParentIndex := diObject1Index ); xFirst := FALSE ; END_IF jsonArrayWriter ( xExecute := TRUE , pwData := ADR ( wsJsonData ), udiSize := SIZEOF ( wsJsonData ), jsonData := pJsonData ^, xAsyncMode := FALSE ); InOut: Scope Name Type Input pJsonData POINTER TO JSONData Output diRootObj DINT Methods: Reset SetKey SetKeyWithArray SetKeyWithObject SetKeyWithValue SetKeyWithValueNull SetObject SetValue Structure: Reset (Method) SetKey (Method) SetKeyWithArray (Method) SetKeyWithObject (Method) SetKeyWithValue (Method) SetKeyWithValueNull (Method) SetObject (Method) SetValue (Method)
JSONByteArrayReader (FB) ¶ FUNCTION_BLOCK JSONByteArrayReader EXTENDS CBM.ETrig Function block for reading of JSON data arrays. InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input pwData POINTER TO WORD Pointer to the data array with JSON data (WSTRING) xIgnoreValueStringLength BOOL If True, the error is ignored and the value is shortened and xValueTrunked will be TRUE xAsyncMode BOOL TRUE If true, reader runs in asynchronous mode Inout jsonData JSONData JSONData object Output eError ERROR xValueTruncated BOOL minimum one String value was > GParams.g_diMaxStringSize