@zimo-elektronik/zcan 1.0.44 → 1.0.46

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.
@@ -17,12 +17,13 @@ import { MsgLocoGuiReq, MsgLocoGuiRsp } from './lanDataMsg';
17
17
  export default class LanDataGroup
18
18
  {
19
19
  public readonly onLocoGuiExtended = new Subject<MsgLocoGuiRsp>();
20
- public readonly onLocoGuiMXExtended = new Subject<LocoGuiMXExtended>();
20
+ // public readonly onOldLocoGuiExtended = new Subject<MsgOldLocoGuiRsp>();
21
21
  public readonly onDataValueExtended = new Subject<DataValueExtendedData>();
22
22
  public readonly onDataNameExtended = new Subject<DataNameExtendedData>();
23
23
  public readonly onLocoSpeedTabExtended = new Subject<LocoSpeedTabExtended>();
24
24
 
25
25
  private locoGuiQ: Query<MsgLocoGuiRsp> | undefined = undefined;
26
+ // private oldLocoGuiQ: Query<MsgOldLocoGuiRsp> | undefined = undefined;
26
27
 
27
28
  private mx10: MX10;
28
29
 
@@ -82,7 +83,7 @@ export default class LanDataGroup
82
83
  ]);
83
84
  }
84
85
 
85
- async locoGuiExtended(nid: number): Promise<MsgLocoGuiRsp | undefined>
86
+ async getLocoGuiExtended(nid: number): Promise<MsgLocoGuiRsp | undefined>
86
87
  {
87
88
  if(this.locoGuiQ !== undefined && !await this.locoGuiQ.lock()) {
88
89
  this.mx10.logInfo.next("mx10.locoGuiExtended: failed to acquire lock");
@@ -98,16 +99,73 @@ export default class LanDataGroup
98
99
  this.mx10.sendMsg(msg);
99
100
  });
100
101
  this.locoGuiQ.match = ((msg) => {
101
- this.mx10.logInfo.next('locoGuiExtended query rx: ' + JSON.stringify(msg));
102
+ // this.mx10.logInfo.next('locoGuiExtended query rx: ' + JSON.stringify(msg));
102
103
  return (msg.locoNid() === nid);
103
104
  })
104
105
  const rv = await this.locoGuiQ.run();
105
- this.mx10.logInfo.next("mx10.locoGuiExtended.rv: " + JSON.stringify(rv));
106
+ // this.mx10.logInfo.next("mx10.locoGuiExtended.rv: " + JSON.stringify(rv));
106
107
  this.locoGuiQ.unlock();
107
108
  this.locoGuiQ = undefined;
108
109
  return rv;
109
110
  }
110
111
 
112
+ async setLocoGuiExtended(loco: Train): Promise<MsgLocoGuiRsp | undefined>
113
+ {
114
+ if(this.locoGuiQ !== undefined && !await this.locoGuiQ.lock()) {
115
+ this.mx10.logInfo.next("mx10.locoGuiExtended: failed to acquire lock");
116
+ return undefined;
117
+ }
118
+ this.locoGuiQ = new Query(MsgLocoGuiReq.header(MsgMode.CMD, this.mx10.myNID), this.onLocoGuiExtended);
119
+ this.locoGuiQ.log = ((msg) => {
120
+ this.mx10.logInfo.next(msg);
121
+ });
122
+ this.locoGuiQ.tx = ((header) => {
123
+ const msg = new MsgLocoGuiRsp(header, loco.nid, loco.subId, 0, 0, loco.group, loco.name,
124
+ loco.image ? parseInt(loco.image) : 0, 0, parseInt(loco.tacho), 0, loco.speedFwd, loco.speedRev,
125
+ loco.speedRange, loco.driveType, parseInt(loco.era), loco.countryCode,
126
+ loco.functions.map(fun => fun.icon ? parseInt(fun.icon) : 0), loco.functions.map(fun => fun.mode)
127
+ );
128
+ // this.mx10.logInfo.next('locoGuiExtended query tx: ' + JSON.stringify(msg));
129
+ this.mx10.sendMsg(msg);
130
+ });
131
+ this.locoGuiQ.match = ((msg) => {
132
+ // this.mx10.logInfo.next('locoGuiExtended query rx: ' + JSON.stringify(msg));
133
+ return (msg.locoNid() === loco.nid);
134
+ })
135
+ this.locoGuiQ.subscribe(false);
136
+ const rv = await this.locoGuiQ.run(40);
137
+ // this.mx10.logInfo.next("mx10.locoGuiExtended.rv: " + JSON.stringify(rv));
138
+ this.locoGuiQ.unlock();
139
+ this.locoGuiQ = undefined;
140
+ return rv;
141
+ }
142
+
143
+ // async oldLocoGuiExtended(nid: number): Promise<MsgOldLocoGuiRsp | undefined>
144
+ // {
145
+ // if(this.oldLocoGuiQ !== undefined && !await this.oldLocoGuiQ.lock()) {
146
+ // this.mx10.logInfo.next("mx10.locoGuiExtended: failed to acquire lock");
147
+ // return undefined;
148
+ // }
149
+ // this.oldLocoGuiQ = new Query(MsgOldLocoGuiReq.header(MsgMode.REQ, this.mx10.mx10NID), this.onOldLocoGuiExtended);
150
+ // this.oldLocoGuiQ.log = ((msg) => {
151
+ // this.mx10.logInfo.next(msg);
152
+ // });
153
+ // this.oldLocoGuiQ.tx = ((header) => {
154
+ // const msg = new MsgOldLocoGuiReq(header, nid, 0);
155
+ // this.mx10.logInfo.next('locoGuiExtended query tx: ' + JSON.stringify(msg));
156
+ // this.mx10.sendMsg(msg);
157
+ // });
158
+ // this.oldLocoGuiQ.match = ((msg) => {
159
+ // this.mx10.logInfo.next('locoGuiExtended query rx: ' + JSON.stringify(msg));
160
+ // return (msg.locoNid() === nid);
161
+ // })
162
+ // const rv = await this.oldLocoGuiQ.run();
163
+ // this.mx10.logInfo.next("mx10.locoGuiExtended.rv: " + JSON.stringify(rv));
164
+ // this.oldLocoGuiQ.unlock();
165
+ // this.oldLocoGuiQ = undefined;
166
+ // return rv;
167
+ // }
168
+
111
169
  // locoGuiExtended(NID: number)
112
170
  // {
113
171
  // this.mx10.sendData(0x17, 0x27, [
@@ -117,14 +175,14 @@ export default class LanDataGroup
117
175
  // ], 0b00);
118
176
  // }
119
177
 
120
- locoGuiMXExtended(NID: number)
121
- {
122
- this.mx10.sendData(0x17,0x28, [
123
- {value: this.mx10.mx10NID, length: 2},
124
- {value: NID, length: 2},
125
- {value: 0, length: 2},
126
- ], 0b00);
127
- }
178
+ // locoGuiMXExtended(NID: number)
179
+ // {
180
+ // this.mx10.sendData(0x17,0x28, [
181
+ // {value: this.mx10.mx10NID, length: 2},
182
+ // {value: NID, length: 2},
183
+ // {value: 0, length: 2},
184
+ // ], 0b00);
185
+ // }
128
186
 
129
187
  locoSpeedTapExtended(NID: number)
130
188
  {
@@ -136,10 +194,10 @@ export default class LanDataGroup
136
194
  ], 0b00);
137
195
  }
138
196
 
139
- mxUpdateFnIcons(destructuredBuffer: ZcanDataArray)
140
- {
141
- this.mx10.sendData(0x17, 0x28, destructuredBuffer, 0b01);
142
- }
197
+ // mxUpdateFnIcons(destructuredBuffer: ZcanDataArray)
198
+ // {
199
+ // this.mx10.sendData(0x17, 0x28, destructuredBuffer, 0b01);
200
+ // }
143
201
 
144
202
  parse(size: number, command: number, mode: number, nid: number, buffer: Buffer)
145
203
  {
@@ -151,15 +209,17 @@ export default class LanDataGroup
151
209
  case 0x10:
152
210
  this.parseDataNameExtended(size, mode, nid, buffer);
153
211
  break;
154
- case 0x27:
155
- this.parseLocoGuiExtended(size, mode, nid, buffer);
156
- break;
212
+ // case 0x27:
213
+ // this.parseOldLocoGuiExtended(size, mode, nid, buffer);
214
+ // break;
157
215
  case 0x28:
158
- this.parseLocoGuiMXExtended(size, mode, nid, buffer);
216
+ this.parseLocoGuiExtended(size, mode, nid, buffer);
159
217
  break;
160
218
  case 0x19:
161
219
  this.parseLocoSpeedTabExtended(size, mode, nid, buffer);
162
220
  break;
221
+ default:
222
+ this.mx10.logInfo.next('lanDataGroup command ' + command + ' not parsed: ' + JSON.stringify(buffer));
163
223
  }
164
224
  }
165
225
 
@@ -213,91 +273,107 @@ export default class LanDataGroup
213
273
  }
214
274
 
215
275
  // 0x17.0x27
276
+ // private parseOldLocoGuiExtended(size: number, mode: number, nid: number, buffer: Buffer)
277
+ // {
278
+ // if(!this.onOldLocoGuiExtended.observed)
279
+ // return;
280
+
281
+ // const NID = buffer.readUInt16LE(0);
282
+ // const SubID = buffer.readUInt16LE(2);
283
+ // const vehicleGroup = buffer.readUInt16LE(4);
284
+ // const name = ExtendedASCII.byte2str(buffer.subarray(6, 32));
285
+ // const imageId = buffer.readUInt16LE(38);
286
+ // const tacho = buffer.readUInt16LE(40);
287
+ // const speedFwd = buffer.readUInt16LE(42);
288
+ // const speedRev = buffer.readUInt16LE(44);
289
+ // const speedRank = buffer.readUInt16LE(46);
290
+ // const driveType = buffer.readUInt16LE(48);
291
+ // const era = buffer.readUInt16LE(50);
292
+ // const countryCode = buffer.readUInt16LE(52);
293
+ // const functions: number[] = [];
294
+ // for (let i = 0; i < 32; i++) {
295
+ // const fun = buffer.readUInt16LE(54 + 2*i);
296
+ // functions.push(fun);
297
+ // }
298
+
299
+ // const msg = new MsgOldLocoGuiRsp(MsgLocoGuiRsp.header(mode, nid), NID, SubID, vehicleGroup, name, imageId, tacho, speedFwd, speedRev, speedRank,
300
+ // driveType, era, countryCode, functions);
301
+
302
+ // this.onOldLocoGuiExtended.next(msg);
303
+ // }
304
+
305
+ // 0x17.0x28
216
306
  private parseLocoGuiExtended(size: number, mode: number, nid: number, buffer: Buffer)
217
307
  {
218
308
  if(!this.onLocoGuiExtended.observed)
219
309
  return;
220
310
 
311
+ this.mx10.logInfo.next('parseLocoGuiExtended: ' + JSON.stringify(buffer));
312
+
221
313
  const NID = buffer.readUInt16LE(0);
222
314
  const SubID = buffer.readUInt16LE(2);
223
- const vehicleGroup = buffer.readUInt16LE(4);
224
- const name = ExtendedASCII.byte2str(buffer.subarray(6, 32));
225
- const imageId = buffer.readUInt16LE(38);
226
- const tacho = buffer.readUInt16LE(40);
227
- const speedFwd = buffer.readUInt16LE(42);
228
- const speedRev = buffer.readUInt16LE(44);
229
- const speedRange = buffer.readUInt16LE(46);
230
- const driveType = buffer.readUInt16LE(48);
231
- const era = buffer.readUInt16LE(50);
232
- const countryCode = buffer.readUInt16LE(52);
233
- const functions: number[] = [];
234
- for (let i = 0; i < 32; i++) {
235
- const fun = buffer.readUInt16LE(54 + 2*i);
236
- functions.push(fun);
315
+ const version = buffer.readUInt32LE(4);
316
+ const flags = buffer.readUInt16LE(8);
317
+ const group = buffer.readUInt16LE(10);
318
+ const name = ExtendedASCII.byte2str(buffer.subarray(12, 32));
319
+ const imageId = buffer.readUInt16LE(44);
320
+ const imageCrc = buffer.readUInt32LE(46);
321
+ const tachoId = buffer.readUInt16LE(50);
322
+ const tachoCrc = buffer.readUInt32LE(52);
323
+ const speedFwd = buffer.readUInt16LE(56);
324
+ const speedRev = buffer.readUInt16LE(58);
325
+ const speedRank = buffer.readUInt16LE(60);
326
+ const driveType = buffer.readUInt16LE(62);
327
+ const era = buffer.readUInt16LE(64);
328
+ const countryCode = buffer.readUInt16LE(66);
329
+ const funImg: number[] = [];
330
+ for (let i = 0; i < 64; i++) {
331
+ const fun = buffer.readUInt16LE(68 + 2*i);
332
+ funImg.push(fun);
333
+ }
334
+ const funMode: number[] = [];
335
+ for (let i = 0; i < 64; i++) {
336
+ const fun = buffer.readUInt16LE(132 + 2*i);
337
+ funMode.push(fun);
237
338
  }
238
339
 
239
- const msg = new MsgLocoGuiRsp(MsgLocoGuiRsp.header(mode, nid), NID, SubID, vehicleGroup, name, imageId, tacho, speedFwd, speedRev, speedRange,
240
- driveType, era, countryCode, functions);
340
+ const msg = new MsgLocoGuiRsp(MsgLocoGuiRsp.header(mode, nid), NID, SubID, version, flags, group, name,
341
+ imageId, imageCrc, tachoId, tachoCrc, speedFwd, speedRev, speedRank, driveType, era, countryCode,
342
+ funImg, funMode);
241
343
 
242
344
  this.onLocoGuiExtended.next(msg);
243
345
 
346
+ // const NID = buffer.readUInt16LE(0);
347
+ // const name = ExtendedASCII.byte2str(buffer.subarray(12, 38));
348
+ // const imageId = buffer.readUInt16LE(44);
349
+
350
+ // // TODO: after documentation
351
+ // // const SubID = buffer.readUInt16LE(2);
352
+ // // const vehicleGroup = buffer.readUInt16LE(4);
353
+
354
+ // // const name = ExtendedASCII.byte2str(buffer.subarray(6, 32));
355
+ // // const imageId = buffer.readUInt16LE(38);
356
+ // // const tacho = buffer.readUInt16LE(40);
357
+ // // const speedFwd = buffer.readUInt16LE(42);
358
+ // // const speedRev = buffer.readUInt16LE(44);
359
+ // // const speedRange = buffer.readUInt16LE(46);
360
+ // // const driveType = buffer.readUInt16LE(48);
361
+ // // const era = buffer.readUInt16LE(50);
362
+ // // const countryCode = buffer.readUInt16LE(52);
363
+
244
364
  // // reading 64 bytes of functions
245
365
  // const functions = Array<TrainFunction>();
246
- // for (let i = 0; i < 32; i++) {
247
- // const icon = buffer.readUInt16LE(54 + i * 2);
248
- // const iconString =
249
- // icon === 0 ? String(i).padStart(2, '0') : String(icon);
250
- // functions.push({
251
- // mode: FunctionMode.switch,
252
- // active: false,
253
- // icon: iconString.padStart(4, icon === 0 ? '07' : '0'),
366
+ // for (let i = 0; i < 64; i++) {
367
+ // const icon = buffer.readUInt16LE(68 + i * 2);
368
+ // const fxMode = buffer.readUInt16LE(196 + i * 2) as FunctionMode;
369
+ // const iconString = icon === 0 ? String(i).padStart(2, '0') : String(icon);
370
+ // functions.push({mode: fxMode, active: false, icon: iconString.padStart(4, icon === 0 ? '07' : '0'),
254
371
  // });
255
372
  // }
256
- // this.onLocoGuiExtended.next({nid: NID, subId: SubID, name: name, group: vehicleGroup,
257
- // image: imageId == 0 ? undefined : imageId.toString(), tacho: tacho.toString(),
258
- // speedFwd: speedFwd, speedRev: speedRev, speedRange: speedRange,
259
- // operatingMode: OperatingMode.UNKNOWN, driveType: driveType, era: this.parseEra(era),
260
- // countryCode: countryCode, functions,
261
- // });
262
- }
263
-
264
- // 0x17.0x28
265
- private parseLocoGuiMXExtended(size: number, mode: number, nid: number, buffer: Buffer)
266
- {
267
- if(!this.onLocoGuiMXExtended.observed)
268
- return;
269
-
270
- const NID = buffer.readUInt16LE(0);
271
- const name = ExtendedASCII.byte2str(buffer.subarray(12, 38));
272
- const imageId = buffer.readUInt16LE(44);
273
-
274
- // TODO: after documentation
275
- // const SubID = buffer.readUInt16LE(2);
276
- // const vehicleGroup = buffer.readUInt16LE(4);
277
-
278
- // const name = ExtendedASCII.byte2str(buffer.subarray(6, 32));
279
- // const imageId = buffer.readUInt16LE(38);
280
- // const tacho = buffer.readUInt16LE(40);
281
- // const speedFwd = buffer.readUInt16LE(42);
282
- // const speedRev = buffer.readUInt16LE(44);
283
- // const speedRange = buffer.readUInt16LE(46);
284
- // const driveType = buffer.readUInt16LE(48);
285
- // const era = buffer.readUInt16LE(50);
286
- // const countryCode = buffer.readUInt16LE(52);
287
-
288
- // reading 64 bytes of functions
289
- const functions = Array<TrainFunction>();
290
- for (let i = 0; i < 64; i++) {
291
- const icon = buffer.readUInt16LE(68 + i * 2);
292
- const fxMode = buffer.readUInt16LE(196 + i * 2) as FunctionMode;
293
- const iconString = icon === 0 ? String(i).padStart(2, '0') : String(icon);
294
- functions.push({mode: fxMode, active: false, icon: iconString.padStart(4, icon === 0 ? '07' : '0'),
295
- });
296
- }
297
373
 
298
- //TODO: implement rest
299
- this.onLocoGuiMXExtended.next({nid: NID, name: name, image: imageId == 0 ? undefined : imageId.toString(),
300
- destructuredBuffer: this.destructureBuffer(buffer), functions});
374
+ // //TODO: implement rest
375
+ // this.onLocoGuiMXExtended.next({nid: NID, name: name, image: imageId == 0 ? undefined : imageId.toString(),
376
+ // destructuredBuffer: this.destructureBuffer(buffer), functions});
301
377
  }
302
378
 
303
379
  // 0x17.0x19
@@ -3,10 +3,77 @@ import { Header, Message } from "../common/communication";
3
3
  import { TrainFunction } from "../docs_entrypoint";
4
4
 
5
5
 
6
+ // export class MsgOldLocoGuiReq extends Message
7
+ // {
8
+ // public static header(mode: MsgMode, nid: number): Header
9
+ // {return {group: 0x17, cmd: 0x27, mode: mode, nid: nid}}
10
+
11
+ // constructor(header: Header, locoNid: number, subNid: number)
12
+ // {
13
+ // super(header);
14
+ // super.push({value: locoNid, length: 2});
15
+ // super.push({value: subNid, length: 2});
16
+ // }
17
+ // locoNid(): number {return (this.data[0].value as number)}
18
+ // subNid(): number {return (this.data[1].value as number)}
19
+ // }
20
+
21
+ // export class MsgOldLocoGuiRsp extends Message
22
+ // {
23
+ // public static header(mode: MsgMode, nid: number): Header
24
+ // {return {group: 0x17, cmd: 0x27, mode: mode, nid: nid}}
25
+
26
+ // constructor(header: Header, locoNid: number, subNid: number, group: number, name: string, imageId: number,
27
+ // tacho: number, speedFwd: number, speedRev: number, speedRange: number, driveType: number, era: number,
28
+ // country: number, functions: number[])
29
+ // {
30
+ // super(header);
31
+ // super.push({value: locoNid, length: 2});
32
+ // super.push({value: subNid, length: 2});
33
+ // super.push({value: group, length: 2});
34
+ // super.push({value: name, length: 32});
35
+ // super.push({value: imageId, length: 2});
36
+ // super.push({value: tacho, length: 2});
37
+ // super.push({value: speedFwd, length: 2});
38
+ // super.push({value: speedRev, length: 2});
39
+ // super.push({value: speedRange, length: 2});
40
+ // super.push({value: driveType, length: 2});
41
+ // super.push({value: era, length: 2});
42
+ // super.push({value: country, length: 2});
43
+ // functions.forEach(funk => {
44
+ // super.push({value: funk, length: 2});
45
+ // });
46
+ // }
47
+ // locoNid(): number {return (this.data[0].value as number)}
48
+ // subNid(): number {return (this.data[1].value as number)}
49
+ // group(): number {return (this.data[2].value as number)}
50
+ // name(): string {return (this.data[3].value as string)}
51
+ // imageId(): number {return (this.data[4].value as number)}
52
+ // tacho(): number {return (this.data[5].value as number)}
53
+ // speedFwd(): number {return (this.data[6].value as number)}
54
+ // speedRev(): number {return (this.data[7].value as number)}
55
+ // speedRange(): number {return (this.data[8].value as number)}
56
+ // driveType(): number {return (this.data[9].value as number)}
57
+ // era(): number {return (this.data[10].value as number)}
58
+ // country(): number {return (this.data[11].value as number)}
59
+ // functions(): Array<TrainFunction>
60
+ // {
61
+ // const rv = Array<TrainFunction>();
62
+ // for (let i = 12; i < this.data.length; i++) {
63
+ // const icon = (this.data[i].value as number);
64
+ // const iconString = icon === 0 ? String(i).padStart(2, '0') : String(icon);
65
+ // rv.push({mode: FunctionMode.switch, active: false,
66
+ // icon: iconString.padStart(4, icon === 0 ? '07' : '0'),
67
+ // });
68
+ // }
69
+ // return rv;
70
+ // }
71
+ // }
72
+
6
73
  export class MsgLocoGuiReq extends Message
7
74
  {
8
75
  public static header(mode: MsgMode, nid: number): Header
9
- {return {group: 0x17, cmd: 0x27, mode: mode, nid: nid}}
76
+ {return {group: 0x17, cmd: 0x28, mode: mode, nid: nid}}
10
77
 
11
78
  constructor(header: Header, locoNid: number, subNid: number)
12
79
  {
@@ -21,51 +88,74 @@ export class MsgLocoGuiReq extends Message
21
88
  export class MsgLocoGuiRsp extends Message
22
89
  {
23
90
  public static header(mode: MsgMode, nid: number): Header
24
- {return {group: 0x17, cmd: 0x27, mode: mode, nid: nid}}
91
+ {return {group: 0x17, cmd: 0x28, mode: mode, nid: nid}}
25
92
 
26
- constructor(header: Header, locoNid: number, subNid: number, group: number, name: string, imageId: number,
27
- tacho: number, speedFwd: number, speedRev: number, speedRange: number, driveType: number, era: number,
28
- country: number, functions: number[])
93
+ constructor(header: Header, locoNid: number, subNid: number, version: number, flags: number, group: number,
94
+ name: string, imageId: number, imageCrc: number, tachoId: number, tachoCrc: number,
95
+ speedFwd: number, speedRev: number, speedRnk: number, driveType: number, era: number,
96
+ country: number, funImgs: number[], funModes: number[])
29
97
  {
30
98
  super(header);
31
99
  super.push({value: locoNid, length: 2});
32
100
  super.push({value: subNid, length: 2});
101
+ super.push({value: version, length: 4});
102
+ super.push({value: flags, length: 2});
33
103
  super.push({value: group, length: 2});
34
104
  super.push({value: name, length: 32});
35
105
  super.push({value: imageId, length: 2});
36
- super.push({value: tacho, length: 2});
106
+ super.push({value: imageCrc, length: 4});
107
+ super.push({value: tachoId, length: 2});
108
+ super.push({value: tachoCrc, length: 4});
37
109
  super.push({value: speedFwd, length: 2});
38
110
  super.push({value: speedRev, length: 2});
39
- super.push({value: speedRange, length: 2});
111
+ super.push({value: speedRnk, length: 2});
40
112
  super.push({value: driveType, length: 2});
41
113
  super.push({value: era, length: 2});
42
114
  super.push({value: country, length: 2});
43
- functions.forEach(funk => {
115
+ funImgs.forEach(funk => {
116
+ super.push({value: funk, length: 2});
117
+ });
118
+ funModes.forEach(funk => {
44
119
  super.push({value: funk, length: 2});
45
120
  });
46
121
  }
47
122
  locoNid(): number {return (this.data[0].value as number)}
48
123
  subNid(): number {return (this.data[1].value as number)}
49
- group(): number {return (this.data[2].value as number)}
50
- name(): string {return (this.data[3].value as string)}
51
- imageId(): number {return (this.data[4].value as number)}
52
- tacho(): number {return (this.data[5].value as number)}
53
- speedFwd(): number {return (this.data[6].value as number)}
54
- speedRev(): number {return (this.data[7].value as number)}
55
- speedRange(): number {return (this.data[8].value as number)}
56
- driveType(): number {return (this.data[9].value as number)}
57
- era(): number {return (this.data[10].value as number)}
58
- country(): number {return (this.data[11].value as number)}
124
+ group(): number {return (this.data[4].value as number)}
125
+ name(): string {return (this.data[5].value as string)}
126
+ imageId(): number {return (this.data[6].value as number)}
127
+ tacho(): number {return (this.data[8].value as number)}
128
+ speedFwd(): number {return (this.data[10].value as number)}
129
+ speedRev(): number {return (this.data[11].value as number)}
130
+ speedRnk(): number {return (this.data[12].value as number)}
131
+ driveType(): number {return (this.data[13].value as number)}
132
+ era(): number {return (this.data[14].value as number)}
133
+ country(): number {return (this.data[15].value as number)}
59
134
  functions(): Array<TrainFunction>
60
135
  {
61
136
  const rv = Array<TrainFunction>();
62
- for (let i = 12; i < this.data.length; i++) {
137
+ for (let i = 16; i < 80; i++) {
63
138
  const icon = (this.data[i].value as number);
64
139
  const iconString = icon === 0 ? String(i).padStart(2, '0') : String(icon);
65
140
  rv.push({mode: FunctionMode.switch, active: false,
66
141
  icon: iconString.padStart(4, icon === 0 ? '07' : '0'),
67
142
  });
68
143
  }
144
+ for (let i = 80; i < 144; i++) {
145
+ rv[i-80].mode = this.data[i].value as number;
146
+ }
69
147
  return rv;
70
148
  }
149
+ // funModes(): Array<TrainFunction>
150
+ // {
151
+ // const rv = Array<TrainFunction>();
152
+ // for (let i = 12; i < this.data.length; i++) {
153
+ // const icon = (this.data[i].value as number);
154
+ // const iconString = icon === 0 ? String(i).padStart(2, '0') : String(icon);
155
+ // rv.push({mode: FunctionMode.switch, active: false,
156
+ // icon: iconString.padStart(4, icon === 0 ? '07' : '0'),
157
+ // });
158
+ // }
159
+ // return rv;
160
+ // }
71
161
  }
@@ -62,7 +62,7 @@ export default class InfoGroup
62
62
  this.parseModuleInfo(size, mode, nid, buffer);
63
63
  break;
64
64
  default:
65
- this.mx10.logInfo.next('command not parsed: ' + command.toString());
65
+ this.mx10.logInfo.next('infoGroup command ' + command + ' not parsed: ' + JSON.stringify(buffer));
66
66
  }
67
67
  }
68
68
 
@@ -77,8 +77,7 @@ export default class LanNetworkGroup
77
77
  this.parseUnknownCommand(size, mode, nid, buffer);
78
78
  break;
79
79
  default:
80
- // eslint-disable-next-line no-console
81
- console.warn('command not parsed: ' + command.toString());
80
+ this.mx10.logInfo.next('lanNetworkGroup command ' + command + ' not parsed: ' + JSON.stringify(buffer));
82
81
  }
83
82
  }
84
83
 
@@ -86,7 +86,7 @@ export default class NetworkGroup
86
86
  // TODO reconnect when uuid has changed
87
87
  // const uuid = buffer.readUInt32LE(0);
88
88
 
89
- this.mx10.reconnectLogic();
89
+ // this.mx10.reconnectLogic();
90
90
 
91
91
  if (this.pingTimeout)
92
92
  clearTimeout(this.pingTimeout);