@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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [1.3.7](https://github.com/things-scene/operato-scene/compare/v1.3.6...v1.3.7) (2024-01-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* mpi module moved from things-factory ([47b743f](https://github.com/things-scene/operato-scene/commit/47b743fd19001f195db85e50b8f6e457a1573aa5))
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## node package를 설치한다.
|
|
2
|
+
|
|
3
|
+
`$ yarn`
|
|
4
|
+
|
|
5
|
+
## 실행
|
|
6
|
+
|
|
7
|
+
`$ yarn serve`
|
|
8
|
+
`$ yarn serve:dev`
|
|
9
|
+
|
|
10
|
+
## 포트를 바꾸려면, -p 3001 식으로 추가해준다.
|
|
11
|
+
|
|
12
|
+
`$ yarn serve`
|
|
13
|
+
`$ yarn serve -p 3001`
|
|
14
|
+
|
|
15
|
+
## test in browser
|
|
16
|
+
|
|
17
|
+
http://localhost:3000
|
|
18
|
+
|
|
19
|
+
## build
|
|
20
|
+
|
|
21
|
+
`$ yarn build`
|
|
22
|
+
|
|
23
|
+
| type | filename | for | tested |
|
|
24
|
+
| ---- | ---------------------- | -------------- | ------ |
|
|
25
|
+
| UMD | things-scene-mpi.js | modern browser | O |
|
|
26
|
+
| UMD | things-scene-mpi-ie.js | ie 11 | O |
|
|
27
|
+
| ESM | things-scene-mpi.mjs | modern browser | O |
|
|
28
|
+
|
|
29
|
+
## publish
|
|
30
|
+
|
|
31
|
+
`$ yarn publish`
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentNature, Shape } from '@hatiolab/things-scene';
|
|
2
|
+
declare const AutoClicker_base: typeof Shape;
|
|
3
|
+
export default class AutoClicker extends AutoClicker_base {
|
|
4
|
+
autoClicker: any;
|
|
5
|
+
dispose(): void;
|
|
6
|
+
render(context: CanvasRenderingContext2D): void;
|
|
7
|
+
onmousedown(e: Event, hint: any): void;
|
|
8
|
+
get nature(): ComponentNature;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Component, RectPath, Shape } from '@hatiolab/things-scene';
|
|
2
|
+
import { consoleLogger } from './gateway-on-message';
|
|
3
|
+
const NATURE = {
|
|
4
|
+
mutable: false,
|
|
5
|
+
resizable: true,
|
|
6
|
+
rotatable: true,
|
|
7
|
+
properties: [
|
|
8
|
+
{
|
|
9
|
+
type: 'select',
|
|
10
|
+
name: 'switch',
|
|
11
|
+
label: 'switch',
|
|
12
|
+
placeholder: 'false',
|
|
13
|
+
property: {
|
|
14
|
+
options: [
|
|
15
|
+
{
|
|
16
|
+
display: 'OFF',
|
|
17
|
+
value: 'false'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
display: 'ON',
|
|
21
|
+
value: 'true'
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'string',
|
|
28
|
+
name: 'target',
|
|
29
|
+
label: 'target',
|
|
30
|
+
placeholder: ''
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'number',
|
|
34
|
+
name: 'interval',
|
|
35
|
+
label: 'interval',
|
|
36
|
+
placeholder: '0'
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
help: 'scene/component/auto-clicker'
|
|
40
|
+
};
|
|
41
|
+
export default class AutoClicker extends RectPath(Shape) {
|
|
42
|
+
dispose() {
|
|
43
|
+
clearInterval(this.autoClicker);
|
|
44
|
+
delete this.autoClicker;
|
|
45
|
+
super.dispose();
|
|
46
|
+
}
|
|
47
|
+
render(context) {
|
|
48
|
+
var { left, top, width, height } = this.bounds;
|
|
49
|
+
context.beginPath();
|
|
50
|
+
context.rect(left, top, width, height);
|
|
51
|
+
this.drawFill(context);
|
|
52
|
+
this.drawStroke(context);
|
|
53
|
+
}
|
|
54
|
+
onmousedown(e, hint) {
|
|
55
|
+
var autoClicker = () => {
|
|
56
|
+
this.autoClicker = setTimeout(() => {
|
|
57
|
+
//@ts-ignore
|
|
58
|
+
target === null || target === void 0 ? void 0 : target.onmousedown.call(target, e, hint);
|
|
59
|
+
autoClicker();
|
|
60
|
+
}, interval);
|
|
61
|
+
};
|
|
62
|
+
var pp = { true: true, false: false };
|
|
63
|
+
//@ts-ignore
|
|
64
|
+
var currentSwitchState = pp[this.getState('switch')];
|
|
65
|
+
var interval = this.getState('interval');
|
|
66
|
+
var target = this.root.findById(this.getState('target'));
|
|
67
|
+
this.setState('switch', !currentSwitchState);
|
|
68
|
+
currentSwitchState = !currentSwitchState;
|
|
69
|
+
this.text = currentSwitchState ? 'ON' : 'OFF';
|
|
70
|
+
this.setState('fontColor', currentSwitchState ? 'rgb(0, 173, 31)' : 'rgb(254, 3, 3)');
|
|
71
|
+
consoleLogger('Auto response:', currentSwitchState);
|
|
72
|
+
if (currentSwitchState && target && interval >= 1000) {
|
|
73
|
+
autoClicker();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
clearTimeout(this.autoClicker);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
get nature() {
|
|
80
|
+
return NATURE;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
Component.register('auto-clicker', AutoClicker);
|
|
84
|
+
//# sourceMappingURL=auto-clicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-clicker.js","sourceRoot":"","sources":["../src/auto-clicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE;gBACR,OAAO,EAAE;oBACP;wBACE,OAAO,EAAE,KAAK;wBACd,KAAK,EAAE,OAAO;qBACf;oBACD;wBACE,OAAO,EAAE,IAAI;wBACb,KAAK,EAAE,MAAM;qBACd;iBACF;aACF;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,WA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,CAAC,CAAC,CAAA;QACpD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;QACxC,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAA;QAExD,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,kBAAkB,CAAC,CAAA;QAC5C,kBAAkB,GAAG,CAAC,kBAAkB,CAAA;QAExC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;QAC7C,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;QACrF,aAAa,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAA;QAEnD,IAAI,kBAAkB,IAAI,MAAM,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrD,WAAW,EAAE,CAAA;QACf,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'\nimport { consoleLogger } from './gateway-on-message'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n name: 'switch',\n label: 'switch',\n placeholder: 'false',\n property: {\n options: [\n {\n display: 'OFF',\n value: 'false'\n },\n {\n display: 'ON',\n value: 'true'\n }\n ]\n }\n },\n {\n type: 'string',\n name: 'target',\n label: 'target',\n placeholder: ''\n },\n {\n type: 'number',\n name: 'interval',\n label: 'interval',\n placeholder: '0'\n }\n ],\n help: 'scene/component/auto-clicker'\n}\n\nexport default class AutoClicker extends RectPath(Shape) {\n autoClicker: any\n\n dispose() {\n clearInterval(this.autoClicker)\n delete this.autoClicker\n super.dispose()\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n\n context.rect(left, top, width, height)\n\n this.drawFill(context)\n this.drawStroke(context)\n }\n\n onmousedown(e: Event, hint: any) {\n var autoClicker = () => {\n this.autoClicker = setTimeout(() => {\n //@ts-ignore\n target?.onmousedown.call(target, e, hint)\n autoClicker()\n }, interval)\n }\n\n var pp = { true: true, false: false }\n //@ts-ignore\n var currentSwitchState = pp[this.getState('switch')]\n var interval = this.getState('interval')\n var target = this.root.findById(this.getState('target'))\n\n this.setState('switch', !currentSwitchState)\n currentSwitchState = !currentSwitchState\n\n this.text = currentSwitchState ? 'ON' : 'OFF'\n this.setState('fontColor', currentSwitchState ? 'rgb(0, 173, 31)' : 'rgb(254, 3, 3)')\n consoleLogger('Auto response:', currentSwitchState)\n\n if (currentSwitchState && target && interval >= 1000) {\n autoClicker()\n } else {\n clearTimeout(this.autoClicker)\n }\n }\n\n get nature() {\n return NATURE\n }\n}\n\nComponent.register('auto-clicker', AutoClicker)\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component, ComponentNature, Shape } from '@hatiolab/things-scene';
|
|
2
|
+
export declare const buttons: {
|
|
3
|
+
icon: string;
|
|
4
|
+
handler: typeof onclickBoot;
|
|
5
|
+
}[];
|
|
6
|
+
declare const BootButton_base: typeof Shape;
|
|
7
|
+
export default class BootButton extends BootButton_base {
|
|
8
|
+
static _image: HTMLImageElement;
|
|
9
|
+
static get image(): HTMLImageElement;
|
|
10
|
+
get publisher(): Component | undefined;
|
|
11
|
+
render(context: CanvasRenderingContext2D): void;
|
|
12
|
+
onmousedown(e: MouseEvent, hint: any): void;
|
|
13
|
+
buttonContains(x: number, y: number): {
|
|
14
|
+
icon: string;
|
|
15
|
+
handler: typeof onclickBoot;
|
|
16
|
+
};
|
|
17
|
+
get nature(): ComponentNature;
|
|
18
|
+
}
|
|
19
|
+
declare function onclickBoot(button: BootButton): void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const boot = new URL('../../icons/boot-button.png', import.meta.url).href;
|
|
2
|
+
import { Component, RectPath, Shape } from '@hatiolab/things-scene';
|
|
3
|
+
import { uuid } from './uuid';
|
|
4
|
+
import { consoleLogger } from './gateway-on-message';
|
|
5
|
+
export const buttons = [
|
|
6
|
+
{
|
|
7
|
+
icon: boot,
|
|
8
|
+
handler: onclickBoot
|
|
9
|
+
}
|
|
10
|
+
];
|
|
11
|
+
const BUTTONS_MARGIN = 10;
|
|
12
|
+
const NATURE = {
|
|
13
|
+
mutable: false,
|
|
14
|
+
resizable: true,
|
|
15
|
+
rotatable: true,
|
|
16
|
+
properties: [
|
|
17
|
+
{
|
|
18
|
+
type: 'string',
|
|
19
|
+
name: 'publisher',
|
|
20
|
+
label: 'publisher'
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
help: 'scene/component/boot-button'
|
|
24
|
+
};
|
|
25
|
+
export default class BootButton extends RectPath(Shape) {
|
|
26
|
+
static get image() {
|
|
27
|
+
if (!BootButton._image) {
|
|
28
|
+
BootButton._image = new Image();
|
|
29
|
+
BootButton._image.src = boot;
|
|
30
|
+
}
|
|
31
|
+
return BootButton._image;
|
|
32
|
+
}
|
|
33
|
+
get publisher() {
|
|
34
|
+
if (this.state.publisher) {
|
|
35
|
+
return this.root.findById(this.state.publisher);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
render(context) {
|
|
39
|
+
var { left, top, width, height } = this.bounds;
|
|
40
|
+
context.beginPath();
|
|
41
|
+
context.rect(left, top, width, height);
|
|
42
|
+
this.drawFill(context);
|
|
43
|
+
this.drawStroke(context);
|
|
44
|
+
this.drawImage(context, BootButton.image, left, top, width, height);
|
|
45
|
+
}
|
|
46
|
+
onmousedown(e, hint) {
|
|
47
|
+
var { left, top, width, height } = this.bounds;
|
|
48
|
+
var { x, y } = this.transcoordC2S(e.offsetX, e.offsetY);
|
|
49
|
+
var button = this.buttonContains(x - left - BUTTONS_MARGIN, y - top - BUTTONS_MARGIN);
|
|
50
|
+
if (button) {
|
|
51
|
+
button.handler(this);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
buttonContains(x, y) {
|
|
55
|
+
return buttons[0];
|
|
56
|
+
}
|
|
57
|
+
get nature() {
|
|
58
|
+
return NATURE;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function onclickBoot(button) {
|
|
62
|
+
consoleLogger('onclickBoot');
|
|
63
|
+
if (!button.data)
|
|
64
|
+
return;
|
|
65
|
+
var gateways = button.data;
|
|
66
|
+
for (let i = 0; i < gateways.length; i++) {
|
|
67
|
+
// var gatewayObjects = gateways.map((value, index) => {
|
|
68
|
+
// return this.root.findById(value);
|
|
69
|
+
// }, this);
|
|
70
|
+
// gatewayObjects.forEach((gateway, index) => {
|
|
71
|
+
// gateway.boot();
|
|
72
|
+
// });
|
|
73
|
+
button.publisher.data = {
|
|
74
|
+
properties: {
|
|
75
|
+
id: uuid(),
|
|
76
|
+
time: Date.now(),
|
|
77
|
+
dest_id: 'mps_server',
|
|
78
|
+
source_id: gateways[i],
|
|
79
|
+
is_reply: false
|
|
80
|
+
},
|
|
81
|
+
body: {
|
|
82
|
+
action: 'GW_INIT_REQ',
|
|
83
|
+
id: gateways[i]
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
consoleLogger('sent GW_INIT_REQ', button.publisher.data);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
Component.register('boot-button', BootButton);
|
|
90
|
+
//# sourceMappingURL=boot-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot-button.js","sourceRoot":"","sources":["../src/boot-button.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAA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G,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,wDAAwD;QACxD,sCAAsC;QACtC,YAAY;QAEZ,+CAA+C;QAC/C,oBAAoB;QACpB,MAAM;QACN,MAAM,CAAC,SAAU,CAAC,IAAI,GAAG;YACvB,UAAU,EAAE;gBACV,EAAE,EAAE,IAAI,EAAE;gBACV,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;gBAChB,OAAO,EAAE,YAAY;gBACrB,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;gBACtB,QAAQ,EAAE,KAAK;aAChB;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,aAAa;gBACrB,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;aAChB;SACF,CAAA;QAED,aAAa,CAAC,kBAAkB,EAAE,MAAM,CAAC,SAAU,CAAC,IAAI,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC;AAED,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA","sourcesContent":["const boot = new URL('../../icons/boot-button.png', import.meta.url).href\nimport { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'\n\nimport { uuid } from './uuid'\n\nimport { consoleLogger } from './gateway-on-message'\n\nexport const buttons = [\n {\n icon: boot,\n handler: onclickBoot\n }\n]\n\nconst BUTTONS_MARGIN = 10\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'string',\n name: 'publisher',\n label: 'publisher'\n }\n ],\n help: 'scene/component/boot-button'\n}\n\nexport default class BootButton extends RectPath(Shape) {\n static _image: HTMLImageElement\n\n static get image() {\n if (!BootButton._image) {\n BootButton._image = new Image()\n BootButton._image.src = boot\n }\n\n return BootButton._image\n }\n\n get publisher() {\n if (this.state.publisher) {\n return this.root.findById(this.state.publisher)\n }\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n\n context.rect(left, top, width, height)\n\n this.drawFill(context)\n this.drawStroke(context)\n\n this.drawImage(context, BootButton.image, left, top, width, height)\n }\n\n onmousedown(e: MouseEvent, hint: any) {\n var { left, top, width, height } = this.bounds\n\n var { x, y } = this.transcoordC2S(e.offsetX, e.offsetY)\n\n var button = this.buttonContains(x - left - BUTTONS_MARGIN, y - top - BUTTONS_MARGIN)\n if (button) {\n button.handler(this)\n }\n }\n\n buttonContains(x: number, y: number) {\n return buttons[0]\n }\n\n get nature() {\n return NATURE\n }\n}\n\nfunction onclickBoot(button: BootButton) {\n consoleLogger('onclickBoot')\n if (!button.data) return\n var gateways = button.data\n for (let i = 0; i < gateways.length; i++) {\n // var gatewayObjects = gateways.map((value, index) => {\n // return this.root.findById(value);\n // }, this);\n\n // gatewayObjects.forEach((gateway, index) => {\n // gateway.boot();\n // });\n button.publisher!.data = {\n properties: {\n id: uuid(),\n time: Date.now(),\n dest_id: 'mps_server',\n source_id: gateways[i],\n is_reply: false\n },\n body: {\n action: 'GW_INIT_REQ',\n id: gateways[i]\n }\n }\n\n consoleLogger('sent GW_INIT_REQ', button.publisher!.data)\n }\n}\n\nComponent.register('boot-button', BootButton)\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const start = new URL('../../icons/button-start.png', import.meta.url).href;
|
|
2
|
+
const stop = new URL('../../icons/button-stop.png', import.meta.url).href;
|
|
3
|
+
const status = new URL('../../icons/button-status.png', import.meta.url).href;
|
|
4
|
+
const error = new URL('../../icons/button-error.png', import.meta.url).href;
|
|
5
|
+
import { consoleLogger } from './gateway-on-message';
|
|
6
|
+
export const buttons = [
|
|
7
|
+
{
|
|
8
|
+
icon: start,
|
|
9
|
+
handler: onclickStart
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
icon: stop,
|
|
13
|
+
handler: onclickStop
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
icon: status,
|
|
17
|
+
handler: onclickStatus
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
icon: error,
|
|
21
|
+
handler: onclickError
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
icon: status,
|
|
25
|
+
handler: onclickTimesync
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
function onclickStart(gateway) {
|
|
29
|
+
// Boot
|
|
30
|
+
// 전원 ON
|
|
31
|
+
consoleLogger('onclickStart');
|
|
32
|
+
gateway.boot();
|
|
33
|
+
}
|
|
34
|
+
function onclickStop(gateway) {
|
|
35
|
+
// 전원 OFF
|
|
36
|
+
consoleLogger('onclickStop');
|
|
37
|
+
gateway.off();
|
|
38
|
+
}
|
|
39
|
+
function onclickStatus(gateway) {
|
|
40
|
+
consoleLogger('onclickStatus');
|
|
41
|
+
if (gateway.state.power_flag == 'false')
|
|
42
|
+
return;
|
|
43
|
+
////////random indicator////////
|
|
44
|
+
var indicator = gateway.indicators[Math.floor(Math.random() * gateway.indicators.length)];
|
|
45
|
+
gateway.replyPublisher.data = {
|
|
46
|
+
properties: gateway.generateMessageProperties(),
|
|
47
|
+
body: {
|
|
48
|
+
action: 'IND_STATUS_RPT',
|
|
49
|
+
id: indicator.model.id,
|
|
50
|
+
version: indicator.version,
|
|
51
|
+
status: Math.random() > 0.5 ? 'ok' : 'offline', // random status
|
|
52
|
+
rssi: Math.floor(Math.random() * 100).toString(),
|
|
53
|
+
battery: Math.floor(Math.random() * 100).toString()
|
|
54
|
+
// status: (indicator.state.boot_flag == "true") ? "ok" : "offline"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
consoleLogger('sent IND_STATUS_RPT', gateway.replyPublisher.data);
|
|
58
|
+
////////////////////////////////
|
|
59
|
+
}
|
|
60
|
+
function onclickError(gateway) {
|
|
61
|
+
consoleLogger('onclickError');
|
|
62
|
+
if (gateway.state.power_flag == 'false')
|
|
63
|
+
return;
|
|
64
|
+
let hwgb = Math.random();
|
|
65
|
+
gateway.replyPublisher.data = {
|
|
66
|
+
properties: gateway.generateMessageProperties(),
|
|
67
|
+
body: {
|
|
68
|
+
action: 'ERR_RPT',
|
|
69
|
+
hw_gb: hwgb > 0.5 ? 'gw' : 'ind',
|
|
70
|
+
id: hwgb > 0.5 ? gateway.model.id : gateway.indicators[Math.floor(hwgb * gateway.indicators.length * 2)].model.id,
|
|
71
|
+
message: ['ERR001', 'ERR002', 'ERR003', 'ERR004', 'ERR005', 'ERR006'][Math.floor(Math.random() * 6)]
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
consoleLogger('sent ERR_RPT', gateway.replyPublisher.data);
|
|
75
|
+
}
|
|
76
|
+
function onclickTimesync(gateway) {
|
|
77
|
+
consoleLogger('onclickTimesync');
|
|
78
|
+
if (gateway.state.power_flag == 'false')
|
|
79
|
+
return;
|
|
80
|
+
gateway.replyPublisher.data = {
|
|
81
|
+
properties: gateway.generateMessageProperties(),
|
|
82
|
+
body: {
|
|
83
|
+
action: 'TIMESYNC_REQ'
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
consoleLogger('sent TIMESYNC_REQ', gateway.replyPublisher.data);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=gateway-on-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-on-button.js","sourceRoot":"","sources":["../src/gateway-on-button.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,8BAA8B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAC3E,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AACzE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,+BAA+B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAC7E,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,8BAA8B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,C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AC,CAAC;SACrG;KACF,CAAA;IACD,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,cAAe,CAAC,IAAI,CAAC,CAAA;AAC7D,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB;IACvC,aAAa,CAAC,iBAAiB,CAAC,CAAA;IAChC,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,OAAO;QAAE,OAAM;IAE/C,OAAO,CAAC,cAAe,CAAC,IAAI,GAAG;QAC7B,UAAU,EAAE,OAAO,CAAC,yBAAyB,EAAE;QAC/C,IAAI,EAAE;YACJ,MAAM,EAAE,cAAc;SACvB;KACF,CAAA;IACD,aAAa,CAAC,mBAAmB,EAAE,OAAO,CAAC,cAAe,CAAC,IAAI,CAAC,CAAA;AAClE,CAAC","sourcesContent":["const start = new URL('../../icons/button-start.png', import.meta.url).href\nconst stop = new URL('../../icons/button-stop.png', import.meta.url).href\nconst status = new URL('../../icons/button-status.png', import.meta.url).href\nconst error = new URL('../../icons/button-error.png', import.meta.url).href\n\nimport Gateway from './gateway'\nimport { consoleLogger } from './gateway-on-message'\n\nexport const buttons = [\n {\n icon: start,\n handler: onclickStart\n },\n {\n icon: stop,\n handler: onclickStop\n },\n {\n icon: status,\n handler: onclickStatus\n },\n {\n icon: error,\n handler: onclickError\n },\n {\n icon: status,\n handler: onclickTimesync\n }\n]\n\nfunction onclickStart(gateway: Gateway) {\n // Boot\n // 전원 ON\n consoleLogger('onclickStart')\n gateway.boot()\n}\n\nfunction onclickStop(gateway: Gateway) {\n // 전원 OFF\n consoleLogger('onclickStop')\n gateway.off()\n}\n\nfunction onclickStatus(gateway: Gateway) {\n consoleLogger('onclickStatus')\n if (gateway.state.power_flag == 'false') return\n\n ////////random indicator////////\n var indicator = gateway.indicators[Math.floor(Math.random() * gateway.indicators.length)]\n\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'IND_STATUS_RPT',\n id: indicator.model.id,\n version: indicator.version,\n status: Math.random() > 0.5 ? 'ok' : 'offline', // random status\n rssi: Math.floor(Math.random() * 100).toString(),\n battery: Math.floor(Math.random() * 100).toString()\n // status: (indicator.state.boot_flag == \"true\") ? \"ok\" : \"offline\"\n }\n }\n consoleLogger('sent IND_STATUS_RPT', gateway.replyPublisher!.data)\n ////////////////////////////////\n}\n\nfunction onclickError(gateway: Gateway) {\n consoleLogger('onclickError')\n if (gateway.state.power_flag == 'false') return\n\n let hwgb = Math.random()\n\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'ERR_RPT',\n hw_gb: hwgb > 0.5 ? 'gw' : 'ind',\n id: hwgb > 0.5 ? gateway.model.id : gateway.indicators[Math.floor(hwgb * gateway.indicators.length * 2)].model.id,\n message: ['ERR001', 'ERR002', 'ERR003', 'ERR004', 'ERR005', 'ERR006'][Math.floor(Math.random() * 6)]\n }\n }\n consoleLogger('sent ERR_RPT', gateway.replyPublisher!.data)\n}\n\nfunction onclickTimesync(gateway: Gateway) {\n consoleLogger('onclickTimesync')\n if (gateway.state.power_flag == 'false') return\n\n gateway.replyPublisher!.data = {\n properties: gateway.generateMessageProperties(),\n body: {\n action: 'TIMESYNC_REQ'\n }\n }\n consoleLogger('sent TIMESYNC_REQ', gateway.replyPublisher!.data)\n}\n"]}
|