@emdzej/ediabasx-interface-base 0.1.0
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/LICENSE +131 -0
- package/README.md +35 -0
- package/dist/EdiabasInterface.d.ts +19 -0
- package/dist/EdiabasInterface.d.ts.map +1 -0
- package/dist/EdiabasInterface.js +18 -0
- package/dist/EdiabasInterface.js.map +1 -0
- package/dist/SimulationInterface.d.ts +37 -0
- package/dist/SimulationInterface.d.ts.map +1 -0
- package/dist/SimulationInterface.js +136 -0
- package/dist/SimulationInterface.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose. However, you may
|
|
17
|
+
only distribute the software according to [Distribution
|
|
18
|
+
License](#distribution-license) and make changes or new works
|
|
19
|
+
based on the software according to [Changes and New Works
|
|
20
|
+
License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license
|
|
25
|
+
to distribute copies of the software. Your license
|
|
26
|
+
to distribute covers distributing the software with
|
|
27
|
+
changes and new works permitted by [Changes and New Works
|
|
28
|
+
License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to
|
|
43
|
+
make changes and new works based on the software for any
|
|
44
|
+
permitted purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Noncommercial Purposes
|
|
53
|
+
|
|
54
|
+
Any noncommercial purpose is a permitted purpose.
|
|
55
|
+
|
|
56
|
+
## Personal Uses
|
|
57
|
+
|
|
58
|
+
Personal use for research, experiment, and testing for
|
|
59
|
+
the benefit of public knowledge, personal study, private
|
|
60
|
+
entertainment, hobby projects, amateur pursuits, or religious
|
|
61
|
+
observance, without any anticipated commercial application,
|
|
62
|
+
is use for a permitted purpose.
|
|
63
|
+
|
|
64
|
+
## Noncommercial Organizations
|
|
65
|
+
|
|
66
|
+
Use by any charitable organization, educational institution,
|
|
67
|
+
public research organization, public safety or health
|
|
68
|
+
organization, environmental protection organization,
|
|
69
|
+
or government institution is use for a permitted purpose
|
|
70
|
+
regardless of the source of funding or obligations resulting
|
|
71
|
+
from the funding.
|
|
72
|
+
|
|
73
|
+
## Fair Use
|
|
74
|
+
|
|
75
|
+
You may have "fair use" rights for the software under the
|
|
76
|
+
law. These terms do not limit them.
|
|
77
|
+
|
|
78
|
+
## No Other Rights
|
|
79
|
+
|
|
80
|
+
These terms do not allow you to sublicense or transfer any of
|
|
81
|
+
your licenses to anyone else, or prevent the licensor from
|
|
82
|
+
granting licenses to anyone else. These terms do not imply
|
|
83
|
+
any other licenses.
|
|
84
|
+
|
|
85
|
+
## Patent Defense
|
|
86
|
+
|
|
87
|
+
If you make any written claim that the software infringes or
|
|
88
|
+
contributes to infringement of any patent, your patent license
|
|
89
|
+
for the software granted under these terms ends immediately. If
|
|
90
|
+
your company makes such a claim, your patent license ends
|
|
91
|
+
immediately for work on behalf of your company.
|
|
92
|
+
|
|
93
|
+
## Violations
|
|
94
|
+
|
|
95
|
+
The first time you are notified in writing that you have
|
|
96
|
+
violated any of these terms, or done anything with the software
|
|
97
|
+
not covered by your licenses, your licenses can nonetheless
|
|
98
|
+
continue if you come into full compliance with these terms,
|
|
99
|
+
and take practical steps to correct past violations, within
|
|
100
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
101
|
+
end immediately.
|
|
102
|
+
|
|
103
|
+
## No Liability
|
|
104
|
+
|
|
105
|
+
***As far as the law allows, the software comes as is, without
|
|
106
|
+
any warranty or condition, and the licensor will not be liable
|
|
107
|
+
to you for any damages arising out of these terms or the use
|
|
108
|
+
or nature of the software, under any kind of legal claim.***
|
|
109
|
+
|
|
110
|
+
## Definitions
|
|
111
|
+
|
|
112
|
+
The **licensor** is the individual or entity offering these
|
|
113
|
+
terms, and the **software** is the software the licensor makes
|
|
114
|
+
available under these terms.
|
|
115
|
+
|
|
116
|
+
**You** refers to the individual or entity agreeing to these
|
|
117
|
+
terms.
|
|
118
|
+
|
|
119
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
120
|
+
or other kind of organization that you work for, plus all
|
|
121
|
+
organizations that have control over, are under the control of,
|
|
122
|
+
or are under common control with that organization. **Control**
|
|
123
|
+
means ownership of substantially all the assets of an entity,
|
|
124
|
+
or the power to direct its management and policies by vote,
|
|
125
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
126
|
+
|
|
127
|
+
**Your licenses** are all the licenses granted to you for the
|
|
128
|
+
software under these terms.
|
|
129
|
+
|
|
130
|
+
**Use** means anything you do with the software requiring one
|
|
131
|
+
of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @emdzej/ediabasx-interface-base
|
|
2
|
+
|
|
3
|
+
Abstract communication interface for the [EdiabasX](https://github.com/emdzej/ediabasx) BEST2 interpreter, plus an in-memory simulation transport useful for tests and offline development.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @emdzej/ediabasx-interface-base
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What it exports
|
|
12
|
+
|
|
13
|
+
- `EdiabasInterface` — abstract base class. Concrete transports (`@emdzej/ediabasx-interface-serial`, `@emdzej/ediabasx-interface-enet`, the JSON-RPC gateway client) extend this.
|
|
14
|
+
- `SimulationInterface` — in-memory transport. Register canned responses keyed by the request bytes; `send()` replays them on the matching request. Lets you run BEST2 jobs without hardware.
|
|
15
|
+
- `EdiabasTimeoutError` — thrown by `receive(timeoutMs)` when no data arrives in time.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { SimulationInterface } from "@emdzej/ediabasx-interface-base";
|
|
21
|
+
import { Ediabas } from "@emdzej/ediabasx-ediabas";
|
|
22
|
+
|
|
23
|
+
const sim = new SimulationInterface();
|
|
24
|
+
// Map request bytes → canned response (BMW DS2 telegram including header
|
|
25
|
+
// and checksum, just like the wire format).
|
|
26
|
+
sim.setResponse([0x12, 0x04, 0x00], [0x12, 0x2e, 0xa0, /* …fault data… */]);
|
|
27
|
+
|
|
28
|
+
const ediabas = new Ediabas({ ecuPath: "./ecu", transport: sim });
|
|
29
|
+
await ediabas.loadSgbd("MS430DS0.prg");
|
|
30
|
+
const sets = await ediabas.executeJob("FS_LESEN");
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
[PolyForm Noncommercial 1.0.0](../../LICENSE).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare abstract class EdiabasInterface {
|
|
2
|
+
protected connected: boolean;
|
|
3
|
+
abstract connect(): Promise<void>;
|
|
4
|
+
abstract disconnect(): Promise<void>;
|
|
5
|
+
abstract send(data: Uint8Array): Promise<void>;
|
|
6
|
+
abstract receive(timeoutMs?: number): Promise<Uint8Array>;
|
|
7
|
+
transmitFrequent(data: Uint8Array): Promise<void>;
|
|
8
|
+
receiveFrequent(): Promise<Uint8Array>;
|
|
9
|
+
stopFrequent(): Promise<void>;
|
|
10
|
+
abstract getPort(index: number): number | Promise<number>;
|
|
11
|
+
abstract setPort(index: number, value: number): void | Promise<void>;
|
|
12
|
+
abstract get ignitionVoltage(): number | Promise<number>;
|
|
13
|
+
abstract get loopTest(): number | Promise<number>;
|
|
14
|
+
abstract setProgramVoltage(value: number): void | Promise<void>;
|
|
15
|
+
abstract rawData(request: Uint8Array): Uint8Array | Promise<Uint8Array>;
|
|
16
|
+
abstract switchSiRelais(time: number): void | Promise<void>;
|
|
17
|
+
isConnected(): boolean;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=EdiabasInterface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdiabasInterface.d.ts","sourceRoot":"","sources":["../src/EdiabasInterface.ts"],"names":[],"mappings":"AAAA,8BAAsB,gBAAgB;IACpC,SAAS,CAAC,SAAS,UAAS;IAE5B,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IACjC,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IACpC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAC9C,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAEnD,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAGjD,eAAe,IAAI,OAAO,CAAC,UAAU,CAAC;IAGtC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAEnC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACzD,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACpE,QAAQ,KAAK,eAAe,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,QAAQ,KAAK,QAAQ,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC/D,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACvE,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D,WAAW,IAAI,OAAO;CAGvB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EdiabasInterface = void 0;
|
|
4
|
+
class EdiabasInterface {
|
|
5
|
+
connected = false;
|
|
6
|
+
async transmitFrequent(data) {
|
|
7
|
+
void data;
|
|
8
|
+
}
|
|
9
|
+
async receiveFrequent() {
|
|
10
|
+
return new Uint8Array(0);
|
|
11
|
+
}
|
|
12
|
+
async stopFrequent() { }
|
|
13
|
+
isConnected() {
|
|
14
|
+
return this.connected;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.EdiabasInterface = EdiabasInterface;
|
|
18
|
+
//# sourceMappingURL=EdiabasInterface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdiabasInterface.js","sourceRoot":"","sources":["../src/EdiabasInterface.ts"],"names":[],"mappings":";;;AAAA,MAAsB,gBAAgB;IAC1B,SAAS,GAAG,KAAK,CAAC;IAO5B,KAAK,CAAC,gBAAgB,CAAC,IAAgB;QACrC,KAAK,IAAI,CAAC;IACZ,CAAC;IACD,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,YAAY,KAAmB,CAAC;IAUtC,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AA3BD,4CA2BC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EdiabasInterface } from "./EdiabasInterface";
|
|
2
|
+
export declare class EdiabasTimeoutError extends Error {
|
|
3
|
+
constructor(message?: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class SimulationInterface extends EdiabasInterface {
|
|
6
|
+
private responses;
|
|
7
|
+
private responseQueue;
|
|
8
|
+
private frequentBuffer;
|
|
9
|
+
private pendingReceivers;
|
|
10
|
+
private ports;
|
|
11
|
+
private _ignitionVoltage;
|
|
12
|
+
private _loopTest;
|
|
13
|
+
private _programVoltage;
|
|
14
|
+
private _siRelaisTime;
|
|
15
|
+
connect(): Promise<void>;
|
|
16
|
+
disconnect(): Promise<void>;
|
|
17
|
+
send(data: Uint8Array): Promise<void>;
|
|
18
|
+
receive(timeoutMs?: number): Promise<Uint8Array>;
|
|
19
|
+
transmitFrequent(data: Uint8Array): Promise<void>;
|
|
20
|
+
receiveFrequent(): Promise<Uint8Array>;
|
|
21
|
+
stopFrequent(): Promise<void>;
|
|
22
|
+
getPort(index: number): number;
|
|
23
|
+
setPort(index: number, value: number): void;
|
|
24
|
+
get ignitionVoltage(): number;
|
|
25
|
+
get loopTest(): number;
|
|
26
|
+
setProgramVoltage(value: number): void;
|
|
27
|
+
rawData(request: Uint8Array): Uint8Array;
|
|
28
|
+
switchSiRelais(time: number): void;
|
|
29
|
+
setResponse(request: Uint8Array | number[], response: Uint8Array | number[]): void;
|
|
30
|
+
private enqueueResponse;
|
|
31
|
+
private flushPending;
|
|
32
|
+
private removePending;
|
|
33
|
+
private toBytes;
|
|
34
|
+
private toKey;
|
|
35
|
+
private assertConnected;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=SimulationInterface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimulationInterface.d.ts","sourceRoot":"","sources":["../src/SimulationInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,SAAsB;CAI1C;AAQD,qBAAa,mBAAoB,SAAQ,gBAAgB;IACvD,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,aAAa,CAAoB;IACzC,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,gBAAgB,CAAyB;IACjD,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,aAAa,CAAK;IAEpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrC,OAAO,CAAC,SAAS,SAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IAmB3C,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjD,eAAe,IAAI,OAAO,CAAC,UAAU,CAAC;IAKtC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI9B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI3C,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAItC,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;IAMxC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,EAAE,GAAG,IAAI;IAKlF,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,KAAK;IASb,OAAO,CAAC,eAAe;CAKxB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimulationInterface = exports.EdiabasTimeoutError = void 0;
|
|
4
|
+
const EdiabasInterface_1 = require("./EdiabasInterface");
|
|
5
|
+
class EdiabasTimeoutError extends Error {
|
|
6
|
+
constructor(message = "Receive timed out") {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "EdiabasTimeoutError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.EdiabasTimeoutError = EdiabasTimeoutError;
|
|
12
|
+
class SimulationInterface extends EdiabasInterface_1.EdiabasInterface {
|
|
13
|
+
responses = new Map();
|
|
14
|
+
responseQueue = [];
|
|
15
|
+
frequentBuffer = null;
|
|
16
|
+
pendingReceivers = [];
|
|
17
|
+
ports = new Map();
|
|
18
|
+
_ignitionVoltage = 0;
|
|
19
|
+
_loopTest = 0;
|
|
20
|
+
_programVoltage = 0;
|
|
21
|
+
_siRelaisTime = 0;
|
|
22
|
+
async connect() {
|
|
23
|
+
this.connected = true;
|
|
24
|
+
}
|
|
25
|
+
async disconnect() {
|
|
26
|
+
this.connected = false;
|
|
27
|
+
this.flushPending(new Error("Disconnected"));
|
|
28
|
+
}
|
|
29
|
+
async send(data) {
|
|
30
|
+
this.assertConnected();
|
|
31
|
+
const key = this.toKey(data);
|
|
32
|
+
const response = this.responses.get(key);
|
|
33
|
+
if (!response) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.enqueueResponse(response);
|
|
37
|
+
}
|
|
38
|
+
async receive(timeoutMs = 0) {
|
|
39
|
+
this.assertConnected();
|
|
40
|
+
const queued = this.responseQueue.shift();
|
|
41
|
+
if (queued) {
|
|
42
|
+
return queued;
|
|
43
|
+
}
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const pending = { resolve, reject };
|
|
46
|
+
if (timeoutMs > 0) {
|
|
47
|
+
pending.timer = setTimeout(() => {
|
|
48
|
+
this.removePending(pending);
|
|
49
|
+
reject(new EdiabasTimeoutError());
|
|
50
|
+
}, timeoutMs);
|
|
51
|
+
}
|
|
52
|
+
this.pendingReceivers.push(pending);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async transmitFrequent(data) {
|
|
56
|
+
this.assertConnected();
|
|
57
|
+
this.frequentBuffer = data;
|
|
58
|
+
}
|
|
59
|
+
async receiveFrequent() {
|
|
60
|
+
this.assertConnected();
|
|
61
|
+
return this.frequentBuffer ?? new Uint8Array(0);
|
|
62
|
+
}
|
|
63
|
+
async stopFrequent() {
|
|
64
|
+
this.frequentBuffer = null;
|
|
65
|
+
}
|
|
66
|
+
getPort(index) {
|
|
67
|
+
return this.ports.get(index) ?? 0;
|
|
68
|
+
}
|
|
69
|
+
setPort(index, value) {
|
|
70
|
+
this.ports.set(index, value);
|
|
71
|
+
}
|
|
72
|
+
get ignitionVoltage() {
|
|
73
|
+
return this._ignitionVoltage;
|
|
74
|
+
}
|
|
75
|
+
get loopTest() {
|
|
76
|
+
return this._loopTest;
|
|
77
|
+
}
|
|
78
|
+
setProgramVoltage(value) {
|
|
79
|
+
this._programVoltage = value;
|
|
80
|
+
}
|
|
81
|
+
rawData(request) {
|
|
82
|
+
this.assertConnected();
|
|
83
|
+
const key = this.toKey(request);
|
|
84
|
+
return this.responses.get(key) ?? new Uint8Array();
|
|
85
|
+
}
|
|
86
|
+
switchSiRelais(time) {
|
|
87
|
+
this._siRelaisTime = time;
|
|
88
|
+
}
|
|
89
|
+
setResponse(request, response) {
|
|
90
|
+
const key = this.toKey(request);
|
|
91
|
+
this.responses.set(key, this.toBytes(response));
|
|
92
|
+
}
|
|
93
|
+
enqueueResponse(response) {
|
|
94
|
+
const pending = this.pendingReceivers.shift();
|
|
95
|
+
if (!pending) {
|
|
96
|
+
this.responseQueue.push(response);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (pending.timer) {
|
|
100
|
+
clearTimeout(pending.timer);
|
|
101
|
+
}
|
|
102
|
+
pending.resolve(response);
|
|
103
|
+
}
|
|
104
|
+
flushPending(error) {
|
|
105
|
+
for (const pending of this.pendingReceivers.splice(0)) {
|
|
106
|
+
if (pending.timer) {
|
|
107
|
+
clearTimeout(pending.timer);
|
|
108
|
+
}
|
|
109
|
+
pending.reject(error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
removePending(pending) {
|
|
113
|
+
const index = this.pendingReceivers.indexOf(pending);
|
|
114
|
+
if (index >= 0) {
|
|
115
|
+
this.pendingReceivers.splice(index, 1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
toBytes(data) {
|
|
119
|
+
return data instanceof Uint8Array ? data : Uint8Array.from(data);
|
|
120
|
+
}
|
|
121
|
+
toKey(data) {
|
|
122
|
+
const bytes = this.toBytes(data);
|
|
123
|
+
let hex = "";
|
|
124
|
+
for (const value of bytes) {
|
|
125
|
+
hex += value.toString(16).padStart(2, "0");
|
|
126
|
+
}
|
|
127
|
+
return hex;
|
|
128
|
+
}
|
|
129
|
+
assertConnected() {
|
|
130
|
+
if (!this.connected) {
|
|
131
|
+
throw new Error("Not connected");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.SimulationInterface = SimulationInterface;
|
|
136
|
+
//# sourceMappingURL=SimulationInterface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimulationInterface.js","sourceRoot":"","sources":["../src/SimulationInterface.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAEtD,MAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAO,GAAG,mBAAmB;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC;AAQD,MAAa,mBAAoB,SAAQ,mCAAgB;IAC/C,SAAS,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC1C,aAAa,GAAiB,EAAE,CAAC;IACjC,cAAc,GAAsB,IAAI,CAAC;IACzC,gBAAgB,GAAsB,EAAE,CAAC;IACzC,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,gBAAgB,GAAG,CAAC,CAAC;IACrB,SAAS,GAAG,CAAC,CAAC;IACd,eAAe,GAAG,CAAC,CAAC;IACpB,aAAa,GAAG,CAAC,CAAC;IAE1B,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB;QACzB,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,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CAAC;CACF;AAhJD,kDAgJC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EdiabasTimeoutError = exports.SimulationInterface = exports.EdiabasInterface = void 0;
|
|
4
|
+
var EdiabasInterface_1 = require("./EdiabasInterface");
|
|
5
|
+
Object.defineProperty(exports, "EdiabasInterface", { enumerable: true, get: function () { return EdiabasInterface_1.EdiabasInterface; } });
|
|
6
|
+
var SimulationInterface_1 = require("./SimulationInterface");
|
|
7
|
+
Object.defineProperty(exports, "SimulationInterface", { enumerable: true, get: function () { return SimulationInterface_1.SimulationInterface; } });
|
|
8
|
+
Object.defineProperty(exports, "EdiabasTimeoutError", { enumerable: true, get: function () { return SimulationInterface_1.EdiabasTimeoutError; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,6DAAiF;AAAxE,0HAAA,mBAAmB,OAAA;AAAE,0HAAA,mBAAmB,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@emdzej/ediabasx-interface-base",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Abstract communication interface for EDIABAS BEST2 jobs, plus an in-memory simulation transport.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/emdzej/ediabasx.git"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"test": "vitest run --passWithNoTests",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"dev": "tsc -p tsconfig.json -w --preserveWatchOutput"
|
|
23
|
+
}
|
|
24
|
+
}
|