vrack2-core 1.0.1 → 1.0.3
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/README.md +3 -4
- package/lib/Container.d.ts +6 -0
- package/lib/Container.js +2 -2
- package/lib/boot/DeviceManager.js +0 -5
- package/lib/service/DevicePort.d.ts +4 -1
- package/lib/service/DevicePort.js +2 -1
- package/package.json +1 -1
- package/src/Container.ts +7 -2
- package/src/boot/DeviceManager.ts +0 -6
- package/src/service/DevicePort.ts +6 -1
package/README.md
CHANGED
|
@@ -9,11 +9,10 @@ VRack2 Core
|
|
|
9
9
|
|
|
10
10
|
--------
|
|
11
11
|
|
|
12
|
+
### Последнее обновленте 1.0.3
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Обновлены пакеты TypeScript
|
|
16
|
-
- Добавлена валидация параметров класса устройства в `DeviceManager.getDeviceInfo()`
|
|
14
|
+
- Теперь порты `DevicePort` имеют ссылки на устройство своего владельца `Device`
|
|
15
|
+
- Добавлено свойство meta внутри контейнера для хранения дополнительной информации
|
|
17
16
|
|
|
18
17
|
**Использовать эту документацию имеет смысл только для более глубокого изучения устройства VRack2 или для создания сервиса независимого от VRack2**
|
|
19
18
|
|
package/lib/Container.d.ts
CHANGED
package/lib/Container.js
CHANGED
|
@@ -368,7 +368,7 @@ class Container extends events_1.default {
|
|
|
368
368
|
this.checkPortName(subkey);
|
|
369
369
|
const handler = ImportManager_1.default.camelize('input.' + subkey);
|
|
370
370
|
this.checkInputHandler(subkey, handler, dev);
|
|
371
|
-
const ndp = new DevicePort_1.default(subkey, pList[subkey]);
|
|
371
|
+
const ndp = new DevicePort_1.default(subkey, pList[subkey], dev);
|
|
372
372
|
dev.ports.input[subkey] = ndp;
|
|
373
373
|
// add structure device input ports
|
|
374
374
|
this.structure[dconf.id].inputs[subkey] = [];
|
|
@@ -384,7 +384,7 @@ class Container extends events_1.default {
|
|
|
384
384
|
const pList = this.getPortList(key, exp);
|
|
385
385
|
for (const subkey in pList) {
|
|
386
386
|
this.checkPortName(subkey);
|
|
387
|
-
const ndp = new DevicePort_1.default(subkey, pList[subkey]);
|
|
387
|
+
const ndp = new DevicePort_1.default(subkey, pList[subkey], dev);
|
|
388
388
|
dev.ports.output[subkey] = ndp;
|
|
389
389
|
// add structure device output ports
|
|
390
390
|
this.structure[dconf.id].outputs[subkey] = [];
|
|
@@ -42,7 +42,6 @@ const Rule_1 = __importDefault(require("../validator/Rule"));
|
|
|
42
42
|
const CoreError_1 = __importDefault(require("../errors/CoreError"));
|
|
43
43
|
const BootClass_1 = __importDefault(require("./BootClass"));
|
|
44
44
|
const ImportManager_1 = __importDefault(require("../ImportManager"));
|
|
45
|
-
const Validator_1 = __importDefault(require("../validator/Validator"));
|
|
46
45
|
ErrorManager_1.default.register('DeviceManager', 'S5dBTBKTnVbF', 'DM_DEVICE_NOT_FOUND', 'Device not found', {
|
|
47
46
|
device: Rule_1.default.string().require().example('Master').description('Device name')
|
|
48
47
|
});
|
|
@@ -130,10 +129,6 @@ class DeviceManager extends BootClass_1.default {
|
|
|
130
129
|
const di = [vendor, device].join('.');
|
|
131
130
|
const DeviceClass = yield this.get(di);
|
|
132
131
|
const dev = new DeviceClass('1', di, this);
|
|
133
|
-
// Заполняем значения по умолчанию валидатором
|
|
134
|
-
// Это нужно динамических портов которые определяются через options
|
|
135
|
-
const rules = dev.checkOptions();
|
|
136
|
-
Validator_1.default.validate(rules, dev.options);
|
|
137
132
|
const result = { actions: {}, metrics: {}, inputs: {}, outputs: {}, options: {}, description: '' };
|
|
138
133
|
try {
|
|
139
134
|
const preOptions = dev.checkOptions();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import IPort from "../ports/IPort";
|
|
2
2
|
import DeviceConnect from "./DeviceConnect";
|
|
3
|
+
import Device from "./Device";
|
|
3
4
|
/**
|
|
4
5
|
* A class to implement a device port.
|
|
5
6
|
* The port can be either incoming or outgoing
|
|
@@ -15,13 +16,15 @@ export default class DevicePort {
|
|
|
15
16
|
type: string;
|
|
16
17
|
/** Flag determines whether the port should be connected */
|
|
17
18
|
required: boolean;
|
|
19
|
+
/** Ссылка на устройсто владельца */
|
|
20
|
+
Device: Device;
|
|
18
21
|
/**
|
|
19
22
|
* Список слушателей порта
|
|
20
23
|
* Используется для захвата порта. Если какие либо данные будут проброшены
|
|
21
24
|
* в порт, они будут переданы для каждого вызнванного слушателя
|
|
22
25
|
*/
|
|
23
26
|
listens: Map<number, (data: any) => void>;
|
|
24
|
-
constructor(id: string, port: IPort);
|
|
27
|
+
constructor(id: string, port: IPort, device: Device);
|
|
25
28
|
/**
|
|
26
29
|
* Adding communication to a port
|
|
27
30
|
*/
|
|
@@ -13,7 +13,7 @@ const Utility_1 = __importDefault(require("../Utility"));
|
|
|
13
13
|
* The port can be either incoming or outgoing
|
|
14
14
|
*/
|
|
15
15
|
class DevicePort {
|
|
16
|
-
constructor(id, port) {
|
|
16
|
+
constructor(id, port, device) {
|
|
17
17
|
/** Flag to determine if the port is connected */
|
|
18
18
|
this.connected = false;
|
|
19
19
|
/** Port connection list. One port can have multiple connections */
|
|
@@ -27,6 +27,7 @@ class DevicePort {
|
|
|
27
27
|
this.id = id;
|
|
28
28
|
this.type = port.type;
|
|
29
29
|
this.required = port.required;
|
|
30
|
+
this.Device = device;
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Adding communication to a port
|
package/package.json
CHANGED
package/src/Container.ts
CHANGED
|
@@ -173,6 +173,11 @@ export default class Container extends EventEmitter {
|
|
|
173
173
|
* */
|
|
174
174
|
confFile?: string
|
|
175
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Дополнительные метаданные
|
|
178
|
+
*/
|
|
179
|
+
meta?: {[key: string]: any}
|
|
180
|
+
|
|
176
181
|
/**
|
|
177
182
|
* Container bootstrap class
|
|
178
183
|
*
|
|
@@ -462,7 +467,7 @@ export default class Container extends EventEmitter {
|
|
|
462
467
|
this.checkPortName(subkey)
|
|
463
468
|
const handler = ImportManager.camelize('input.' + subkey) as keyof Device
|
|
464
469
|
this.checkInputHandler(subkey, handler, dev)
|
|
465
|
-
const ndp = new DevicePort(subkey, pList[subkey])
|
|
470
|
+
const ndp = new DevicePort(subkey, pList[subkey], dev)
|
|
466
471
|
dev.ports.input[subkey] = ndp
|
|
467
472
|
// add structure device input ports
|
|
468
473
|
this.structure[dconf.id].inputs[subkey] = []
|
|
@@ -480,7 +485,7 @@ export default class Container extends EventEmitter {
|
|
|
480
485
|
const pList = this.getPortList(key, exp)
|
|
481
486
|
for (const subkey in pList) {
|
|
482
487
|
this.checkPortName(subkey)
|
|
483
|
-
const ndp = new DevicePort(subkey, pList[subkey])
|
|
488
|
+
const ndp = new DevicePort(subkey, pList[subkey], dev)
|
|
484
489
|
dev.ports.output[subkey] = ndp
|
|
485
490
|
// add structure device output ports
|
|
486
491
|
this.structure[dconf.id].outputs[subkey] = []
|
|
@@ -11,7 +11,6 @@ import IAction from '../actions/IAction'
|
|
|
11
11
|
import IMetricSettings from '../metrics/IMetricSettings'
|
|
12
12
|
import IPort from '../ports/IPort'
|
|
13
13
|
import IValidationRule from '../validator/IValidationRule'
|
|
14
|
-
import Validator from '../validator/Validator'
|
|
15
14
|
|
|
16
15
|
export interface IDeviceVendor {
|
|
17
16
|
/** Group name = Vendor name */
|
|
@@ -176,11 +175,6 @@ export default class DeviceManager extends BootClass {
|
|
|
176
175
|
const DeviceClass = await this.get(di)
|
|
177
176
|
const dev = new DeviceClass('1', di, this) as Device
|
|
178
177
|
|
|
179
|
-
// Заполняем значения по умолчанию валидатором
|
|
180
|
-
// Это нужно динамических портов которые определяются через options
|
|
181
|
-
const rules = dev.checkOptions()
|
|
182
|
-
Validator.validate(rules, dev.options)
|
|
183
|
-
|
|
184
178
|
const result: IDeivceInfo = { actions: {}, metrics: {}, inputs: {}, outputs: {}, options: {}, description: '' }
|
|
185
179
|
try {
|
|
186
180
|
const preOptions = dev.checkOptions();
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import IPort from "../ports/IPort"
|
|
7
7
|
import DeviceConnect from "./DeviceConnect"
|
|
8
8
|
import Utility from "../Utility"
|
|
9
|
+
import Device from "./Device"
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* A class to implement a device port.
|
|
@@ -26,6 +27,9 @@ export default class DevicePort {
|
|
|
26
27
|
/** Flag determines whether the port should be connected */
|
|
27
28
|
required: boolean
|
|
28
29
|
|
|
30
|
+
/** Ссылка на устройсто владельца */
|
|
31
|
+
Device: Device
|
|
32
|
+
|
|
29
33
|
/**
|
|
30
34
|
* Список слушателей порта
|
|
31
35
|
* Используется для захвата порта. Если какие либо данные будут проброшены
|
|
@@ -33,10 +37,11 @@ export default class DevicePort {
|
|
|
33
37
|
*/
|
|
34
38
|
listens = new Map<number, (data:any) => void>()
|
|
35
39
|
|
|
36
|
-
constructor(id: string, port: IPort) {
|
|
40
|
+
constructor(id: string, port: IPort, device: Device) {
|
|
37
41
|
this.id = id
|
|
38
42
|
this.type = port.type
|
|
39
43
|
this.required = port.required
|
|
44
|
+
this.Device = device
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
/**
|