UNPKG

node-fxplc

Version:

Node.js library for low-level Mitsubishi FX (MELSEC) PLC framed protocol communication

38 lines (37 loc) 1.69 kB
"use strict"; // errors.js - definizione errori custom protocollo FXPLC // errors.js - custom error hierarchy for FX PLC protocol Object.defineProperty(exports, "__esModule", { value: true }); exports.NotConnectedError = exports.ResponseMalformedError = exports.NoResponseError = exports.NotSupportedCommandError = exports.FXPLCError = void 0; /** Base class for all FX PLC related errors */ class FXPLCError extends Error { constructor(message) { super(message); this.name = 'FXPLCError'; } } exports.FXPLCError = FXPLCError; /** PLC responded with NAK / unsupported command */ class NotSupportedCommandError extends FXPLCError { constructor(msg = 'Command not supported') { super(msg); this.name = 'NotSupportedCommandError'; } } exports.NotSupportedCommandError = NotSupportedCommandError; /** No data received within expected timeframe */ class NoResponseError extends FXPLCError { constructor(msg = 'No response from PLC') { super(msg); this.name = 'NoResponseError'; } } exports.NoResponseError = NoResponseError; /** Response frame failed structural / checksum validation */ class ResponseMalformedError extends FXPLCError { constructor(msg = 'Malformed response') { super(msg); this.name = 'ResponseMalformedError'; } } exports.ResponseMalformedError = ResponseMalformedError; /** Operation attempted while transport not connected/open */ class NotConnectedError extends FXPLCError { constructor(msg = 'Not connected') { super(msg); this.name = 'NotConnectedError'; } } exports.NotConnectedError = NotConnectedError; exports.default = { FXPLCError, NotSupportedCommandError, NoResponseError, ResponseMalformedError, NotConnectedError };