Inheritance: Vixen.Sys.Dispatch.CommandDispatch
        internal void SendUpdate(ICommand[] outputStates, Data _Data, CommandHandler _commandHandler)
        {
            if (serialPortIsValid && isSerialPortOpen)
            {
                byte[] _header = Encoding.ASCII.GetBytes(_Data.Header == null ? string.Empty : _Data.Header);
                var headerLen = _header.Length; // compute this here so we don't have to compute it in the loop

                byte[] _footer = Encoding.ASCII.GetBytes(_Data.Footer == null ? string.Empty : _Data.Footer);

                byte[] _packet = new byte[headerLen + outputStates.Length + _footer.Length];

                _header.CopyTo(_packet, 0);
                _footer.CopyTo(_packet, _packet.Length - _footer.Length);

                ICommand command = null;

                // Why do we use the command handler?  For this module, it just seems like unnecessary overhead.
                for (int i = 0; i < outputStates.Length; i++)
                {
                    _commandHandler.Reset();
                    command = outputStates[i];
                    if (command != null)
                    {
                        command.Dispatch(_commandHandler);
                    }
                    _packet[i + headerLen] = _commandHandler.Value;
                }

                if (_packet.Length > 0)
                {
                    _SerialPort.Write(_packet, 0, _packet.Length);
                }
            }
        }
Beispiel #2
0
		public Module()
		{
			_commandHandler = new CommandHandler();
			DataPolicyFactory = new DataPolicyFactory();

			//set 2 minute timer before retrying to access com port
			_retryTimer = new System.Timers.Timer(120000);
			_retryTimer.Elapsed += new ElapsedEventHandler(_retryTimer_Elapsed);
			_retryCounter = 0;
		}
Beispiel #3
0
 public Module()
 {
     _commandHandler = new CommandHandler();
     DataPolicyFactory = new DataPolicyFactory();
 }