import EthernetIP from "../enip"; import { TagGroup } from "../tag-group"; import { ExtendedTagType, TagItem, TagList } from "../tag-list"; import { TaskEasy as Queue } from "task-easy"; import { Tag } from "../tag"; import { Types } from "../enip/cip/data-types"; export declare class Controller extends EthernetIP { worker_group: Queue; /** * * @param {boolean} [connectedMessaging=true] whether to use connected or unconnected messaging * @param {object} [opts] * @param {number} [opts.unconnectedSendTimeout=2000] */ constructor(connectedMessaging?: boolean, opts?: { unconnectedSendTimeout?: number; maxScanSize?: number; }); /** * Returns the Scan Rate of Subscription Tags * * @memberof Controller * @returns {number} ms */ get scan_rate(): number | undefined; /** * Sets the Subsciption Group Scan Rate * * @memberof Controller */ set scan_rate(rate: number | undefined); /** * Returns the Timeout Setpoint * * @memberof Controller * @returns {number} ms */ get timeout_sp(): any; /** * Sets the Timeout Setpoint * * @memberof Controller */ set timeout_sp(sp: any); /** * Returns the Rpi * * @memberof Controller * @returns {number} ms */ get rpi(): any; /** * Sets the Rpi * * @memberof Controller */ set rpi(sp: any); /** * Get the status of Scan Group * * @readonly * @memberof Controller */ get scanning(): any; /** * Returns the connected / unconnected messaging mode * * @memberof Controller * @returns {boolean} true, if connected messaging; false, if unconnected messaging */ get connectedMessaging(): any; /** * Sets the Mode to connected / unconnected messaging * * @memberof Controller */ set connectedMessaging(conn: any); /** * Gets the Controller Properties Object * * @readonly * @memberof Controller * @returns {object} */ get properties(): any; /** * Fetches the last timestamp retrieved from the controller * in human readable form * * @readonly * @memberof Controller */ get time(): string; /** * Initializes Session with Desired IP Address * and Returns a Promise with the Established Session ID * * @override * @param {string} IP_ADDR - IPv4 Address (can also accept a FQDN, provided port forwarding is configured correctly.) * @param {number} SLOT - Controller Slot Number (0 if CompactLogix) * @returns {Promise} * @memberof ENIP */ connect(IP_ADDR: any, SLOT?: number): Promise; /** * Disconnects the PLC instance gracefully by issuing forwardClose, UnregisterSession * and then destroying the socket * and Returns a Promise indicating a success or failure or the disconnection * * @memberof Controller * @returns {Promise} */ disconnect(): Promise; /** * Writes a forwardOpen Request and retrieves the connection ID used for * connected messages. * @memberof Controller * @returns {Promise} */ forwardOpen(): Promise; /** * Writes a forwardClose Request and retrieves the connection ID used for * connected messages. */ forwardClose(): Promise; /** * Writes Ethernet/IP Data to Socket as an Unconnected Message * or a Transport Class 1 Datagram * * NOTE: Cant Override Socket Write due to net.Socket.write * implementation. =[. Thus, I am spinning up a new Method to * handle it. Dont Use Enip.write, use this function instead. * * @override * @param {buffer} data - Message Router Packet Buffer * @param {boolean} [connected=false] * @param {number} [timeout=10] - Timeout (sec) * @param {function} [cb=null] - Callback to be Passed to Parent.Write() * @memberof ENIP */ write_cip(data: any, connected?: boolean, timeout?: number, cb?: null): void; /** * Reads Controller Identity Object * * @memberof Controller * @returns {Promise} */ readControllerProps(): Promise; /** * Reads the Controller Wall Clock Object * * @memberof Controller * @returns {Promise} */ readWallClock(): Promise; /** * Write to PLC Wall Clock * * @param {Date} [date=new Date()] * @memberof Controller * @returns {Promise} */ writeWallClock(date?: Date): Promise; /** * Reads Value of Tag and Type from Controller * * @param {Tag} tag - Tag Object to read * @param {number} [size=null] * @returns {Promise} * @memberof Controller */ readTag(tag: Tag, size?: null): Promise; /** * Writes value to Tag * * @param {Tag} tag - Tag Object to Write * @param {number|boolean|object|string} [value=null] - If Omitted, Tag.value will be used * @param {number} [size=0x01] * @returns {Promise} * @memberof Controller */ writeTag(tag: any, value?: null, size?: number): Promise; /** * Reads All Tags in the Passed Tag Group * * @param {TagGroup} group * @returns {Promise} * @memberof Controller */ readTagGroup(group: any): Promise; /** * Writes to Tag Group Tags * * @param {TAgGroup} group * @returns {Promise} * @memberof Controller */ writeTagGroup(group: any): Promise; /** * Adds Tag to Subscription Group * * @param {Tag} tag * @memberof Controller */ subscribe(tag: Tag): void; /** * Begin Scanning Subscription Group * * @memberof Controller */ scan(): Promise; /** * Pauses Scanning of Subscription Group * * @memberof Controller */ pauseScan(): void; /** * Iterates of each tag in Subscription Group * * @param {function} callback * @memberof Controller */ forEach(callback: any): void; getControllerTagList(tagList: TagList, program?: null): Promise; /** * Initialized Controller Specific Event Handlers * * @memberof Controller */ _initializeControllerEventHandlers(): void; /** * Remove Controller Specific Event Handlers * * @memberof Controller */ _removeControllerEventHandlers(): void; /** * Reads Value of Tag and Type from Controller * * @param {Tag} tag - Tag Object to Write * @param {number} [size=null] * @returns {Promise} * @memberof Controller */ _readTag(tag: Tag, size?: null): Promise; /** * Reads Data of Tag from Controller To Big To Fit In One Packet * * @param {Tag} tag - Tag Object to Write * @param {number} [size=null] * @returns {Promise} * @memberof Controller */ _readTagFragmented(tag: any, size?: null): Promise; /** * Writes value to Tag * * @param {Tag} tag - Tag Object to Write * @param {number|boolean|object|string} [value=null] - If Omitted, Tag.value will be used * @param {number} [size=0x01] * @returns {Promise} * @memberof Controller */ _writeTag(tag: any, value?: null, size?: number): Promise; /** * Writes value to Tag To Big To Fit In One Packet * * @param {Tag} tag - Tag Object to Write * @param {number|boolean|object|string} [value=null] - If Omitted, Tag.value will be used * @param {number} [size=0x01] * @returns {Promise} * @memberof Controller */ _writeTagFragmented(tag: any, value?: null, size?: number): Promise; /** * Reads All Tags in the Passed Tag Group * * @param {TagGroup} group * @returns {Promise} * @memberof Controller */ _readTagGroup(group: TagGroup): Promise; /** * Writes to Tag Group Tags * * @param {TagGroup} group * @returns {Promise} * @memberof Controller */ _writeTagGroup(group: any): Promise; /** * @typedef EncapsulationData * @type {Object} * @property {number} commandCode - Ecapsulation Command Code * @property {string} command - Encapsulation Command String Interpretation * @property {number} length - Length of Encapsulated Data * @property {number} session - Session ID * @property {number} statusCode - Status Code * @property {string} status - Status Code String Interpretation * @property {number} options - Options (Typically 0x00) * @property {Buffer} data - Encapsulated Data Buffer */ /*****************************************************************/ /** * @typedef MessageRouter * @type {Object} * @property {number} service - Reply Service Code * @property {number} generalStatusCode - General Status Code (Vol 1 - Appendix B) * @property {number} extendedStatusLength - Length of Extended Status (In 16-bit Words) * @property {Array} extendedStatus - Extended Status * @property {Buffer} data - Status Code */ /*****************************************************************/ /** * Handles SendRRData Event Emmitted by Parent and Routes * incoming Message * * @param {Array} srrd - Array of Common Packet Formatted Objects * @memberof Controller */ _handleSendRRDataReceived(srrd: any): void; _handleSendUnitDataReceived(sud: any): void; getStructureObject(tag: string): any; get tagList(): ({ type: ExtendedTagType; } & TagItem)[]; get templateList(): { [key: string]: import("../structure").Template | null; } | undefined; getTagArraySize(tag: any): Promise; newTag(tagname: any, program?: string | null, subscribe?: boolean, dataType?: Types, keepAlive?: number, arrayDims?: number, arraySize?: number): Tag; getTagByName(name: any): unknown; }