Skip to content

Commit

Permalink
Merge pull request #89 from simatic-ax/Update_to_SDK2311
Browse files Browse the repository at this point in the history
Update to sdk2311
  • Loading branch information
sjuergen authored Feb 19, 2024
2 parents 29d3b4d + e36e5e5 commit e4c1e3d
Show file tree
Hide file tree
Showing 21 changed files with 1,863 additions and 1,601 deletions.
1,109 changes: 708 additions & 401 deletions apax-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ variables:
APAX_BUILD_ARGS:
- '--debug'
targets:
- 'axunit-llvm'
- '1500'
- 'llvm'
# Dependencies
devDependencies:
"@ax/sdk": 2311.0.1
"@simatic-ax/snippetscollection": 0.1.3
"@simatic-ax/snippetscollection": 1.0.0
dependencies:
"@ax/system-strings": 6.0.94
"@simatic-ax/conversion": 4.0.1
"@simatic-ax/conversion": 2311.1.2
registries:
'@simatic-ax': 'https://npm.pkg.github.com/'
# Files which 'apax pack' will include
Expand All @@ -32,3 +33,5 @@ files:
- 'snippets'
- 'docs'
- 'src'
installStrategy: strict
apaxVersion: 3.1.0
18 changes: 18 additions & 0 deletions src/Document/Deserializer.st
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ NAMESPACE Simatic.Ax.Json
END_IF;
END_FOR;
END_METHOD
/// TryParse(STRING) : STRING
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -233,6 +234,7 @@ NAMESPACE Simatic.Ax.Json
value := '';
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : STRING
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand All @@ -251,6 +253,7 @@ NAMESPACE Simatic.Ax.Json
value := '';
END_IF;
END_METHOD
/// TryParse(STRING) : SINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -272,6 +275,7 @@ NAMESPACE Simatic.Ax.Json
value := SINT#0;
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : SINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand All @@ -291,6 +295,7 @@ NAMESPACE Simatic.Ax.Json
value := SINT#0;
END_IF;
END_METHOD
/// TryParse(STRING) : LINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -312,6 +317,7 @@ NAMESPACE Simatic.Ax.Json
value := 0;
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : LINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand All @@ -331,6 +337,7 @@ NAMESPACE Simatic.Ax.Json
value := 0;
END_IF;
END_METHOD
/// TryParse(STRING) : DINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -352,6 +359,7 @@ NAMESPACE Simatic.Ax.Json
value := 0;
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : DINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand All @@ -371,6 +379,7 @@ NAMESPACE Simatic.Ax.Json
value := 0;
END_IF;
END_METHOD
/// TryParse(STRING) : LINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -392,6 +401,7 @@ NAMESPACE Simatic.Ax.Json
value := 0;
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : LINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand All @@ -411,6 +421,7 @@ NAMESPACE Simatic.Ax.Json
value := 0;
END_IF;
END_METHOD
/// TryParse(STRING) : USINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -432,6 +443,7 @@ NAMESPACE Simatic.Ax.Json
value := USINT#0;
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : USINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand All @@ -451,6 +463,7 @@ NAMESPACE Simatic.Ax.Json
value := USINT#0;
END_IF;
END_METHOD
/// TryParse(STRING) : UINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -472,6 +485,7 @@ NAMESPACE Simatic.Ax.Json
value := USINT#0;
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : UINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand All @@ -491,6 +505,7 @@ NAMESPACE Simatic.Ax.Json
value := USINT#0;
END_IF;
END_METHOD
/// TryParse(STRING) : UDINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -512,6 +527,7 @@ NAMESPACE Simatic.Ax.Json
value := USINT#0;
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : UDINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand All @@ -531,6 +547,7 @@ NAMESPACE Simatic.Ax.Json
value := USINT#0;
END_IF;
END_METHOD
/// TryParse(STRING) : ULINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
key : STRING;
Expand All @@ -552,6 +569,7 @@ NAMESPACE Simatic.Ax.Json
value := USINT#0;
END_IF;
END_METHOD
/// TryParse(ARRAY[*] OF STRING) : ULINT
METHOD PUBLIC TryParse : BOOL
VAR_INPUT
keyArray : ARRAY[*] OF STRING;
Expand Down
120 changes: 55 additions & 65 deletions test/Deserializer/GetValues/Test_GetValues_Arrays.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,62 @@ USING AxUnit.Assert;
USING System.Strings;
USING Simatic.Ax.Json;


NAMESPACE Deserializer
NAMESPACE GetValues

{TestFixture}
CLASS Test_Deserializer_GetValues_Arrays
VAR protected
deserializer : Deserializer;

buffer : ARRAY[0..999] OF CHAR;
key: STRING;
value: STRING;
END_VAR

{Test}
Method Public Test_FindValue_in_JSON_SimpleArray
VAR
JSON_Entry: STRING := '{ "arraykey": [123, 456]}';

len:DINT;
keyFound: BOOL;
END_VAR

len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer);
deserializer.buffer := REF(buffer);

key := 'arraykey';
keyFound := deserializer.TryParse( key, value);
Equal('[123, 456]', value);
END_Method

{Test}
Method Public Test_FindValue_in_JSON_ComplexArray
VAR
JSON_Entry: STRING := '{ "key1": 1234,"arraykey": [123, 456], "key2": 456}';

len:DINT;
keyFound: BOOL;
END_VAR

len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer);
deserializer.buffer := REF(buffer);

key := 'arraykey';
keyFound := deserializer.TryParse( key, value);
Equal('[123, 456]', value);
END_Method

{Test}
Method Public Test_FindValue_in_JSON_NestedArray
VAR
JSON_Entry: STRING := '{ "key1": 1234,"arraykey": [{"nestedkey1": 1234, "nestedkey2": 456}, {"nestedkey3": 1234, "nestedkey4": 456}], "key2": 456}';

len:DINT;
keyFound: BOOL;
END_VAR

len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer);
deserializer.buffer := REF(buffer);

key := 'arraykey';
keyFound := deserializer.TryParse( key, value);
Equal('[{"nestedkey1": 1234, "nestedkey2": 456}, {"nestedkey3": 1234, "nestedkey4": 456}]', value);
END_Method

END_CLASS
NAMESPACE GetValues

{TestFixture}
CLASS Test_Deserializer_GetValues_Arrays
VAR PROTECTED
deserializer : Deserializer;
buffer : ARRAY[0..999] OF CHAR;
key : STRING;
value : STRING;
END_VAR

{Test}
METHOD PUBLIC Test_FindValue_in_JSON_SimpleArray
VAR
JSON_Entry : STRING := '{ "arraykey": [123, 456]}';
len : DINT;
keyFound : BOOL;
END_VAR
len := Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer);
deserializer.buffer := REF(buffer);
key := 'arraykey';
keyFound := deserializer.TryParse(key, value);
Equal('[123, 456]', value);
END_METHOD

{Test}
METHOD PUBLIC Test_FindValue_in_JSON_ComplexArray
VAR
JSON_Entry : STRING := '{ "key1": 1234,"arraykey": [123, 456], "key2": 456}';
len : DINT;
keyFound : BOOL;
END_VAR
len := Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer);
deserializer.buffer := REF(buffer);
key := 'arraykey';
keyFound := deserializer.TryParse(key, value);
Equal('[123, 456]', value);
END_METHOD

{Test}
METHOD PUBLIC Test_FindValue_in_JSON_NestedArray
VAR
JSON_Entry : STRING := '{ "key1": 1234,"arraykey": [{"nestedkey1": 1234, "nestedkey2": 456}, {"nestedkey3": 1234, "nestedkey4": 456}], "key2": 456}';
len : DINT;
keyFound : BOOL;
END_VAR
len := Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer);
deserializer.buffer := REF(buffer);
key := 'arraykey';
keyFound := deserializer.TryParse(key, value);
Equal('[{"nestedkey1": 1234, "nestedkey2": 456}, {"nestedkey3": 1234, "nestedkey4": 456}]', value);
END_METHOD
END_CLASS

END_NAMESPACE

END_NAMESPACE
END_NAMESPACE
78 changes: 36 additions & 42 deletions test/Deserializer/GetValues/Test_GetValues_BasicDataTypes.st
Original file line number Diff line number Diff line change
@@ -1,50 +1,44 @@
USING Simatic.Ax.Conversion;
USING AxUnit.Assert;
USING System.Strings;
using Simatic.Ax.Json;

USING Simatic.Ax.Json;

NAMESPACE Deserializer
NAMESPACE GetValues

{TestFixture}
CLASS Test_Deserializer_GetValues_BasicDataTypes
VAR protected
deserializer : Deserializer;

buffer : ARRAY[0..999] OF CHAR;
key: STRING;
value: STRING;
END_VAR

{Test}
Method Public Test_FindValue_in_JSON_SimpleEntries
VAR
JSON_Entry: STRING := '{"key": "Element1", "key 2": "something", "key 3": 456, "Key 4": 1234 }';

len:DINT;
keyFound: BOOL;
END_VAR

len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer);
deserializer.buffer := REF(buffer);

key := 'key';
keyFound := deserializer.TryParse( key, value);
Equal(8, LengthOf(value));
Equal('Element1', value);

key := 'Key 4';
keyFound := deserializer.TryParse( key, value);
Equal(4, LengthOf(value));
Equal('1234', value);

key := 'not a key';
keyFound := deserializer.TryParse( key, value);
Equal('', value);
END_Method

END_CLASS
NAMESPACE GetValues

{TestFixture}
CLASS Test_Deserializer_GetValues_BasicDataTypes
VAR PROTECTED
deserializer : Deserializer;
buffer : ARRAY[0..999] OF CHAR;
key : STRING;
value : STRING;
END_VAR

{Test}
METHOD PUBLIC Test_FindValue_in_JSON_SimpleEntries
VAR
JSON_Entry : STRING := '{"key": "Element1", "key 2": "something", "key 3": 456, "Key 4": 1234 }';
len : DINT;
keyFound : BOOL;
END_VAR
len := Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer);
deserializer.buffer := REF(buffer);
key := 'key';
keyFound := deserializer.TryParse(key, value);
Equal(8, LengthOf(value));
Equal('Element1', value);
key := 'Key 4';
keyFound := deserializer.TryParse(key, value);
Equal(4, LengthOf(value));
Equal('1234', value);
key := 'not a key';
keyFound := deserializer.TryParse(key, value);
Equal('', value);
END_METHOD
END_CLASS

END_NAMESPACE

END_NAMESPACE
END_NAMESPACE
Loading

0 comments on commit e4c1e3d

Please sign in to comment.