@openrfid/readers 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 +23 -0
- package/dist/index.d.mts +103 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.js +149 -0
- package/dist/index.mjs +121 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RFID Software India Private Limited - https://rfidsoftwares.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
For RFID developer resources, documentation, hardware integrations, and enterprise software solutions, visit https://rfidsoftwares.com
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenRFID Simulator - The Open Source RFID Reader Simulator for Developers.
|
|
3
|
+
* Copyright (c) 2026 RFID Software India Private Limited - https://rfidsoftwares.com
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
* For RFID software, enterprise tools, and hardware drivers, visit https://rfidsoftwares.com
|
|
7
|
+
*/
|
|
8
|
+
interface AntennaProps {
|
|
9
|
+
id?: string;
|
|
10
|
+
readerId: string;
|
|
11
|
+
index: number;
|
|
12
|
+
gain?: number;
|
|
13
|
+
power?: number;
|
|
14
|
+
frequency?: number;
|
|
15
|
+
rssiOffset?: number;
|
|
16
|
+
readZone?: string;
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare class Antenna {
|
|
20
|
+
id: string;
|
|
21
|
+
readerId: string;
|
|
22
|
+
index: number;
|
|
23
|
+
gain: number;
|
|
24
|
+
power: number;
|
|
25
|
+
frequency: number;
|
|
26
|
+
rssiOffset: number;
|
|
27
|
+
readZone: string;
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
constructor(props: AntennaProps);
|
|
30
|
+
toJSON(): AntennaProps;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* OpenRFID Simulator - The Open Source RFID Reader Simulator for Developers.
|
|
35
|
+
* Copyright (c) 2026 RFID Software India Private Limited - https://rfidsoftwares.com
|
|
36
|
+
*
|
|
37
|
+
* Licensed under the MIT License.
|
|
38
|
+
* For RFID software, enterprise tools, and hardware drivers, visit https://rfidsoftwares.com
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
type ReaderStatus = 'OFFLINE' | 'ONLINE' | 'CONNECTING' | 'ERROR';
|
|
42
|
+
interface ReaderProps {
|
|
43
|
+
id?: string;
|
|
44
|
+
name: string;
|
|
45
|
+
vendor?: string;
|
|
46
|
+
model?: string;
|
|
47
|
+
ip?: string;
|
|
48
|
+
port?: number;
|
|
49
|
+
protocol?: string;
|
|
50
|
+
antennasCount?: number;
|
|
51
|
+
readRate?: number;
|
|
52
|
+
readMode?: 'continuous' | 'periodic';
|
|
53
|
+
readIntervalValue?: number;
|
|
54
|
+
readIntervalUnit?: 'seconds' | 'minutes' | 'hours';
|
|
55
|
+
epcFilterStart?: string;
|
|
56
|
+
epcFilterEnd?: string;
|
|
57
|
+
epcFilterPrefix?: string;
|
|
58
|
+
}
|
|
59
|
+
declare class VirtualReader {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
vendor: string;
|
|
63
|
+
model: string;
|
|
64
|
+
ip: string;
|
|
65
|
+
port: number;
|
|
66
|
+
protocol: string;
|
|
67
|
+
status: ReaderStatus;
|
|
68
|
+
antennas: Map<number, Antenna>;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
readRate: number;
|
|
71
|
+
readMode: 'continuous' | 'periodic';
|
|
72
|
+
readIntervalValue: number;
|
|
73
|
+
readIntervalUnit: 'seconds' | 'minutes' | 'hours';
|
|
74
|
+
epcFilterStart: string;
|
|
75
|
+
epcFilterEnd: string;
|
|
76
|
+
epcFilterPrefix: string;
|
|
77
|
+
constructor(props: ReaderProps);
|
|
78
|
+
setStatus(status: ReaderStatus): void;
|
|
79
|
+
getAntenna(index: number): Antenna | undefined;
|
|
80
|
+
getActiveAntennas(): Antenna[];
|
|
81
|
+
addAntenna(props: Partial<AntennaProps>): Antenna;
|
|
82
|
+
toJSON(): {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
vendor: string;
|
|
86
|
+
model: string;
|
|
87
|
+
ip: string;
|
|
88
|
+
port: number;
|
|
89
|
+
protocol: string;
|
|
90
|
+
status: ReaderStatus;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
antennas: AntennaProps[];
|
|
93
|
+
readRate: number;
|
|
94
|
+
readMode: "continuous" | "periodic";
|
|
95
|
+
readIntervalValue: number;
|
|
96
|
+
readIntervalUnit: "seconds" | "minutes" | "hours";
|
|
97
|
+
epcFilterStart: string;
|
|
98
|
+
epcFilterEnd: string;
|
|
99
|
+
epcFilterPrefix: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { Antenna, type AntennaProps, type ReaderProps, type ReaderStatus, VirtualReader };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenRFID Simulator - The Open Source RFID Reader Simulator for Developers.
|
|
3
|
+
* Copyright (c) 2026 RFID Software India Private Limited - https://rfidsoftwares.com
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
* For RFID software, enterprise tools, and hardware drivers, visit https://rfidsoftwares.com
|
|
7
|
+
*/
|
|
8
|
+
interface AntennaProps {
|
|
9
|
+
id?: string;
|
|
10
|
+
readerId: string;
|
|
11
|
+
index: number;
|
|
12
|
+
gain?: number;
|
|
13
|
+
power?: number;
|
|
14
|
+
frequency?: number;
|
|
15
|
+
rssiOffset?: number;
|
|
16
|
+
readZone?: string;
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare class Antenna {
|
|
20
|
+
id: string;
|
|
21
|
+
readerId: string;
|
|
22
|
+
index: number;
|
|
23
|
+
gain: number;
|
|
24
|
+
power: number;
|
|
25
|
+
frequency: number;
|
|
26
|
+
rssiOffset: number;
|
|
27
|
+
readZone: string;
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
constructor(props: AntennaProps);
|
|
30
|
+
toJSON(): AntennaProps;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* OpenRFID Simulator - The Open Source RFID Reader Simulator for Developers.
|
|
35
|
+
* Copyright (c) 2026 RFID Software India Private Limited - https://rfidsoftwares.com
|
|
36
|
+
*
|
|
37
|
+
* Licensed under the MIT License.
|
|
38
|
+
* For RFID software, enterprise tools, and hardware drivers, visit https://rfidsoftwares.com
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
type ReaderStatus = 'OFFLINE' | 'ONLINE' | 'CONNECTING' | 'ERROR';
|
|
42
|
+
interface ReaderProps {
|
|
43
|
+
id?: string;
|
|
44
|
+
name: string;
|
|
45
|
+
vendor?: string;
|
|
46
|
+
model?: string;
|
|
47
|
+
ip?: string;
|
|
48
|
+
port?: number;
|
|
49
|
+
protocol?: string;
|
|
50
|
+
antennasCount?: number;
|
|
51
|
+
readRate?: number;
|
|
52
|
+
readMode?: 'continuous' | 'periodic';
|
|
53
|
+
readIntervalValue?: number;
|
|
54
|
+
readIntervalUnit?: 'seconds' | 'minutes' | 'hours';
|
|
55
|
+
epcFilterStart?: string;
|
|
56
|
+
epcFilterEnd?: string;
|
|
57
|
+
epcFilterPrefix?: string;
|
|
58
|
+
}
|
|
59
|
+
declare class VirtualReader {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
vendor: string;
|
|
63
|
+
model: string;
|
|
64
|
+
ip: string;
|
|
65
|
+
port: number;
|
|
66
|
+
protocol: string;
|
|
67
|
+
status: ReaderStatus;
|
|
68
|
+
antennas: Map<number, Antenna>;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
readRate: number;
|
|
71
|
+
readMode: 'continuous' | 'periodic';
|
|
72
|
+
readIntervalValue: number;
|
|
73
|
+
readIntervalUnit: 'seconds' | 'minutes' | 'hours';
|
|
74
|
+
epcFilterStart: string;
|
|
75
|
+
epcFilterEnd: string;
|
|
76
|
+
epcFilterPrefix: string;
|
|
77
|
+
constructor(props: ReaderProps);
|
|
78
|
+
setStatus(status: ReaderStatus): void;
|
|
79
|
+
getAntenna(index: number): Antenna | undefined;
|
|
80
|
+
getActiveAntennas(): Antenna[];
|
|
81
|
+
addAntenna(props: Partial<AntennaProps>): Antenna;
|
|
82
|
+
toJSON(): {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
vendor: string;
|
|
86
|
+
model: string;
|
|
87
|
+
ip: string;
|
|
88
|
+
port: number;
|
|
89
|
+
protocol: string;
|
|
90
|
+
status: ReaderStatus;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
antennas: AntennaProps[];
|
|
93
|
+
readRate: number;
|
|
94
|
+
readMode: "continuous" | "periodic";
|
|
95
|
+
readIntervalValue: number;
|
|
96
|
+
readIntervalUnit: "seconds" | "minutes" | "hours";
|
|
97
|
+
epcFilterStart: string;
|
|
98
|
+
epcFilterEnd: string;
|
|
99
|
+
epcFilterPrefix: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { Antenna, type AntennaProps, type ReaderProps, type ReaderStatus, VirtualReader };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Antenna: () => Antenna,
|
|
24
|
+
VirtualReader: () => VirtualReader
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/antenna.ts
|
|
29
|
+
var Antenna = class {
|
|
30
|
+
id;
|
|
31
|
+
readerId;
|
|
32
|
+
index;
|
|
33
|
+
gain;
|
|
34
|
+
power;
|
|
35
|
+
frequency;
|
|
36
|
+
rssiOffset;
|
|
37
|
+
readZone;
|
|
38
|
+
enabled;
|
|
39
|
+
constructor(props) {
|
|
40
|
+
if (props.index < 1 || props.index > 16) {
|
|
41
|
+
throw new Error(`Antenna index must be between 1 and 16 (got ${props.index})`);
|
|
42
|
+
}
|
|
43
|
+
this.readerId = props.readerId;
|
|
44
|
+
this.index = props.index;
|
|
45
|
+
this.id = props.id || `${props.readerId}_ant_${props.index}`;
|
|
46
|
+
this.gain = props.gain ?? 6;
|
|
47
|
+
this.power = props.power ?? 30;
|
|
48
|
+
this.frequency = props.frequency ?? 915;
|
|
49
|
+
this.rssiOffset = props.rssiOffset ?? 0;
|
|
50
|
+
this.readZone = props.readZone || "DefaultZone";
|
|
51
|
+
this.enabled = props.enabled ?? true;
|
|
52
|
+
}
|
|
53
|
+
toJSON() {
|
|
54
|
+
return {
|
|
55
|
+
id: this.id,
|
|
56
|
+
readerId: this.readerId,
|
|
57
|
+
index: this.index,
|
|
58
|
+
gain: this.gain,
|
|
59
|
+
power: this.power,
|
|
60
|
+
frequency: this.frequency,
|
|
61
|
+
rssiOffset: this.rssiOffset,
|
|
62
|
+
readZone: this.readZone,
|
|
63
|
+
enabled: this.enabled
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/reader.ts
|
|
69
|
+
var VirtualReader = class {
|
|
70
|
+
id;
|
|
71
|
+
name;
|
|
72
|
+
vendor;
|
|
73
|
+
model;
|
|
74
|
+
ip;
|
|
75
|
+
port;
|
|
76
|
+
protocol;
|
|
77
|
+
status = "OFFLINE";
|
|
78
|
+
antennas = /* @__PURE__ */ new Map();
|
|
79
|
+
createdAt;
|
|
80
|
+
readRate;
|
|
81
|
+
readMode;
|
|
82
|
+
readIntervalValue;
|
|
83
|
+
readIntervalUnit;
|
|
84
|
+
epcFilterStart;
|
|
85
|
+
epcFilterEnd;
|
|
86
|
+
epcFilterPrefix;
|
|
87
|
+
constructor(props) {
|
|
88
|
+
this.name = props.name;
|
|
89
|
+
this.id = props.id || `reader_${Date.now()}_${Math.floor(Math.random() * 1e3)}`;
|
|
90
|
+
this.vendor = props.vendor || "Generic";
|
|
91
|
+
this.model = props.model || "Simulated Reader v1";
|
|
92
|
+
this.ip = props.ip || "127.0.0.1";
|
|
93
|
+
this.port = props.port || 5084;
|
|
94
|
+
this.protocol = props.protocol || "LLRP";
|
|
95
|
+
this.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
96
|
+
this.readRate = props.readRate ?? 0;
|
|
97
|
+
this.readMode = props.readMode || "continuous";
|
|
98
|
+
this.readIntervalValue = props.readIntervalValue ?? 1;
|
|
99
|
+
this.readIntervalUnit = props.readIntervalUnit || "seconds";
|
|
100
|
+
this.epcFilterStart = props.epcFilterStart || "";
|
|
101
|
+
this.epcFilterEnd = props.epcFilterEnd || "";
|
|
102
|
+
this.epcFilterPrefix = props.epcFilterPrefix || "";
|
|
103
|
+
const count = props.antennasCount || 4;
|
|
104
|
+
for (let i = 1; i <= count; i++) {
|
|
105
|
+
this.antennas.set(i, new Antenna({ readerId: this.id, index: i }));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
setStatus(status) {
|
|
109
|
+
this.status = status;
|
|
110
|
+
}
|
|
111
|
+
getAntenna(index) {
|
|
112
|
+
return this.antennas.get(index);
|
|
113
|
+
}
|
|
114
|
+
getActiveAntennas() {
|
|
115
|
+
return Array.from(this.antennas.values()).filter((ant) => ant.enabled);
|
|
116
|
+
}
|
|
117
|
+
addAntenna(props) {
|
|
118
|
+
const nextIndex = props.index || this.antennas.size + 1;
|
|
119
|
+
const antenna = new Antenna({ ...props, readerId: this.id, index: nextIndex });
|
|
120
|
+
this.antennas.set(nextIndex, antenna);
|
|
121
|
+
return antenna;
|
|
122
|
+
}
|
|
123
|
+
toJSON() {
|
|
124
|
+
return {
|
|
125
|
+
id: this.id,
|
|
126
|
+
name: this.name,
|
|
127
|
+
vendor: this.vendor,
|
|
128
|
+
model: this.model,
|
|
129
|
+
ip: this.ip,
|
|
130
|
+
port: this.port,
|
|
131
|
+
protocol: this.protocol,
|
|
132
|
+
status: this.status,
|
|
133
|
+
createdAt: this.createdAt,
|
|
134
|
+
antennas: Array.from(this.antennas.values()).map((a) => a.toJSON()),
|
|
135
|
+
readRate: this.readRate,
|
|
136
|
+
readMode: this.readMode,
|
|
137
|
+
readIntervalValue: this.readIntervalValue,
|
|
138
|
+
readIntervalUnit: this.readIntervalUnit,
|
|
139
|
+
epcFilterStart: this.epcFilterStart,
|
|
140
|
+
epcFilterEnd: this.epcFilterEnd,
|
|
141
|
+
epcFilterPrefix: this.epcFilterPrefix
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
146
|
+
0 && (module.exports = {
|
|
147
|
+
Antenna,
|
|
148
|
+
VirtualReader
|
|
149
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// src/antenna.ts
|
|
2
|
+
var Antenna = class {
|
|
3
|
+
id;
|
|
4
|
+
readerId;
|
|
5
|
+
index;
|
|
6
|
+
gain;
|
|
7
|
+
power;
|
|
8
|
+
frequency;
|
|
9
|
+
rssiOffset;
|
|
10
|
+
readZone;
|
|
11
|
+
enabled;
|
|
12
|
+
constructor(props) {
|
|
13
|
+
if (props.index < 1 || props.index > 16) {
|
|
14
|
+
throw new Error(`Antenna index must be between 1 and 16 (got ${props.index})`);
|
|
15
|
+
}
|
|
16
|
+
this.readerId = props.readerId;
|
|
17
|
+
this.index = props.index;
|
|
18
|
+
this.id = props.id || `${props.readerId}_ant_${props.index}`;
|
|
19
|
+
this.gain = props.gain ?? 6;
|
|
20
|
+
this.power = props.power ?? 30;
|
|
21
|
+
this.frequency = props.frequency ?? 915;
|
|
22
|
+
this.rssiOffset = props.rssiOffset ?? 0;
|
|
23
|
+
this.readZone = props.readZone || "DefaultZone";
|
|
24
|
+
this.enabled = props.enabled ?? true;
|
|
25
|
+
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
return {
|
|
28
|
+
id: this.id,
|
|
29
|
+
readerId: this.readerId,
|
|
30
|
+
index: this.index,
|
|
31
|
+
gain: this.gain,
|
|
32
|
+
power: this.power,
|
|
33
|
+
frequency: this.frequency,
|
|
34
|
+
rssiOffset: this.rssiOffset,
|
|
35
|
+
readZone: this.readZone,
|
|
36
|
+
enabled: this.enabled
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/reader.ts
|
|
42
|
+
var VirtualReader = class {
|
|
43
|
+
id;
|
|
44
|
+
name;
|
|
45
|
+
vendor;
|
|
46
|
+
model;
|
|
47
|
+
ip;
|
|
48
|
+
port;
|
|
49
|
+
protocol;
|
|
50
|
+
status = "OFFLINE";
|
|
51
|
+
antennas = /* @__PURE__ */ new Map();
|
|
52
|
+
createdAt;
|
|
53
|
+
readRate;
|
|
54
|
+
readMode;
|
|
55
|
+
readIntervalValue;
|
|
56
|
+
readIntervalUnit;
|
|
57
|
+
epcFilterStart;
|
|
58
|
+
epcFilterEnd;
|
|
59
|
+
epcFilterPrefix;
|
|
60
|
+
constructor(props) {
|
|
61
|
+
this.name = props.name;
|
|
62
|
+
this.id = props.id || `reader_${Date.now()}_${Math.floor(Math.random() * 1e3)}`;
|
|
63
|
+
this.vendor = props.vendor || "Generic";
|
|
64
|
+
this.model = props.model || "Simulated Reader v1";
|
|
65
|
+
this.ip = props.ip || "127.0.0.1";
|
|
66
|
+
this.port = props.port || 5084;
|
|
67
|
+
this.protocol = props.protocol || "LLRP";
|
|
68
|
+
this.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
69
|
+
this.readRate = props.readRate ?? 0;
|
|
70
|
+
this.readMode = props.readMode || "continuous";
|
|
71
|
+
this.readIntervalValue = props.readIntervalValue ?? 1;
|
|
72
|
+
this.readIntervalUnit = props.readIntervalUnit || "seconds";
|
|
73
|
+
this.epcFilterStart = props.epcFilterStart || "";
|
|
74
|
+
this.epcFilterEnd = props.epcFilterEnd || "";
|
|
75
|
+
this.epcFilterPrefix = props.epcFilterPrefix || "";
|
|
76
|
+
const count = props.antennasCount || 4;
|
|
77
|
+
for (let i = 1; i <= count; i++) {
|
|
78
|
+
this.antennas.set(i, new Antenna({ readerId: this.id, index: i }));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
setStatus(status) {
|
|
82
|
+
this.status = status;
|
|
83
|
+
}
|
|
84
|
+
getAntenna(index) {
|
|
85
|
+
return this.antennas.get(index);
|
|
86
|
+
}
|
|
87
|
+
getActiveAntennas() {
|
|
88
|
+
return Array.from(this.antennas.values()).filter((ant) => ant.enabled);
|
|
89
|
+
}
|
|
90
|
+
addAntenna(props) {
|
|
91
|
+
const nextIndex = props.index || this.antennas.size + 1;
|
|
92
|
+
const antenna = new Antenna({ ...props, readerId: this.id, index: nextIndex });
|
|
93
|
+
this.antennas.set(nextIndex, antenna);
|
|
94
|
+
return antenna;
|
|
95
|
+
}
|
|
96
|
+
toJSON() {
|
|
97
|
+
return {
|
|
98
|
+
id: this.id,
|
|
99
|
+
name: this.name,
|
|
100
|
+
vendor: this.vendor,
|
|
101
|
+
model: this.model,
|
|
102
|
+
ip: this.ip,
|
|
103
|
+
port: this.port,
|
|
104
|
+
protocol: this.protocol,
|
|
105
|
+
status: this.status,
|
|
106
|
+
createdAt: this.createdAt,
|
|
107
|
+
antennas: Array.from(this.antennas.values()).map((a) => a.toJSON()),
|
|
108
|
+
readRate: this.readRate,
|
|
109
|
+
readMode: this.readMode,
|
|
110
|
+
readIntervalValue: this.readIntervalValue,
|
|
111
|
+
readIntervalUnit: this.readIntervalUnit,
|
|
112
|
+
epcFilterStart: this.epcFilterStart,
|
|
113
|
+
epcFilterEnd: this.epcFilterEnd,
|
|
114
|
+
epcFilterPrefix: this.epcFilterPrefix
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
Antenna,
|
|
120
|
+
VirtualReader
|
|
121
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openrfid/readers",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Virtual Reader and Antenna Engine domain models with state machine support for OpenRFID Simulator.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@openrfid/core": "0.1.0",
|
|
20
|
+
"@openrfid/utils": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"tsup": "^8.0.2",
|
|
24
|
+
"typescript": "^5.4.5",
|
|
25
|
+
"vitest": "^1.5.0"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/rfidsoftwares/openrfid-simulator.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/rfidsoftwares/openrfid-simulator/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://rfidsoftwares.com",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
41
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
44
|
+
}
|
|
45
|
+
}
|