@packtrack/layout 1.0.10 → 1.0.11
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/device/channel.js +5 -1
- package/.built/device/device.js +5 -1
- package/.built/district.js +7 -3
- package/.built/layout.js +29 -25
- package/.built/position.js +5 -1
- package/.built/positioner/index.js +5 -1
- package/.built/positioner/point.js +6 -2
- package/.built/positioner/responder-type.js +5 -1
- package/.built/power-district.js +5 -1
- package/.built/route.js +5 -1
- package/.built/router.js +5 -1
- package/.built/section.js +12 -8
- package/.built/source/device/channel.d.ts +8 -0
- package/.built/source/device/channel.js +16 -0
- package/.built/source/device/device.d.ts +11 -0
- package/.built/source/device/device.js +24 -0
- package/.built/source/district.d.ts +20 -0
- package/.built/source/district.js +86 -0
- package/.built/source/layout.d.ts +29 -0
- package/.built/source/layout.js +286 -0
- package/.built/source/position.d.ts +10 -0
- package/.built/source/position.js +33 -0
- package/.built/source/power-district.d.ts +8 -0
- package/.built/source/power-district.js +18 -0
- package/.built/source/route.d.ts +10 -0
- package/.built/source/route.js +17 -0
- package/.built/source/router.d.ts +14 -0
- package/.built/source/router.js +40 -0
- package/.built/source/section.d.ts +40 -0
- package/.built/source/section.js +217 -0
- package/.built/source/tile.d.ts +57 -0
- package/.built/source/tile.js +78 -0
- package/.built/source/track.d.ts +12 -0
- package/.built/source/track.js +29 -0
- package/.built/tile.js +7 -2
- package/.built/track.js +7 -3
- package/package.json +1 -1
- package/source/index.ts +3 -0
- package/.built/index.d.ts +0 -12
- package/.built/index.js +0 -12
package/.built/device/channel.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Channel = void 0;
|
|
4
|
+
class Channel {
|
|
2
5
|
device;
|
|
3
6
|
name;
|
|
4
7
|
constructor(device, name) {
|
|
@@ -10,3 +13,4 @@ export class Channel {
|
|
|
10
13
|
}
|
|
11
14
|
publish(data) { }
|
|
12
15
|
}
|
|
16
|
+
exports.Channel = Channel;
|
package/.built/device/device.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Device = void 0;
|
|
4
|
+
class Device {
|
|
2
5
|
identifier;
|
|
3
6
|
channels = [];
|
|
4
7
|
lastDiscovery;
|
|
@@ -18,3 +21,4 @@ export class Device {
|
|
|
18
21
|
console.groupEnd();
|
|
19
22
|
}
|
|
20
23
|
}
|
|
24
|
+
exports.Device = Device;
|
package/.built/district.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.District = void 0;
|
|
4
|
+
const layout_1 = require("./layout");
|
|
5
|
+
class District {
|
|
3
6
|
name;
|
|
4
7
|
parent;
|
|
5
8
|
children = [];
|
|
@@ -11,7 +14,7 @@ export class District {
|
|
|
11
14
|
this.parent = parent;
|
|
12
15
|
}
|
|
13
16
|
get domainName() {
|
|
14
|
-
if (this.parent instanceof Layout) {
|
|
17
|
+
if (this.parent instanceof layout_1.Layout) {
|
|
15
18
|
return `${this.name}.${this.parent.name}`;
|
|
16
19
|
}
|
|
17
20
|
return `${this.name}.${this.parent.domainName}`;
|
|
@@ -80,3 +83,4 @@ export class District {
|
|
|
80
83
|
];
|
|
81
84
|
}
|
|
82
85
|
}
|
|
86
|
+
exports.District = District;
|
package/.built/layout.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Layout = void 0;
|
|
4
|
+
const district_1 = require("./district");
|
|
5
|
+
const power_district_1 = require("./power-district");
|
|
6
|
+
const route_1 = require("./route");
|
|
7
|
+
const router_1 = require("./router");
|
|
8
|
+
const section_1 = require("./section");
|
|
9
|
+
const tile_1 = require("./tile");
|
|
10
|
+
const track_1 = require("./track");
|
|
11
|
+
const device_1 = require("./device/device");
|
|
12
|
+
const responder_type_1 = require("./positioner/responder-type");
|
|
13
|
+
const channel_1 = require("./device/channel");
|
|
14
|
+
const point_1 = require("./positioner/point");
|
|
15
|
+
class Layout {
|
|
13
16
|
name;
|
|
14
17
|
districts = [];
|
|
15
18
|
devices = [];
|
|
@@ -56,7 +59,7 @@ export class Layout {
|
|
|
56
59
|
return layout;
|
|
57
60
|
}
|
|
58
61
|
loadDistrict(source, parent) {
|
|
59
|
-
const district = new District(source.getAttribute('name'), parent);
|
|
62
|
+
const district = new district_1.District(source.getAttribute('name'), parent);
|
|
60
63
|
let child = source.firstChild;
|
|
61
64
|
while (child) {
|
|
62
65
|
if (child.tagName == 'power-districts') {
|
|
@@ -101,7 +104,7 @@ export class Layout {
|
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
loadSection(source, district) {
|
|
104
|
-
const section = new Section(source.getAttribute('name'), district);
|
|
107
|
+
const section = new section_1.Section(source.getAttribute('name'), district);
|
|
105
108
|
district.sections.push(section);
|
|
106
109
|
let child = source.firstChild;
|
|
107
110
|
while (child) {
|
|
@@ -109,7 +112,7 @@ export class Layout {
|
|
|
109
112
|
let trackNode = child.firstChild;
|
|
110
113
|
while (trackNode) {
|
|
111
114
|
if (trackNode.tagName == 'track') {
|
|
112
|
-
const track = new Track(section, +trackNode.getAttribute('length'), trackNode.getAttribute('path'));
|
|
115
|
+
const track = new track_1.Track(section, +trackNode.getAttribute('length'), trackNode.getAttribute('path'));
|
|
113
116
|
section.tracks.push(track);
|
|
114
117
|
let trackChild = trackNode.firstChild;
|
|
115
118
|
while (trackChild) {
|
|
@@ -120,7 +123,7 @@ export class Layout {
|
|
|
120
123
|
const device = this.findDevice(positioner.getAttribute('device'));
|
|
121
124
|
const channel = this.findChannel(device, positioner.getAttribute('channel'));
|
|
122
125
|
const responderType = this.findResponderType(positioner.getAttribute('responder'));
|
|
123
|
-
track.positioners.push(new PointPositioner(track, +positioner.getAttribute('offset'), channel, responderType));
|
|
126
|
+
track.positioners.push(new point_1.PointPositioner(track, +positioner.getAttribute('offset'), channel, responderType));
|
|
124
127
|
}
|
|
125
128
|
positioner = positioner.nextSibling;
|
|
126
129
|
}
|
|
@@ -133,10 +136,10 @@ export class Layout {
|
|
|
133
136
|
}
|
|
134
137
|
if (child.tagName == 'tile') {
|
|
135
138
|
const pattern = child.getAttribute('pattern');
|
|
136
|
-
if (!(pattern in TilePattern.patterns)) {
|
|
139
|
+
if (!(pattern in tile_1.TilePattern.patterns)) {
|
|
137
140
|
throw new Error(`Unknown tile pattern '${pattern}' in tile ${section.tiles.length + 1} in ${section.domainName}`);
|
|
138
141
|
}
|
|
139
|
-
section.tiles.push(new Tile(section, +child.getAttribute('x'), +child.getAttribute('y'), TilePattern.patterns[pattern]));
|
|
142
|
+
section.tiles.push(new tile_1.Tile(section, +child.getAttribute('x'), +child.getAttribute('y'), tile_1.TilePattern.patterns[pattern]));
|
|
140
143
|
}
|
|
141
144
|
child = child.nextSibling;
|
|
142
145
|
}
|
|
@@ -146,7 +149,7 @@ export class Layout {
|
|
|
146
149
|
if (device) {
|
|
147
150
|
return device;
|
|
148
151
|
}
|
|
149
|
-
device = new Device(identifier);
|
|
152
|
+
device = new device_1.Device(identifier);
|
|
150
153
|
this.devices.push(device);
|
|
151
154
|
return device;
|
|
152
155
|
}
|
|
@@ -155,7 +158,7 @@ export class Layout {
|
|
|
155
158
|
if (channel) {
|
|
156
159
|
return channel;
|
|
157
160
|
}
|
|
158
|
-
channel = new Channel(device, name);
|
|
161
|
+
channel = new channel_1.Channel(device, name);
|
|
159
162
|
device.channels.push(channel);
|
|
160
163
|
return channel;
|
|
161
164
|
}
|
|
@@ -164,7 +167,7 @@ export class Layout {
|
|
|
164
167
|
if (type) {
|
|
165
168
|
return type;
|
|
166
169
|
}
|
|
167
|
-
type = new ResponderType(name);
|
|
170
|
+
type = new responder_type_1.ResponderType(name);
|
|
168
171
|
this.responderType.push(type);
|
|
169
172
|
return type;
|
|
170
173
|
}
|
|
@@ -200,7 +203,7 @@ export class Layout {
|
|
|
200
203
|
pool = pool.parent;
|
|
201
204
|
}
|
|
202
205
|
for (let part of parts) {
|
|
203
|
-
const child = (pool instanceof District ? pool.children : pool.districts).find(child => child.name == part);
|
|
206
|
+
const child = (pool instanceof district_1.District ? pool.children : pool.districts).find(child => child.name == part);
|
|
204
207
|
if (!child) {
|
|
205
208
|
throw new Error(`Section '${path}' could not be found from '${source.name}': district '${pool.name}' does not have a child named '${part}'`);
|
|
206
209
|
}
|
|
@@ -212,14 +215,14 @@ export class Layout {
|
|
|
212
215
|
return this.findSection(sectionName, pool, source);
|
|
213
216
|
}
|
|
214
217
|
loadRouter(source, district) {
|
|
215
|
-
const router = new Router(source.getAttribute('name'), district);
|
|
218
|
+
const router = new router_1.Router(source.getAttribute('name'), district);
|
|
216
219
|
return router;
|
|
217
220
|
}
|
|
218
221
|
linkRouter(source, router) {
|
|
219
222
|
let child = source.firstChild;
|
|
220
223
|
while (child) {
|
|
221
224
|
if (child.tagName == 'route') {
|
|
222
|
-
const route = new Route(child.getAttribute('name'), router);
|
|
225
|
+
const route = new route_1.Route(child.getAttribute('name'), router);
|
|
223
226
|
route.in = this.findSection(child.getAttribute('in'), router.district);
|
|
224
227
|
route.in.out = router;
|
|
225
228
|
route.out = this.findSection(child.getAttribute('out'), router.district);
|
|
@@ -230,7 +233,7 @@ export class Layout {
|
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
loadPowerDistrict(source, district) {
|
|
233
|
-
const powerDistrict = new PowerDistrict(source.getAttribute('name'), district);
|
|
236
|
+
const powerDistrict = new power_district_1.PowerDistrict(source.getAttribute('name'), district);
|
|
234
237
|
return powerDistrict;
|
|
235
238
|
}
|
|
236
239
|
toDot() {
|
|
@@ -280,3 +283,4 @@ export class Layout {
|
|
|
280
283
|
console.groupEnd();
|
|
281
284
|
}
|
|
282
285
|
}
|
|
286
|
+
exports.Layout = Layout;
|
package/.built/position.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SectionPosition = void 0;
|
|
4
|
+
class SectionPosition {
|
|
2
5
|
section;
|
|
3
6
|
offset;
|
|
4
7
|
reversed;
|
|
@@ -27,3 +30,4 @@ export class SectionPosition {
|
|
|
27
30
|
return `${this.section.name} @ ${this.offset.toFixed(1)} ${this.reversed ? 'backward' : 'forward'}`;
|
|
28
31
|
}
|
|
29
32
|
}
|
|
33
|
+
exports.SectionPosition = SectionPosition;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PointPositioner = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
class PointPositioner extends _1.Positioner {
|
|
3
6
|
track;
|
|
4
7
|
offset;
|
|
5
8
|
channel;
|
|
@@ -21,3 +24,4 @@ export class PointPositioner extends Positioner {
|
|
|
21
24
|
console.groupEnd();
|
|
22
25
|
}
|
|
23
26
|
}
|
|
27
|
+
exports.PointPositioner = PointPositioner;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponderType = void 0;
|
|
4
|
+
class ResponderType {
|
|
2
5
|
name;
|
|
3
6
|
constructor(name) {
|
|
4
7
|
this.name = name;
|
|
@@ -7,3 +10,4 @@ export class ResponderType {
|
|
|
7
10
|
console.log(`Responder Type '${this.name}'`);
|
|
8
11
|
}
|
|
9
12
|
}
|
|
13
|
+
exports.ResponderType = ResponderType;
|
package/.built/power-district.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PowerDistrict = void 0;
|
|
4
|
+
class PowerDistrict {
|
|
2
5
|
name;
|
|
3
6
|
district;
|
|
4
7
|
constructor(name, district) {
|
|
@@ -12,3 +15,4 @@ export class PowerDistrict {
|
|
|
12
15
|
console.log(this.name);
|
|
13
16
|
}
|
|
14
17
|
}
|
|
18
|
+
exports.PowerDistrict = PowerDistrict;
|
package/.built/route.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Route = void 0;
|
|
4
|
+
class Route {
|
|
2
5
|
name;
|
|
3
6
|
router;
|
|
4
7
|
in;
|
|
@@ -11,3 +14,4 @@ export class Route {
|
|
|
11
14
|
console.log(`Route ${this.name}: ${this.in.domainName} → ${this.out.domainName}`);
|
|
12
15
|
}
|
|
13
16
|
}
|
|
17
|
+
exports.Route = Route;
|
package/.built/router.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Router = void 0;
|
|
4
|
+
class Router {
|
|
2
5
|
name;
|
|
3
6
|
district;
|
|
4
7
|
activeRoute;
|
|
@@ -34,3 +37,4 @@ export class Router {
|
|
|
34
37
|
`;
|
|
35
38
|
}
|
|
36
39
|
}
|
|
40
|
+
exports.Router = Router;
|
package/.built/section.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Section = void 0;
|
|
4
|
+
const position_1 = require("./position");
|
|
5
|
+
const router_1 = require("./router");
|
|
6
|
+
class Section {
|
|
4
7
|
name;
|
|
5
8
|
district;
|
|
6
9
|
powerDistrict;
|
|
@@ -24,7 +27,7 @@ export class Section {
|
|
|
24
27
|
if (this.in instanceof Section) {
|
|
25
28
|
return this.in;
|
|
26
29
|
}
|
|
27
|
-
if (this.in instanceof Router) {
|
|
30
|
+
if (this.in instanceof router_1.Router) {
|
|
28
31
|
const activeRoute = this.in.activeRoute;
|
|
29
32
|
if (!activeRoute) {
|
|
30
33
|
throw new Error(`Router '${this.in.domainName}' has no active route`);
|
|
@@ -45,7 +48,7 @@ export class Section {
|
|
|
45
48
|
if (this.out instanceof Section) {
|
|
46
49
|
return this.out;
|
|
47
50
|
}
|
|
48
|
-
if (this.out instanceof Router) {
|
|
51
|
+
if (this.out instanceof router_1.Router) {
|
|
49
52
|
const activeRoute = this.out.activeRoute;
|
|
50
53
|
if (!activeRoute) {
|
|
51
54
|
throw new Error(`Router '${this.out.domainName}' has no active route`);
|
|
@@ -150,13 +153,13 @@ export class Section {
|
|
|
150
153
|
if (!next) {
|
|
151
154
|
return {
|
|
152
155
|
sections,
|
|
153
|
-
tip: new SectionPosition(tip, tip.length, false)
|
|
156
|
+
tip: new position_1.SectionPosition(tip, tip.length, false)
|
|
154
157
|
};
|
|
155
158
|
}
|
|
156
159
|
if (next instanceof Section) {
|
|
157
160
|
tip = next;
|
|
158
161
|
}
|
|
159
|
-
if (next instanceof Router) {
|
|
162
|
+
if (next instanceof router_1.Router) {
|
|
160
163
|
if (!next.activeRoute) {
|
|
161
164
|
throw new Error(`Router '${next.domainName}' has no active route (routes: ${next.routes.map(route => `'${route.name}'`).join(', ')})`);
|
|
162
165
|
}
|
|
@@ -173,7 +176,7 @@ export class Section {
|
|
|
173
176
|
}
|
|
174
177
|
return {
|
|
175
178
|
sections,
|
|
176
|
-
tip: new SectionPosition(tip, reversed ? -length : tip.length + length, false)
|
|
179
|
+
tip: new position_1.SectionPosition(tip, reversed ? -length : tip.length + length, false)
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
182
|
toDotReference() {
|
|
@@ -211,3 +214,4 @@ export class Section {
|
|
|
211
214
|
}));
|
|
212
215
|
}
|
|
213
216
|
}
|
|
217
|
+
exports.Section = Section;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Channel = void 0;
|
|
4
|
+
class Channel {
|
|
5
|
+
device;
|
|
6
|
+
name;
|
|
7
|
+
constructor(device, name) {
|
|
8
|
+
this.device = device;
|
|
9
|
+
this.name = name;
|
|
10
|
+
}
|
|
11
|
+
dump() {
|
|
12
|
+
console.log(`Channel '${this.name}' on ${this.device.identifier}`);
|
|
13
|
+
}
|
|
14
|
+
publish(data) { }
|
|
15
|
+
}
|
|
16
|
+
exports.Channel = Channel;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Device = void 0;
|
|
4
|
+
class Device {
|
|
5
|
+
identifier;
|
|
6
|
+
channels = [];
|
|
7
|
+
lastDiscovery;
|
|
8
|
+
constructor(identifier) {
|
|
9
|
+
this.identifier = identifier;
|
|
10
|
+
}
|
|
11
|
+
dump() {
|
|
12
|
+
console.group(`Device ${this.identifier}`);
|
|
13
|
+
if (this.lastDiscovery) {
|
|
14
|
+
console.log(`last discovery: ${this.lastDiscovery.date.toISOString()} ${this.lastDiscovery.address}`);
|
|
15
|
+
}
|
|
16
|
+
console.group('channels');
|
|
17
|
+
for (let channel of this.channels) {
|
|
18
|
+
channel.dump();
|
|
19
|
+
}
|
|
20
|
+
console.groupEnd();
|
|
21
|
+
console.groupEnd();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Device = Device;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Layout } from "./layout";
|
|
2
|
+
import { PowerDistrict } from "./power-district";
|
|
3
|
+
import { Router } from "./router";
|
|
4
|
+
import { Section } from "./section";
|
|
5
|
+
export declare class District {
|
|
6
|
+
name: string;
|
|
7
|
+
parent: District | Layout;
|
|
8
|
+
children: District[];
|
|
9
|
+
powerDistricts: PowerDistrict[];
|
|
10
|
+
sections: Section[];
|
|
11
|
+
routers: Router[];
|
|
12
|
+
constructor(name: string, parent: District | Layout);
|
|
13
|
+
get domainName(): string;
|
|
14
|
+
dump(): void;
|
|
15
|
+
toDotReference(): any;
|
|
16
|
+
toDotDefinition(): any;
|
|
17
|
+
toDotConnection(): any;
|
|
18
|
+
toSVG(): any;
|
|
19
|
+
findSVGPositions(): any;
|
|
20
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.District = void 0;
|
|
4
|
+
const layout_1 = require("./layout");
|
|
5
|
+
class District {
|
|
6
|
+
name;
|
|
7
|
+
parent;
|
|
8
|
+
children = [];
|
|
9
|
+
powerDistricts = [];
|
|
10
|
+
sections = [];
|
|
11
|
+
routers = [];
|
|
12
|
+
constructor(name, parent) {
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.parent = parent;
|
|
15
|
+
}
|
|
16
|
+
get domainName() {
|
|
17
|
+
if (this.parent instanceof layout_1.Layout) {
|
|
18
|
+
return `${this.name}.${this.parent.name}`;
|
|
19
|
+
}
|
|
20
|
+
return `${this.name}.${this.parent.domainName}`;
|
|
21
|
+
}
|
|
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
|
+
}
|
|
86
|
+
exports.District = District;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { District } from "./district";
|
|
2
|
+
import { PowerDistrict } from "./power-district";
|
|
3
|
+
import { Router } from "./router";
|
|
4
|
+
import { Section } from "./section";
|
|
5
|
+
import { Device } from "./device/device";
|
|
6
|
+
import { ResponderType } from "../positioner/responder-type";
|
|
7
|
+
import { Channel } from "./device/channel";
|
|
8
|
+
export declare class Layout {
|
|
9
|
+
name: string;
|
|
10
|
+
districts: District[];
|
|
11
|
+
devices: Device[];
|
|
12
|
+
responderType: ResponderType[];
|
|
13
|
+
get allDistricts(): District[];
|
|
14
|
+
static from(document: any): Layout;
|
|
15
|
+
loadDistrict(source: any, parent: District | Layout): District;
|
|
16
|
+
linkDistrict(source: any, district: District): void;
|
|
17
|
+
loadSection(source: any, district: District): void;
|
|
18
|
+
findDevice(identifier: string): Device;
|
|
19
|
+
findChannel(device: Device, name: string): Channel;
|
|
20
|
+
findResponderType(name: string): ResponderType;
|
|
21
|
+
linkSection(source: any, section: Section): void;
|
|
22
|
+
findSection(path: string, base: District, source?: District): any;
|
|
23
|
+
loadRouter(source: any, district: District): Router;
|
|
24
|
+
linkRouter(source: any, router: Router): void;
|
|
25
|
+
loadPowerDistrict(source: any, district: District): PowerDistrict;
|
|
26
|
+
toDot(): string;
|
|
27
|
+
toSVG(inject?: string): string;
|
|
28
|
+
dump(): void;
|
|
29
|
+
}
|