Writing from PLC to Node Application
Phil-Davies-Github opened this issue · 3 comments
Phil-Davies-Github commented
Hi, thanks for the library.
As the node client application has no router attached to it I assume that only read and write from the node client is possible.
Is it possible to read the state of the node client and then write to from the PLC?
Also do you have the typescript def file you could share please?
Thanks Phil
jisotalo commented
If you want to write from PLC to Node.js, you need to run ads-server (https://github.com/jisotalo/ads-server).
This project has no typescript definitions yet. That ads-server project does though.
Phil-Davies-Github commented
Thanks. Here is some type defs I started to use, perhaps you could finalise and update the project?
interface AdsClient {
_events: {};
_eventsCount: number;
_maxListeners: number | undefined;
settings: {
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;
targetAmsNetId: string;
targetAdsPort: number;
};
_internals: {
debugLevel: number;
receiveDataBuffer: undefined;
socket: {};
nextInvokeId: number;
amsTcpCallback: {};
activeAdsRequests: {};
activeSubscriptions: {};
symbolVersionNotification: {};
systemManagerStatePoller: { id: number; timer: {} };
firstStateReadFaultTime: {};
socketConnectionLostHandler: {};
socketErrorHandler: {};
oldSubscriptions: {};
reconnectionTimer: { id: number; timer: null };
portRegisterTimeoutTimer: {};
};
metaData: {
deviceInfo: {};
systemManagerState: {};
plcRuntimeState: {};
uploadInfo: {};
symbolVersion: number;
allSymbolsCached: boolean;
symbols: {};
allDataTypesCached: boolean;
dataTypes: {};
routerState: {};
};
connection: AdsConnection;
Symbol: boolean[];
connect(): AdsConnection;
subscribe(): any;
}
interface AdsData {
value: number;
timeStamp: Date;
type: {
name: string;
type: string;
size: number;
offset: number;
adsDataType: number;
adsDataTypeStr: string;
comment: string;
attributes: {}[];
rpcMethods: [];
arrayData: [];
subItems: [];
};
symbol: {
indexGroup: number;
indexOffset: number;
size: number;
adsDataType: number;
adsDataTypeStr: string;
flags: number;
flagsStr: string[];
arrayDimension: number;
nameLength: number;
typeLength: number;
commentLength: number;
name: string;
type: string;
comment: string;
arrayData: [];
typeGuid: string;
attributes: [];
reserved: undefined;
};
}
interface AdsSubscribe {
target: string;
settings: {
transmissionMode: number;
cycleTime: number;
maximumDelay: number;
};
callback: Function[];
symbolInfo: {
indexGroup: number;
indexOffset: number;
size: number;
adsDataType: number;
adsDataTypeStr: string;
flags: number;
flagsStr: string[];
arrayDimension: number;
nameLength: number;
typeLength: number;
commentLength: number;
name: string;
type: string;
comment: string;
arrayData: [];
typeGuid: string;
attributes: [];
reserved: undefined;
};
notificationHandle: number;
lastValue: number;
internal: boolean;
unsubscribe: any;
dataParser: any;
}
jisotalo commented
Thanks!
I'm actually planning to rewrite the library to Typescript someday. Let's see..