@operato/scene-mpi 7.0.1 → 7.3.19
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/package.json +3 -3
- package/CHANGELOG.md +0 -95
- package/src/auto-clicker.ts +0 -97
- package/src/boot-button.ts +0 -112
- package/src/gateway-on-button.ts +0 -97
- package/src/gateway-on-message.ts +0 -405
- package/src/gateway.ts +0 -484
- package/src/index.ts +0 -6
- package/src/indicator-on-message.ts +0 -6
- package/src/indicator-user-action.ts +0 -292
- package/src/indicator.ts +0 -638
- package/src/reply-button.ts +0 -88
- package/src/segment-display.ts +0 -608
- package/src/seven-segment.ts +0 -162
- package/src/templates/auto-clicker.ts +0 -19
- package/src/templates/boot-button.ts +0 -18
- package/src/templates/gateway.ts +0 -18
- package/src/templates/index.ts +0 -15
- package/src/templates/indicator.ts +0 -18
- package/src/templates/reply-button.ts +0 -18
- package/src/templates/seven-segment.ts +0 -30
- package/src/uuid.ts +0 -20
- package/tsconfig.json +0 -23
- package/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@operato/scene-mpi",
|
|
3
3
|
"description": "Multi-purpose indicator integration component for things-scene",
|
|
4
4
|
"author": "heartyoh",
|
|
5
|
-
"version": "7.
|
|
5
|
+
"version": "7.3.19",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"migration": "things-factory-migration"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@hatiolab/things-scene": "^3.
|
|
30
|
+
"@hatiolab/things-scene": "^3.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@hatiolab/prettier-config": "^1.0.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"prettier --write"
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "ff73072a62ee02520f9d986d0095f6d329de64f9"
|
|
61
61
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
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
|
-
## [7.0.1](https://github.com/things-scene/operato-scene/compare/v7.0.0...v7.0.1) (2024-06-30)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### :bug: Bug Fix
|
|
10
|
-
|
|
11
|
-
* things-factory@7.0.0 ([f4cfe44](https://github.com/things-scene/operato-scene/commit/f4cfe44cb565e7b8fdc0df210a722b6526871848))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## [7.0.0](https://github.com/things-scene/operato-scene/compare/v7.0.0-rc.4...v7.0.0) (2024-06-30)
|
|
16
|
-
|
|
17
|
-
**Note:** Version bump only for package @operato/scene-mpi
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## [7.0.0-rc.1](https://github.com/things-scene/operato-scene/compare/v7.0.0-rc.0...v7.0.0-rc.1) (2024-06-21)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### :bug: Bug Fix
|
|
27
|
-
|
|
28
|
-
* apply v7-rc dependencies ([eee5612](https://github.com/things-scene/operato-scene/commit/eee5612e1d569387c284a7c6c49d64ef44b6d701))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## [7.0.0-rc.0](https://github.com/things-scene/operato-scene/compare/v2.0.0-beta.8...v7.0.0-rc.0) (2024-06-21)
|
|
33
|
-
|
|
34
|
-
**Note:** Version bump only for package @operato/scene-mpi
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## [2.0.0-beta.0](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.12...v2.0.0-beta.0) (2024-06-01)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### :rocket: New Features
|
|
44
|
-
|
|
45
|
-
* 2.0.0-beta.0 ([a2e2869](https://github.com/things-scene/operato-scene/commit/a2e28694eedf5bab0c54bcab5432d54ec59edd7f))
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### :bug: Bug Fix
|
|
49
|
-
|
|
50
|
-
* allowJs in tsconfig option ([fa77174](https://github.com/things-scene/operato-scene/commit/fa771742188f21f177f0a85281570f59f0c478cf))
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## [2.0.0-alpha.9](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.8...v2.0.0-alpha.9) (2024-04-11)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### :bug: Bug Fix
|
|
58
|
-
|
|
59
|
-
* things-factory@7.0.1 ([a9f4c18](https://github.com/things-scene/operato-scene/commit/a9f4c1873b80c540e4c2e16649e127ccffcf9a4c))
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## [2.0.0-alpha.6](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.5...v2.0.0-alpha.6) (2024-03-24)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
### :bug: Bug Fix
|
|
67
|
-
|
|
68
|
-
* translation ([266d423](https://github.com/things-scene/operato-scene/commit/266d423d9d6992464f45a437acc90ccf8ed33bf6))
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
## [2.0.0-alpha.4](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.3...v2.0.0-alpha.4) (2024-03-21)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### :bug: Bug Fix
|
|
76
|
-
|
|
77
|
-
* 컴포넌트 명 다국어 ([64e1f08](https://github.com/things-scene/operato-scene/commit/64e1f08af32d2ac193c3d31b0025f8d06f569ca4))
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
## [2.0.0-alpha.0](https://github.com/things-scene/operato-scene/compare/v1.3.9...v2.0.0-alpha.0) (2024-01-14)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
### :bug: Bug Fix
|
|
85
|
-
|
|
86
|
-
* 2.0.0-alpha.0 ([93274e3](https://github.com/things-scene/operato-scene/commit/93274e36c5d184f339f83899654dd48b4786ac2b))
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
## [1.3.7](https://github.com/things-scene/operato-scene/compare/v1.3.6...v1.3.7) (2024-01-01)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
### :bug: Bug Fix
|
|
94
|
-
|
|
95
|
-
* mpi module moved from things-factory ([47b743f](https://github.com/things-scene/operato-scene/commit/47b743fd19001f195db85e50b8f6e457a1573aa5))
|
package/src/auto-clicker.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'
|
|
2
|
-
import { consoleLogger } from './gateway-on-message'
|
|
3
|
-
|
|
4
|
-
const NATURE: ComponentNature = {
|
|
5
|
-
mutable: false,
|
|
6
|
-
resizable: true,
|
|
7
|
-
rotatable: true,
|
|
8
|
-
properties: [
|
|
9
|
-
{
|
|
10
|
-
type: 'select',
|
|
11
|
-
name: 'switch',
|
|
12
|
-
label: 'switch',
|
|
13
|
-
placeholder: 'false',
|
|
14
|
-
property: {
|
|
15
|
-
options: [
|
|
16
|
-
{
|
|
17
|
-
display: 'OFF',
|
|
18
|
-
value: 'false'
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
display: 'ON',
|
|
22
|
-
value: 'true'
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: 'string',
|
|
29
|
-
name: 'target',
|
|
30
|
-
label: 'target',
|
|
31
|
-
placeholder: ''
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
type: 'number',
|
|
35
|
-
name: 'interval',
|
|
36
|
-
label: 'interval',
|
|
37
|
-
placeholder: '0'
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
help: 'scene/component/auto-clicker'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default class AutoClicker extends RectPath(Shape) {
|
|
44
|
-
autoClicker: any
|
|
45
|
-
|
|
46
|
-
dispose() {
|
|
47
|
-
clearInterval(this.autoClicker)
|
|
48
|
-
delete this.autoClicker
|
|
49
|
-
super.dispose()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
render(context: CanvasRenderingContext2D) {
|
|
53
|
-
var { left, top, width, height } = this.bounds
|
|
54
|
-
|
|
55
|
-
context.beginPath()
|
|
56
|
-
|
|
57
|
-
context.rect(left, top, width, height)
|
|
58
|
-
|
|
59
|
-
this.drawFill(context)
|
|
60
|
-
this.drawStroke(context)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
onmousedown(e: Event, hint: any) {
|
|
64
|
-
var autoClicker = () => {
|
|
65
|
-
this.autoClicker = setTimeout(() => {
|
|
66
|
-
//@ts-ignore
|
|
67
|
-
target?.onmousedown.call(target, e, hint)
|
|
68
|
-
autoClicker()
|
|
69
|
-
}, interval)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var pp = { true: true, false: false }
|
|
73
|
-
//@ts-ignore
|
|
74
|
-
var currentSwitchState = pp[this.getState('switch')]
|
|
75
|
-
var interval = this.getState('interval')
|
|
76
|
-
var target = this.root.findById(this.getState('target'))
|
|
77
|
-
|
|
78
|
-
this.setState('switch', !currentSwitchState)
|
|
79
|
-
currentSwitchState = !currentSwitchState
|
|
80
|
-
|
|
81
|
-
this.text = currentSwitchState ? 'ON' : 'OFF'
|
|
82
|
-
this.setState('fontColor', currentSwitchState ? 'rgb(0, 173, 31)' : 'rgb(254, 3, 3)')
|
|
83
|
-
consoleLogger('Auto response:', currentSwitchState)
|
|
84
|
-
|
|
85
|
-
if (currentSwitchState && target && interval >= 1000) {
|
|
86
|
-
autoClicker()
|
|
87
|
-
} else {
|
|
88
|
-
clearTimeout(this.autoClicker)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
get nature() {
|
|
93
|
-
return NATURE
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
Component.register('auto-clicker', AutoClicker)
|
package/src/boot-button.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
const boot = new URL('../../icons/boot-button.png', import.meta.url).href
|
|
2
|
-
import { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'
|
|
3
|
-
|
|
4
|
-
import { uuid } from './uuid'
|
|
5
|
-
|
|
6
|
-
import { consoleLogger } from './gateway-on-message'
|
|
7
|
-
|
|
8
|
-
export const buttons = [
|
|
9
|
-
{
|
|
10
|
-
icon: boot,
|
|
11
|
-
handler: onclickBoot
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
const BUTTONS_MARGIN = 10
|
|
16
|
-
|
|
17
|
-
const NATURE: ComponentNature = {
|
|
18
|
-
mutable: false,
|
|
19
|
-
resizable: true,
|
|
20
|
-
rotatable: true,
|
|
21
|
-
properties: [
|
|
22
|
-
{
|
|
23
|
-
type: 'string',
|
|
24
|
-
name: 'publisher',
|
|
25
|
-
label: 'publisher'
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
help: 'scene/component/boot-button'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default class BootButton extends RectPath(Shape) {
|
|
32
|
-
static _image: HTMLImageElement
|
|
33
|
-
|
|
34
|
-
static get image() {
|
|
35
|
-
if (!BootButton._image) {
|
|
36
|
-
BootButton._image = new Image()
|
|
37
|
-
BootButton._image.src = boot
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return BootButton._image
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
get publisher() {
|
|
44
|
-
if (this.state.publisher) {
|
|
45
|
-
return this.root.findById(this.state.publisher)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
render(context: CanvasRenderingContext2D) {
|
|
50
|
-
var { left, top, width, height } = this.bounds
|
|
51
|
-
|
|
52
|
-
context.beginPath()
|
|
53
|
-
|
|
54
|
-
context.rect(left, top, width, height)
|
|
55
|
-
|
|
56
|
-
this.drawFill(context)
|
|
57
|
-
this.drawStroke(context)
|
|
58
|
-
|
|
59
|
-
this.drawImage(context, BootButton.image, left, top, width, height)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
onmousedown(e: MouseEvent, hint: any) {
|
|
63
|
-
var { left, top, width, height } = this.bounds
|
|
64
|
-
|
|
65
|
-
var { x, y } = this.transcoordC2S(e.offsetX, e.offsetY)
|
|
66
|
-
|
|
67
|
-
var button = this.buttonContains(x - left - BUTTONS_MARGIN, y - top - BUTTONS_MARGIN)
|
|
68
|
-
if (button) {
|
|
69
|
-
button.handler(this)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
buttonContains(x: number, y: number) {
|
|
74
|
-
return buttons[0]
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get nature() {
|
|
78
|
-
return NATURE
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function onclickBoot(button: BootButton) {
|
|
83
|
-
consoleLogger('onclickBoot')
|
|
84
|
-
if (!button.data) return
|
|
85
|
-
var gateways = button.data
|
|
86
|
-
for (let i = 0; i < gateways.length; i++) {
|
|
87
|
-
// var gatewayObjects = gateways.map((value, index) => {
|
|
88
|
-
// return this.root.findById(value);
|
|
89
|
-
// }, this);
|
|
90
|
-
|
|
91
|
-
// gatewayObjects.forEach((gateway, index) => {
|
|
92
|
-
// gateway.boot();
|
|
93
|
-
// });
|
|
94
|
-
button.publisher!.data = {
|
|
95
|
-
properties: {
|
|
96
|
-
id: uuid(),
|
|
97
|
-
time: Date.now(),
|
|
98
|
-
dest_id: 'mps_server',
|
|
99
|
-
source_id: gateways[i],
|
|
100
|
-
is_reply: false
|
|
101
|
-
},
|
|
102
|
-
body: {
|
|
103
|
-
action: 'GW_INIT_REQ',
|
|
104
|
-
id: gateways[i]
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
consoleLogger('sent GW_INIT_REQ', button.publisher!.data)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
Component.register('boot-button', BootButton)
|
package/src/gateway-on-button.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
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
|
-
|
|
6
|
-
import Gateway from './gateway'
|
|
7
|
-
import { consoleLogger } from './gateway-on-message'
|
|
8
|
-
|
|
9
|
-
export const buttons = [
|
|
10
|
-
{
|
|
11
|
-
icon: start,
|
|
12
|
-
handler: onclickStart
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
icon: stop,
|
|
16
|
-
handler: onclickStop
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
icon: status,
|
|
20
|
-
handler: onclickStatus
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
icon: error,
|
|
24
|
-
handler: onclickError
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
icon: status,
|
|
28
|
-
handler: onclickTimesync
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
function onclickStart(gateway: Gateway) {
|
|
33
|
-
// Boot
|
|
34
|
-
// 전원 ON
|
|
35
|
-
consoleLogger('onclickStart')
|
|
36
|
-
gateway.boot()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function onclickStop(gateway: Gateway) {
|
|
40
|
-
// 전원 OFF
|
|
41
|
-
consoleLogger('onclickStop')
|
|
42
|
-
gateway.off()
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function onclickStatus(gateway: Gateway) {
|
|
46
|
-
consoleLogger('onclickStatus')
|
|
47
|
-
if (gateway.state.power_flag == 'false') return
|
|
48
|
-
|
|
49
|
-
////////random indicator////////
|
|
50
|
-
var indicator = gateway.indicators[Math.floor(Math.random() * gateway.indicators.length)]
|
|
51
|
-
|
|
52
|
-
gateway.replyPublisher!.data = {
|
|
53
|
-
properties: gateway.generateMessageProperties(),
|
|
54
|
-
body: {
|
|
55
|
-
action: 'IND_STATUS_RPT',
|
|
56
|
-
id: indicator.model.id,
|
|
57
|
-
version: indicator.version,
|
|
58
|
-
status: Math.random() > 0.5 ? 'ok' : 'offline', // random status
|
|
59
|
-
rssi: Math.floor(Math.random() * 100).toString(),
|
|
60
|
-
battery: Math.floor(Math.random() * 100).toString()
|
|
61
|
-
// status: (indicator.state.boot_flag == "true") ? "ok" : "offline"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
consoleLogger('sent IND_STATUS_RPT', gateway.replyPublisher!.data)
|
|
65
|
-
////////////////////////////////
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function onclickError(gateway: Gateway) {
|
|
69
|
-
consoleLogger('onclickError')
|
|
70
|
-
if (gateway.state.power_flag == 'false') return
|
|
71
|
-
|
|
72
|
-
let hwgb = Math.random()
|
|
73
|
-
|
|
74
|
-
gateway.replyPublisher!.data = {
|
|
75
|
-
properties: gateway.generateMessageProperties(),
|
|
76
|
-
body: {
|
|
77
|
-
action: 'ERR_RPT',
|
|
78
|
-
hw_gb: hwgb > 0.5 ? 'gw' : 'ind',
|
|
79
|
-
id: hwgb > 0.5 ? gateway.model.id : gateway.indicators[Math.floor(hwgb * gateway.indicators.length * 2)].model.id,
|
|
80
|
-
message: ['ERR001', 'ERR002', 'ERR003', 'ERR004', 'ERR005', 'ERR006'][Math.floor(Math.random() * 6)]
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
consoleLogger('sent ERR_RPT', gateway.replyPublisher!.data)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function onclickTimesync(gateway: Gateway) {
|
|
87
|
-
consoleLogger('onclickTimesync')
|
|
88
|
-
if (gateway.state.power_flag == 'false') return
|
|
89
|
-
|
|
90
|
-
gateway.replyPublisher!.data = {
|
|
91
|
-
properties: gateway.generateMessageProperties(),
|
|
92
|
-
body: {
|
|
93
|
-
action: 'TIMESYNC_REQ'
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
consoleLogger('sent TIMESYNC_REQ', gateway.replyPublisher!.data)
|
|
97
|
-
}
|