s7-server
Version:
TypeScript S7 PLC Server Simulator
121 lines • 6.2 kB
JavaScript
/**
* S7 PLC Server Types and Constants
* Based on the SNAP7 library and S7 protocol specification
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerError = exports.ServerParam = exports.EventResult = exports.EventCode = exports.CpuStatus = exports.ServerStatus = exports.Operation = exports.S7WordLength = exports.S7Area = void 0;
// Server Area IDs (matching C++ SNAP7 implementation)
var S7Area;
(function (S7Area) {
S7Area[S7Area["PE"] = 129] = "PE";
S7Area[S7Area["PA"] = 130] = "PA";
S7Area[S7Area["MK"] = 131] = "MK";
S7Area[S7Area["DB"] = 132] = "DB";
S7Area[S7Area["CT"] = 28] = "CT";
S7Area[S7Area["TM"] = 29] = "TM"; // Timers
})(S7Area || (exports.S7Area = S7Area = {}));
// Word Length constants
var S7WordLength;
(function (S7WordLength) {
S7WordLength[S7WordLength["Bit"] = 1] = "Bit";
S7WordLength[S7WordLength["Byte"] = 2] = "Byte";
S7WordLength[S7WordLength["Word"] = 4] = "Word";
S7WordLength[S7WordLength["DWord"] = 6] = "DWord";
S7WordLength[S7WordLength["Real"] = 8] = "Real";
S7WordLength[S7WordLength["Counter"] = 28] = "Counter";
S7WordLength[S7WordLength["Timer"] = 29] = "Timer";
})(S7WordLength || (exports.S7WordLength = S7WordLength = {}));
// Operation types
var Operation;
(function (Operation) {
Operation[Operation["Read"] = 0] = "Read";
Operation[Operation["Write"] = 1] = "Write";
})(Operation || (exports.Operation = Operation = {}));
// Server status codes
var ServerStatus;
(function (ServerStatus) {
ServerStatus[ServerStatus["Stopped"] = 0] = "Stopped";
ServerStatus[ServerStatus["Running"] = 1] = "Running";
ServerStatus[ServerStatus["Error"] = 2] = "Error";
})(ServerStatus || (exports.ServerStatus = ServerStatus = {}));
// CPU status codes
var CpuStatus;
(function (CpuStatus) {
CpuStatus[CpuStatus["Unknown"] = 0] = "Unknown";
CpuStatus[CpuStatus["Run"] = 8] = "Run";
CpuStatus[CpuStatus["Stop"] = 4] = "Stop";
})(CpuStatus || (exports.CpuStatus = CpuStatus = {}));
// Event codes
var EventCode;
(function (EventCode) {
// TCP Server Events
EventCode[EventCode["ServerStarted"] = 1] = "ServerStarted";
EventCode[EventCode["ServerStopped"] = 2] = "ServerStopped";
EventCode[EventCode["ListenerCannotStart"] = 4] = "ListenerCannotStart";
EventCode[EventCode["ClientAdded"] = 8] = "ClientAdded";
EventCode[EventCode["ClientRejected"] = 16] = "ClientRejected";
EventCode[EventCode["ClientNoRoom"] = 32] = "ClientNoRoom";
EventCode[EventCode["ClientException"] = 64] = "ClientException";
EventCode[EventCode["ClientDisconnected"] = 128] = "ClientDisconnected";
EventCode[EventCode["ClientTerminated"] = 256] = "ClientTerminated";
EventCode[EventCode["ClientsDropped"] = 512] = "ClientsDropped";
// S7 Server Events
EventCode[EventCode["PDUIncoming"] = 65536] = "PDUIncoming";
EventCode[EventCode["DataRead"] = 131072] = "DataRead";
EventCode[EventCode["DataWrite"] = 262144] = "DataWrite";
EventCode[EventCode["NegotiatePDU"] = 524288] = "NegotiatePDU";
EventCode[EventCode["ReadSZL"] = 1048576] = "ReadSZL";
EventCode[EventCode["Clock"] = 2097152] = "Clock";
EventCode[EventCode["Upload"] = 4194304] = "Upload";
EventCode[EventCode["Download"] = 8388608] = "Download";
EventCode[EventCode["Directory"] = 16777216] = "Directory";
EventCode[EventCode["Security"] = 33554432] = "Security";
EventCode[EventCode["Control"] = 67108864] = "Control";
// Masks
EventCode[EventCode["All"] = 4294967295] = "All";
EventCode[EventCode["None"] = 0] = "None";
})(EventCode || (exports.EventCode = EventCode = {}));
// Event result codes
var EventResult;
(function (EventResult) {
EventResult[EventResult["NoError"] = 0] = "NoError";
EventResult[EventResult["FragmentRejected"] = 1] = "FragmentRejected";
EventResult[EventResult["MalformedPDU"] = 2] = "MalformedPDU";
EventResult[EventResult["SparseBytes"] = 3] = "SparseBytes";
EventResult[EventResult["CannotHandlePDU"] = 4] = "CannotHandlePDU";
EventResult[EventResult["NotImplemented"] = 5] = "NotImplemented";
EventResult[EventResult["ErrException"] = 6] = "ErrException";
EventResult[EventResult["ErrAreaNotFound"] = 7] = "ErrAreaNotFound";
EventResult[EventResult["ErrOutOfRange"] = 8] = "ErrOutOfRange";
EventResult[EventResult["ErrOverPDU"] = 9] = "ErrOverPDU";
EventResult[EventResult["ErrTransportSize"] = 10] = "ErrTransportSize";
EventResult[EventResult["InvalidGroupUData"] = 11] = "InvalidGroupUData";
EventResult[EventResult["InvalidSZL"] = 12] = "InvalidSZL";
EventResult[EventResult["DataSizeMismatch"] = 13] = "DataSizeMismatch";
EventResult[EventResult["CannotUpload"] = 14] = "CannotUpload";
EventResult[EventResult["CannotDownload"] = 15] = "CannotDownload";
EventResult[EventResult["UploadInvalidID"] = 16] = "UploadInvalidID";
EventResult[EventResult["ResNotFound"] = 17] = "ResNotFound";
})(EventResult || (exports.EventResult = EventResult = {}));
// Server parameters
var ServerParam;
(function (ServerParam) {
ServerParam[ServerParam["LocalPort"] = 1] = "LocalPort";
ServerParam[ServerParam["WorkInterval"] = 6] = "WorkInterval";
ServerParam[ServerParam["PDURequest"] = 10] = "PDURequest";
ServerParam[ServerParam["MaxClients"] = 11] = "MaxClients";
})(ServerParam || (exports.ServerParam = ServerParam = {}));
// Error codes
var ServerError;
(function (ServerError) {
ServerError[ServerError["CannotStart"] = 1048576] = "CannotStart";
ServerError[ServerError["DBNullPointer"] = 2097152] = "DBNullPointer";
ServerError[ServerError["AreaAlreadyExists"] = 3145728] = "AreaAlreadyExists";
ServerError[ServerError["UnknownArea"] = 4194304] = "UnknownArea";
ServerError[ServerError["InvalidParams"] = 5242880] = "InvalidParams";
ServerError[ServerError["TooManyDB"] = 6291456] = "TooManyDB";
ServerError[ServerError["InvalidParamNumber"] = 7340032] = "InvalidParamNumber";
ServerError[ServerError["CannotChangeParam"] = 8388608] = "CannotChangeParam";
})(ServerError || (exports.ServerError = ServerError = {}));
//# sourceMappingURL=s7-types.js.map
;