@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Positioner } from "
|
|
1
|
+
import { Positioner } from "./index";
|
|
2
2
|
export class PointPositioner extends Positioner {
|
|
3
3
|
track;
|
|
4
4
|
offset;
|
|
@@ -14,10 +14,4 @@ export class PointPositioner extends Positioner {
|
|
|
14
14
|
get position() {
|
|
15
15
|
return this.track.head.advance(this.offset);
|
|
16
16
|
}
|
|
17
|
-
dump() {
|
|
18
|
-
console.group('Point positioner');
|
|
19
|
-
console.log('offset:', this.offset);
|
|
20
|
-
this.channel.dump();
|
|
21
|
-
console.groupEnd();
|
|
22
|
-
}
|
|
23
17
|
}
|
package/.built/source/route.d.ts
CHANGED
package/.built/source/route.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Route = void 0;
|
|
4
|
-
class Route {
|
|
1
|
+
export class Route {
|
|
5
2
|
name;
|
|
6
3
|
router;
|
|
7
4
|
in;
|
|
@@ -10,8 +7,4 @@ class Route {
|
|
|
10
7
|
this.name = name;
|
|
11
8
|
this.router = router;
|
|
12
9
|
}
|
|
13
|
-
dump() {
|
|
14
|
-
console.log(`Route ${this.name}: ${this.in.domainName} → ${this.out.domainName}`);
|
|
15
|
-
}
|
|
16
10
|
}
|
|
17
|
-
exports.Route = Route;
|
package/.built/source/router.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Router = void 0;
|
|
4
|
-
class Router {
|
|
1
|
+
export class Router {
|
|
5
2
|
name;
|
|
6
3
|
district;
|
|
7
4
|
activeRoute;
|
|
@@ -13,28 +10,4 @@ class Router {
|
|
|
13
10
|
get domainName() {
|
|
14
11
|
return `${this.name}.${this.district.domainName}`;
|
|
15
12
|
}
|
|
16
|
-
dump() {
|
|
17
|
-
console.group(`Router ${this.domainName}`);
|
|
18
|
-
for (let route of this.routes) {
|
|
19
|
-
route.dump();
|
|
20
|
-
}
|
|
21
|
-
console.groupEnd();
|
|
22
|
-
}
|
|
23
|
-
toDotReference() {
|
|
24
|
-
return `router_${this.name.replace(/-/g, '_')}_${this.district.toDotReference()}`;
|
|
25
|
-
}
|
|
26
|
-
toDotDefinition() {
|
|
27
|
-
return `
|
|
28
|
-
${this.toDotReference()} [ label = ${JSON.stringify(this.name)}, shape = diamond ]
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
toDotConnection() {
|
|
32
|
-
return `
|
|
33
|
-
${this.routes.map(route => `
|
|
34
|
-
${route.in.toDotReference()} -> ${this.toDotReference()} [ headlabel = ${JSON.stringify(route.name)} ]
|
|
35
|
-
${this.toDotReference()} -> ${route.out.toDotReference()} [ taillabel = ${JSON.stringify(route.name)} ]
|
|
36
|
-
`).join('')}
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
13
|
}
|
|
40
|
-
exports.Router = Router;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { District } from "./district";
|
|
2
2
|
import { SectionPosition } from "./position";
|
|
3
|
-
import { PowerDistrict } from "./power-district";
|
|
3
|
+
import { PowerDistrict } from "./power-district/index";
|
|
4
4
|
import { Router } from "./router";
|
|
5
5
|
import { Tile } from "./tile";
|
|
6
6
|
import { Track } from "./track";
|
|
@@ -22,19 +22,10 @@ export declare class Section {
|
|
|
22
22
|
};
|
|
23
23
|
tiles: Tile[];
|
|
24
24
|
};
|
|
25
|
-
dump(): void;
|
|
26
25
|
get length(): number;
|
|
27
26
|
get tileLength(): number;
|
|
28
27
|
trail(offset: number, reversed: boolean, length: number): {
|
|
29
28
|
sections: Section[];
|
|
30
29
|
tip: SectionPosition;
|
|
31
30
|
};
|
|
32
|
-
toDotReference(): string;
|
|
33
|
-
toDotDefinition(): string;
|
|
34
|
-
toDotConnection(): string;
|
|
35
|
-
toSVG(): string;
|
|
36
|
-
findSVGPositions(): {
|
|
37
|
-
x: number;
|
|
38
|
-
y: number;
|
|
39
|
-
}[];
|
|
40
31
|
}
|
package/.built/source/section.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const position_1 = require("./position");
|
|
5
|
-
const router_1 = require("./router");
|
|
6
|
-
class Section {
|
|
1
|
+
import { SectionPosition } from "./position";
|
|
2
|
+
import { Router } from "./router";
|
|
3
|
+
export class Section {
|
|
7
4
|
name;
|
|
8
5
|
district;
|
|
9
6
|
powerDistrict;
|
|
@@ -27,7 +24,7 @@ class Section {
|
|
|
27
24
|
if (this.in instanceof Section) {
|
|
28
25
|
return this.in;
|
|
29
26
|
}
|
|
30
|
-
if (this.in instanceof
|
|
27
|
+
if (this.in instanceof Router) {
|
|
31
28
|
const activeRoute = this.in.activeRoute;
|
|
32
29
|
if (!activeRoute) {
|
|
33
30
|
throw new Error(`Router '${this.in.domainName}' has no active route`);
|
|
@@ -48,7 +45,7 @@ class Section {
|
|
|
48
45
|
if (this.out instanceof Section) {
|
|
49
46
|
return this.out;
|
|
50
47
|
}
|
|
51
|
-
if (this.out instanceof
|
|
48
|
+
if (this.out instanceof Router) {
|
|
52
49
|
const activeRoute = this.out.activeRoute;
|
|
53
50
|
if (!activeRoute) {
|
|
54
51
|
throw new Error(`Router '${this.out.domainName}' has no active route`);
|
|
@@ -113,17 +110,6 @@ class Section {
|
|
|
113
110
|
tiles
|
|
114
111
|
};
|
|
115
112
|
}
|
|
116
|
-
dump() {
|
|
117
|
-
console.group(`Section ${this.domainName}`);
|
|
118
|
-
console.log('in', this.in?.name ?? 'buffer');
|
|
119
|
-
console.log('out', this.out?.name ?? 'buffer');
|
|
120
|
-
console.group(`tracks`);
|
|
121
|
-
for (let track of this.tracks) {
|
|
122
|
-
track.dump();
|
|
123
|
-
}
|
|
124
|
-
console.groupEnd();
|
|
125
|
-
console.groupEnd();
|
|
126
|
-
}
|
|
127
113
|
get length() {
|
|
128
114
|
return this.tracks.reduce((accumulator, track) => accumulator + track.length, 0);
|
|
129
115
|
}
|
|
@@ -153,13 +139,13 @@ class Section {
|
|
|
153
139
|
if (!next) {
|
|
154
140
|
return {
|
|
155
141
|
sections,
|
|
156
|
-
tip: new
|
|
142
|
+
tip: new SectionPosition(tip, tip.length, false)
|
|
157
143
|
};
|
|
158
144
|
}
|
|
159
145
|
if (next instanceof Section) {
|
|
160
146
|
tip = next;
|
|
161
147
|
}
|
|
162
|
-
if (next instanceof
|
|
148
|
+
if (next instanceof Router) {
|
|
163
149
|
if (!next.activeRoute) {
|
|
164
150
|
throw new Error(`Router '${next.domainName}' has no active route (routes: ${next.routes.map(route => `'${route.name}'`).join(', ')})`);
|
|
165
151
|
}
|
|
@@ -176,42 +162,7 @@ class Section {
|
|
|
176
162
|
}
|
|
177
163
|
return {
|
|
178
164
|
sections,
|
|
179
|
-
tip: new
|
|
165
|
+
tip: new SectionPosition(tip, reversed ? -length : tip.length + length, false)
|
|
180
166
|
};
|
|
181
167
|
}
|
|
182
|
-
toDotReference() {
|
|
183
|
-
return `section_${this.name.replace(/-/g, '_')}_${this.district.toDotReference()}`;
|
|
184
|
-
}
|
|
185
|
-
toDotDefinition() {
|
|
186
|
-
return `
|
|
187
|
-
${this.toDotReference()} [ label = ${JSON.stringify(`${this.name}\n${this.length}`)}, shape = box ]
|
|
188
|
-
`;
|
|
189
|
-
}
|
|
190
|
-
toDotConnection() {
|
|
191
|
-
return `
|
|
192
|
-
${this.out instanceof Section ? `${this.toDotReference()} -> ${this.out.toDotReference()}` : ''}
|
|
193
|
-
`;
|
|
194
|
-
}
|
|
195
|
-
toSVG() {
|
|
196
|
-
return `
|
|
197
|
-
<g id=${JSON.stringify(this.domainName).split('.').join('_')}>
|
|
198
|
-
<style>
|
|
199
|
-
|
|
200
|
-
g#${this.domainName.split('.').join('_')} path {
|
|
201
|
-
stroke: hsl(${(this.length / this.tileLength)}deg, 100%, 50%);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
</style>
|
|
205
|
-
|
|
206
|
-
${this.tiles.map(tile => tile.toSVG()).join('')}
|
|
207
|
-
</g>
|
|
208
|
-
`;
|
|
209
|
-
}
|
|
210
|
-
findSVGPositions() {
|
|
211
|
-
return this.tiles.map(tile => ({
|
|
212
|
-
x: tile.x,
|
|
213
|
-
y: tile.y
|
|
214
|
-
}));
|
|
215
|
-
}
|
|
216
168
|
}
|
|
217
|
-
exports.Section = Section;
|
|
@@ -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 Throttle {
|
|
5
5
|
device: Device;
|
|
6
6
|
scope: District | Layout;
|
|
7
7
|
constructor(device: Device, scope: District | Layout);
|
|
8
|
-
dump(): void;
|
|
9
8
|
}
|
package/.built/source/tile.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Tile = exports.TilePattern = void 0;
|
|
4
|
-
class TilePattern {
|
|
1
|
+
export class TilePattern {
|
|
5
2
|
length;
|
|
6
3
|
path;
|
|
7
4
|
// TODO: replace simple paths with rounded versions
|
|
@@ -53,8 +50,7 @@ class TilePattern {
|
|
|
53
50
|
this.path = path;
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
|
-
|
|
57
|
-
class Tile {
|
|
53
|
+
export class Tile {
|
|
58
54
|
section;
|
|
59
55
|
x;
|
|
60
56
|
y;
|
|
@@ -75,4 +71,3 @@ class Tile {
|
|
|
75
71
|
`;
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
|
-
exports.Tile = Tile;
|
package/.built/source/track.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Positioner } from "
|
|
1
|
+
import { Positioner } from "./positioner/index";
|
|
2
2
|
import { Section } from "./section";
|
|
3
3
|
import { SectionPosition } from "./position";
|
|
4
4
|
export declare class Track {
|
|
@@ -8,5 +8,4 @@ export declare class Track {
|
|
|
8
8
|
positioners: Positioner[];
|
|
9
9
|
constructor(section: Section, length: number, path: string);
|
|
10
10
|
get head(): SectionPosition;
|
|
11
|
-
dump(): void;
|
|
12
11
|
}
|
package/.built/source/track.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Track = void 0;
|
|
4
|
-
const position_1 = require("./position");
|
|
5
|
-
class Track {
|
|
1
|
+
import { SectionPosition } from "./position";
|
|
2
|
+
export class Track {
|
|
6
3
|
section;
|
|
7
4
|
length;
|
|
8
5
|
path;
|
|
@@ -17,13 +14,9 @@ class Track {
|
|
|
17
14
|
let offset = 0;
|
|
18
15
|
for (let track of this.section.tracks) {
|
|
19
16
|
if (track == this) {
|
|
20
|
-
return new
|
|
17
|
+
return new SectionPosition(this.section, offset, false);
|
|
21
18
|
}
|
|
22
19
|
offset += track.length;
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
dump() {
|
|
26
|
-
console.log(this.length);
|
|
27
|
-
}
|
|
28
22
|
}
|
|
29
|
-
exports.Track = Track;
|
package/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
|
|
13
|
+
export * from './source/power-district/index';
|
|
14
|
+
export * from './source/power-district/activator';
|
|
15
|
+
export * from './source/power-district/monitor';
|
|
16
|
+
export * from './source/power-district/reverser';
|
|
17
|
+
|
|
18
|
+
export * from './source/positioner/index';
|
|
19
|
+
export * from './source/positioner/point';
|
|
20
|
+
export * from './source/positioner/responder-type';
|
|
21
|
+
|
|
22
|
+
export * from './source/device/index';
|
|
23
|
+
export * from './source/device/channel';
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@packtrack/layout",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"main": ".built/index.js",
|
|
5
5
|
"typings": ".built/index.d.ts",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"preversion": "
|
|
9
|
+
"preversion": "npm run build"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"typescript": "^5.3.3"
|
package/source/device/channel.ts
CHANGED
package/source/device/index.ts
CHANGED
|
@@ -4,25 +4,8 @@ export class Device {
|
|
|
4
4
|
channels: Channel[] = [];
|
|
5
5
|
|
|
6
6
|
lastDiscovery: { date: Date, address: string };
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
constructor(
|
|
9
9
|
public identifier: string
|
|
10
10
|
) {}
|
|
11
|
-
|
|
12
|
-
dump() {
|
|
13
|
-
console.group(`Device ${this.identifier}`);
|
|
14
|
-
|
|
15
|
-
if (this.lastDiscovery) {
|
|
16
|
-
console.log(`last discovery: ${this.lastDiscovery.date.toISOString()} ${this.lastDiscovery.address}`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
console.group('channels');
|
|
20
|
-
|
|
21
|
-
for (let channel of this.channels) {
|
|
22
|
-
channel.dump();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
console.groupEnd();
|
|
26
|
-
console.groupEnd();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
11
|
+
}
|
package/source/district.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Layout } from "./layout";
|
|
2
2
|
import { Monitor } from "./monitor";
|
|
3
|
-
import { PowerDistrict } from "./power-district";
|
|
3
|
+
import { PowerDistrict } from "./power-district/index";
|
|
4
4
|
import { Router } from "./router";
|
|
5
5
|
import { Section } from "./section";
|
|
6
6
|
|
|
@@ -25,83 +25,4 @@ export class District {
|
|
|
25
25
|
|
|
26
26
|
return `${this.name}.${this.parent.domainName}`;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
dump() {
|
|
30
|
-
console.group(`District ${this.domainName}`);
|
|
31
|
-
|
|
32
|
-
if (this.powerDistricts.length) {
|
|
33
|
-
console.group('power districts');
|
|
34
|
-
|
|
35
|
-
for (let district of this.powerDistricts) {
|
|
36
|
-
district.dump();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
console.groupEnd();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (this.sections.length) {
|
|
43
|
-
console.group('sections');
|
|
44
|
-
|
|
45
|
-
for (let section of this.sections) {
|
|
46
|
-
section.dump();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
console.groupEnd();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (this.children.length) {
|
|
53
|
-
console.group('children');
|
|
54
|
-
|
|
55
|
-
for (let district of this.children) {
|
|
56
|
-
district.dump();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
console.groupEnd();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
console.groupEnd();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
toDotReference() {
|
|
66
|
-
return `cluster_${this.name.replace(/-/g, '_')}${this.parent instanceof District ? this.parent.toDotReference() : ''}`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
toDotDefinition() {
|
|
70
|
-
return `
|
|
71
|
-
subgraph ${this.toDotReference()} {
|
|
72
|
-
label = ${JSON.stringify(this.name)}
|
|
73
|
-
|
|
74
|
-
${this.sections.map(section => section.toDotDefinition()).join('')}
|
|
75
|
-
${this.routers.map(router => router.toDotDefinition()).join('')}
|
|
76
|
-
|
|
77
|
-
${this.children.map(child => child.toDotDefinition()).join('')}
|
|
78
|
-
}
|
|
79
|
-
`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
toDotConnection() {
|
|
83
|
-
return `
|
|
84
|
-
${this.sections.map(section => section.toDotConnection()).join('')}
|
|
85
|
-
${this.routers.map(router => router.toDotConnection()).join('')}
|
|
86
|
-
|
|
87
|
-
${this.children.map(child => child.toDotConnection()).join('')}
|
|
88
|
-
`;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
toSVG() {
|
|
92
|
-
return `
|
|
93
|
-
<g id=${JSON.stringify(this.domainName)}>
|
|
94
|
-
${this.sections.map(section => section.toSVG()).join('')}
|
|
95
|
-
|
|
96
|
-
${this.children.map(child => child.toSVG()).join('')}
|
|
97
|
-
</g>
|
|
98
|
-
`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
findSVGPositions() {
|
|
102
|
-
return [
|
|
103
|
-
...this.sections.map(section => section.findSVGPositions()),
|
|
104
|
-
...this.children.map(child => child.findSVGPositions())
|
|
105
|
-
];
|
|
106
|
-
}
|
|
107
28
|
}
|
package/source/layout.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { District } from "./district";
|
|
2
|
-
import { PowerDistrict } from "./power-district";
|
|
2
|
+
import { PowerDistrict } from "./power-district/index";
|
|
3
3
|
import { Route } from "./route";
|
|
4
4
|
import { Router } from "./router";
|
|
5
5
|
import { Section } from "./section";
|
|
@@ -400,66 +400,4 @@ export class Layout {
|
|
|
400
400
|
|
|
401
401
|
return powerDistrict;
|
|
402
402
|
}
|
|
403
|
-
|
|
404
|
-
toDot() {
|
|
405
|
-
let dot = 'digraph G {';
|
|
406
|
-
|
|
407
|
-
for (let district of this.districts) {
|
|
408
|
-
dot += district.toDotDefinition();
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
for (let district of this.districts) {
|
|
412
|
-
dot += district.toDotConnection();
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
return `${dot}}`;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
toSVG(inject = '') {
|
|
419
|
-
const positons = this.districts.map(district => district.findSVGPositions()).flat(Infinity);
|
|
420
|
-
|
|
421
|
-
const width = Math.max(...positons.map(position => position.x));
|
|
422
|
-
const height = Math.max(...positons.map(position => position.y));
|
|
423
|
-
|
|
424
|
-
let svg = `<svg width="100vw" height="100vh" viewBox="0 0 ${width + 1} ${height + 1}" xmlns="http://www.w3.org/2000/svg">
|
|
425
|
-
<style>
|
|
426
|
-
|
|
427
|
-
path {
|
|
428
|
-
fill: none;
|
|
429
|
-
stroke: #000;
|
|
430
|
-
stroke-width: 0.2;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
</style>
|
|
434
|
-
`;
|
|
435
|
-
|
|
436
|
-
for (let district of this.districts) {
|
|
437
|
-
svg += district.toSVG();
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
return `${svg}${inject}</svg>`;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
dump() {
|
|
444
|
-
console.group(`Layout ${this.name}`);
|
|
445
|
-
console.log('devices');
|
|
446
|
-
|
|
447
|
-
for (let device of this.devices) {
|
|
448
|
-
device.dump();
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
console.log('responder types');
|
|
452
|
-
|
|
453
|
-
for (let type of this.responderType) {
|
|
454
|
-
type.dump();
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
console.log('districts');
|
|
458
|
-
|
|
459
|
-
for (let district of this.districts) {
|
|
460
|
-
district.dump();
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
console.groupEnd();
|
|
464
|
-
}
|
|
465
403
|
}
|
package/source/monitor.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
|
@@ -7,13 +7,4 @@ export class Monitor {
|
|
|
7
7
|
public device: Device,
|
|
8
8
|
public scope: District | Layout
|
|
9
9
|
) { }
|
|
10
|
-
|
|
11
|
-
dump() {
|
|
12
|
-
console.group('Monitor');
|
|
13
|
-
console.log('scope:', this.scope instanceof Layout ? '*' : this.scope.domainName);
|
|
14
|
-
|
|
15
|
-
this.device.dump();
|
|
16
|
-
|
|
17
|
-
console.groupEnd();
|
|
18
|
-
}
|
|
19
10
|
}
|
|
@@ -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";
|
|
@@ -16,13 +16,4 @@ export class PointPositioner extends Positioner {
|
|
|
16
16
|
get position() {
|
|
17
17
|
return this.track.head.advance(this.offset);
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
dump() {
|
|
21
|
-
console.group('Point positioner');
|
|
22
|
-
console.log('offset:', this.offset);
|
|
23
|
-
|
|
24
|
-
this.channel.dump();
|
|
25
|
-
|
|
26
|
-
console.groupEnd();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
19
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PowerDistrictActivator } from "./activator";
|
|
2
|
-
import { Device } from "../device/index";
|
|
3
2
|
import { District } from "../district";
|
|
4
3
|
import { PowerDistrictMonitor } from "./monitor";
|
|
5
4
|
import { PowerDistrictReverser } from "./reverser";
|
|
@@ -17,8 +16,4 @@ export class PowerDistrict {
|
|
|
17
16
|
get domainName() {
|
|
18
17
|
return `${this.name}.${this.district.domainName}`;
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
dump() {
|
|
22
|
-
console.log(this.name);
|
|
23
|
-
}
|
|
24
19
|
}
|
package/source/route.ts
CHANGED
|
@@ -4,13 +4,9 @@ import { Section } from "./section";
|
|
|
4
4
|
export class Route {
|
|
5
5
|
in: Section;
|
|
6
6
|
out: Section;
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
constructor(
|
|
9
9
|
public name: string,
|
|
10
10
|
public router: Router,
|
|
11
11
|
) {}
|
|
12
|
-
|
|
13
|
-
dump() {
|
|
14
|
-
console.log(`Route ${this.name}: ${this.in.domainName} → ${this.out.domainName}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
12
|
+
}
|