@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.
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": "8.0.0-beta.1",
5
+ "version": "8.0.0-beta.2",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
8
8
  "license": "MIT",
@@ -57,5 +57,5 @@
57
57
  "prettier --write"
58
58
  ]
59
59
  },
60
- "gitHead": "acb632aa522d8348f2602bcb614e2819d19a09ed"
60
+ "gitHead": "d6329b4f15ae63c2a99ec5b58ee1d527e88a4c36"
61
61
  }
package/CHANGELOG.md DELETED
@@ -1,130 +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
- ## [8.0.0-beta.1](https://github.com/things-scene/operato-scene/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-07)
7
-
8
-
9
- ### :bug: Bug Fix
10
-
11
- * [@things-factory](https://github.com/things-factory)@v8.0.0-beta ([2cd95a8](https://github.com/things-scene/operato-scene/commit/2cd95a8b07b588f3d96e5da2a0309910e683e33f))
12
-
13
-
14
-
15
- ## [8.0.0-beta.0](https://github.com/things-scene/operato-scene/compare/v8.0.0-alpha.12...v8.0.0-beta.0) (2025-01-07)
16
-
17
-
18
- ### :bug: Bug Fix
19
-
20
- * @hatiolab/things-scene@^8.0.0-beta ([c32f4c0](https://github.com/things-scene/operato-scene/commit/c32f4c00decf244ca82ae17a41e33f269e1882e7))
21
-
22
-
23
-
24
- ## [8.0.0-alpha.1](https://github.com/things-scene/operato-scene/compare/v8.0.0-alpha.0...v8.0.0-alpha.1) (2024-09-09)
25
-
26
-
27
- ### :bug: Bug Fix
28
-
29
- * update [@things-factory](https://github.com/things-factory)@^8.0.0-alpha ([1dc3163](https://github.com/things-scene/operato-scene/commit/1dc31638ed9d3fd0ecb2ac55be0ce541e5599ab8))
30
-
31
-
32
-
33
- ## [8.0.0-alpha.0](https://github.com/things-scene/operato-scene/compare/v7.3.7...v8.0.0-alpha.0) (2024-09-01)
34
-
35
- **Note:** Version bump only for package @operato/scene-mpi
36
-
37
-
38
-
39
-
40
-
41
- ## [7.0.1](https://github.com/things-scene/operato-scene/compare/v7.0.0...v7.0.1) (2024-06-30)
42
-
43
-
44
- ### :bug: Bug Fix
45
-
46
- * things-factory@7.0.0 ([f4cfe44](https://github.com/things-scene/operato-scene/commit/f4cfe44cb565e7b8fdc0df210a722b6526871848))
47
-
48
-
49
-
50
- ## [7.0.0](https://github.com/things-scene/operato-scene/compare/v7.0.0-rc.4...v7.0.0) (2024-06-30)
51
-
52
- **Note:** Version bump only for package @operato/scene-mpi
53
-
54
-
55
-
56
-
57
-
58
- ## [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)
59
-
60
-
61
- ### :bug: Bug Fix
62
-
63
- * apply v7-rc dependencies ([eee5612](https://github.com/things-scene/operato-scene/commit/eee5612e1d569387c284a7c6c49d64ef44b6d701))
64
-
65
-
66
-
67
- ## [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)
68
-
69
- **Note:** Version bump only for package @operato/scene-mpi
70
-
71
-
72
-
73
-
74
-
75
- ## [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)
76
-
77
-
78
- ### :rocket: New Features
79
-
80
- * 2.0.0-beta.0 ([a2e2869](https://github.com/things-scene/operato-scene/commit/a2e28694eedf5bab0c54bcab5432d54ec59edd7f))
81
-
82
-
83
- ### :bug: Bug Fix
84
-
85
- * allowJs in tsconfig option ([fa77174](https://github.com/things-scene/operato-scene/commit/fa771742188f21f177f0a85281570f59f0c478cf))
86
-
87
-
88
-
89
- ## [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)
90
-
91
-
92
- ### :bug: Bug Fix
93
-
94
- * things-factory@7.0.1 ([a9f4c18](https://github.com/things-scene/operato-scene/commit/a9f4c1873b80c540e4c2e16649e127ccffcf9a4c))
95
-
96
-
97
-
98
- ## [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)
99
-
100
-
101
- ### :bug: Bug Fix
102
-
103
- * translation ([266d423](https://github.com/things-scene/operato-scene/commit/266d423d9d6992464f45a437acc90ccf8ed33bf6))
104
-
105
-
106
-
107
- ## [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)
108
-
109
-
110
- ### :bug: Bug Fix
111
-
112
- * 컴포넌트 명 다국어 ([64e1f08](https://github.com/things-scene/operato-scene/commit/64e1f08af32d2ac193c3d31b0025f8d06f569ca4))
113
-
114
-
115
-
116
- ## [2.0.0-alpha.0](https://github.com/things-scene/operato-scene/compare/v1.3.9...v2.0.0-alpha.0) (2024-01-14)
117
-
118
-
119
- ### :bug: Bug Fix
120
-
121
- * 2.0.0-alpha.0 ([93274e3](https://github.com/things-scene/operato-scene/commit/93274e36c5d184f339f83899654dd48b4786ac2b))
122
-
123
-
124
-
125
- ## [1.3.7](https://github.com/things-scene/operato-scene/compare/v1.3.6...v1.3.7) (2024-01-01)
126
-
127
-
128
- ### :bug: Bug Fix
129
-
130
- * mpi module moved from things-factory ([47b743f](https://github.com/things-scene/operato-scene/commit/47b743fd19001f195db85e50b8f6e457a1573aa5))
@@ -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)
@@ -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)
@@ -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
- }