Wagoappjson: Release 1.1.0.11
Wagoappjson: Release 1.1.0.11
Release 1.1.0.11
1 Description 1
2 10 Documentation 3
2.1 doc10_SystemProperties (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
i
FbJSON_Sax_Parser.RegisterParserListener (METH) . . . . . . . . . . . 17
4 29 Data types 19
4.1 eJsonRuleType (ENUM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2 eType (ENUM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.3 typAuxiliaries (STRUCT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.4 typJSON_Pointer (STRUCT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.5 typRuleBase (STRUCT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5 80 Status 21
5.1 Status (GVL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.2 eStatus (ENUM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6 ParameterList (PARAMS) 24
7 VersionHistory (GVL) 25
8 Library Reference 26
8.1 SysMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.1.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.1.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.2 WagoAppFileDir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.2.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.2.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.2.3 Library Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.3 WagoAppString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.3.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.3.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.4 WagoSysErrorBase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.4.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.4.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.4.3 Library Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.5 WagoSysFileDir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.5.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.5.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.6 WagoSysStandard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.6.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.6.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.7 WagoSysVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.7.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.7.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.8 WagoTypesErrorBase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.8.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.8.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
ii
CHAPTER 1
Description
This document is automatically generated. Because of this, the chapter 30 Visualization is not shown in this
document. If you are interested in getting to know more about visualization, we refer to the library manager of
e!Cockpit.
Subject to Changes
WAGO Kontakttechnik GmbH & Co. KG reserves the right to provide for any alterations or modifications. WAGO
Kontakttechnik GmbH & Co. KG owns all rights arising from the granting of patents or from the legal protection
of utility patents. Third-party products are always mentioned without any reference to patent rights. Thus, the
existence of such rights cannot be excluded.
Personnel Qualification
All tasks that are carried out with libraries made for the e!COCKPIT software must only be performed by qualified
electrical specialists instructed in PLC programming according to IEC 61131-3.
All tasks that have an effect on the properties or the behavior of automation hardware or software products must
only be performed by qualified employees with a thorough knowledge of handling the products concerned.
Intended Use of e!COCKPIT Libraries
Libraries created for the e!COCKPIT software are used to simplify the development of application projects in the
IEC 61131-3 programming languages.
For automation tasks, WAGO offers programmable logic controllers in a wide variety of performance classes.
In combination with a wide range of I/O modules, the controllers can process standard types of field signals.
Controllers can be implemented centrally or in decentralized configurations. The controllers offer interfaces for
the most commonly used fieldbuses for use in decentralized configurations. Fieldbus independent I/O modules
are then linked via fieldbus couplers. WAGO controllers offer a runtime environment for user programs called
e!RUNTIME. Software projects for implementation in e!RUNTIME environments can be created in e!COCKPIT.
The programming environment in e!COCKPIT is based on the established CODESYS 3 industrial standard. Users
with a previous knowledge of CODESYS 3 will thus find this environment largely familiar. The following pro-
gramming languages of the IEC 61131-3 standard are available:
• Structured Text (ST)
• Ladder Diagram (LD)
• Function Block Diagram (FBD)
• Instruction List (IL)
• Sequential Function Chart (SFC)
1
WagoAppJSON, Release 1.1.0.11
2
CHAPTER 2
10 Documentation
3
CHAPTER 3
3.1 10 Main
3.1.1 FbWrite_ToIEC_ByRule (FB)
Interface variables
4
WagoAppJSON, Release 1.1.0.11
Function Description
This function block imports JSON data, which is stored as an array, to a codesys variable.
JSON data may look like:
{
“Data_Objects”:[
{ “t1”: 15199355, “chan”: 5, “rx”: 1.9, “payload”:”567”},
{ “t1”: 1519935777, “chan”: 2, “rx”: 5.1, “payload”: “110a000f00551001”}
]
}
VAR
MyJsonData:ARRAY[0..1] OF typCustomData;
END_VAR
with
(sPath:=’t1’,iConvertType:=eUint),
(sPath:=’chan’,iConvertType:=eByte),
(sPath:=’rx’,iConvertType:=eReal),
(sPath:=’payload’,iConvertType:=eString)
];
3.1. 10 Main 5
WagoAppJSON, Release 1.1.0.11
eWORD := 0,
eBYTE:=1,
eBool:=2,
eReal:=3,
eString:=4,
eInt:=5,
eTime:=6,
eUint:=7,
Example
VAR
MyJson_string: STRING(5000):='
{
"Data_Objects":[
{ "tmst": 1519935596, "chan": 5, "rfch": 1, "freq": 869525,
˓→ "stat": 1, "modu": "LORA", "datr": "SF8BW125", "payload":"567"},
]
}';
MyRule:ARRAY[0..MAX_ARRAY_ELEMENTS_CUSTOM] OF typRuleBase:=[
(sPath:='tmst',iConvertType:=eUint),
(sPath:='chan',iConvertType:=eByte),
(sPath:='rfch',iConvertType:=eByte),
(sPath:='freq',iConvertType:=eUint),
(sPath:='stat',iConvertType:=eByte),
(sPath:='modu',iConvertType:=eString),
(sPath:='datr',iConvertType:=eString),
(sPath:='payload',iConvertType:=eString)
];
MyJsonData:ARRAY[0..2] OF typMyCustomData;
END_VAR
3.1. 10 Main 6
WagoAppJSON, Release 1.1.0.11
Function Description
Using this block, needs at least one time running the build up process by using input xTrigger. The method
GetValueByPath allows reading a JSON value. The method SetValueByPath allows writing a JSON
value.
Fb_JSON_ParseAndModify.GetValueByPath (METH)
Interface variables
3.1. 10 Main 7
WagoAppJSON, Release 1.1.0.11
Function Description
Example JSON string:
json_string2: STRING(400):='{
"Vendor" : "WAGO",}
"VendorID": null,
"Product" : [
{"Ordernumber": "750-8204", "CpuMHz": 600,"Fieldbus": ["CanOpen
˓→","Modbus"],"SdCard": true},
]
}';
Fb_JSON_ParseAndModify.SetValueByPath (METH)
Interface variables
3.1. 10 Main 8
WagoAppJSON, Release 1.1.0.11
Function Description
This function block generates a JSON string sOutput.
All variable values must be replaced by #Parameter to allow inserting the actual values from the input
aParameterValues.
Note For each #Parameter a appropriate value must exist within the aParameterValues input.
Example
The following JSON string should be generated:
{“Menu”:
3.1. 10 Main 9
WagoAppJSON, Release 1.1.0.11
{“id”: “CountryCode”,
“value”: “DE”,
“popup”: {“menuitem”:
[{“value”: “4.1”,”onclick”: “down1”},
{“value”: “4.2”,”onclick”: “down2”},
{“value”: “4.3”,”onclick”: “down3”}]
}
}
}
VAR
MyTemplateString:String(JSON_MAX_STRING):='
{"Menu": {"id": "#Parameter","value": "#Parameter","popup": {"menuitem": [{
˓→"value": "#Parameter","onclick": "#Parameter"},{"value": "#Parameter","onclick":
˓→"#Parameter"},
MyValueArray:ARRAY[0..7] OF STRING:=['CountryCode','DE','4.1','down1','4.2',
˓→'down2','4.3','down3'];
END_VAR
3.2 20 Advanced
3.2.1 FbJson_Advanced (FB)
Interface variables
3.2. 20 Advanced 10
WagoAppJSON, Release 1.1.0.11
Function Description
An IEC variable must be defined by the user. The variable must be of typMain.
e.g.:
TYPE typMain:
STRUCT
EDL_DataBase: typElement;
END_STRUCT
END_TYPE
Note A type definition is only allowed in derived types or as a basic type but not in both ways at the same time.
Example
Refere to chapter 10 Documentation
Datentypen
BaseDataMethods
FbJson_Advanced.aArrayBool (METH)
Interface variables
FbJson_Advanced.aArrayByte (METH)
Interface variables
FbJson_Advanced.aArrayDword (METH)
Interface variables
3.2. 20 Advanced 11
WagoAppJSON, Release 1.1.0.11
FbJson_Advanced.aArrayInt (METH)
Interface variables
FbJson_Advanced.aArrayReal (METH)
Interface variables
FbJson_Advanced.aArrayString (METH)
Interface variables
FbJson_Advanced.aArrayWord (METH)
Interface variables
FbJson_Advanced.aArray_ArrayBool (METH)
Interface variables
FbJson_Advanced.aArray_ArrayByte (METH)
Interface variables
FbJson_Advanced.aArray_ArrayDword (METH)
Interface variables
3.2. 20 Advanced 12
WagoAppJSON, Release 1.1.0.11
FbJson_Advanced.aArray_ArrayREAL (METH)
Interface variables
FbJson_Advanced.aArray_ArrayString (METH)
Interface variables
FbJson_Advanced.aArray_ArrayWord (METH)
Interface variables
FbJson_Advanced.MyFileClose (METH)
3.3 30 Sax_Parser
3.3.1 FbJSON_Handler (FB)
Function
This function block must be extended by an own function block. The different methods may be used according to
the special needs of each application.
Graphical Illustration
FbJSON_Handler.JSON_ArrayClosed (METH)
Function
Called each time an array close “]” has been evaluated
Graphical Illustration
3.3. 30 Sax_Parser 13
WagoAppJSON, Release 1.1.0.11
FbJSON_Handler.JSON_ArrayDetected (METH)
Function
Called each time an array open “[” has been evaluated
Graphical Illustration
FbJSON_Handler.JSON_DataFinished (METH)
Function
This method is called after the last byte has been detected
Graphical Illustration
FbJSON_Handler.JSON_KeyDetected (METH)
Interface variables
3.3. 30 Sax_Parser 14
WagoAppJSON, Release 1.1.0.11
FbJSON_Handler.JSON_NullDetected (METH)
Function
Graphical Illustration
FbJSON_Handler.JSON_ObjectClosed (METH)
Function
Called each time an object close “}” has been evaluated
Graphical Illustration
FbJSON_Handler.JSON_ObjectDetected (METH)
Interface variables
3.3. 30 Sax_Parser 15
WagoAppJSON, Release 1.1.0.11
FbJSON_Handler.JSON_ValueDetected (METH)
Interface variables
3.3. 30 Sax_Parser 16
WagoAppJSON, Release 1.1.0.11
Description
This function block allows parsing JSON data either from input pData or from a file assigned to input
sFileName. An appropriate JSON handler function block must be programmed to take care of the data.
Use method RegisterParserListener to assign an appropriate JSON handler.
File handling maybe controlled by the parameter JSON_SAX_CHUNK_SIZE.
VAR
FbMyJSON_Handler_0 : FbMyJSON_Handler;
myData : typMyData;
FbJSON_Sax_Parser_0 : FbJSON_Sax_Parser(FbMyJSON_Handler_0);
sTest_2 : STRING(255):=
'{
"id":"2ab06eaa-6417-41c8-beca-
˓→ 3d2bb92cdd98",
"source":"mockup",
"specversion":"0.2",
"relation":"noData"
}';
go1 : BOOL;
myValueCount : UDINT;
END_VAR
IF go1 THEN
FbJSON_Sax_Parser_0.RegisterParserListener(FbMyJSON_Handler_0);
FbMyJSON_Handler_0(typMyData:=MyData); //the handler must be called before the
˓→parser is activated, input ``typMyData`` must be assigned
FbJSON_Sax_Parser_0(
pData:=ADR(sTest_2) ,
udiSizeData:=SIZEOF(sTest_2) ,
sFileName:= ,
xTrigger:=go1 ,
oStatus=> ,
xDone=> ,
xError=> ,
udiValueCount=>myValueCount ,
iChunksCompleted=> );
END_IF
FbJSON_Sax_Parser.RegisterParserListener (METH)
Interface variables
3.3. 30 Sax_Parser 17
WagoAppJSON, Release 1.1.0.11
3.3. 30 Sax_Parser 18
CHAPTER 4
29 Data types
19
WagoAppJSON, Release 1.1.0.11
80 Status
21
WagoAppJSON, Release 1.1.0.11
ParameterList (PARAMS)
24
CHAPTER 7
VersionHistory (GVL)
WagoAppJSON.library
date version author change
04.08.2020 1.1.0.11 u010663 Method JSON_ValueDetected new string length
JSON_MAX_STRING_SAX
24.06.2020 1.1.0.10 u010663 Status attribute qualified only set
15.06.2020 1.1.0.9 u010663 Internal improvement
04.06.2020 1.1.0.7 u010663 Bugfix FbJson_Advanced
02.06.2020 1.1.0.6 u010663 Bugfix FbJson_Advanced
16.04.2020 1.1.0.5 u010663 Add two dimensional arrays in FbJson_Advanced
16.04.2020 1.1.0.2 u010663 Improve robustness FbJson_Advanced
09.04.2020 1.1.0.1 u010663 Enhancement data type null
08.04.2020 1.1.0.0 u010663 Enhancement FbJson_Advanced, FbJSON_Sax_Parser
31.03.2020 1.0.2.3 u010663 Bugfix FbJson_Advanced
20.01.2020 1.0.2.2 u010663 Bugfix FbJSON_Sax_Parser
10.12.2019 1.0.2.1 u010663 Documentation improved
03.04.2019 1.0.2.0 u010663 New FbJSON_Sax_Parser
04.03.2019 1.0.1.3 u010663 Documentation issues FbWrite_ToIEC_ByRule
11.02.2019 1.0.1.2 u010663 Improve documentaion function block Fb_Json_Writer_01
07.01.2019 1.0.0.0 u010663 Release
Release Notes:
25
CHAPTER 8
Library Reference
8.1 SysMem
8.1.1 Library Identification
Placeholder: SysMem
Default Resolution: SysMem, * (System)
Namespace: SysMem
8.2 WagoAppFileDir
8.2.1 Library Identification
Placeholder: WagoAppFileDir
Default Resolution: WagoAppFileDir, * (WAGO)
Namespace: WagoAppFileDir
26
WagoAppJSON, Release 1.1.0.11
8.3 WagoAppString
8.3.1 Library Identification
Placeholder: WagoAppString
Default Resolution: WagoAppString, * (WAGO)
Namespace: WagoAppString
8.4 WagoSysErrorBase
8.4.1 Library Identification
Placeholder: WagoSysErrorBase
Default Resolution: WagoSysErrorBase, * (WAGO)
Namespace: WagoSysErrorBase
Parameter: RES_LOG_MAX_FILES = 1
8.3. WagoAppString 27
WagoAppJSON, Release 1.1.0.11
8.5 WagoSysFileDir
8.5.1 Library Identification
Placeholder: WagoSysFileDir
Default Resolution: WagoSysFileDir, * (WAGO)
Namespace: WagoSysFileDir
8.6 WagoSysStandard
8.6.1 Library Identification
Placeholder: WagoSysStandard
Default Resolution: WagoSysStandard, * (WAGO)
Namespace: WagoSysStandard
8.7 WagoSysVersion
8.7.1 Library Identification
Name: WagoSysVersion
Version: 1.0.0.0
Company: WAGO
Namespace: WagoSysVersion
8.8 WagoTypesErrorBase
8.8.1 Library Identification
Placeholder: WagoTypesErrorBase
8.5. WagoSysFileDir 28
WagoAppJSON, Release 1.1.0.11
8.8. WagoTypesErrorBase 29