@operato/scene-mpi 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +31 -0
- package/assets/favicon.ico +0 -0
- package/assets/images/spinner.png +0 -0
- package/dist/auto-clicker.d.ts +10 -0
- package/dist/auto-clicker.js +84 -0
- package/dist/auto-clicker.js.map +1 -0
- package/dist/boot-button.d.ts +20 -0
- package/dist/boot-button.js +90 -0
- package/dist/boot-button.js.map +1 -0
- package/dist/gateway-on-button.d.ts +7 -0
- package/dist/gateway-on-button.js +88 -0
- package/dist/gateway-on-button.js.map +1 -0
- package/dist/gateway-on-message.d.ts +3 -0
- package/dist/gateway-on-message.js +375 -0
- package/dist/gateway-on-message.js.map +1 -0
- package/dist/gateway.d.ts +58 -0
- package/dist/gateway.js +396 -0
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/indicator-on-message.d.ts +2 -0
- package/dist/indicator-on-message.js +5 -0
- package/dist/indicator-on-message.js.map +1 -0
- package/dist/indicator-user-action.d.ts +5 -0
- package/dist/indicator-user-action.js +263 -0
- package/dist/indicator-user-action.js.map +1 -0
- package/dist/indicator.d.ts +83 -0
- package/dist/indicator.js +544 -0
- package/dist/indicator.js.map +1 -0
- package/dist/reply-button.d.ts +20 -0
- package/dist/reply-button.js +67 -0
- package/dist/reply-button.js.map +1 -0
- package/dist/segment-display.d.ts +41 -0
- package/dist/segment-display.js +521 -0
- package/dist/segment-display.js.map +1 -0
- package/dist/seven-segment.d.ts +7 -0
- package/dist/seven-segment.js +137 -0
- package/dist/seven-segment.js.map +1 -0
- package/dist/templates/auto-clicker.d.ts +17 -0
- package/dist/templates/auto-clicker.js +19 -0
- package/dist/templates/auto-clicker.js.map +1 -0
- package/dist/templates/boot-button.d.ts +16 -0
- package/dist/templates/boot-button.js +18 -0
- package/dist/templates/boot-button.js.map +1 -0
- package/dist/templates/gateway.d.ts +16 -0
- package/dist/templates/gateway.js +18 -0
- package/dist/templates/gateway.js.map +1 -0
- package/dist/templates/index.d.ts +16 -0
- package/dist/templates/index.js +15 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/indicator.d.ts +16 -0
- package/dist/templates/indicator.js +18 -0
- package/dist/templates/indicator.js.map +1 -0
- package/dist/templates/reply-button.d.ts +16 -0
- package/dist/templates/reply-button.js +18 -0
- package/dist/templates/reply-button.js.map +1 -0
- package/dist/templates/seven-segment.d.ts +28 -0
- package/dist/templates/seven-segment.js +30 -0
- package/dist/templates/seven-segment.js.map +1 -0
- package/dist/uuid.d.ts +1 -0
- package/dist/uuid.js +21 -0
- package/dist/uuid.js.map +1 -0
- package/helps/scene/component/auto-clicker.ko.md +3 -0
- package/helps/scene/component/auto-clicker.md +3 -0
- package/helps/scene/component/auto-clicker.zh.md +3 -0
- package/helps/scene/component/boot-button.ko.md +3 -0
- package/helps/scene/component/boot-button.md +3 -0
- package/helps/scene/component/boot-button.zh.md +3 -0
- package/helps/scene/component/gateway.ko.md +3 -0
- package/helps/scene/component/gateway.md +3 -0
- package/helps/scene/component/gateway.zh.md +3 -0
- package/helps/scene/component/indicator.ko.md +3 -0
- package/helps/scene/component/indicator.md +3 -0
- package/helps/scene/component/indicator.zh.md +3 -0
- package/helps/scene/component/reply-button.ko.md +3 -0
- package/helps/scene/component/reply-button.md +3 -0
- package/helps/scene/component/reply-button.zh.md +3 -0
- package/helps/scene/component/seven-segment.ko.md +3 -0
- package/helps/scene/component/seven-segment.md +3 -0
- package/helps/scene/component/seven-segment.zh.md +3 -0
- package/icons/boot-button.png +0 -0
- package/icons/button-error.png +0 -0
- package/icons/button-start.png +0 -0
- package/icons/button-status.png +0 -0
- package/icons/button-stop.png +0 -0
- package/icons/gateway.png +0 -0
- package/icons/icon-boot-button.png +0 -0
- package/icons/icon-gateway.png +0 -0
- package/icons/icon-indicator.png +0 -0
- package/icons/icon-reply-button.png +0 -0
- package/icons/icon-seven-segment.png +0 -0
- package/icons/indicator.png +0 -0
- package/icons/no-image.png +0 -0
- package/icons/reply-button.png +0 -0
- package/package.json +61 -0
- package/src/auto-clicker.ts +97 -0
- package/src/boot-button.ts +112 -0
- package/src/gateway-on-button.ts +97 -0
- package/src/gateway-on-message.ts +405 -0
- package/src/gateway.ts +484 -0
- package/src/index.ts +6 -0
- package/src/indicator-on-message.ts +6 -0
- package/src/indicator-user-action.ts +292 -0
- package/src/indicator.ts +638 -0
- package/src/reply-button.ts +88 -0
- package/src/segment-display.ts +608 -0
- package/src/seven-segment.ts +162 -0
- package/src/templates/auto-clicker.ts +19 -0
- package/src/templates/boot-button.ts +18 -0
- package/src/templates/gateway.ts +18 -0
- package/src/templates/index.ts +15 -0
- package/src/templates/indicator.ts +18 -0
- package/src/templates/reply-button.ts +18 -0
- package/src/templates/seven-segment.ts +30 -0
- package/src/uuid.ts +20 -0
- package/things-scene.config.js +5 -0
- package/translations/en.json +26 -0
- package/translations/ja.json +26 -0
- package/translations/ko.json +26 -0
- package/translations/ms.json +23 -0
- package/translations/zh.json +23 -0
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
export function consoleLogger(...args) {
|
|
2
|
+
console.log(Date(), ...args);
|
|
3
|
+
}
|
|
4
|
+
export function onmessage(gateway, message) {
|
|
5
|
+
if (gateway.state.power_flag == 'false') {
|
|
6
|
+
consoleLogger('got a message when power is off', message);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (!message.properties.is_reply) {
|
|
10
|
+
consoleLogger('received ' + (message.body.action ? message.body.action : 'unknown action'), message);
|
|
11
|
+
//
|
|
12
|
+
gateway.replyPublisher.data = gateway.generateReplyMessage(message.properties.id, message.properties.source_id, message.body.action, message.body);
|
|
13
|
+
consoleLogger('sent reply: ', gateway.replyPublisher.data);
|
|
14
|
+
switch (message.body.action) {
|
|
15
|
+
// 2.5 boot response
|
|
16
|
+
case 'GW_INIT_RES':
|
|
17
|
+
{
|
|
18
|
+
if (gateway.state.boot_flag == 'true') {
|
|
19
|
+
consoleLogger('Already booted');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// 2.6 gateway initialize
|
|
23
|
+
if (!gateway.version)
|
|
24
|
+
gateway.version = message.body.gw_version;
|
|
25
|
+
gateway.setTimer(parseInt(message.body.svr_time) * 1000);
|
|
26
|
+
gateway.timerOn();
|
|
27
|
+
gateway.startBlinkingLed();
|
|
28
|
+
gateway.startBlinkingLedBar();
|
|
29
|
+
gateway.replyPublisher.data = {
|
|
30
|
+
properties: gateway.generateMessageProperties(),
|
|
31
|
+
body: {
|
|
32
|
+
action: 'GW_INIT_RPT',
|
|
33
|
+
id: gateway.model.id,
|
|
34
|
+
version: gateway.version
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
consoleLogger('sent GW_INIT_RPT', gateway.replyPublisher.data);
|
|
38
|
+
gateway.setState('boot_flag', String('true')); // gw on
|
|
39
|
+
// 2.7 indicator 초기화 요청
|
|
40
|
+
let indConf = message && message.body && message.body.ind_conf;
|
|
41
|
+
let indIds = message &&
|
|
42
|
+
message.body &&
|
|
43
|
+
message.body.ind_list &&
|
|
44
|
+
message.body.ind_list.map((ind) => {
|
|
45
|
+
return ind.id;
|
|
46
|
+
});
|
|
47
|
+
// 이전 프로토콜과 호환성 유지
|
|
48
|
+
if (!indIds) {
|
|
49
|
+
indIds = message && message.body && message.body.ind_id;
|
|
50
|
+
}
|
|
51
|
+
let i = 0;
|
|
52
|
+
// ?? indicator 초기화 모두 완료 ??
|
|
53
|
+
gateway.indicators.forEach(indicator => {
|
|
54
|
+
// 2.8 indicator 초기화
|
|
55
|
+
// 시뮬레이션 편의용: MPI 아이디 서버에서 부여 //
|
|
56
|
+
if (!indicator.model.id && i < indIds.length && !gateway.findById(indIds[i])) {
|
|
57
|
+
indicator.set('id', indIds[i]);
|
|
58
|
+
i++;
|
|
59
|
+
}
|
|
60
|
+
///////////////////////////////////////
|
|
61
|
+
indicator.setState('boot_flag', String('true'));
|
|
62
|
+
if (!indicator.version)
|
|
63
|
+
indicator.version = message.body.ind_version;
|
|
64
|
+
Object.keys(indConf).forEach(key => {
|
|
65
|
+
if (indicator.conf.hasOwnProperty(key)) {
|
|
66
|
+
indicator.conf[key] = indConf[key];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// 세그먼트 개수 맞춤
|
|
70
|
+
indicator.setState('segments', new Array(indicator.getConf.seg_role.length).join(','));
|
|
71
|
+
// 2.9 indicator 준비 완료
|
|
72
|
+
gateway.replyPublisher.data = {
|
|
73
|
+
properties: gateway.generateMessageProperties(),
|
|
74
|
+
body: {
|
|
75
|
+
action: 'IND_INIT_RPT',
|
|
76
|
+
id: indicator.model.id,
|
|
77
|
+
version: indicator.version
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
consoleLogger('sent IND_INIT_RPT', gateway.replyPublisher.data);
|
|
81
|
+
// 2.10 indicator ID 소등
|
|
82
|
+
indicator.lightOff();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// indicator 초기화 모두 완료
|
|
86
|
+
break;
|
|
87
|
+
// 3.3 G/W에 indicator 점등 요청
|
|
88
|
+
case 'IND_ON_REQ':
|
|
89
|
+
{
|
|
90
|
+
if (gateway.state.boot_flag == 'false')
|
|
91
|
+
return;
|
|
92
|
+
// 3.4 indicator에 점등 요청
|
|
93
|
+
let indicators = message && message.body && message.body.ind_on;
|
|
94
|
+
// 3.5 인디케이터 점등
|
|
95
|
+
indicators &&
|
|
96
|
+
indicators.forEach((indicator) => {
|
|
97
|
+
let component = gateway.findById(indicator.id);
|
|
98
|
+
if (!component)
|
|
99
|
+
return;
|
|
100
|
+
if (component.state.boot_flag == 'false')
|
|
101
|
+
return;
|
|
102
|
+
// full 점등일 때 메시지 무시, 18.11.01 추가
|
|
103
|
+
component.store = indicator;
|
|
104
|
+
component.store.biz_type = message.body.biz_type;
|
|
105
|
+
component.store.action_type = message.body.action_type;
|
|
106
|
+
component.store.ret_args = message.body.ret_args;
|
|
107
|
+
component.readOnly = message.body.read_only; // readonly
|
|
108
|
+
Object.keys(component.conf).forEach(opt => {
|
|
109
|
+
if (indicator.hasOwnProperty(opt)) {
|
|
110
|
+
switch (opt // 오버라이드 제외 목록
|
|
111
|
+
) {
|
|
112
|
+
case 'seg_role':
|
|
113
|
+
case '':
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
component.conf[opt] = indicator[opt];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
let r = indicator.org_relay, b = indicator.org_box_qty == null ? 0 : indicator.org_box_qty, p = indicator.org_ea_qty == null ? 0 : indicator.org_ea_qty, c = indicator.color;
|
|
120
|
+
let cookedData = {};
|
|
121
|
+
switch (message['body']['action_type']) {
|
|
122
|
+
case component.tasks.PICK:
|
|
123
|
+
component.currentTask = component.tasks.PICK;
|
|
124
|
+
break;
|
|
125
|
+
case component.tasks.STOCK:
|
|
126
|
+
component.currentTask = component.tasks.STOCK;
|
|
127
|
+
break;
|
|
128
|
+
case component.tasks.FULL:
|
|
129
|
+
component.currentTask = component.tasks.FULL;
|
|
130
|
+
cookedData = {};
|
|
131
|
+
cookedData.viewStr = component.store.view_str;
|
|
132
|
+
cookedData.buttonColor = component.colors[c];
|
|
133
|
+
component.lightOn(cookedData);
|
|
134
|
+
component.displayMessage('-FULL-', c);
|
|
135
|
+
return;
|
|
136
|
+
case component.tasks.FULL_MODIFY:
|
|
137
|
+
component.currentTask = component.tasks.FULL_MODIFY;
|
|
138
|
+
component.displayMessage('FUL' + indicator.org_ea_qty, c);
|
|
139
|
+
return;
|
|
140
|
+
case component.tasks.END:
|
|
141
|
+
component.currentTask = component.tasks.END;
|
|
142
|
+
cookedData = {};
|
|
143
|
+
cookedData.viewStr = component.store.view_str;
|
|
144
|
+
cookedData.buttonColor = component.colors[c];
|
|
145
|
+
component.lightOn(cookedData);
|
|
146
|
+
component.displayMessage('END', c);
|
|
147
|
+
return;
|
|
148
|
+
case component.tasks.DISPLAY:
|
|
149
|
+
component.currentTask = component.tasks.DISPLAY;
|
|
150
|
+
c = 'K';
|
|
151
|
+
break;
|
|
152
|
+
case component.tasks.INSPECT:
|
|
153
|
+
component.currentTask = component.tasks.INSPECT;
|
|
154
|
+
c = 'I';
|
|
155
|
+
break;
|
|
156
|
+
case component.tasks.STRSHOW:
|
|
157
|
+
component.currentTask = component.tasks.STRSHOW;
|
|
158
|
+
cookedData = {};
|
|
159
|
+
cookedData.viewStr = component.store.view_str;
|
|
160
|
+
cookedData.buttonColor = component.colors[c];
|
|
161
|
+
component.lightOn(cookedData);
|
|
162
|
+
component.displayMessage(component.store.view_str, c);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (r || r >= 0)
|
|
166
|
+
cookedData.org_relay = r;
|
|
167
|
+
if (b || b >= 0)
|
|
168
|
+
cookedData.org_box_qty = b;
|
|
169
|
+
if (p || p >= 0)
|
|
170
|
+
cookedData.org_ea_qty = p;
|
|
171
|
+
if (c)
|
|
172
|
+
cookedData.buttonColor = component.colors[c];
|
|
173
|
+
component.cookedData = cookedData;
|
|
174
|
+
if (component.lit && component.currentTask == component.tasks.FULL)
|
|
175
|
+
return;
|
|
176
|
+
if (r || b || p || c) {
|
|
177
|
+
component.jobLightOn(cookedData);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
case 'IND_ON_RES':
|
|
183
|
+
{
|
|
184
|
+
if (gateway.state.boot_flag == 'false')
|
|
185
|
+
return;
|
|
186
|
+
gateway.indicators.forEach(indicator => {
|
|
187
|
+
if (indicator.model.id === message.body.id) {
|
|
188
|
+
var displayData = {};
|
|
189
|
+
if (message.body.biz_flag == 'cancel') {
|
|
190
|
+
displayData.org_ea_qty = message.body.res_ea_qty;
|
|
191
|
+
displayData.org_box_qty = message.body.org_box_qty;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
displayData.org_ea_qty = message.body.res_ea_qty;
|
|
195
|
+
displayData.org_box_qty = message.body.res_box_qty;
|
|
196
|
+
}
|
|
197
|
+
displayData.buttonColor = '';
|
|
198
|
+
indicator.cookedData = displayData;
|
|
199
|
+
indicator.jobLightOn(displayData);
|
|
200
|
+
indicator.currentTask = indicator.tasks.END;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
case 'IND_OFF_REQ':
|
|
206
|
+
{
|
|
207
|
+
if (gateway.state.boot_flag == 'false')
|
|
208
|
+
return;
|
|
209
|
+
gateway.indicators.forEach(indicator => {
|
|
210
|
+
// 인디케이터가 END 상태이면서 end_off_flag가 false이고, force_flag가 false이면 소등 안 함
|
|
211
|
+
if (indicator.currentTask == indicator.tasks.END && !message.body.end_off_flag && !message.body.force_flag)
|
|
212
|
+
return;
|
|
213
|
+
// 인디케이터의 불이 꺼져있고, 설정의 off_use_res가 false이면 소등 안 함
|
|
214
|
+
if (!indicator.getConf.off_use_res && !indicator.lit)
|
|
215
|
+
return;
|
|
216
|
+
let ind;
|
|
217
|
+
if (message.body.ind_off)
|
|
218
|
+
ind = message.body.ind_off.find((element, index) => {
|
|
219
|
+
return element === indicator.model.id;
|
|
220
|
+
});
|
|
221
|
+
if (!ind)
|
|
222
|
+
return;
|
|
223
|
+
indicator.lightOff();
|
|
224
|
+
gateway.replyPublisher.data = {
|
|
225
|
+
properties: gateway.generateMessageProperties(),
|
|
226
|
+
body: {
|
|
227
|
+
action: 'IND_OFF_RES',
|
|
228
|
+
id: indicator.model.id,
|
|
229
|
+
result: true
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
consoleLogger('sent IND_OFF_RES', gateway.replyPublisher.data);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
// 4.4 gateway에 배포 요청
|
|
237
|
+
case 'GW_DEP_REQ': // 게이트웨이 펌웨어 업데이트
|
|
238
|
+
{
|
|
239
|
+
if (gateway.state.boot_flag == 'false')
|
|
240
|
+
return;
|
|
241
|
+
// 4.5 firmware download
|
|
242
|
+
// is G/W's firmware update?
|
|
243
|
+
// - 인디케이터 펌웨어 업데이트 프로토콜은 따로임
|
|
244
|
+
//firmware update//
|
|
245
|
+
let isUpdated = false;
|
|
246
|
+
let random = Math.random();
|
|
247
|
+
if (random > 0.5) {
|
|
248
|
+
message.body.ind_url;
|
|
249
|
+
gateway.version = message.body.version;
|
|
250
|
+
isUpdated = true;
|
|
251
|
+
}
|
|
252
|
+
///////////////////
|
|
253
|
+
///완료 확인 로직?///
|
|
254
|
+
////////////////
|
|
255
|
+
gateway.replyPublisher.data = {
|
|
256
|
+
properties: gateway.generateMessageProperties(),
|
|
257
|
+
body: {
|
|
258
|
+
action: 'GW_DEP_RES',
|
|
259
|
+
id: gateway.model.id,
|
|
260
|
+
result: isUpdated,
|
|
261
|
+
version: gateway.version,
|
|
262
|
+
time: Date.now()
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
consoleLogger('sent GW_DEP_RES', gateway.replyPublisher.data);
|
|
266
|
+
gateway.off();
|
|
267
|
+
gateway.boot();
|
|
268
|
+
}
|
|
269
|
+
//gateway.replyPublisher!.data = null;
|
|
270
|
+
break;
|
|
271
|
+
// 4.4 gateway에 배포 요청
|
|
272
|
+
case 'IND_DEP_REQ': // 인디케이터 펌웨어 업데이트
|
|
273
|
+
{
|
|
274
|
+
if (gateway.state.boot_flag == 'false')
|
|
275
|
+
return;
|
|
276
|
+
// 4.5 firmware download//
|
|
277
|
+
//////////////////////////
|
|
278
|
+
// 4.6 indicator에 firmware 전송
|
|
279
|
+
gateway.indicators.forEach(indicator => {
|
|
280
|
+
if (indicator.state.boot_flag == false)
|
|
281
|
+
return;
|
|
282
|
+
//4.7 firmware 파일 접수//
|
|
283
|
+
////////////////////////
|
|
284
|
+
//4.8 firmware 업데이트//
|
|
285
|
+
let result;
|
|
286
|
+
if (Math.random() > 0.5) {
|
|
287
|
+
indicator.version = message.body.version;
|
|
288
|
+
result = true;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
result = false;
|
|
292
|
+
}
|
|
293
|
+
///////////////////////
|
|
294
|
+
gateway.replyPublisher.data = {
|
|
295
|
+
properties: gateway.generateMessageProperties(),
|
|
296
|
+
body: {
|
|
297
|
+
action: 'IND_DEP_RES',
|
|
298
|
+
id: indicator.model.id,
|
|
299
|
+
result: result,
|
|
300
|
+
version: indicator.version,
|
|
301
|
+
time: Date.now()
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
consoleLogger('sent IND_DEP_RES', gateway.replyPublisher.data);
|
|
305
|
+
});
|
|
306
|
+
// boot
|
|
307
|
+
gateway.off();
|
|
308
|
+
gateway.boot();
|
|
309
|
+
}
|
|
310
|
+
break;
|
|
311
|
+
case 'TIMESYNC_RES': // 시간 동기화
|
|
312
|
+
{
|
|
313
|
+
if (gateway.state.boot_flag == 'false')
|
|
314
|
+
return;
|
|
315
|
+
gateway.setTimer(parseInt(message.body.svr_time) * 1000);
|
|
316
|
+
if (!gateway.time)
|
|
317
|
+
gateway.timerOn();
|
|
318
|
+
}
|
|
319
|
+
break;
|
|
320
|
+
case 'MW_MOD_IP_REQ':
|
|
321
|
+
{
|
|
322
|
+
gateway.replyPublisher.data = {
|
|
323
|
+
properties: gateway.generateMessageProperties(),
|
|
324
|
+
body: {
|
|
325
|
+
action: 'MW_MOD_IP_RES',
|
|
326
|
+
id: gateway.model.id,
|
|
327
|
+
result: Math.random() > 0.5 ? true : false
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
case 'LED_ON_REQ':
|
|
333
|
+
{
|
|
334
|
+
let ind = gateway.indicators.findIndex((indicator, index) => {
|
|
335
|
+
return indicator.model.id === message.body.id;
|
|
336
|
+
});
|
|
337
|
+
if (ind != -1) {
|
|
338
|
+
Object.keys(gateway.indicators[ind].conf).forEach(opt => {
|
|
339
|
+
if (message.body.hasOwnProperty(opt)) {
|
|
340
|
+
gateway.indicators[ind].conf[opt] = message.body[opt];
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
let color = '#f00';
|
|
344
|
+
if (gateway.indicators[ind].getConf.led_bar_brtns > 10)
|
|
345
|
+
gateway.indicators[ind].conf.led_bar_brtns = 10;
|
|
346
|
+
color = color + Math.round((gateway.indicators[ind].getConf.led_bar_brtns * 15) / 10).toString(16);
|
|
347
|
+
gateway.indicators[ind].ledRect.strokeStyle = color;
|
|
348
|
+
gateway.indicators[ind].ledLit = true;
|
|
349
|
+
}
|
|
350
|
+
else
|
|
351
|
+
consoleLogger('Could not find indicator', message.body.id);
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
case 'LED_OFF_REQ':
|
|
355
|
+
{
|
|
356
|
+
let ind = gateway.indicators.findIndex((indicator, index) => {
|
|
357
|
+
return indicator.model.id === message.body.id;
|
|
358
|
+
});
|
|
359
|
+
if (ind != -1) {
|
|
360
|
+
gateway.indicators[ind].ledRect.strokeStyle = '#0000';
|
|
361
|
+
gateway.indicators[ind].ledLit = false;
|
|
362
|
+
}
|
|
363
|
+
else
|
|
364
|
+
consoleLogger('Could not find indicator', message.body.id);
|
|
365
|
+
}
|
|
366
|
+
break;
|
|
367
|
+
default:
|
|
368
|
+
consoleLogger('unknown message', message);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
consoleLogger('server reply: ', message);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
//# sourceMappingURL=gateway-on-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-on-message.js","sourceRoot":"","sources":["../src/gateway-on-message.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,aAAa,CAAC,GAAG,IAAW;IAC1C,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;AAC9B,CA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AG,CAAC,CAAC,MAAM,GAAG,KAAK,CAAA;oBACxC,CAAC;;wBAAM,aAAa,CAAC,0BAA0B,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBACnE,CAAC;gBACD,MAAK;YACP;gBACE,aAAa,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;QAC7C,CAAC;IACH,CAAC;SAAM,CAAC;QACN,aAAa,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IAC1C,CAAC;AACH,CAAC","sourcesContent":["import Gateway from './gateway'\nimport Indicator from './indicator'\n\nexport function consoleLogger(...args: any[]) {\n console.log(Date(), ...args)\n}\n\nexport function onmessage(gateway: Gateway, message: any) {\n if (gateway.state.power_flag == 'false') {\n consoleLogger('got a message when power is off', message)\n return\n }\n if (!message.properties.is_reply) {\n consoleLogger('received ' + (message.body.action ? message.body.action : 'unknown action'), message)\n\n //\n gateway.replyPublisher!.data = gateway.generateReplyMessage(\n message.properties.id,\n message.properties.source_id,\n message.body.action,\n message.body\n )\n consoleLogger('sent reply: ', gateway.replyPublisher!.data)\n\n switch (message.body.action) {\n // 2.5 boot response\n case 'GW_INIT_RES':\n {\n if (gateway.state.boot_flag == 'true') {\n consoleLogger('Already booted')\n return\n }\n\n // 2.6 gateway initialize\n if (!gateway.version) gateway.version = message.body.gw_version\n\n gateway.setTimer(parseInt(message.body.svr_time) * 1000)\n gateway.timerOn()\n gateway.startBlinkingLed()\n gateway.startBlinkingLedBar()\n\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'GW_INIT_RPT',\n id: gateway.model.id,\n version: gateway.version\n }\n }\n consoleLogger('sent GW_INIT_RPT', gateway.replyPublisher!.data)\n\n gateway.setState('boot_flag', String('true')) // gw on\n\n // 2.7 indicator 초기화 요청\n let indConf = message && message.body && message.body.ind_conf\n let indIds =\n message &&\n message.body &&\n message.body.ind_list &&\n message.body.ind_list.map((ind: any) => {\n return ind.id\n })\n // 이전 프로토콜과 호환성 유지\n if (!indIds) {\n indIds = message && message.body && message.body.ind_id\n }\n\n let i = 0\n // ?? indicator 초기화 모두 완료 ??\n gateway.indicators.forEach(indicator => {\n // 2.8 indicator 초기화\n // 시뮬레이션 편의용: MPI 아이디 서버에서 부여 //\n if (!indicator.model.id && i < indIds.length && !gateway.findById(indIds[i])) {\n indicator.set('id', indIds[i])\n i++\n }\n ///////////////////////////////////////\n\n indicator.setState('boot_flag', String('true'))\n\n if (!indicator.version) indicator.version = message.body.ind_version\n\n Object.keys(indConf).forEach(key => {\n if (indicator.conf.hasOwnProperty(key)) {\n indicator.conf[key] = indConf[key]\n }\n })\n\n // 세그먼트 개수 맞춤\n indicator.setState('segments', new Array(indicator.getConf.seg_role.length).join(','))\n\n // 2.9 indicator 준비 완료\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'IND_INIT_RPT',\n id: indicator.model.id,\n version: indicator.version\n }\n }\n consoleLogger('sent IND_INIT_RPT', gateway.replyPublisher!.data)\n\n // 2.10 indicator ID 소등\n indicator.lightOff()\n })\n }\n // indicator 초기화 모두 완료\n break\n // 3.3 G/W에 indicator 점등 요청\n case 'IND_ON_REQ':\n {\n if (gateway.state.boot_flag == 'false') return\n\n // 3.4 indicator에 점등 요청\n let indicators = message && message.body && message.body.ind_on\n\n // 3.5 인디케이터 점등\n indicators &&\n indicators.forEach((indicator: any) => {\n let component = gateway.findById(indicator.id) as Indicator\n\n if (!component) return\n if (component.state.boot_flag == 'false') return\n // full 점등일 때 메시지 무시, 18.11.01 추가\n\n component.store = indicator\n component.store.biz_type = message.body.biz_type\n component.store.action_type = message.body.action_type\n component.store.ret_args = message.body.ret_args\n\n component.readOnly = message.body.read_only // readonly\n\n Object.keys(component.conf).forEach(opt => {\n if (indicator.hasOwnProperty(opt)) {\n switch (\n opt // 오버라이드 제외 목록\n ) {\n case 'seg_role':\n case '':\n return\n }\n component.conf[opt] = indicator[opt]\n }\n })\n let r = indicator.org_relay,\n b = indicator.org_box_qty == null ? 0 : indicator.org_box_qty,\n p = indicator.org_ea_qty == null ? 0 : indicator.org_ea_qty,\n c = indicator.color\n\n let cookedData: any = {}\n\n switch (message['body']['action_type']) {\n case component.tasks.PICK:\n component.currentTask = component.tasks.PICK\n break\n case component.tasks.STOCK:\n component.currentTask = component.tasks.STOCK\n break\n case component.tasks.FULL:\n component.currentTask = component.tasks.FULL\n cookedData = {}\n cookedData.viewStr = component.store.view_str\n cookedData.buttonColor = component.colors[c]\n component.lightOn(cookedData)\n component.displayMessage('-FULL-', c)\n return\n case component.tasks.FULL_MODIFY:\n component.currentTask = component.tasks.FULL_MODIFY\n component.displayMessage('FUL' + indicator.org_ea_qty, c)\n return\n case component.tasks.END:\n component.currentTask = component.tasks.END\n cookedData = {}\n cookedData.viewStr = component.store.view_str\n cookedData.buttonColor = component.colors[c]\n component.lightOn(cookedData)\n component.displayMessage('END', c)\n return\n case component.tasks.DISPLAY:\n component.currentTask = component.tasks.DISPLAY\n c = 'K'\n break\n case component.tasks.INSPECT:\n component.currentTask = component.tasks.INSPECT\n c = 'I'\n break\n case component.tasks.STRSHOW:\n component.currentTask = component.tasks.STRSHOW\n cookedData = {}\n cookedData.viewStr = component.store.view_str\n cookedData.buttonColor = component.colors[c]\n component.lightOn(cookedData)\n component.displayMessage(component.store.view_str, c)\n return\n }\n\n if (r || r >= 0) cookedData.org_relay = r\n if (b || b >= 0) cookedData.org_box_qty = b\n if (p || p >= 0) cookedData.org_ea_qty = p\n if (c) cookedData.buttonColor = component.colors[c]\n component.cookedData = cookedData\n\n if (component.lit && component.currentTask == component.tasks.FULL) return\n\n if (r || b || p || c) {\n component.jobLightOn(cookedData)\n }\n })\n }\n break\n case 'IND_ON_RES':\n {\n if (gateway.state.boot_flag == 'false') return\n gateway.indicators.forEach(indicator => {\n if (indicator.model.id === message.body.id) {\n var displayData: any = {}\n if (message.body.biz_flag == 'cancel') {\n displayData.org_ea_qty = message.body.res_ea_qty\n displayData.org_box_qty = message.body.org_box_qty\n } else {\n displayData.org_ea_qty = message.body.res_ea_qty\n displayData.org_box_qty = message.body.res_box_qty\n }\n\n displayData.buttonColor = ''\n indicator.cookedData = displayData\n indicator.jobLightOn(displayData)\n indicator.currentTask = indicator.tasks.END\n }\n })\n }\n break\n case 'IND_OFF_REQ':\n {\n if (gateway.state.boot_flag == 'false') return\n\n gateway.indicators.forEach(indicator => {\n // 인디케이터가 END 상태이면서 end_off_flag가 false이고, force_flag가 false이면 소등 안 함\n if (indicator.currentTask == indicator.tasks.END && !message.body.end_off_flag && !message.body.force_flag)\n return\n\n // 인디케이터의 불이 꺼져있고, 설정의 off_use_res가 false이면 소등 안 함\n if (!indicator.getConf.off_use_res && !indicator.lit) return\n\n let ind\n if (message.body.ind_off)\n ind = message.body.ind_off.find((element: any, index: number) => {\n return element === indicator.model.id\n })\n if (!ind) return\n\n indicator.lightOff()\n\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'IND_OFF_RES',\n id: indicator.model.id,\n result: true\n }\n }\n consoleLogger('sent IND_OFF_RES', gateway.replyPublisher!.data)\n })\n }\n break\n // 4.4 gateway에 배포 요청\n case 'GW_DEP_REQ': // 게이트웨이 펌웨어 업데이트\n {\n if (gateway.state.boot_flag == 'false') return\n\n // 4.5 firmware download\n\n // is G/W's firmware update?\n // - 인디케이터 펌웨어 업데이트 프로토콜은 따로임\n\n //firmware update//\n let isUpdated = false\n let random = Math.random()\n if (random > 0.5) {\n message.body.ind_url\n gateway.version = message.body.version\n isUpdated = true\n }\n ///////////////////\n\n ///완료 확인 로직?///\n ////////////////\n\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'GW_DEP_RES',\n id: gateway.model.id,\n result: isUpdated,\n version: gateway.version,\n time: Date.now()\n }\n }\n consoleLogger('sent GW_DEP_RES', gateway.replyPublisher!.data)\n\n gateway.off()\n gateway.boot()\n }\n //gateway.replyPublisher!.data = null;\n break\n // 4.4 gateway에 배포 요청\n case 'IND_DEP_REQ': // 인디케이터 펌웨어 업데이트\n {\n if (gateway.state.boot_flag == 'false') return\n\n // 4.5 firmware download//\n //////////////////////////\n\n // 4.6 indicator에 firmware 전송\n gateway.indicators.forEach(indicator => {\n if (indicator.state.boot_flag == false) return\n\n //4.7 firmware 파일 접수//\n ////////////////////////\n\n //4.8 firmware 업데이트//\n let result\n if (Math.random() > 0.5) {\n indicator.version = message.body.version\n result = true\n } else {\n result = false\n }\n ///////////////////////\n\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'IND_DEP_RES',\n id: indicator.model.id,\n result: result,\n version: indicator.version,\n time: Date.now()\n }\n }\n consoleLogger('sent IND_DEP_RES', gateway.replyPublisher!.data)\n })\n // boot\n gateway.off()\n gateway.boot()\n }\n break\n case 'TIMESYNC_RES': // 시간 동기화\n {\n if (gateway.state.boot_flag == 'false') return\n gateway.setTimer(parseInt(message.body.svr_time) * 1000)\n if (!gateway.time) gateway.timerOn()\n }\n break\n case 'MW_MOD_IP_REQ':\n {\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'MW_MOD_IP_RES',\n id: gateway.model.id,\n result: Math.random() > 0.5 ? true : false\n }\n }\n }\n break\n case 'LED_ON_REQ':\n {\n let ind = gateway.indicators.findIndex((indicator, index) => {\n return indicator.model.id === message.body.id\n })\n if (ind != -1) {\n Object.keys(gateway.indicators[ind].conf).forEach(opt => {\n if (message.body.hasOwnProperty(opt)) {\n gateway.indicators[ind].conf[opt] = message.body[opt]\n }\n })\n let color = '#f00'\n\n if (gateway.indicators[ind].getConf.led_bar_brtns > 10) gateway.indicators[ind].conf.led_bar_brtns = 10\n color = color + Math.round((gateway.indicators[ind].getConf.led_bar_brtns * 15) / 10).toString(16)\n\n gateway.indicators[ind].ledRect.strokeStyle = color\n gateway.indicators[ind].ledLit = true\n } else consoleLogger('Could not find indicator', message.body.id)\n }\n break\n case 'LED_OFF_REQ':\n {\n let ind = gateway.indicators.findIndex((indicator, index) => {\n return indicator.model.id === message.body.id\n })\n if (ind != -1) {\n gateway.indicators[ind].ledRect.strokeStyle = '#0000'\n gateway.indicators[ind].ledLit = false\n } else consoleLogger('Could not find indicator', message.body.id)\n }\n break\n default:\n consoleLogger('unknown message', message)\n }\n } else {\n consoleLogger('server reply: ', message)\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Component, ComponentNature, Container, Properties } from '@hatiolab/things-scene';
|
|
2
|
+
import Indicator from './indicator';
|
|
3
|
+
export default class Gateway extends Container {
|
|
4
|
+
static _image?: HTMLImageElement;
|
|
5
|
+
static _buttonImages: HTMLImageElement[];
|
|
6
|
+
private timeflow?;
|
|
7
|
+
private ledBlinker?;
|
|
8
|
+
private ledBarBlinker?;
|
|
9
|
+
private _focusedButton?;
|
|
10
|
+
version?: any;
|
|
11
|
+
publisher?: any;
|
|
12
|
+
time?: any;
|
|
13
|
+
static get image(): HTMLImageElement;
|
|
14
|
+
static get buttonImages(): HTMLImageElement[];
|
|
15
|
+
dispose(): void;
|
|
16
|
+
buttonContains(x: number, y: number): {
|
|
17
|
+
icon: string;
|
|
18
|
+
handler: (gateway: Gateway) => void;
|
|
19
|
+
} | undefined;
|
|
20
|
+
passIndicatorsMessage(indicatorMessage: any): void;
|
|
21
|
+
generateMessageProperties(): {
|
|
22
|
+
id: string;
|
|
23
|
+
time: number;
|
|
24
|
+
dest_id: any;
|
|
25
|
+
source_id: any;
|
|
26
|
+
is_reply: boolean;
|
|
27
|
+
};
|
|
28
|
+
generateReplyMessage(messageId: string, destId: string, action: string, body: any): {
|
|
29
|
+
properties: {
|
|
30
|
+
id: string;
|
|
31
|
+
time: number;
|
|
32
|
+
dest_id: any;
|
|
33
|
+
source_id: any;
|
|
34
|
+
is_reply: boolean;
|
|
35
|
+
};
|
|
36
|
+
body: any;
|
|
37
|
+
};
|
|
38
|
+
render(context: CanvasRenderingContext2D): void;
|
|
39
|
+
get indicators(): Indicator[];
|
|
40
|
+
get replyPublisher(): Component | undefined;
|
|
41
|
+
get replyGraphQl(): Component | undefined;
|
|
42
|
+
get reqPublisher(): Component | undefined;
|
|
43
|
+
get timer(): Component;
|
|
44
|
+
startBlinkingLed(): void;
|
|
45
|
+
stopBlinkingLed(): void;
|
|
46
|
+
startBlinkingLedBar(): void;
|
|
47
|
+
stopBlinkingLedBar(): void;
|
|
48
|
+
boot(): void;
|
|
49
|
+
off(): void;
|
|
50
|
+
setTimer(timestamp: number): void;
|
|
51
|
+
timerOn(): void;
|
|
52
|
+
timerOff(): void;
|
|
53
|
+
onchangeData(after: Properties, before: Properties): void;
|
|
54
|
+
onmousedown(e: MouseEvent, hint: any): void;
|
|
55
|
+
onmousemove(e: MouseEvent, hint: any): void;
|
|
56
|
+
get hasTextProperty(): boolean;
|
|
57
|
+
get nature(): ComponentNature;
|
|
58
|
+
}
|