@operato/scene-mpi 8.0.0-beta.1 → 8.0.0-beta.2

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.
@@ -1,292 +0,0 @@
1
- import { consoleLogger } from './gateway-on-message'
2
- import Indicator from './indicator'
3
-
4
- const colors = {
5
- R: '#f00',
6
- G: '#0f0',
7
- B: '#00f',
8
- C: '#0ff',
9
- M: '#f0f',
10
- Y: '#ff0',
11
- K: '#0000',
12
- W: '#fff'
13
- } as { [key: string]: string }
14
-
15
- export function onMouseDownMButton(indicator: Indicator) {
16
- if (
17
- indicator.state.boot_flag != 'true' ||
18
- !indicator.lit ||
19
- indicator.readOnly ||
20
- indicator.currentTask === indicator.tasks.FULL ||
21
- indicator.currentTask === indicator.tasks.END ||
22
- indicator.currentTask === indicator.tasks.INSPECT
23
- )
24
- return
25
- // modify
26
- consoleLogger('onMouseDownButton', 'M')
27
- var displayData = {} as any
28
- if (indicator.currentTask == 'modify') {
29
- indicator.currentTask = indicator.tasks.PICK
30
- indicator.currentTask = indicator.store.action_type
31
- displayData.org_box_qty = indicator.store.org_box_qty
32
- displayData.org_ea_qty = indicator.store.org_ea_qty
33
- displayData.buttonColor = colors[indicator.store.color]
34
- indicator.cookedData = displayData
35
- indicator.jobLightOn(displayData)
36
- } else {
37
- indicator.currentTask = indicator.tasks.MODIFY
38
- displayData.org_ea_qty = indicator.store.org_ea_qty
39
- displayData.org_box_qty = indicator.store.org_box_qty
40
- displayData.buttonColor = colors['M']
41
- indicator.cookedData = displayData
42
- indicator.jobLightOn(displayData)
43
- }
44
-
45
- // var boxQuan = indicator.store.org_box_qty
46
- // ? indicator.store.org_box_qty
47
- // : false;
48
- // var eaQuan = indicator.store.org_ea_qty ? indicator.store.org_ea_qty : false;
49
- // var isSame = true;
50
- // var userAction = "modify";
51
-
52
- // switch(indicator.currentTask) {
53
- // case indicator.tasks.PICK: {
54
- // var isQtyLessThenOne = (!indicator.store.org_box_qty && (indicator.store.org_ea_qty <= 1 || !indicator.store.org_ea_qty));
55
-
56
- // if (isQtyLessThenOne) {
57
- // userAction = 'ok';
58
- // } else {
59
- // do {
60
- // if(boxQuan) boxQuan = Math.round(boxQuan * Math.random());
61
- // if(eaQuan) eaQuan = Math.round(eaQuan * Math.random());
62
-
63
- // isSame = (indicator.store.org_box_qty == boxQuan) && (indicator.store.org_ea_qty == eaQuan);
64
- // } while(isSame);
65
- // }
66
- // } break;
67
- // case indicator.tasks.STOCK: {
68
- // if (boxQuan) boxQuan = Math.ceil(boxQuan * Math.random());
69
- // if (eaQuan) eaQuan = Math.ceil(eaQuan * Math.random());
70
- // } break;
71
- // }
72
-
73
- // boxQuan = Math.ceil(boxQuan / 2);
74
- // eaQuan = Math.ceil(eaQuan / 2);
75
-
76
- // isSame =
77
- // boxQuan == indicator.store.org_box_qty &&
78
- // eaQuan == indicator.store.org_ea_qty;
79
-
80
- // isSame ? (userAction = "ok") : (userAction = "modify");
81
-
82
- // indicator.gateway.passIndicatorsMessage(
83
- // _makeMsgBody(
84
- // indicator,
85
- // "IND_ON_RES",
86
- // indicator.store,
87
- // userAction,
88
- // boxQuan,
89
- // eaQuan
90
- // )
91
- // );
92
- // TODO 프로토콜 변경
93
- }
94
-
95
- export function onMouseDownFButton(indicator: Indicator) {
96
- if (
97
- indicator.state.boot_flag != 'true' ||
98
- !indicator.lit ||
99
- indicator.readOnly ||
100
- indicator.currentTask == indicator.tasks.STOCK ||
101
- indicator.currentTask === indicator.tasks.FULL
102
- )
103
- return
104
- consoleLogger('onMouseDownButton', 'F')
105
-
106
- if (indicator.currentTask == 'modify') {
107
- var displayData = {} as any
108
- // var orgEaQty = indicator.cookedData.res_ea_qty ? indicator.cookedData.res_ea_qty : 0;
109
- displayData.org_ea_qty =
110
- indicator.cookedData.org_ea_qty + 1 <= indicator.store.org_ea_qty ? indicator.cookedData.org_ea_qty + 1 : 0
111
- displayData.org_box_qty = indicator.store.org_box_qty
112
- displayData.buttonColor = colors['M']
113
- indicator.cookedData = displayData
114
- indicator.jobLightOn(displayData)
115
- } else {
116
- // full box
117
- if (indicator.state.reply_target == 'GraphQl') {
118
- indicator.gateway.replyGraphQl!.value = {
119
- pubTopic: indicator.gateway.state.subTopic,
120
- subTopic: indicator.gateway.state.pubTopic,
121
- params: {
122
- actionType: 'pick',
123
- bizFlag: 'full',
124
- action: 'IND_ON_RES',
125
- bizType: 'DPS',
126
- orgBoxQty: 0,
127
- orgEaQty: 0,
128
- id: indicator.store.id
129
- }
130
- }
131
- } else if ((indicator.state.reply_target = 'MQTT')) {
132
- indicator.gateway.passIndicatorsMessage(_makeMsgBody(indicator, 'IND_ON_RES', indicator.store, 'full'))
133
- }
134
- // TODO ack 받으면 소등
135
- // TODO 프로토콜 변경
136
- indicator.displayMessage('-FULL-', indicator.store.color)
137
- indicator.currentTask = indicator.tasks.FULL
138
- }
139
- }
140
-
141
- export function onMouseDownCButton(indicator: Indicator) {
142
- if (
143
- indicator.state.boot_flag != 'true' ||
144
- !indicator.lit ||
145
- indicator.readOnly ||
146
- indicator.currentTask == indicator.tasks.STOCK ||
147
- indicator.currentTask === indicator.tasks.FULL ||
148
- indicator.currentTask === indicator.tasks.END
149
- )
150
- return
151
- consoleLogger('onMouseDownButton', 'C')
152
- if (indicator.currentTask == 'modify') {
153
- var displayData = {} as any
154
- displayData.org_box_qty = indicator.store.org_box_qty
155
- displayData.org_ea_qty =
156
- indicator.cookedData.org_ea_qty - 1 >= 0 ? indicator.cookedData.org_ea_qty - 1 : indicator.store.org_ea_qty
157
- displayData.buttonColor = colors['M']
158
- indicator.cookedData = displayData
159
- indicator.jobLightOn(displayData)
160
- } else {
161
- // cancel
162
- if (indicator.state.reply_target == 'GraphQl') {
163
- indicator.gateway.replyGraphQl!.value = {
164
- pubTopic: indicator.gateway.state.subTopic,
165
- subTopic: indicator.gateway.state.pubTopic,
166
- params: {
167
- actionType: 'pick',
168
- bizFlag: 'cancel',
169
- action: 'IND_ON_RES',
170
- bizType: 'DPS',
171
- orgBoxQty: indicator.store.org_box_qty ? indicator.store.org_box_qty : 0,
172
- orgEaQty: 0,
173
- resEaQty: 0,
174
- id: indicator.store.id
175
- }
176
- }
177
- } else if ((indicator.state.reply_target = 'MQTT')) {
178
- indicator.gateway.passIndicatorsMessage(_makeMsgBody(indicator, 'IND_ON_RES', indicator.store, 'cancel', 0, 0))
179
- }
180
- indicator.displayMessage('CAnCEL')
181
- var displayData = {} as any
182
- displayData.org_box_qty = indicator.store.org_box_qty ? indicator.store.org_box_qty : 0
183
- displayData.org_ea_qty = 0
184
- displayData.buttonColor = ''
185
- indicator.cookedData = displayData
186
- indicator.jobLightOn(displayData)
187
-
188
- // 일정 시간 후 소등
189
- // setTimeout(() => {
190
- // indicator.gateway.passIndicatorsMessage(
191
- // _makeMsgBody(indicator, "IND_ON_RES", indicator.store, "cancel", 0, 0)
192
- // );
193
- // indicator.lightOff();
194
- // }, indicator.getConf.cncl_delay * 100);
195
- }
196
- }
197
-
198
- export function onMouseDownBigButton(indicator: Indicator) {
199
- // 작업자 버튼 터치
200
- if (
201
- indicator.state.boot_flag != 'true' ||
202
- !indicator.lit ||
203
- indicator.readOnly ||
204
- indicator.currentTask === indicator.tasks.END
205
- )
206
- return
207
- consoleLogger('onMouseDownBigButton')
208
- if (indicator.currentTask === indicator.tasks.FULL) {
209
- indicator.jobLightOn(indicator.cookedData)
210
- indicator.currentTask = indicator.tasks.DISPLAY
211
- return
212
- } else if (indicator.currentTask === indicator.tasks.INSPECT) {
213
- indicator.lightOff()
214
- return
215
- } else if (indicator.currentTask == 'modify') {
216
- indicator.store.res_ea_qty = indicator.cookedData.org_ea_qty
217
- indicator.store.res_box_qty = indicator.cookedData.org_box_qty
218
- }
219
- indicator.currentTask = indicator.tasks.END
220
- // 3.6 G/W에 정보 전송
221
- // 3.7 MPS에 전달
222
-
223
- if (indicator.state.reply_target == 'GraphQl') {
224
- indicator.gateway.replyGraphQl!.value = {
225
- pubTopic: indicator.gateway.state.subTopic,
226
- subTopic: indicator.gateway.state.pubTopic,
227
- params: {
228
- actionType: 'pick',
229
- bizFlag: 'ok',
230
- action: 'IND_ON_RES',
231
- bizType: 'DPS',
232
- id: indicator.store.id,
233
- orgRelay: indicator.store.org_relay,
234
- orgBoxQty: indicator.store.org_box_qty,
235
- orgEaQty: indicator.store.org_ea_qty,
236
- resBoxQty: indicator.store.org_box_qty,
237
- resEaQty: indicator.store.org_ea_qty
238
- }
239
- }
240
- } else if ((indicator.state.reply_target = 'MQTT')) {
241
- indicator.gateway.passIndicatorsMessage(
242
- _makeMsgBody(
243
- indicator,
244
- 'IND_ON_RES',
245
- indicator.store,
246
- 'ok',
247
- indicator.store.res_box_qty,
248
- indicator.store.res_ea_qty
249
- )
250
- )
251
- }
252
-
253
- // TODO ack 받으면 소등
254
-
255
- // 확정 누르면 오른쪽 세그먼트 숫자만 남기고 소등, display 시퀀스를 생략하기 위함
256
- // TODO 프로토콜 변경
257
- var displayData = {} as any
258
- displayData.org_ea_qty = indicator.store.org_ea_qty
259
- displayData.org_box_qty = indicator.store.org_box_qty
260
- displayData.buttonColor = ''
261
- indicator.cookedData = displayData
262
- indicator.jobLightOn(displayData)
263
- }
264
-
265
- var _makeMsgBody = function (indicator: Indicator, action: any, store: any, biz: any, resBox?: any, resEa?: any) {
266
- var { org_box_qty, org_ea_qty } = indicator.state
267
-
268
- var result
269
- result = {
270
- action: action,
271
- id: indicator.model.id,
272
- biz_id: store ? store.biz_id : undefined,
273
- biz_type: store.biz_type,
274
- action_type: store.action_type,
275
- ret_args: store.ret_args,
276
- biz_flag: biz
277
- } as any
278
- if (store) {
279
- if (store.org_relay || store.org_relay == 0) {
280
- result.org_relay = parseInt(store.org_relay)
281
- }
282
- if (store.org_box_qty || store.org_box_qty == 0) {
283
- result.org_box_qty = parseInt(store.org_box_qty)
284
- result.res_box_qty = resBox >= 0 ? resBox : parseInt(store.org_box_qty)
285
- }
286
- if (store.org_ea_qty || store.org_ea_qty == 0) {
287
- result.org_ea_qty = parseInt(store.org_ea_qty)
288
- result.res_ea_qty = resEa >= 0 ? resEa : parseInt(store.org_ea_qty)
289
- }
290
- }
291
- return result
292
- }