@zimo-elektronik/zcan 1.0.51 → 1.0.52
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/.prettierrc.json +3 -1
- package/__tests__/accessoriesGroup.test.ts +26 -26
- package/__tests__/connection.test.ts +52 -52
- package/__tests__/dataGroup.test.ts +82 -92
- package/__tests__/infoGroup.test.ts +18 -18
- package/__tests__/lanDataGroup.test.ts +54 -66
- package/__tests__/lanInfoGroup.test.ts +34 -34
- package/__tests__/lanLocoStateGroup.test.ts +17 -17
- package/__tests__/systemControlGroup.test.ts +36 -36
- package/__tests__/trackCfgGroup.test.ts +38 -38
- package/__tests__/vehicleGroup.test.ts +109 -110
- package/dist/common/models.d.ts +1 -12
- package/dist/info/infoGroup.d.ts +0 -4
- package/dist/info/infoGroup.js +1 -28
- package/dist/info/infoGroup.js.map +1 -1
- package/dist/info/infoMsg.d.ts +4 -0
- package/dist/info/infoMsg.js +12 -0
- package/dist/info/infoMsg.js.map +1 -1
- package/package.json +1 -1
- package/src/common/models.ts +11 -11
- package/src/info/infoGroup.ts +21 -33
- package/src/info/infoMsg.ts +20 -0
package/src/info/infoGroup.ts
CHANGED
|
@@ -2,8 +2,7 @@ import {Buffer} from 'buffer';
|
|
|
2
2
|
import MX10 from '../MX10';
|
|
3
3
|
import {Subject} from 'rxjs';
|
|
4
4
|
import {Query} from '../common/communication';
|
|
5
|
-
import {
|
|
6
|
-
import {BidiType, Direction, ForwardOrReverse, ModInfoType, MsgMode} from '../common/enums';
|
|
5
|
+
import {ModInfoType, MsgMode} from '../common/enums';
|
|
7
6
|
import {MsgBidiInfo, MsgModInfo} from './infoMsg';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -111,41 +110,30 @@ export default class InfoGroup
|
|
|
111
110
|
const type = buffer.readUInt16LE(2);
|
|
112
111
|
const info = buffer.readUInt32LE(4);
|
|
113
112
|
|
|
114
|
-
let data: BidiDirectionData | number = {};
|
|
115
|
-
switch (type) {
|
|
116
|
-
case BidiType.DIRECTION:
|
|
117
|
-
data.direction = this.parseEastWest(info);
|
|
118
|
-
data.directionChange = this.parseDirChange(info);
|
|
119
|
-
data.directionConfirm = this.parseDirectionConfirm(info);
|
|
120
|
-
data.forwardOrReverse = this.parseFwdRev(info);
|
|
121
|
-
break;
|
|
122
|
-
default:
|
|
123
|
-
data = info;
|
|
124
|
-
}
|
|
125
113
|
const msg = new MsgBidiInfo(MsgBidiInfo.header(mode, NID), type, undefined, info);
|
|
126
114
|
this.onBidiInfoChange.next(msg);
|
|
127
115
|
}
|
|
128
116
|
|
|
129
|
-
private parseEastWest(data: number)
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
117
|
+
// private parseEastWest(data: number)
|
|
118
|
+
// {
|
|
119
|
+
// if ((data & 0x02) == 0x02)
|
|
120
|
+
// return Direction.EAST;
|
|
121
|
+
// return Direction.WEST;
|
|
122
|
+
// }
|
|
135
123
|
|
|
136
|
-
private parseDirChange(data: number)
|
|
137
|
-
{
|
|
138
|
-
|
|
139
|
-
}
|
|
124
|
+
// private parseDirChange(data: number)
|
|
125
|
+
// {
|
|
126
|
+
// return (data & 0x04) == 0x04;
|
|
127
|
+
// }
|
|
140
128
|
|
|
141
|
-
private parseFwdRev(data: number)
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
private parseDirectionConfirm(data: number)
|
|
148
|
-
{
|
|
149
|
-
|
|
150
|
-
}
|
|
129
|
+
// private parseFwdRev(data: number)
|
|
130
|
+
// {
|
|
131
|
+
// if ((data & 0x01) == 0)
|
|
132
|
+
// return ForwardOrReverse.REVERSE;
|
|
133
|
+
// return ForwardOrReverse.FORWARD;
|
|
134
|
+
// }
|
|
135
|
+
// private parseDirectionConfirm(data: number)
|
|
136
|
+
// {
|
|
137
|
+
// return (data & 0x08) == 0x08;
|
|
138
|
+
// }
|
|
151
139
|
}
|
package/src/info/infoMsg.ts
CHANGED
|
@@ -40,4 +40,24 @@ export class MsgBidiInfo extends Message
|
|
|
40
40
|
nid(): number {return this.header.mode === MsgMode.REQ ? this.data[0].value as number : this.header.nid || 0}
|
|
41
41
|
type(): number {return this.data[this.header.mode === MsgMode.REQ ? 1 : 0].value as number}
|
|
42
42
|
info(): number | undefined {return this.data.length > 1 ? this.data[1].value as number : undefined}
|
|
43
|
+
|
|
44
|
+
public static dirEast(info: number)
|
|
45
|
+
{
|
|
46
|
+
return ((info & 0x02) == 0x02)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public static dirChanging(info: number)
|
|
50
|
+
{
|
|
51
|
+
return ((info & 0x04) == 0x04)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static dirForward(info: number)
|
|
55
|
+
{
|
|
56
|
+
return ((info & 0x01) == 0x01)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public static dirConfirm(info: number)
|
|
60
|
+
{
|
|
61
|
+
return ((info & 0x08) == 0x08)
|
|
62
|
+
}
|
|
43
63
|
}
|