Ejemplo n.º 1
0
        public override void Write(byte[] data)
        {
            if (this.IsConnected())
            {
                // Instead of sending the data directly to the device, encapsulate the data 
                // and put it into the queue
                switch (data.Length)
                {
                    case 2:
                        {
                            var message = new KdmWriteMessage { OperationCode = data[0], Data = data[1] };
                            this.Log.Debug("A write message is added to the message queue");
                            this.EnqueueMessage(message);
                        }
                        break;
                    case 1:
                        {
                            var operationCode = data[0];
                            IKdmMessage message;

                            if (Constants.OperationCodes.IsRestartCommand(operationCode))
                            {
                                message = new KdmRestartMessage { OperationCode = operationCode };
                                this.Log.Debug("A restart message is added to message queue");
                            }
                            else
                            {
                                message = new KdmReadMessage { OperationCode = operationCode };
                                this.Log.Debug("A read message is added to the message queue");
                            }

                            this.EnqueueMessage(message);
                        }
                        break;
                    default:
                        this.Log.Error("Unknown message format");
                        break;
                }
            }
            else
            {
                this.Log.Error("Cannot send command because there is no connection available with the device");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// This method is called if the operation code is sent to device and it's echo is received and the message is a restart message
 /// </summary>
 /// <param name="message"></param>
 private void CheckForRestartMessageStates(KdmRestartMessage message)
 {
     // Since this method is called only if the operation code echo is received, there is nothing more to do. The message processing is completed
     this.Log.Debug($"Restart message successfully processed. Retry count {this.OnProcessMessage.RetryCount}");
     message.IsMessageProcessingCompleted = true;
 }
Ejemplo n.º 3
0
 private void btnSwReset_Click(object sender, EventArgs e)
 {
     var message = new KdmRestartMessage { OperationCode = Constants.OperationCodes.RestartCommands.SwReset.Code };
     this.deviceProxy.Write(message.GetBytes());
 }