-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitoring.central.index.ts
executable file
·241 lines (177 loc) · 10.7 KB
/
monitoring.central.index.ts
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
import {CommunicationBus} from "./src/infrastructure/communication.bus";
import {MonitoringCentral} from "./src/application/monitoring.central";
import {ScriptsMonitoringCentral} from "./utils/scripts.monitoring.central";
let bus: CommunicationBus = new CommunicationBus();
let central: MonitoringCentral= new MonitoringCentral();
let time: number = 180000;
let repeatNumber = 0;
let tesNumber = 10;
let openIceStarted = false;
let dicomServerStarted = false;
async function closeUdpTcp(): Promise<void> {
await central.closeSdnController(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_CONTROLLER_SCRIPT);
await central.closeSdnManager(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_MANAGER_SCRIPT);
// Clean sdn controller configuration
await central.cleanSdnConfiguration(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_CONFIGURATIONS_SCRIPT);
// Closing Network Monitoring over Wireshark
await central.closeWireshark(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_WIRESHARK_SCRIPT);
// Stoping to send messages from workstation DICOM
await bus.sendWorkstationDicomMenssage({action:'stop'});
// Closing UDP Server and stoping to send messages
await central.closeUdpServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_UDP_SERVER_SCRIPT);
await bus.sendUdpTrafficMenssage({action:'stop'});
// Closing Supervisor OpenICE and stoping to send messages from Medical Devices of OpenICE
// await central.closeOpenIce(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_OPENICE_SCRIPT);
await bus.sendMedicalDeviceMenssage({action:'stop'});
}
async function closeUdpUdp(): Promise<void> {
await central.closeSdnController(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_CONTROLLER_SCRIPT);
await central.closeSdnManager(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_MANAGER_SCRIPT);
// Clean sdn controller configuration
await central.cleanSdnConfiguration(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_CONFIGURATIONS_SCRIPT);
// Closing Network Monitoring over Wireshark
await central.closeWireshark(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_WIRESHARK_SCRIPT);
// Closing Call VoIp
await central.closeVoipServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_VOIP_SERVER_SCRIPT);
await bus.sendCallVoIpMenssage({action:'stop'});
// Closing UDP Server and stoping to send messages
await central.closeUdpServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_UDP_SERVER_SCRIPT);
await bus.sendUdpTrafficMenssage({action:'stop'});
// Closing Supervisor OpenICE and stoping to send messages from Medical Devices of OpenICE
// await central.closeOpenIce(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_OPENICE_SCRIPT);
await bus.sendMedicalDeviceMenssage({action:'stop'});
}
async function closeTcpTcp(): Promise<void> {
await central.closeSdnController(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_CONTROLLER_SCRIPT);
await central.closeSdnManager(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_MANAGER_SCRIPT);
// Clean sdn controller configuration
await central.cleanSdnConfiguration(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_SDN_CONFIGURATIONS_SCRIPT);
// Closing Network Monitoring over Wireshark
await central.closeWireshark(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_WIRESHARK_SCRIPT);
// Stoping to send messages from workstation DICOM
await bus.sendWorkstationDicomMenssage({action:'stop'});
// Stoping to send messages from The second workstation DICOM
await bus.sendSecondWorkstationDicomMenssage({action:'stop'});
}
async function mainUdpTcp(bandwitdh: string, sndManager?: boolean): Promise<void> {
if(repeatNumber === tesNumber){
await closeUdpTcp();
process.exit(0)
}
const path: string = ScriptsMonitoringCentral.SCRIPT_PATH + bandwitdh
// Clear and Close all configuration and application
await closeUdpTcp();
if (sndManager){
await central.startSdnController(__dirname,ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_SDN_CONTROLLER_SCRIPT);
}
// Starting sdn controller configuration
await central.startSdnConfiguration(path + ScriptsMonitoringCentral.MONITORING_CENTRAL + ScriptsMonitoringCentral.START_SDN_CONFIGURATIONS_SCRIPT);
// Stating Network Monitoring over Wireshark
await central.startWireshark(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_WIRESHARK_SCRIPT);
// Starting Supervisor OpenICE and send a message for Medical Devices of OpenICE to sending data
if (!openIceStarted){
openIceStarted = true;
await central.closeOpenIce(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_OPENICE_SCRIPT);
await central.startOpenIce(__dirname,ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_OPENICE_SCRIPT);
}
await bus.sendMedicalDeviceMenssage({action:'start'});
// Starting DCM4CHEE and send a message for workstation DICOM sending images
if (!dicomServerStarted) {
dicomServerStarted = true;
await central.closeDicomServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_DICOM_SERVER_SCRIPT);
await central.startDicomServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_DICOM_SERVER_SCRIPT);
}
await bus.sendWorkstationDicomMenssage({action:'start', bandwidth: bandwitdh});
// Starting UDP Server and send a message for start sending data
await central.startUdpServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_UDP_SERVER_SCRIPT);
await bus.sendUdpTrafficMenssage({action:'start', bandwidth: bandwitdh});
if (sndManager){
await central.startSdnManager(__dirname,path + ScriptsMonitoringCentral.MONITORING_CENTRAL + "udp-tcp-" + ScriptsMonitoringCentral.START_SDN_MANAGER_SCRIPT);
}
repeatNumber++;
}
async function mainUdpUdp(bandwitdh: string, sndManager?: boolean): Promise<void> {
if(repeatNumber === tesNumber){
await closeUdpUdp();
process.exit(0)
}
const path: string = ScriptsMonitoringCentral.SCRIPT_PATH + bandwitdh
// // Clear and Close all configuration and application
await closeUdpUdp();
if (sndManager){
await central.startSdnController(__dirname,ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_SDN_CONTROLLER_SCRIPT);
}
// Starting sdn controller configuration
await central.startSdnConfiguration(path + ScriptsMonitoringCentral.MONITORING_CENTRAL + ScriptsMonitoringCentral.START_SDN_CONFIGURATIONS_SCRIPT);
// Stating Network Monitoring over Wireshark
await central.startWireshark(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_WIRESHARK_SCRIPT);
// Starting Supervisor OpenICE and send a message for Medical Devices of OpenICE to sending data
if (!openIceStarted){
openIceStarted = true;
await central.closeOpenIce(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_OPENICE_SCRIPT);
await central.startOpenIce(__dirname,ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_OPENICE_SCRIPT);
}
await bus.sendMedicalDeviceMenssage({action:'start'});
// Starting Call VoIp
await central.startVoipServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_VOIP_SERVER_SCRIPT);
await bus.sendCallVoIpMenssage({action:'start'});
// Starting UDP Server and send a message for start sending data
await central.startUdpServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_UDP_SERVER_SCRIPT);
await bus.sendUdpTrafficMenssage({action:'start', bandwidth: bandwitdh});
if (sndManager){
await central.startSdnManager(__dirname,path + ScriptsMonitoringCentral.MONITORING_CENTRAL + "udp-udp-" + ScriptsMonitoringCentral.START_SDN_MANAGER_SCRIPT);
}
repeatNumber++;
}
async function mainTcpTcp(bandwitdh: string, sndManager?: boolean): Promise<void> {
if(repeatNumber === tesNumber){
await closeTcpTcp();
process.exit(0)
}
const path: string = ScriptsMonitoringCentral.SCRIPT_PATH + bandwitdh
// Clear and Close all configuration and application
await closeTcpTcp();
if (sndManager){
await central.startSdnController(__dirname,ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_SDN_CONTROLLER_SCRIPT);
}
// Starting sdn controller configuration
await central.startSdnConfiguration(path + ScriptsMonitoringCentral.MONITORING_CENTRAL + ScriptsMonitoringCentral.START_SDN_CONFIGURATIONS_SCRIPT);
// Stating Network Monitoring over Wireshark
await central.startWireshark(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_WIRESHARK_SCRIPT);
// Starting DCM4CHEE and send a message for workstation DICOM start sending images
if (!dicomServerStarted) {
dicomServerStarted = true;
await central.closeDicomServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.STOP_DICOM_SERVER_SCRIPT);
await central.startDicomServer(ScriptsMonitoringCentral.NORMAL_SCENARIO + ScriptsMonitoringCentral.START_DICOM_SERVER_SCRIPT);
}
await bus.sendWorkstationDicomMenssage({action:'start', bandwidth: bandwitdh});
// Send a message for The second workstation DICOM to start sending images
await bus.sendSecondWorkstationDicomMenssage({action:'start', bandwidth: bandwitdh});
if (sndManager){
await central.startSdnManager(__dirname, path + ScriptsMonitoringCentral.MONITORING_CENTRAL + "tcp-tcp-" + ScriptsMonitoringCentral.START_SDN_MANAGER_SCRIPT);
}
repeatNumber++;
}
bus.startConnection('192.168.0.105').then(async () => {
setInterval(mainUdpTcp, time, '100');
// mainUdpTcp('500')
});
// bus.startConnection('127.0.0.1').then(async () => {
// setInterval(mainUdpTcp, time);
// });
//
// bus.startConnection('127.0.0.1',true).then(async () => {
// bus.receiveMenssage('exchangeMedicalDevice', 'queueMedicalDevice',
// (msg) => {
// console.log(msg)
// }).catch((e) => {
// console.log(e);
// })
// });
// bus.startConnection().then(() => {
// setInterval(mainUdpUdp, time);
// });
//
// bus.startConnection().then(() => {
// setInterval(mainTcpTcp, time);
// });