@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.
Files changed (125) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +31 -0
  3. package/assets/favicon.ico +0 -0
  4. package/assets/images/spinner.png +0 -0
  5. package/dist/auto-clicker.d.ts +10 -0
  6. package/dist/auto-clicker.js +84 -0
  7. package/dist/auto-clicker.js.map +1 -0
  8. package/dist/boot-button.d.ts +20 -0
  9. package/dist/boot-button.js +90 -0
  10. package/dist/boot-button.js.map +1 -0
  11. package/dist/gateway-on-button.d.ts +7 -0
  12. package/dist/gateway-on-button.js +88 -0
  13. package/dist/gateway-on-button.js.map +1 -0
  14. package/dist/gateway-on-message.d.ts +3 -0
  15. package/dist/gateway-on-message.js +375 -0
  16. package/dist/gateway-on-message.js.map +1 -0
  17. package/dist/gateway.d.ts +58 -0
  18. package/dist/gateway.js +396 -0
  19. package/dist/gateway.js.map +1 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.js +7 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/indicator-on-message.d.ts +2 -0
  24. package/dist/indicator-on-message.js +5 -0
  25. package/dist/indicator-on-message.js.map +1 -0
  26. package/dist/indicator-user-action.d.ts +5 -0
  27. package/dist/indicator-user-action.js +263 -0
  28. package/dist/indicator-user-action.js.map +1 -0
  29. package/dist/indicator.d.ts +83 -0
  30. package/dist/indicator.js +544 -0
  31. package/dist/indicator.js.map +1 -0
  32. package/dist/reply-button.d.ts +20 -0
  33. package/dist/reply-button.js +67 -0
  34. package/dist/reply-button.js.map +1 -0
  35. package/dist/segment-display.d.ts +41 -0
  36. package/dist/segment-display.js +521 -0
  37. package/dist/segment-display.js.map +1 -0
  38. package/dist/seven-segment.d.ts +7 -0
  39. package/dist/seven-segment.js +137 -0
  40. package/dist/seven-segment.js.map +1 -0
  41. package/dist/templates/auto-clicker.d.ts +17 -0
  42. package/dist/templates/auto-clicker.js +19 -0
  43. package/dist/templates/auto-clicker.js.map +1 -0
  44. package/dist/templates/boot-button.d.ts +16 -0
  45. package/dist/templates/boot-button.js +18 -0
  46. package/dist/templates/boot-button.js.map +1 -0
  47. package/dist/templates/gateway.d.ts +16 -0
  48. package/dist/templates/gateway.js +18 -0
  49. package/dist/templates/gateway.js.map +1 -0
  50. package/dist/templates/index.d.ts +16 -0
  51. package/dist/templates/index.js +15 -0
  52. package/dist/templates/index.js.map +1 -0
  53. package/dist/templates/indicator.d.ts +16 -0
  54. package/dist/templates/indicator.js +18 -0
  55. package/dist/templates/indicator.js.map +1 -0
  56. package/dist/templates/reply-button.d.ts +16 -0
  57. package/dist/templates/reply-button.js +18 -0
  58. package/dist/templates/reply-button.js.map +1 -0
  59. package/dist/templates/seven-segment.d.ts +28 -0
  60. package/dist/templates/seven-segment.js +30 -0
  61. package/dist/templates/seven-segment.js.map +1 -0
  62. package/dist/uuid.d.ts +1 -0
  63. package/dist/uuid.js +21 -0
  64. package/dist/uuid.js.map +1 -0
  65. package/helps/scene/component/auto-clicker.ko.md +3 -0
  66. package/helps/scene/component/auto-clicker.md +3 -0
  67. package/helps/scene/component/auto-clicker.zh.md +3 -0
  68. package/helps/scene/component/boot-button.ko.md +3 -0
  69. package/helps/scene/component/boot-button.md +3 -0
  70. package/helps/scene/component/boot-button.zh.md +3 -0
  71. package/helps/scene/component/gateway.ko.md +3 -0
  72. package/helps/scene/component/gateway.md +3 -0
  73. package/helps/scene/component/gateway.zh.md +3 -0
  74. package/helps/scene/component/indicator.ko.md +3 -0
  75. package/helps/scene/component/indicator.md +3 -0
  76. package/helps/scene/component/indicator.zh.md +3 -0
  77. package/helps/scene/component/reply-button.ko.md +3 -0
  78. package/helps/scene/component/reply-button.md +3 -0
  79. package/helps/scene/component/reply-button.zh.md +3 -0
  80. package/helps/scene/component/seven-segment.ko.md +3 -0
  81. package/helps/scene/component/seven-segment.md +3 -0
  82. package/helps/scene/component/seven-segment.zh.md +3 -0
  83. package/icons/boot-button.png +0 -0
  84. package/icons/button-error.png +0 -0
  85. package/icons/button-start.png +0 -0
  86. package/icons/button-status.png +0 -0
  87. package/icons/button-stop.png +0 -0
  88. package/icons/gateway.png +0 -0
  89. package/icons/icon-boot-button.png +0 -0
  90. package/icons/icon-gateway.png +0 -0
  91. package/icons/icon-indicator.png +0 -0
  92. package/icons/icon-reply-button.png +0 -0
  93. package/icons/icon-seven-segment.png +0 -0
  94. package/icons/indicator.png +0 -0
  95. package/icons/no-image.png +0 -0
  96. package/icons/reply-button.png +0 -0
  97. package/package.json +61 -0
  98. package/src/auto-clicker.ts +97 -0
  99. package/src/boot-button.ts +112 -0
  100. package/src/gateway-on-button.ts +97 -0
  101. package/src/gateway-on-message.ts +405 -0
  102. package/src/gateway.ts +484 -0
  103. package/src/index.ts +6 -0
  104. package/src/indicator-on-message.ts +6 -0
  105. package/src/indicator-user-action.ts +292 -0
  106. package/src/indicator.ts +638 -0
  107. package/src/reply-button.ts +88 -0
  108. package/src/segment-display.ts +608 -0
  109. package/src/seven-segment.ts +162 -0
  110. package/src/templates/auto-clicker.ts +19 -0
  111. package/src/templates/boot-button.ts +18 -0
  112. package/src/templates/gateway.ts +18 -0
  113. package/src/templates/index.ts +15 -0
  114. package/src/templates/indicator.ts +18 -0
  115. package/src/templates/reply-button.ts +18 -0
  116. package/src/templates/seven-segment.ts +30 -0
  117. package/src/uuid.ts +20 -0
  118. package/things-scene.config.js +5 -0
  119. package/translations/en.json +26 -0
  120. package/translations/ja.json +26 -0
  121. package/translations/ko.json +26 -0
  122. package/translations/ms.json +23 -0
  123. package/translations/zh.json +23 -0
  124. package/tsconfig.json +22 -0
  125. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,292 @@
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
+ }