@packtrack/layout 1.5.0 → 1.6.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 +1 -0
- package/.built/index.js +1 -0
- package/.built/source/layout.js +22 -0
- package/.built/source/route-controller.d.ts +5 -0
- package/.built/source/route-controller.js +4 -0
- package/.built/source/route.d.ts +2 -0
- package/.built/source/route.js +1 -0
- package/.built/source/span.js +7 -2
- package/index.ts +1 -0
- package/package.json +1 -1
- package/source/layout.ts +30 -0
- package/source/route-controller.ts +6 -0
- package/source/route.ts +3 -0
- package/source/span.ts +8 -2
package/.built/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './source/district';
|
|
|
2
2
|
export * from './source/layout';
|
|
3
3
|
export * from './source/position';
|
|
4
4
|
export * from './source/route';
|
|
5
|
+
export * from './source/route-controller';
|
|
5
6
|
export * from './source/router';
|
|
6
7
|
export * from './source/section';
|
|
7
8
|
export * from './source/span';
|
package/.built/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './source/district';
|
|
|
2
2
|
export * from './source/layout';
|
|
3
3
|
export * from './source/position';
|
|
4
4
|
export * from './source/route';
|
|
5
|
+
export * from './source/route-controller';
|
|
5
6
|
export * from './source/router';
|
|
6
7
|
export * from './source/section';
|
|
7
8
|
export * from './source/span';
|
package/.built/source/layout.js
CHANGED
|
@@ -14,6 +14,7 @@ import { PowerDistrictReverser } from "./power-district/reverser";
|
|
|
14
14
|
import { PowerDistrictMonitor } from "./power-district/monitor";
|
|
15
15
|
import { Monitor } from "./monitor";
|
|
16
16
|
import { Throttle } from "./throttle";
|
|
17
|
+
import { RouteController } from "./route-controller";
|
|
17
18
|
export class Layout {
|
|
18
19
|
name;
|
|
19
20
|
districts = [];
|
|
@@ -241,13 +242,34 @@ export class Layout {
|
|
|
241
242
|
}
|
|
242
243
|
linkRouter(source, router) {
|
|
243
244
|
let child = source.firstChild;
|
|
245
|
+
// controller can be set on router level if common for all routes
|
|
246
|
+
let commonController;
|
|
244
247
|
while (child) {
|
|
248
|
+
if (child.tagName == 'controller') {
|
|
249
|
+
commonController = this.findChannel(this.findDevice(child.getAttribute('device')), child.getAttribute('channel'));
|
|
250
|
+
}
|
|
245
251
|
if (child.tagName == 'route') {
|
|
246
252
|
const route = new Route(child.getAttribute('name'), router);
|
|
247
253
|
route.in = this.findSection(child.getAttribute('in'), router.district);
|
|
248
254
|
route.in.out = router;
|
|
249
255
|
route.out = this.findSection(child.getAttribute('out'), router.district);
|
|
250
256
|
route.out.in = router;
|
|
257
|
+
if (child.hasAttribute('command')) {
|
|
258
|
+
const controller = new RouteController();
|
|
259
|
+
controller.channel = commonController;
|
|
260
|
+
controller.command = child.getAttribute('command');
|
|
261
|
+
route.controllers.push(controller);
|
|
262
|
+
}
|
|
263
|
+
let routeChild = child.firstChild;
|
|
264
|
+
while (routeChild) {
|
|
265
|
+
if (routeChild.tagName == 'controller') {
|
|
266
|
+
const controller = new RouteController();
|
|
267
|
+
controller.channel = this.findChannel(this.findDevice(routeChild.getAttribute('device')), routeChild.getAttribute('channel'));
|
|
268
|
+
controller.command = routeChild.getAttribute('command');
|
|
269
|
+
route.controllers.push(controller);
|
|
270
|
+
}
|
|
271
|
+
routeChild = routeChild.nextSibling;
|
|
272
|
+
}
|
|
251
273
|
router.routes.push(route);
|
|
252
274
|
}
|
|
253
275
|
child = child.nextSibling;
|
package/.built/source/route.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RouteController } from "./route-controller";
|
|
1
2
|
import { Router } from "./router";
|
|
2
3
|
import { Section } from "./section";
|
|
3
4
|
export declare class Route {
|
|
@@ -5,5 +6,6 @@ export declare class Route {
|
|
|
5
6
|
router: Router;
|
|
6
7
|
in: Section;
|
|
7
8
|
out: Section;
|
|
9
|
+
controllers: RouteController[];
|
|
8
10
|
constructor(name: string, router: Router);
|
|
9
11
|
}
|
package/.built/source/route.js
CHANGED
package/.built/source/span.js
CHANGED
|
@@ -42,6 +42,10 @@ export class Span {
|
|
|
42
42
|
return this.contains(peer.head) || this.contains(peer.tail);
|
|
43
43
|
}
|
|
44
44
|
get length() {
|
|
45
|
+
// TODO verify reverse
|
|
46
|
+
if (this.head.section == this.tail.section) {
|
|
47
|
+
return Math.abs(this.head.offset - this.tail.offset);
|
|
48
|
+
}
|
|
45
49
|
let length = 0;
|
|
46
50
|
if (this.head.reversed) {
|
|
47
51
|
length += this.head.section.length - this.head.offset;
|
|
@@ -52,11 +56,12 @@ export class Span {
|
|
|
52
56
|
for (let section of this.inside) {
|
|
53
57
|
length += section.length;
|
|
54
58
|
}
|
|
59
|
+
// TODO verify
|
|
55
60
|
if (this.tail.reversed) {
|
|
56
|
-
length += this.tail.
|
|
61
|
+
length += this.tail.offset;
|
|
57
62
|
}
|
|
58
63
|
else {
|
|
59
|
-
length += this.tail.offset;
|
|
64
|
+
length += this.tail.section.length - this.tail.offset;
|
|
60
65
|
}
|
|
61
66
|
return length;
|
|
62
67
|
}
|
package/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './source/district';
|
|
|
2
2
|
export * from './source/layout';
|
|
3
3
|
export * from './source/position';
|
|
4
4
|
export * from './source/route';
|
|
5
|
+
export * from './source/route-controller';
|
|
5
6
|
export * from './source/router';
|
|
6
7
|
export * from './source/section';
|
|
7
8
|
export * from './source/span';
|
package/package.json
CHANGED
package/source/layout.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { PowerDistrictReverser } from "./power-district/reverser";
|
|
|
14
14
|
import { PowerDistrictMonitor } from "./power-district/monitor";
|
|
15
15
|
import { Monitor } from "./monitor";
|
|
16
16
|
import { Throttle } from "./throttle";
|
|
17
|
+
import { RouteController } from "./route-controller";
|
|
17
18
|
|
|
18
19
|
export class Layout {
|
|
19
20
|
name: string;
|
|
@@ -344,7 +345,14 @@ export class Layout {
|
|
|
344
345
|
linkRouter(source, router: Router) {
|
|
345
346
|
let child = source.firstChild;
|
|
346
347
|
|
|
348
|
+
// controller can be set on router level if common for all routes
|
|
349
|
+
let commonController: Channel;
|
|
350
|
+
|
|
347
351
|
while (child) {
|
|
352
|
+
if (child.tagName == 'controller') {
|
|
353
|
+
commonController = this.findChannel(this.findDevice(child.getAttribute('device')), child.getAttribute('channel'));
|
|
354
|
+
}
|
|
355
|
+
|
|
348
356
|
if (child.tagName == 'route') {
|
|
349
357
|
const route = new Route(child.getAttribute('name'), router);
|
|
350
358
|
|
|
@@ -354,6 +362,28 @@ export class Layout {
|
|
|
354
362
|
route.out = this.findSection(child.getAttribute('out'), router.district);
|
|
355
363
|
route.out.in = router;
|
|
356
364
|
|
|
365
|
+
if (child.hasAttribute('command')) {
|
|
366
|
+
const controller = new RouteController();
|
|
367
|
+
controller.channel = commonController;
|
|
368
|
+
controller.command = child.getAttribute('command');
|
|
369
|
+
|
|
370
|
+
route.controllers.push(controller);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
let routeChild = child.firstChild;
|
|
374
|
+
|
|
375
|
+
while (routeChild) {
|
|
376
|
+
if (routeChild.tagName == 'controller') {
|
|
377
|
+
const controller = new RouteController();
|
|
378
|
+
controller.channel = this.findChannel(this.findDevice(routeChild.getAttribute('device')), routeChild.getAttribute('channel'));
|
|
379
|
+
controller.command = routeChild.getAttribute('command');
|
|
380
|
+
|
|
381
|
+
route.controllers.push(controller);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
routeChild = routeChild.nextSibling;
|
|
385
|
+
}
|
|
386
|
+
|
|
357
387
|
router.routes.push(route);
|
|
358
388
|
}
|
|
359
389
|
|
package/source/route.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RouteController } from "./route-controller";
|
|
1
2
|
import { Router } from "./router";
|
|
2
3
|
import { Section } from "./section";
|
|
3
4
|
|
|
@@ -5,6 +6,8 @@ export class Route {
|
|
|
5
6
|
in: Section;
|
|
6
7
|
out: Section;
|
|
7
8
|
|
|
9
|
+
controllers: RouteController[] = [];
|
|
10
|
+
|
|
8
11
|
constructor(
|
|
9
12
|
public name: string,
|
|
10
13
|
public router: Router,
|
package/source/span.ts
CHANGED
|
@@ -46,6 +46,11 @@ export class Span {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
get length() {
|
|
49
|
+
// TODO verify reverse
|
|
50
|
+
if (this.head.section == this.tail.section) {
|
|
51
|
+
return Math.abs(this.head.offset - this.tail.offset);
|
|
52
|
+
}
|
|
53
|
+
|
|
49
54
|
let length = 0;
|
|
50
55
|
|
|
51
56
|
if (this.head.reversed) {
|
|
@@ -58,10 +63,11 @@ export class Span {
|
|
|
58
63
|
length += section.length;
|
|
59
64
|
}
|
|
60
65
|
|
|
66
|
+
// TODO verify
|
|
61
67
|
if (this.tail.reversed) {
|
|
62
|
-
length += this.tail.section.length - this.tail.offset;
|
|
63
|
-
} else {
|
|
64
68
|
length += this.tail.offset;
|
|
69
|
+
} else {
|
|
70
|
+
length += this.tail.section.length - this.tail.offset;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
return length;
|