-
-
Notifications
You must be signed in to change notification settings - Fork 240
/
ServerTCP.d.ts
64 lines (59 loc) · 2.84 KB
/
ServerTCP.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import * as events from 'events';
import net from "net";
export class ServerTCP extends events.EventEmitter {
socks: Map<net.Socket, 0>
constructor(vector: IServiceVector, options: IServerOptions);
close(cb: FCallback): void;
}
export interface IServiceVector {
getCoil?:
((addr: number, unitID: number, cb: FCallbackVal<boolean>) => void) |
((addr: number, unitID: number) => Promise<boolean>) |
((addr: number, unitID: number) => boolean);
getDiscreteInput?:
((addr: number, unitID: number, cb: FCallbackVal<boolean>) => void) |
((addr: number, unitID: number) => Promise<boolean>) |
((addr: number, unitID: number) => boolean);
getInputRegister?:
((addr: number, unitID: number, cb: FCallbackVal<number>) => void) |
((addr: number, unitID: number) => Promise<number>) |
((addr: number, unitID: number) => number);
getHoldingRegister?:
((addr: number, unitID: number, cb: FCallbackVal<number>) => void) |
((addr: number, unitID: number) => Promise<number>) |
((addr: number, unitID: number) => number);
getMultipleInputRegisters?:
((addr: number, length: number, unitID: number, cb: FCallbackVal<number[]>) => void) |
((addr: number, length: number, unitID: number) => Promise<number[]>) |
((addr: number, length: number, unitID: number) => number[]);
getMultipleHoldingRegisters?:
((addr: number, length: number, unitID: number, cb: FCallbackVal<number[]>) => void) |
((addr: number, length: number, unitID: number) => Promise<number[]>) |
((addr: number, length: number, unitID: number) => number[]);
setCoil?:
((addr: number, value: boolean, unitID: number, cb: FCallback) => void) |
((addr: number, value: boolean, unitID: number) => Promise<void>) |
((addr: number, value: boolean, unitID: number) => void)
setRegister?:
((addr: number, value: number, unitID: number, cb: FCallback) => void) |
((addr: number, value: number, unitID: number) => Promise<void>) |
((addr: number, value: number, unitID: number) => void)
setRegisterArray?:
((addr: number, value: number[], unitID: number, cb: FCallback) => void) |
((addr: number, value: number[], unitID: number) => Promise<void>) |
((addr: number, value: number[], unitID: number) => void);
}
interface IServerOptions {
host?: string,
port?: number,
debug?: boolean,
unitID?: number,
}
export declare interface ServerTCP {
on(event: 'socketError', listener: FCallback): this;
on(event: 'serverError', listener: FCallback): this;
on(event: 'error', listener: FCallback): this;
on(event: 'initialized', listener: FCallback): this;
}
export type FCallbackVal<T> = (err: Error | null, value: T) => void;
export type FCallback = (err: Error | null) => void;