@packtrack/layout 1.2.0 → 1.3.1
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/.built/index.d.ts +20 -20
- package/.built/index.js +20 -20
- package/.built/source/device/channel.d.ts +2 -2
- package/.built/source/device/channel.js +4 -8
- package/.built/{device → source/device}/index.d.ts +0 -1
- package/.built/source/device/index.js +8 -0
- package/.built/source/district.d.ts +3 -7
- package/.built/source/district.js +4 -70
- package/.built/source/layout.d.ts +9 -6
- package/.built/source/layout.js +85 -86
- package/.built/{monitor.d.ts → source/monitor.d.ts} +1 -2
- package/.built/source/monitor.js +8 -0
- package/.built/source/position.d.ts +3 -1
- package/.built/source/position.js +17 -5
- package/.built/{positioner → source/positioner}/point.d.ts +2 -3
- package/.built/{positioner → source/positioner}/point.js +1 -7
- package/.built/{positioner → source/positioner}/responder-type.d.ts +0 -1
- package/.built/{positioner → source/positioner}/responder-type.js +0 -3
- package/.built/{power-district → source/power-district}/index.d.ts +0 -1
- package/.built/{power-district → source/power-district}/index.js +0 -3
- package/.built/source/route.d.ts +0 -1
- package/.built/source/route.js +1 -8
- package/.built/source/router.d.ts +0 -4
- package/.built/source/router.js +1 -28
- package/.built/source/section.d.ts +1 -10
- package/.built/source/section.js +8 -57
- package/.built/{throttle.d.ts → source/throttle.d.ts} +1 -2
- package/.built/source/throttle.js +8 -0
- package/.built/source/tile.js +2 -7
- package/.built/source/track.d.ts +1 -2
- package/.built/source/track.js +3 -10
- package/index.ts +23 -0
- package/package.json +2 -2
- package/source/device/channel.ts +4 -4
- package/source/device/index.ts +2 -19
- package/source/district.ts +1 -80
- package/source/layout.ts +1 -63
- package/source/monitor.ts +1 -10
- package/source/positioner/point.ts +2 -11
- package/source/positioner/responder-type.ts +1 -5
- package/source/power-district/index.ts +0 -5
- package/source/route.ts +2 -6
- package/source/router.ts +2 -31
- package/source/section.ts +10 -65
- package/source/throttle.ts +1 -10
- package/source/track.ts +3 -7
- package/tsconfig.json +7 -8
- package/.built/device/channel.d.ts +0 -8
- package/.built/device/channel.js +0 -12
- package/.built/device/device.d.ts +0 -11
- package/.built/device/device.js +0 -20
- package/.built/device/index.js +0 -20
- package/.built/district.d.ts +0 -22
- package/.built/district.js +0 -83
- package/.built/layout.d.ts +0 -35
- package/.built/layout.js +0 -331
- package/.built/monitor.js +0 -15
- package/.built/position.d.ts +0 -12
- package/.built/position.js +0 -45
- package/.built/power-district.d.ts +0 -8
- package/.built/power-district.js +0 -14
- package/.built/route.d.ts +0 -10
- package/.built/route.js +0 -13
- package/.built/router.d.ts +0 -14
- package/.built/router.js +0 -36
- package/.built/section.d.ts +0 -40
- package/.built/section.js +0 -213
- package/.built/source/device/device.d.ts +0 -11
- package/.built/source/device/device.js +0 -24
- package/.built/source/power-district.d.ts +0 -8
- package/.built/source/power-district.js +0 -18
- package/.built/throttle.js +0 -15
- package/.built/tile.d.ts +0 -57
- package/.built/tile.js +0 -73
- package/.built/track.d.ts +0 -12
- package/.built/track.js +0 -25
- package/source/index.ts +0 -23
- /package/.built/{positioner → source/positioner}/index.d.ts +0 -0
- /package/.built/{positioner → source/positioner}/index.js +0 -0
- /package/.built/{power-district → source/power-district}/activator.d.ts +0 -0
- /package/.built/{power-district → source/power-district}/activator.js +0 -0
- /package/.built/{power-district → source/power-district}/monitor.d.ts +0 -0
- /package/.built/{power-district → source/power-district}/monitor.js +0 -0
- /package/.built/{power-district → source/power-district}/reverser.d.ts +0 -0
- /package/.built/{power-district → source/power-district}/reverser.js +0 -0
- /package/.built/{span.d.ts → source/span.d.ts} +0 -0
- /package/.built/{span.js → source/span.js} +0 -0
package/.built/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export * from './district';
|
|
2
|
-
export * from './layout';
|
|
3
|
-
export * from './position';
|
|
4
|
-
export * from './route';
|
|
5
|
-
export * from './router';
|
|
6
|
-
export * from './section';
|
|
7
|
-
export * from './span';
|
|
8
|
-
export * from './tile';
|
|
9
|
-
export * from './track';
|
|
10
|
-
export * from './monitor';
|
|
11
|
-
export * from './throttle';
|
|
12
|
-
export * from './power-district/index';
|
|
13
|
-
export * from './power-district/activator';
|
|
14
|
-
export * from './power-district/monitor';
|
|
15
|
-
export * from './power-district/reverser';
|
|
16
|
-
export * from './positioner/index';
|
|
17
|
-
export * from './positioner/point';
|
|
18
|
-
export * from './positioner/responder-type';
|
|
19
|
-
export * from './device/index';
|
|
20
|
-
export * from './device/channel';
|
|
1
|
+
export * from './source/district';
|
|
2
|
+
export * from './source/layout';
|
|
3
|
+
export * from './source/position';
|
|
4
|
+
export * from './source/route';
|
|
5
|
+
export * from './source/router';
|
|
6
|
+
export * from './source/section';
|
|
7
|
+
export * from './source/span';
|
|
8
|
+
export * from './source/tile';
|
|
9
|
+
export * from './source/track';
|
|
10
|
+
export * from './source/monitor';
|
|
11
|
+
export * from './source/throttle';
|
|
12
|
+
export * from './source/power-district/index';
|
|
13
|
+
export * from './source/power-district/activator';
|
|
14
|
+
export * from './source/power-district/monitor';
|
|
15
|
+
export * from './source/power-district/reverser';
|
|
16
|
+
export * from './source/positioner/index';
|
|
17
|
+
export * from './source/positioner/point';
|
|
18
|
+
export * from './source/positioner/responder-type';
|
|
19
|
+
export * from './source/device/index';
|
|
20
|
+
export * from './source/device/channel';
|
package/.built/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export * from './district';
|
|
2
|
-
export * from './layout';
|
|
3
|
-
export * from './position';
|
|
4
|
-
export * from './route';
|
|
5
|
-
export * from './router';
|
|
6
|
-
export * from './section';
|
|
7
|
-
export * from './span';
|
|
8
|
-
export * from './tile';
|
|
9
|
-
export * from './track';
|
|
10
|
-
export * from './monitor';
|
|
11
|
-
export * from './throttle';
|
|
12
|
-
export * from './power-district/index';
|
|
13
|
-
export * from './power-district/activator';
|
|
14
|
-
export * from './power-district/monitor';
|
|
15
|
-
export * from './power-district/reverser';
|
|
16
|
-
export * from './positioner/index';
|
|
17
|
-
export * from './positioner/point';
|
|
18
|
-
export * from './positioner/responder-type';
|
|
19
|
-
export * from './device/index';
|
|
20
|
-
export * from './device/channel';
|
|
1
|
+
export * from './source/district';
|
|
2
|
+
export * from './source/layout';
|
|
3
|
+
export * from './source/position';
|
|
4
|
+
export * from './source/route';
|
|
5
|
+
export * from './source/router';
|
|
6
|
+
export * from './source/section';
|
|
7
|
+
export * from './source/span';
|
|
8
|
+
export * from './source/tile';
|
|
9
|
+
export * from './source/track';
|
|
10
|
+
export * from './source/monitor';
|
|
11
|
+
export * from './source/throttle';
|
|
12
|
+
export * from './source/power-district/index';
|
|
13
|
+
export * from './source/power-district/activator';
|
|
14
|
+
export * from './source/power-district/monitor';
|
|
15
|
+
export * from './source/power-district/reverser';
|
|
16
|
+
export * from './source/positioner/index';
|
|
17
|
+
export * from './source/positioner/point';
|
|
18
|
+
export * from './source/positioner/responder-type';
|
|
19
|
+
export * from './source/device/index';
|
|
20
|
+
export * from './source/device/channel';
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Channel = void 0;
|
|
4
|
-
class Channel {
|
|
1
|
+
export class Channel {
|
|
5
2
|
device;
|
|
6
3
|
name;
|
|
7
4
|
constructor(device, name) {
|
|
8
5
|
this.device = device;
|
|
9
6
|
this.name = name;
|
|
10
7
|
}
|
|
11
|
-
dump() {
|
|
12
|
-
console.log(`Channel '${this.name}' on ${this.device.identifier}`);
|
|
13
|
-
}
|
|
14
8
|
publish(data) { }
|
|
9
|
+
toString() {
|
|
10
|
+
return `${this.device.identifier}/${this.name}`;
|
|
11
|
+
}
|
|
15
12
|
}
|
|
16
|
-
exports.Channel = Channel;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Layout } from "./layout";
|
|
2
|
-
import {
|
|
2
|
+
import { Monitor } from "./monitor";
|
|
3
|
+
import { PowerDistrict } from "./power-district/index";
|
|
3
4
|
import { Router } from "./router";
|
|
4
5
|
import { Section } from "./section";
|
|
5
6
|
export declare class District {
|
|
@@ -9,12 +10,7 @@ export declare class District {
|
|
|
9
10
|
powerDistricts: PowerDistrict[];
|
|
10
11
|
sections: Section[];
|
|
11
12
|
routers: Router[];
|
|
13
|
+
monitors: Monitor[];
|
|
12
14
|
constructor(name: string, parent: District | Layout);
|
|
13
15
|
get domainName(): string;
|
|
14
|
-
dump(): void;
|
|
15
|
-
toDotReference(): any;
|
|
16
|
-
toDotDefinition(): any;
|
|
17
|
-
toDotConnection(): any;
|
|
18
|
-
toSVG(): any;
|
|
19
|
-
findSVGPositions(): any;
|
|
20
16
|
}
|
|
@@ -1,86 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.District = void 0;
|
|
4
|
-
const layout_1 = require("./layout");
|
|
5
|
-
class District {
|
|
1
|
+
import { Layout } from "./layout";
|
|
2
|
+
export class District {
|
|
6
3
|
name;
|
|
7
4
|
parent;
|
|
8
5
|
children = [];
|
|
9
6
|
powerDistricts = [];
|
|
10
7
|
sections = [];
|
|
11
8
|
routers = [];
|
|
9
|
+
monitors = [];
|
|
12
10
|
constructor(name, parent) {
|
|
13
11
|
this.name = name;
|
|
14
12
|
this.parent = parent;
|
|
15
13
|
}
|
|
16
14
|
get domainName() {
|
|
17
|
-
if (this.parent instanceof
|
|
15
|
+
if (this.parent instanceof Layout) {
|
|
18
16
|
return `${this.name}.${this.parent.name}`;
|
|
19
17
|
}
|
|
20
18
|
return `${this.name}.${this.parent.domainName}`;
|
|
21
19
|
}
|
|
22
|
-
dump() {
|
|
23
|
-
console.group(`District ${this.domainName}`);
|
|
24
|
-
if (this.powerDistricts.length) {
|
|
25
|
-
console.group('power districts');
|
|
26
|
-
for (let district of this.powerDistricts) {
|
|
27
|
-
district.dump();
|
|
28
|
-
}
|
|
29
|
-
console.groupEnd();
|
|
30
|
-
}
|
|
31
|
-
if (this.sections.length) {
|
|
32
|
-
console.group('sections');
|
|
33
|
-
for (let section of this.sections) {
|
|
34
|
-
section.dump();
|
|
35
|
-
}
|
|
36
|
-
console.groupEnd();
|
|
37
|
-
}
|
|
38
|
-
if (this.children.length) {
|
|
39
|
-
console.group('children');
|
|
40
|
-
for (let district of this.children) {
|
|
41
|
-
district.dump();
|
|
42
|
-
}
|
|
43
|
-
console.groupEnd();
|
|
44
|
-
}
|
|
45
|
-
console.groupEnd();
|
|
46
|
-
}
|
|
47
|
-
toDotReference() {
|
|
48
|
-
return `cluster_${this.name.replace(/-/g, '_')}${this.parent instanceof District ? this.parent.toDotReference() : ''}`;
|
|
49
|
-
}
|
|
50
|
-
toDotDefinition() {
|
|
51
|
-
return `
|
|
52
|
-
subgraph ${this.toDotReference()} {
|
|
53
|
-
label = ${JSON.stringify(this.name)}
|
|
54
|
-
|
|
55
|
-
${this.sections.map(section => section.toDotDefinition()).join('')}
|
|
56
|
-
${this.routers.map(router => router.toDotDefinition()).join('')}
|
|
57
|
-
|
|
58
|
-
${this.children.map(child => child.toDotDefinition()).join('')}
|
|
59
|
-
}
|
|
60
|
-
`;
|
|
61
|
-
}
|
|
62
|
-
toDotConnection() {
|
|
63
|
-
return `
|
|
64
|
-
${this.sections.map(section => section.toDotConnection()).join('')}
|
|
65
|
-
${this.routers.map(router => router.toDotConnection()).join('')}
|
|
66
|
-
|
|
67
|
-
${this.children.map(child => child.toDotConnection()).join('')}
|
|
68
|
-
`;
|
|
69
|
-
}
|
|
70
|
-
toSVG() {
|
|
71
|
-
return `
|
|
72
|
-
<g id=${JSON.stringify(this.domainName)}>
|
|
73
|
-
${this.sections.map(section => section.toSVG()).join('')}
|
|
74
|
-
|
|
75
|
-
${this.children.map(child => child.toSVG()).join('')}
|
|
76
|
-
</g>
|
|
77
|
-
`;
|
|
78
|
-
}
|
|
79
|
-
findSVGPositions() {
|
|
80
|
-
return [
|
|
81
|
-
...this.sections.map(section => section.findSVGPositions()),
|
|
82
|
-
...this.children.map(child => child.findSVGPositions())
|
|
83
|
-
];
|
|
84
|
-
}
|
|
85
20
|
}
|
|
86
|
-
exports.District = District;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { District } from "./district";
|
|
2
|
-
import { PowerDistrict } from "./power-district";
|
|
2
|
+
import { PowerDistrict } from "./power-district/index";
|
|
3
3
|
import { Router } from "./router";
|
|
4
4
|
import { Section } from "./section";
|
|
5
|
-
import { Device } from "./device/
|
|
6
|
-
import { ResponderType } from "
|
|
5
|
+
import { Device } from "./device/index";
|
|
6
|
+
import { ResponderType } from "./positioner/responder-type";
|
|
7
7
|
import { Channel } from "./device/channel";
|
|
8
|
+
import { Monitor } from "./monitor";
|
|
9
|
+
import { Throttle } from "./throttle";
|
|
8
10
|
export declare class Layout {
|
|
9
11
|
name: string;
|
|
10
12
|
districts: District[];
|
|
11
13
|
devices: Device[];
|
|
12
14
|
responderType: ResponderType[];
|
|
15
|
+
monitors: Monitor[];
|
|
16
|
+
throttles: Throttle[];
|
|
13
17
|
get allDistricts(): District[];
|
|
14
18
|
static from(document: any): Layout;
|
|
19
|
+
loadMonitor(source: any, parent: District | Layout): Monitor;
|
|
20
|
+
loadThrottle(source: any, parent: District | Layout): Throttle;
|
|
15
21
|
loadDistrict(source: any, parent: District | Layout): District;
|
|
16
22
|
linkDistrict(source: any, district: District): void;
|
|
17
23
|
loadSection(source: any, district: District): void;
|
|
@@ -23,7 +29,4 @@ export declare class Layout {
|
|
|
23
29
|
loadRouter(source: any, district: District): Router;
|
|
24
30
|
linkRouter(source: any, router: Router): void;
|
|
25
31
|
loadPowerDistrict(source: any, district: District): PowerDistrict;
|
|
26
|
-
toDot(): string;
|
|
27
|
-
toSVG(inject?: string): string;
|
|
28
|
-
dump(): void;
|
|
29
32
|
}
|
package/.built/source/layout.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { District } from "./district";
|
|
2
|
+
import { PowerDistrict } from "./power-district/index";
|
|
3
|
+
import { Route } from "./route";
|
|
4
|
+
import { Router } from "./router";
|
|
5
|
+
import { Section } from "./section";
|
|
6
|
+
import { TilePattern, Tile } from "./tile";
|
|
7
|
+
import { Track } from "./track";
|
|
8
|
+
import { Device } from "./device/index";
|
|
9
|
+
import { ResponderType } from "./positioner/responder-type";
|
|
10
|
+
import { Channel } from "./device/channel";
|
|
11
|
+
import { PointPositioner } from "./positioner/point";
|
|
12
|
+
import { PowerDistrictActivator } from "./power-district/activator";
|
|
13
|
+
import { PowerDistrictReverser } from "./power-district/reverser";
|
|
14
|
+
import { PowerDistrictMonitor } from "./power-district/monitor";
|
|
15
|
+
import { Monitor } from "./monitor";
|
|
16
|
+
import { Throttle } from "./throttle";
|
|
17
|
+
export class Layout {
|
|
16
18
|
name;
|
|
17
19
|
districts = [];
|
|
18
20
|
devices = [];
|
|
19
21
|
responderType = [];
|
|
22
|
+
monitors = [];
|
|
23
|
+
throttles = [];
|
|
20
24
|
get allDistricts() {
|
|
21
25
|
const districts = [];
|
|
22
26
|
function walkDistrict(district) {
|
|
@@ -36,30 +40,44 @@ class Layout {
|
|
|
36
40
|
layout.name = railway.getAttribute('name');
|
|
37
41
|
const version = railway.getAttribute('version');
|
|
38
42
|
if (version == '1') {
|
|
39
|
-
let
|
|
40
|
-
while (
|
|
41
|
-
if (
|
|
42
|
-
layout.districts.push(layout.loadDistrict(
|
|
43
|
+
let child = railway.firstChild;
|
|
44
|
+
while (child) {
|
|
45
|
+
if (child.tagName == 'district') {
|
|
46
|
+
layout.districts.push(layout.loadDistrict(child, layout));
|
|
43
47
|
}
|
|
44
|
-
|
|
48
|
+
if (child.tagName == 'monitor') {
|
|
49
|
+
layout.monitors.push(layout.loadMonitor(child, layout));
|
|
50
|
+
}
|
|
51
|
+
if (child.tagName == 'throttle') {
|
|
52
|
+
layout.throttles.push(layout.loadThrottle(child, layout));
|
|
53
|
+
}
|
|
54
|
+
child = child.nextSibling;
|
|
45
55
|
}
|
|
46
|
-
|
|
56
|
+
child = railway.firstChild;
|
|
47
57
|
let index = 0;
|
|
48
|
-
while (
|
|
49
|
-
if (
|
|
50
|
-
layout.linkDistrict(
|
|
58
|
+
while (child) {
|
|
59
|
+
if (child.tagName == 'district') {
|
|
60
|
+
layout.linkDistrict(child, layout.districts[index]);
|
|
51
61
|
index++;
|
|
52
62
|
}
|
|
53
|
-
|
|
63
|
+
child = child.nextSibling;
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
else {
|
|
57
|
-
throw new Error(`
|
|
67
|
+
throw new Error(`Unsupported railway definition file version '${version}'`);
|
|
58
68
|
}
|
|
59
69
|
return layout;
|
|
60
70
|
}
|
|
71
|
+
loadMonitor(source, parent) {
|
|
72
|
+
const montior = new Monitor(this.findDevice(source.getAttribute('device')), parent);
|
|
73
|
+
return montior;
|
|
74
|
+
}
|
|
75
|
+
loadThrottle(source, parent) {
|
|
76
|
+
const throttle = new Throttle(this.findDevice(source.getAttribute('device')), parent);
|
|
77
|
+
return throttle;
|
|
78
|
+
}
|
|
61
79
|
loadDistrict(source, parent) {
|
|
62
|
-
const district = new
|
|
80
|
+
const district = new District(source.getAttribute('name'), parent);
|
|
63
81
|
let child = source.firstChild;
|
|
64
82
|
while (child) {
|
|
65
83
|
if (child.tagName == 'power-districts') {
|
|
@@ -80,6 +98,9 @@ class Layout {
|
|
|
80
98
|
if (child.tagName == 'district') {
|
|
81
99
|
district.children.push(this.loadDistrict(child, district));
|
|
82
100
|
}
|
|
101
|
+
if (child.tagName == 'monitor') {
|
|
102
|
+
district.monitors.push(this.loadMonitor(child, district));
|
|
103
|
+
}
|
|
83
104
|
child = child.nextSibling;
|
|
84
105
|
}
|
|
85
106
|
return district;
|
|
@@ -104,7 +125,7 @@ class Layout {
|
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
127
|
loadSection(source, district) {
|
|
107
|
-
const section = new
|
|
128
|
+
const section = new Section(source.getAttribute('name'), district);
|
|
108
129
|
district.sections.push(section);
|
|
109
130
|
let child = source.firstChild;
|
|
110
131
|
while (child) {
|
|
@@ -112,7 +133,7 @@ class Layout {
|
|
|
112
133
|
let trackNode = child.firstChild;
|
|
113
134
|
while (trackNode) {
|
|
114
135
|
if (trackNode.tagName == 'track') {
|
|
115
|
-
const track = new
|
|
136
|
+
const track = new Track(section, +trackNode.getAttribute('length'), trackNode.getAttribute('path'));
|
|
116
137
|
section.tracks.push(track);
|
|
117
138
|
let trackChild = trackNode.firstChild;
|
|
118
139
|
while (trackChild) {
|
|
@@ -123,7 +144,7 @@ class Layout {
|
|
|
123
144
|
const device = this.findDevice(positioner.getAttribute('device'));
|
|
124
145
|
const channel = this.findChannel(device, positioner.getAttribute('channel'));
|
|
125
146
|
const responderType = this.findResponderType(positioner.getAttribute('responder'));
|
|
126
|
-
track.positioners.push(new
|
|
147
|
+
track.positioners.push(new PointPositioner(track, +positioner.getAttribute('offset'), channel, responderType));
|
|
127
148
|
}
|
|
128
149
|
positioner = positioner.nextSibling;
|
|
129
150
|
}
|
|
@@ -136,10 +157,10 @@ class Layout {
|
|
|
136
157
|
}
|
|
137
158
|
if (child.tagName == 'tile') {
|
|
138
159
|
const pattern = child.getAttribute('pattern');
|
|
139
|
-
if (!(pattern in
|
|
160
|
+
if (!(pattern in TilePattern.patterns)) {
|
|
140
161
|
throw new Error(`Unknown tile pattern '${pattern}' in tile ${section.tiles.length + 1} in ${section.domainName}`);
|
|
141
162
|
}
|
|
142
|
-
section.tiles.push(new
|
|
163
|
+
section.tiles.push(new Tile(section, +child.getAttribute('x'), +child.getAttribute('y'), TilePattern.patterns[pattern]));
|
|
143
164
|
}
|
|
144
165
|
child = child.nextSibling;
|
|
145
166
|
}
|
|
@@ -149,7 +170,7 @@ class Layout {
|
|
|
149
170
|
if (device) {
|
|
150
171
|
return device;
|
|
151
172
|
}
|
|
152
|
-
device = new
|
|
173
|
+
device = new Device(identifier);
|
|
153
174
|
this.devices.push(device);
|
|
154
175
|
return device;
|
|
155
176
|
}
|
|
@@ -158,7 +179,7 @@ class Layout {
|
|
|
158
179
|
if (channel) {
|
|
159
180
|
return channel;
|
|
160
181
|
}
|
|
161
|
-
channel = new
|
|
182
|
+
channel = new Channel(device, name);
|
|
162
183
|
device.channels.push(channel);
|
|
163
184
|
return channel;
|
|
164
185
|
}
|
|
@@ -167,7 +188,7 @@ class Layout {
|
|
|
167
188
|
if (type) {
|
|
168
189
|
return type;
|
|
169
190
|
}
|
|
170
|
-
type = new
|
|
191
|
+
type = new ResponderType(name);
|
|
171
192
|
this.responderType.push(type);
|
|
172
193
|
return type;
|
|
173
194
|
}
|
|
@@ -203,7 +224,7 @@ class Layout {
|
|
|
203
224
|
pool = pool.parent;
|
|
204
225
|
}
|
|
205
226
|
for (let part of parts) {
|
|
206
|
-
const child = (pool instanceof
|
|
227
|
+
const child = (pool instanceof District ? pool.children : pool.districts).find(child => child.name == part);
|
|
207
228
|
if (!child) {
|
|
208
229
|
throw new Error(`Section '${path}' could not be found from '${source.name}': district '${pool.name}' does not have a child named '${part}'`);
|
|
209
230
|
}
|
|
@@ -215,72 +236,50 @@ class Layout {
|
|
|
215
236
|
return this.findSection(sectionName, pool, source);
|
|
216
237
|
}
|
|
217
238
|
loadRouter(source, district) {
|
|
218
|
-
const router = new
|
|
239
|
+
const router = new Router(source.getAttribute('name'), district);
|
|
219
240
|
return router;
|
|
220
241
|
}
|
|
221
242
|
linkRouter(source, router) {
|
|
222
243
|
let child = source.firstChild;
|
|
244
|
+
let active;
|
|
223
245
|
while (child) {
|
|
224
246
|
if (child.tagName == 'route') {
|
|
225
|
-
const route = new
|
|
247
|
+
const route = new Route(child.getAttribute('name'), router);
|
|
226
248
|
route.in = this.findSection(child.getAttribute('in'), router.district);
|
|
227
249
|
route.in.out = router;
|
|
228
250
|
route.out = this.findSection(child.getAttribute('out'), router.district);
|
|
229
251
|
route.out.in = router;
|
|
252
|
+
if (child.hasAttribute('active')) {
|
|
253
|
+
if (active) {
|
|
254
|
+
throw new Error(`Router '${router.domainName}' has multiple active routes (${active.name}, ${route.name}).`);
|
|
255
|
+
}
|
|
256
|
+
active = route;
|
|
257
|
+
}
|
|
230
258
|
router.routes.push(route);
|
|
231
259
|
}
|
|
232
260
|
child = child.nextSibling;
|
|
233
261
|
}
|
|
262
|
+
router.activeRoute = active;
|
|
234
263
|
}
|
|
235
264
|
loadPowerDistrict(source, district) {
|
|
236
|
-
const powerDistrict = new
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
let svg = `<svg width="100vw" height="100vh" viewBox="0 0 ${width + 1} ${height + 1}" xmlns="http://www.w3.org/2000/svg">
|
|
254
|
-
<style>
|
|
255
|
-
|
|
256
|
-
path {
|
|
257
|
-
fill: none;
|
|
258
|
-
stroke: #000;
|
|
259
|
-
stroke-width: 0.2;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
</style>
|
|
263
|
-
`;
|
|
264
|
-
for (let district of this.districts) {
|
|
265
|
-
svg += district.toSVG();
|
|
266
|
-
}
|
|
267
|
-
return `${svg}${inject}</svg>`;
|
|
268
|
-
}
|
|
269
|
-
dump() {
|
|
270
|
-
console.group(`Layout ${this.name}`);
|
|
271
|
-
console.log('devices');
|
|
272
|
-
for (let device of this.devices) {
|
|
273
|
-
device.dump();
|
|
274
|
-
}
|
|
275
|
-
console.log('responder types');
|
|
276
|
-
for (let type of this.responderType) {
|
|
277
|
-
type.dump();
|
|
278
|
-
}
|
|
279
|
-
console.log('districts');
|
|
280
|
-
for (let district of this.districts) {
|
|
281
|
-
district.dump();
|
|
265
|
+
const powerDistrict = new PowerDistrict(source.getAttribute('name'), district);
|
|
266
|
+
let actor = source.firstChild;
|
|
267
|
+
while (actor) {
|
|
268
|
+
if (actor.tagName == 'activator' || actor.tagName == 'reverser' || actor.tagName == 'monitor') {
|
|
269
|
+
const device = this.findDevice(actor.getAttribute('device'));
|
|
270
|
+
const channel = this.findChannel(device, actor.getAttribute('channel'));
|
|
271
|
+
if (actor.tagName == 'activator') {
|
|
272
|
+
powerDistrict.activator = new PowerDistrictActivator(device, channel);
|
|
273
|
+
}
|
|
274
|
+
if (actor.tagName == 'reverser') {
|
|
275
|
+
powerDistrict.reverser = new PowerDistrictReverser(device, channel);
|
|
276
|
+
}
|
|
277
|
+
if (actor.tagName == 'monitor') {
|
|
278
|
+
powerDistrict.monitor = new PowerDistrictMonitor(device, channel);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
actor = actor.nextSibling;
|
|
282
282
|
}
|
|
283
|
-
|
|
283
|
+
return powerDistrict;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
exports.Layout = Layout;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
1
|
+
import { Device } from "./device/index";
|
|
2
2
|
import { District } from "./district";
|
|
3
3
|
import { Layout } from "./layout";
|
|
4
4
|
export declare class Monitor {
|
|
5
5
|
device: Device;
|
|
6
6
|
scope: District | Layout;
|
|
7
7
|
constructor(device: Device, scope: District | Layout);
|
|
8
|
-
dump(): void;
|
|
9
8
|
}
|
|
@@ -5,6 +5,8 @@ export declare class SectionPosition {
|
|
|
5
5
|
reversed: boolean;
|
|
6
6
|
constructor(section: Section, offset: number, reversed: boolean);
|
|
7
7
|
get absolutePosition(): number;
|
|
8
|
-
advance(distance: number):
|
|
8
|
+
advance(distance: number): SectionPosition;
|
|
9
|
+
private invert;
|
|
9
10
|
toString(): string;
|
|
11
|
+
toPackTrackValue(): string;
|
|
10
12
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SectionPosition = void 0;
|
|
4
|
-
class SectionPosition {
|
|
1
|
+
export class SectionPosition {
|
|
5
2
|
section;
|
|
6
3
|
offset;
|
|
7
4
|
reversed;
|
|
@@ -9,14 +6,23 @@ class SectionPosition {
|
|
|
9
6
|
this.section = section;
|
|
10
7
|
this.offset = offset;
|
|
11
8
|
this.reversed = reversed;
|
|
9
|
+
if (offset > section.length || offset < 0) {
|
|
10
|
+
throw new Error(`Offset ${offset} out of range for section '${section.domainName}' (0 - ${section.length})`);
|
|
11
|
+
}
|
|
12
12
|
}
|
|
13
|
+
// returns the absolute position of the point inside the section
|
|
14
|
+
// regardless of direction
|
|
13
15
|
get absolutePosition() {
|
|
14
16
|
if (this.reversed) {
|
|
15
17
|
return this.section.length - this.offset;
|
|
16
18
|
}
|
|
17
19
|
return this.offset;
|
|
18
20
|
}
|
|
21
|
+
// TODO verify reverse
|
|
19
22
|
advance(distance) {
|
|
23
|
+
if (distance < 0) {
|
|
24
|
+
return this.invert().advance(-distance).invert();
|
|
25
|
+
}
|
|
20
26
|
if (this.offset + distance > this.section.length) {
|
|
21
27
|
const next = this.section.next(this.reversed);
|
|
22
28
|
if (!next) {
|
|
@@ -26,8 +32,14 @@ class SectionPosition {
|
|
|
26
32
|
}
|
|
27
33
|
return new SectionPosition(this.section, this.offset + distance, this.reversed);
|
|
28
34
|
}
|
|
35
|
+
// reverse direction
|
|
36
|
+
invert() {
|
|
37
|
+
return new SectionPosition(this.section, this.section.length - this.offset, !this.reversed);
|
|
38
|
+
}
|
|
29
39
|
toString() {
|
|
30
40
|
return `${this.section.name} @ ${this.offset.toFixed(1)} ${this.reversed ? 'backward' : 'forward'}`;
|
|
31
41
|
}
|
|
42
|
+
toPackTrackValue() {
|
|
43
|
+
return `${this.section.domainName}@${this.offset}${this.reversed ? 'R' : 'F'}`;
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
|
-
exports.SectionPosition = SectionPosition;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Positioner } from "
|
|
1
|
+
import { Positioner } from "./index";
|
|
2
2
|
import { Channel } from "../device/channel";
|
|
3
3
|
import { Track } from "../track";
|
|
4
4
|
import { ResponderType } from "./responder-type";
|
|
@@ -8,6 +8,5 @@ export declare class PointPositioner extends Positioner {
|
|
|
8
8
|
channel: Channel;
|
|
9
9
|
responder: ResponderType;
|
|
10
10
|
constructor(track: Track, offset: number, channel: Channel, responder: ResponderType);
|
|
11
|
-
get position(): import("
|
|
12
|
-
dump(): void;
|
|
11
|
+
get position(): import("../position").SectionPosition;
|
|
13
12
|
}
|