示例#1
0
        /// <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;
                }
            }
        }
示例#2
0
 /// <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;
 }
示例#3
0
 /// <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)
 {
 }