Last active
September 8, 2023 13:47
-
-
Save crishoj/0f225b1dbcaede66d60b3c033fd5a31e to your computer and use it in GitHub Desktop.
`index.d.ts` for `ads-client`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type definitions for ads-client 1.14.2 | |
// Project: https://github.com/jisotalo/ads-client | |
import ADS = require("ads-client/src/ads-client-ads.js"); | |
import EventEmitter = require("events"); | |
interface Settings { | |
targetAmsNetId: string; | |
targetAdsPort: number; | |
objectifyEnumerations?: boolean; | |
convertDatesToJavascript?: boolean; | |
readAndCacheSymbols?: boolean; | |
readAndCacheDataTypes?: boolean; | |
disableSymbolVersionMonitoring?: boolean; | |
routerTcpPort?: number; | |
routerAddress?: string; | |
localAddress?: string; | |
localTcpPort?: number; | |
localAmsNetId?: string; | |
localAdsPort?: number; | |
timeoutDelay?: number; | |
hideConsoleWarnings?: boolean; | |
autoReconnect?: boolean; | |
reconnectInterval?: number; | |
checkStateInterval?: number; | |
connectionDownDelay?: number; | |
allowHalfOpen?: boolean; | |
disableBigInt?: boolean; | |
bareClient?: boolean; | |
} | |
interface Metadata { | |
deviceInfo: object; | |
systemManagerState: object; | |
plcRuntimeState: object; | |
uploadInfo: object; | |
symbolVersion: number; | |
allSymbolsCached: boolean; | |
symbols: object; | |
allDataTypesCached: boolean; | |
dataTypes: object; | |
routerState: object; | |
} | |
interface Connection { | |
connected: boolean; | |
isLocal: boolean; | |
localAmsNetId: string; | |
localAdsPort: number; | |
targetAmsNetId: string; | |
targetAdsPort: number; | |
} | |
interface SymbolData { | |
symbol: object; | |
value: boolean | number | string | object; | |
type: Datatype; | |
} | |
interface Datatype { | |
version: number; | |
hashValue: number; | |
typeHashValue: number; | |
size: number; | |
offset: number; | |
adsDataType: number; | |
adsDataTypeStr: string; | |
flags: number[], | |
flagsStr: string[]; | |
nameLength: string; | |
typeLength: number; | |
commentLength: number; | |
arrayDimension: number; | |
subItemCount: number; | |
name: string; | |
type: string; | |
comment: string; | |
arrayData: unknown[]; | |
subItems: unknown[]; | |
attributes: unknown[]; | |
rpcMethods: unknown[]; | |
} | |
interface Subscription { | |
target: string; | |
settings: SubscriptionSettings; | |
callback: (SubscriptionCallbackData, Subscription) => void; | |
symbolInfo: object; | |
notificationHandle: number; | |
lastValue: boolean | number | string | object; | |
internal: boolean; | |
unsubscribe(): Promise<void>; | |
dataParser(unknown): Promise<SymbolData>; | |
} | |
interface SubscriptionSettings { | |
transmissionMode: number; | |
maximumDelay: number; | |
cycleTime: number; | |
targetAdsPort?: number; | |
internal: boolean; | |
} | |
interface SubscriptionCallbackData { | |
value: boolean | number | string | object; | |
timeStamp: Date; | |
type: Datatype; | |
} | |
interface IndexGroupAndOffset { | |
indexGroup: number; | |
indexOffset: number; | |
} | |
interface MultiResult { | |
error: boolean; | |
errorCode: number; | |
errorStr: string; | |
} | |
interface ReadRawMultiParam { | |
indexGroup: number; | |
indexOffset: number; | |
size: number; | |
} | |
interface ReadRawMultiResult { | |
success: boolean; | |
errorInfo: MultiErrorInfo; | |
target: IndexGroupAndOffset; | |
data: Buffer; | |
} | |
interface WriteRawMultiParam { | |
indexGroup: number; | |
indexOffset: number; | |
data: Buffer; | |
} | |
interface WriteRawMultiResult { | |
success: boolean; | |
errorInfo: MultiErrorInfo; | |
target: IndexGroupAndOffset; | |
} | |
interface CreateVariableHandleResult { | |
handle: number; | |
size: number; | |
type: string; | |
} | |
interface CreateVariableHandleMultiResult { | |
success: boolean; | |
errorInfo: MultiErrorInfo; | |
target: string; | |
handle: number; | |
} | |
interface DeleteVariableHandleMultiResult { | |
success: boolean; | |
errorInfo: MultiErrorInfo; | |
handle: number; | |
} | |
interface RpcMethodResult { | |
returnValue: object; | |
outputs: object; | |
} | |
export class Client extends EventEmitter { | |
static defaultSettings(): Settings; | |
constructor(settings: Settings); | |
settings: Settings; | |
readonly metaData: Metadata; | |
readonly connection: Connection; | |
setDebugging(level: number): void; | |
connect(): Promise<any>; | |
disconnect(forceDisconnect?: boolean): Promise<any>; | |
reconnect(forceDisconnect?: boolean): Promise<any>; | |
readDeviceInfo(): Promise<object>; | |
readSystemManagerState(): Promise<object>; | |
readPlcRuntimeState(adsPort?: number): Promise<object>; | |
readSymbolVersion(): Promise<number>; | |
readUploadInfo(): Promise<object>; | |
readAndCacheSymbols(): Promise<object>; | |
readAndCacheDataTypes(): Promise<object>; | |
getDataType(dataTypeName: string): Promise<Datatype>; | |
getSymbolInfo(variableName: string): Promise<object>; | |
readSymbol(variableName: string): Promise<SymbolData>; | |
writeSymbol(variableName: string, value: object, autoFill?: boolean): Promise<SymbolData>; | |
subscribe(variableName: string, callback: (data: SubscriptionCallbackData, sub: object) => any, cycleTime?: number, onChange?: boolean, initialDelay?: number): Promise<object>; | |
subscribeRaw(indexGroup: number, indexOffset: number, size: number, callback: (data: SubscriptionCallbackData, sub: object) => any, cycleTime?: number, onChange?: boolean, initialDelay?: number): Promise<object>; | |
unsubscribe(notificationHandle: number): Promise<object>; | |
unsubscribeAll(): Promise<object>; | |
readRawByHandle(handle: object | number, size?: number): Promise<Buffer>; | |
readRawByName(variableName: string): Promise<Buffer>; | |
readRawBySymbol(symbol: object): Promise<Buffer>; | |
readRaw(indexGroup: number, indexOffset: number, size: number, targetAdsPort?: number): Promise<Buffer>; | |
readRawMulti(targetArray: ReadRawMultiParam[], targetAdsPort?: number): Promise<ReadRawMultiResult[]>; | |
readWriteRaw(indexGroup: number, indexOffset: number, readLength: number, dataBuffer: Buffer, targetAdsPort?: number): Promise<Buffer>; | |
writeRawByHandle(handle: number, dataBuffer: Buffer): Promise<object>; | |
writeRawBySymbol(symbol: object, dataBuffer: Buffer): Promise<object>; | |
writeRaw(indexGroup: number, indexOffset: number, dataBuffer: Buffer, targetAdsPort?: number): Promise<object>; | |
writeRawMulti(targetArray: WriteRawMultiParam[], targetAdsPort?: number): Promise<WriteRawMultiResult[]>; | |
createVariableHandle(variableName: string): Promise<CreateVariableHandleResult>; | |
createVariableHandleMulti(targetArray: Array<string>): Promise<CreateVariableHandleMultiResult[]>; | |
deleteVariableHandle(handle: number): Promise<object>; | |
deleteVariableHandleMulti(handleArray: Array<string>): Promise<DeleteVariableHandleMultiResult[]>; | |
convertFromRaw(rawData: Buffer, dataTypeName: string): Promise<object>; | |
convertToRaw(value: object, dataTypeName: string, autoFill?: boolean): Promise<object>; | |
getEmptyPlcType(dataTypeName: string): Promise<object>; | |
writeControl(adsPort: number, adsState: number, deviceState?: number, data?: Buffer): Promise<object>; | |
startPlc(adsPort?: number): Promise<object>; | |
stopPlc(adsPort?: number): Promise<object>; | |
restartPlc(adsPort?: number): Promise<object>; | |
setSystemManagerToRun(): Promise<object>; | |
setSystemManagerToConfig(): Promise<object>; | |
restartSystemManager(): Promise<object>; | |
invokeRpcMethod(variableName: string, methodName: string, parameters?: object): Promise<RpcMethodResult>; | |
sendAdsCommand(adsCommand: number, adsData: Buffer, targetAdsPort?: number, targetAmsNetId?: string): Promise<object>; | |
byteArrayToAmsNetIdStr(byteArray: Buffer | any[]): string; | |
amsNetIdStrToByteArray(str: any): any[]; | |
} | |
export {ADS}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment