/// <summary> /// /// </summary> /// <param name="memory"></param> /// <param name="maxHeartbeatInterval">Max time allowed before declaring disconnection when heartbeat signal is not received.</param> /// <param name="heartbeatSignal">Name of the heartbeat signal, default to empty which means any memory modification by anyone is considered as heartbeat.</param> public PLCController(PLCMemory memory, TimeSpan?maxHeartbeatInterval = null, string heartbeatSignal = "") { this.memory = memory; this.maxHeartbeatInterval = maxHeartbeatInterval; this.heartbeatSignal = heartbeatSignal; // register observer this.memory.Modified += new PLCMemory.Observer(this._Enqueue); // copy memory lock (memory) { foreach (var pair in memory) { this.state[pair.Key] = pair.Value; } } }
/// <summary> /// Controling logic for PLC. Handles requests after they are parsed. /// </summary> /// <param name="memory">A custom PLC memory instance.</param> public PLCService(PLCMemory memory) { this.memory = memory; }
/// <summary> /// Creates the ZMQ server. /// </summary> /// <param name="memory">A custom instance of PLC memory</param> /// <param name="addr">Endpoint to listen on. For example, "tcp://*:5555".</param> public PLCServer(PLCMemory memory, string addr) : this(new PLCService(memory), addr) { }