-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCentralSystem.cs
More file actions
101 lines (86 loc) · 2.54 KB
/
Copy pathCentralSystem.cs
File metadata and controls
101 lines (86 loc) · 2.54 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
using System;
using ocpp.Scenarios;
using WebSocketSharp;
using System.Threading.Tasks;
namespace ocpp;
public class CentralSystem : EVSESystem
{
//WebSocketServer? server = null;
public CentralSystem(int port, bool secure = false) : base()
{
CSMSSimulator sim = new CSMSSimulator(9090);
if (secure)
{
//set the SSL options
}
//server.Start();
}
public CentralSystem(WebSocket ws) : base(ws)
{
}
public CentralSystem(string url, string protocol, string username = null, string password = null)
: base(url, protocol, username, password)
{
}
public IScenario[] GetScenarios()
{
return
[
new TC_001_CSMS(),
new TC_003_CSMS(),
new TC_004_1_CSMS(),
new TC_004_2_CSMS(),
new TC_005_1_CSMS(),
new TC_007_CSMS(),
new TC_010_CSMS(),
new TC_023_1_CSMS(),
new TC_023_2_CSMS(),
new TC_023_3_CSMS(),
new TC_024_CSMS(),
new TC_032_1_CSMS(),
new TC_037_1_CSMS(),
new TC_037_3_CSMS(),
new TC_039_CSMS(),
new TC_064_CSMS(),
];
}
public void RunScenarios()
{
if (UnsupportedMethods == null)
GetMethods();
foreach (IScenario s in GetScenarios())
{
bool bad = false;
foreach (string method in s.Dependencies)
{
if (!SupportedMethods.Contains(method))
{
Console.WriteLine("Scenario requires " + method + " but server does not implement it.");
bad = true;
}
}
if (bad)
{
Console.WriteLine("Skipping incompatible test " + s.GetType().ToString());
continue;
}
Console.WriteLine("Running scenario: " + s.GetType().ToString());
var task = Task.Run(() => s.RunScenario(Socket));
if (task.Wait(TimeSpan.FromSeconds(120)))
{
if (task.Result)
{
Console.WriteLine("\t-- PASSED!");
}
else
{
Console.WriteLine("\t-- FAILED!");
}
}
else
{
Console.WriteLine("\t-- FAILED!");
}
}
}
}