@zimo-elektronik/zcan 1.0.49 → 1.0.51
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/dist/data/lanDataGroup.js +1 -1
- package/dist/info/infoGroup.d.ts +4 -3
- package/dist/info/infoGroup.js +26 -2
- package/dist/info/infoGroup.js.map +1 -1
- package/dist/info/infoMsg.d.ts +7 -0
- package/dist/info/infoMsg.js +18 -0
- package/dist/info/infoMsg.js.map +1 -1
- package/package.json +1 -1
- package/src/data/lanDataGroup.ts +1 -1
- package/src/info/infoGroup.ts +29 -5
- package/src/info/infoMsg.ts +22 -0
|
@@ -181,7 +181,7 @@ export default class LanDataGroup {
|
|
|
181
181
|
}
|
|
182
182
|
const funMode = [];
|
|
183
183
|
for (let i = 0; i < 64; i++) {
|
|
184
|
-
const fun = buffer.readUInt16LE(
|
|
184
|
+
const fun = buffer.readUInt16LE(196 + 2 * i);
|
|
185
185
|
funMode.push(fun);
|
|
186
186
|
}
|
|
187
187
|
const msg = new MsgLocoGuiRsp(MsgLocoGuiRsp.header(mode, nid), NID, SubID, version, flags, group, name, imageId, imageCrc, tachoId, tachoCrc, speedFwd, speedRev, speedRank, driveType, era, countryCode, funImg, funMode);
|
package/dist/info/infoGroup.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import MX10 from '../MX10';
|
|
3
3
|
import { Subject } from 'rxjs';
|
|
4
|
-
import { BidiInfoData } from '../common/models';
|
|
5
4
|
import { ModInfoType } from '../common/enums';
|
|
6
|
-
import { MsgModInfo } from './infoMsg';
|
|
5
|
+
import { MsgBidiInfo, MsgModInfo } from './infoMsg';
|
|
7
6
|
export default class InfoGroup {
|
|
8
7
|
private mx10;
|
|
9
|
-
readonly onBidiInfoChange: Subject<
|
|
8
|
+
readonly onBidiInfoChange: Subject<MsgBidiInfo>;
|
|
10
9
|
readonly onModuleInfoChange: Subject<MsgModInfo>;
|
|
11
10
|
private modInfoQ;
|
|
11
|
+
private bidiQ;
|
|
12
12
|
constructor(mx10: MX10);
|
|
13
13
|
getModuleInfo(nid: number, type: ModInfoType | number): Promise<MsgModInfo | undefined>;
|
|
14
|
+
getBidiInfo(locoNid: number, type: number): Promise<MsgBidiInfo | undefined>;
|
|
14
15
|
parse(size: number, command: number, mode: number, nid: number, buffer: Buffer): void;
|
|
15
16
|
private parseModuleInfo;
|
|
16
17
|
private parseBidiInfo;
|
package/dist/info/infoGroup.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
2
|
import { Query } from '../common/communication';
|
|
3
3
|
import { BidiType, Direction, ForwardOrReverse, MsgMode } from '../common/enums';
|
|
4
|
-
import { MsgModInfo } from './infoMsg';
|
|
4
|
+
import { MsgBidiInfo, MsgModInfo } from './infoMsg';
|
|
5
5
|
export default class InfoGroup {
|
|
6
6
|
mx10;
|
|
7
7
|
onBidiInfoChange = new Subject();
|
|
8
8
|
onModuleInfoChange = new Subject();
|
|
9
9
|
modInfoQ = undefined;
|
|
10
|
+
bidiQ = undefined;
|
|
10
11
|
constructor(mx10) {
|
|
11
12
|
this.mx10 = mx10;
|
|
12
13
|
}
|
|
@@ -34,6 +35,28 @@ export default class InfoGroup {
|
|
|
34
35
|
this.modInfoQ = undefined;
|
|
35
36
|
return rv;
|
|
36
37
|
}
|
|
38
|
+
async getBidiInfo(locoNid, type) {
|
|
39
|
+
if (this.bidiQ !== undefined && !await this.bidiQ.lock()) {
|
|
40
|
+
this.mx10.logInfo.next("mx10.getBidiInfo: failed to acquire lock");
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
this.bidiQ = new Query(MsgBidiInfo.header(MsgMode.REQ, locoNid), this.onBidiInfoChange);
|
|
44
|
+
this.bidiQ.tx = ((header) => {
|
|
45
|
+
const msg = new MsgBidiInfo(header, type, locoNid);
|
|
46
|
+
this.mx10.logInfo.next('bidi query tx: ' + JSON.stringify(msg));
|
|
47
|
+
this.mx10.sendMsg(msg);
|
|
48
|
+
});
|
|
49
|
+
this.bidiQ.match = ((msg) => {
|
|
50
|
+
this.mx10.logInfo.next('bidi query rx: ' + JSON.stringify(msg));
|
|
51
|
+
return (msg.type() === type);
|
|
52
|
+
});
|
|
53
|
+
this.bidiQ.subscribe(false);
|
|
54
|
+
const rv = await this.bidiQ.run();
|
|
55
|
+
this.mx10.logInfo.next("mx10.getBidiInfo.rv: " + JSON.stringify(rv));
|
|
56
|
+
this.bidiQ.unlock();
|
|
57
|
+
this.bidiQ = undefined;
|
|
58
|
+
return rv;
|
|
59
|
+
}
|
|
37
60
|
parse(size, command, mode, nid, buffer) {
|
|
38
61
|
switch (command) {
|
|
39
62
|
case 0x05:
|
|
@@ -72,7 +95,8 @@ export default class InfoGroup {
|
|
|
72
95
|
default:
|
|
73
96
|
data = info;
|
|
74
97
|
}
|
|
75
|
-
|
|
98
|
+
const msg = new MsgBidiInfo(MsgBidiInfo.header(mode, NID), type, undefined, info);
|
|
99
|
+
this.onBidiInfoChange.next(msg);
|
|
76
100
|
}
|
|
77
101
|
parseEastWest(data) {
|
|
78
102
|
if ((data & 0x02) == 0x02)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infoGroup.js","sourceRoot":"","sources":["../../src/info/infoGroup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAC,KAAK,EAAC,MAAM,yBAAyB,CAAC;AAE9C,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAe,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"infoGroup.js","sourceRoot":"","sources":["../../src/info/infoGroup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAC,KAAK,EAAC,MAAM,y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info(): number | undefined;
|
|
8
8
|
}
|
|
9
|
+
export declare class MsgBidiInfo extends Message {
|
|
10
|
+
static header(mode: MsgMode, nid: number): Header;
|
|
11
|
+
constructor(header: Header, type: number, nid?: number, info?: number);
|
|
12
|
+
nid(): number;
|
|
13
|
+
type(): number;
|
|
14
|
+
info(): number | undefined;
|
|
15
|
+
}
|
package/dist/info/infoMsg.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Message } from "../common/communication";
|
|
2
|
+
import { MsgMode } from "../common/enums";
|
|
2
3
|
export class MsgModInfo extends Message {
|
|
3
4
|
static header(mode, nid) { return { group: 0x08, cmd: 0x08, mode: mode, nid }; }
|
|
4
5
|
constructor(header, type, data = []) {
|
|
@@ -10,4 +11,21 @@ export class MsgModInfo extends Message {
|
|
|
10
11
|
type() { return this.data[0].value; }
|
|
11
12
|
info() { return this.data.length > 1 ? this.data[1].value : undefined; }
|
|
12
13
|
}
|
|
14
|
+
export class MsgBidiInfo extends Message {
|
|
15
|
+
static header(mode, nid) { return { group: 0x08, cmd: 0x05, mode: mode, nid }; }
|
|
16
|
+
constructor(header, type, nid, info) {
|
|
17
|
+
super(header);
|
|
18
|
+
if (header.mode === MsgMode.REQ) {
|
|
19
|
+
super.push({ value: nid || 0, length: 2 });
|
|
20
|
+
super.push({ value: type, length: 2 });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
super.push({ value: type, length: 2 });
|
|
24
|
+
super.push({ value: info || 0, length: 4 });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
nid() { return this.header.mode === MsgMode.REQ ? this.data[0].value : this.header.nid || 0; }
|
|
28
|
+
type() { return this.data[this.header.mode === MsgMode.REQ ? 1 : 0].value; }
|
|
29
|
+
info() { return this.data.length > 1 ? this.data[1].value : undefined; }
|
|
30
|
+
}
|
|
13
31
|
//# sourceMappingURL=infoMsg.js.map
|
package/dist/info/infoMsg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infoMsg.js","sourceRoot":"","sources":["../../src/info/infoMsg.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,OAAO,EAAiB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"infoMsg.js","sourceRoot":"","sources":["../../src/info/infoMsg.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,OAAO,EAAiB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAe,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAIvD,MAAM,OAAO,UAAW,SAAQ,OAAO;IAE/B,MAAM,CAAC,MAAM,CAAC,IAAa,EAAE,GAAW,IAC9C,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAC,CAAA,CAAA,CAAC;IAElD,YAAY,MAAc,EAAE,IAAiB,EAAE,OAAsB,EAAE;QAEtE,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,KAAK,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAC,CAAC,CAAC;QACrC,IAAG,IAAI,CAAC,MAAM;YACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,KAA6B,OAAS,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAiC,CAAA,CAAA,CAAC;IACzF,IAAI,KAAwB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAe,CAAC,CAAC,CAAC,SAAS,CAAA,CAAA,CAAC;CACnG;AAED,MAAM,OAAO,WAAY,SAAQ,OAAO;IAEhC,MAAM,CAAC,MAAM,CAAC,IAAa,EAAE,GAAW,IAC9C,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,GAAG,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AC,CAAC,CAAC,SAAS,CAAA,CAAA,CAAC;CACnG"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "https://github.com/ZIMO-Elektronik/zcan",
|
|
8
|
-
"version": "1.0.
|
|
8
|
+
"version": "1.0.51",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node dist/main.js",
|
|
11
11
|
"start:dev": "nodemon --ext js,ts,json,env --exec \"node --experimental-specifier-resolution=node --loader ts-node/esm\" src/main.ts",
|
package/src/data/lanDataGroup.ts
CHANGED
package/src/info/infoGroup.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {Subject} from 'rxjs';
|
|
|
4
4
|
import {Query} from '../common/communication';
|
|
5
5
|
import {BidiInfoData, BidiDirectionData} from '../common/models';
|
|
6
6
|
import {BidiType, Direction, ForwardOrReverse, ModInfoType, MsgMode} from '../common/enums';
|
|
7
|
-
import { MsgModInfo
|
|
7
|
+
import {MsgBidiInfo, MsgModInfo} from './infoMsg';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -14,10 +14,11 @@ export default class InfoGroup
|
|
|
14
14
|
{
|
|
15
15
|
private mx10: MX10;
|
|
16
16
|
|
|
17
|
-
public readonly onBidiInfoChange = new Subject<
|
|
17
|
+
public readonly onBidiInfoChange = new Subject<MsgBidiInfo>();
|
|
18
18
|
public readonly onModuleInfoChange = new Subject<MsgModInfo>();
|
|
19
19
|
|
|
20
20
|
private modInfoQ: Query<MsgModInfo> | undefined = undefined;
|
|
21
|
+
private bidiQ: Query<MsgBidiInfo> | undefined = undefined;
|
|
21
22
|
|
|
22
23
|
constructor(mx10: MX10)
|
|
23
24
|
{
|
|
@@ -30,7 +31,6 @@ export default class InfoGroup
|
|
|
30
31
|
this.mx10.logInfo.next("mx10.getModuleInfo: failed to acquire lock");
|
|
31
32
|
return undefined;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
34
|
this.modInfoQ = new Query(MsgModInfo.header(MsgMode.REQ, nid), this.onModuleInfoChange);
|
|
35
35
|
this.modInfoQ.log = ((msg) => {
|
|
36
36
|
this.mx10.logInfo.next(msg);
|
|
@@ -52,6 +52,30 @@ export default class InfoGroup
|
|
|
52
52
|
return rv;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
async getBidiInfo(locoNid: number, type: number): Promise<MsgBidiInfo | undefined>
|
|
56
|
+
{
|
|
57
|
+
if(this.bidiQ !== undefined && !await this.bidiQ.lock()) {
|
|
58
|
+
this.mx10.logInfo.next("mx10.getBidiInfo: failed to acquire lock");
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
this.bidiQ = new Query(MsgBidiInfo.header(MsgMode.REQ, locoNid), this.onBidiInfoChange);
|
|
62
|
+
this.bidiQ.tx = ((header) => {
|
|
63
|
+
const msg = new MsgBidiInfo(header, type, locoNid);
|
|
64
|
+
this.mx10.logInfo.next('bidi query tx: ' + JSON.stringify(msg));
|
|
65
|
+
this.mx10.sendMsg(msg);
|
|
66
|
+
});
|
|
67
|
+
this.bidiQ.match = ((msg) => {
|
|
68
|
+
this.mx10.logInfo.next('bidi query rx: ' + JSON.stringify(msg));
|
|
69
|
+
return (msg.type() === type);
|
|
70
|
+
})
|
|
71
|
+
this.bidiQ.subscribe(false);
|
|
72
|
+
const rv = await this.bidiQ.run();
|
|
73
|
+
this.mx10.logInfo.next("mx10.getBidiInfo.rv: " + JSON.stringify(rv));
|
|
74
|
+
this.bidiQ.unlock();
|
|
75
|
+
this.bidiQ = undefined;
|
|
76
|
+
return rv;
|
|
77
|
+
}
|
|
78
|
+
|
|
55
79
|
parse(size: number, command: number, mode: number, nid: number, buffer: Buffer)
|
|
56
80
|
{
|
|
57
81
|
switch (command) {
|
|
@@ -98,8 +122,8 @@ export default class InfoGroup
|
|
|
98
122
|
default:
|
|
99
123
|
data = info;
|
|
100
124
|
}
|
|
101
|
-
|
|
102
|
-
this.onBidiInfoChange.next(
|
|
125
|
+
const msg = new MsgBidiInfo(MsgBidiInfo.header(mode, NID), type, undefined, info);
|
|
126
|
+
this.onBidiInfoChange.next(msg);
|
|
103
127
|
}
|
|
104
128
|
|
|
105
129
|
private parseEastWest(data: number)
|
package/src/info/infoMsg.ts
CHANGED
|
@@ -18,4 +18,26 @@ export class MsgModInfo extends Message
|
|
|
18
18
|
}
|
|
19
19
|
type(): ModInfoType | undefined {return ((this.data[0].value as unknown) as ModInfoType)}
|
|
20
20
|
info(): number | undefined {return this.data.length > 1 ? this.data[1].value as number : undefined}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class MsgBidiInfo extends Message
|
|
24
|
+
{
|
|
25
|
+
public static header(mode: MsgMode, nid: number): Header
|
|
26
|
+
{return {group: 0x08, cmd: 0x05, mode: mode, nid}}
|
|
27
|
+
|
|
28
|
+
constructor(header: Header, type: number, nid?: number, info?: number)
|
|
29
|
+
{
|
|
30
|
+
super(header);
|
|
31
|
+
|
|
32
|
+
if(header.mode === MsgMode.REQ) {
|
|
33
|
+
super.push({value: nid || 0, length: 2});
|
|
34
|
+
super.push({value: type, length: 2});
|
|
35
|
+
} else {
|
|
36
|
+
super.push({value: type, length: 2});
|
|
37
|
+
super.push({value: info || 0, length: 4});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
nid(): number {return this.header.mode === MsgMode.REQ ? this.data[0].value as number : this.header.nid || 0}
|
|
41
|
+
type(): number {return this.data[this.header.mode === MsgMode.REQ ? 1 : 0].value as number}
|
|
42
|
+
info(): number | undefined {return this.data.length > 1 ? this.data[1].value as number : undefined}
|
|
21
43
|
}
|