StateParserFactoryTests.cs
4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using Microsoft.Extensions.Logging.Abstractions;
using Rcs.Domain.Models.VDA5050.SEER;
using Rcs.Infrastructure.Mqtt.ParseFactory;
using Xunit;
namespace Rcs.Infrastructure.Tests;
public class StateParserFactoryTests
{
[Fact]
public void ParseState_SeerPayloadWithDynamicInformation_ShouldSucceed()
{
var payload = """
{
"headerId": 1314,
"timestamp": "2024-07-10T17:25:03.176Z",
"version": "2.0.0",
"manufacturer": "SEER",
"serialNumber": "ROBOT-001",
"orderId": "5201314",
"orderUpdateId": 0,
"lastNodeId": "",
"lastNodeSequenceId": 0,
"nodeStates": [],
"edgeStates": [],
"agvPosition": {
"deviationRange": 0,
"localizationScore": 0,
"mapDescription": "",
"mapId": "",
"positionInitialized": false,
"theta": 0,
"x": 0,
"y": 0
},
"batteryState": {
"batteryCharge": 0,
"batteryHealth": 0,
"batteryVoltage": 0,
"charging": false,
"reach": 0
},
"driving": false,
"forkState": {
"forkHeight": 0
},
"errors": [
{
"errorType": "57300",
"errorLevel": "WARNING",
"errorReferences": [
{ "referenceKey": "timestamp", "referenceValue": "1721196285" }
],
"errorDescription": "script cancel"
}
],
"information": [
{
"infoType": "script",
"infoLevel": "INFO",
"infoReferences": [
{
"referenceKey": "agv_speed",
"referenceValue": { "rotate": 0.058059, "x": 0, "y": 0 }
},
{
"referenceKey": "args",
"referenceValue": { "operation": "WashStart" }
}
],
"infoDescription": "info of script"
},
{
"infoType": "DI",
"infoLevel": "INFO",
"infoReferences": [
{
"referenceKey": "DI",
"referenceValue": [
{ "id": 0, "status": true },
{ "id": 1, "status": true }
]
}
],
"infoDescription": "info of DI"
}
],
"operatingMode": "AUTOMATIC",
"paused": false,
"safetyState": { "eStop": "NONE", "fieldViolation": false },
"velocity": { "omega": 0, "vx": 0, "vy": 0 },
"waitingForInteractionZoneRelease": false,
"zoneSetId": ""
}
""";
var factory = new StateParserFactory(NullLogger<StateParserFactory>.Instance);
var state = factory.ParseState("SEER", payload);
var seerState = Assert.IsType<State_SEER>(state);
Assert.Equal(1314, seerState.HeaderId);
Assert.Equal("5201314", seerState.OrderId);
Assert.Equal("AUTOMATIC", seerState.OperatingMode);
Assert.Equal("WARNING", Assert.Single(seerState.Errors).ErrorLevel);
Assert.NotNull(seerState.ForkState);
Assert.Equal(0, seerState.ForkState!.ForkHeight);
}
}