示例#1
0
        private void sendButton_Click(object sender, EventArgs e)
        {
            MessageType type = MessageType.NONE;

            if (_Connected == true)
            {
                byte       selCamera;
                CmdMessage msg;

                if (byte.TryParse(selectedCamera.Text, System.Globalization.NumberStyles.HexNumber, null, out selCamera))
                {
                    Command command    = (Command)comboCommand.SelectedIndex;
                    byte    parameters = GetParameter();

                    switch (comboType.SelectedIndex)
                    {
                    case 0:
                        type = MessageType.KEEP_ALIVE;
                        break;

                    case 1:
                        type = MessageType.SINGLE_IMG;
                        break;

                    case 2:
                        type = MessageType.ELAB_IMG;
                        break;

                    case 3:
                        type = MessageType.RUN_SCORR;
                        break;

                    case 4:
                        type = MessageType.RST_TV;
                        break;

                    case 5:
                        type = MessageType.CFG_TV;
                        break;

                    case 6:
                        type = MessageType.STATUS_TV;
                        break;
                    }

                    msg = new CmdMessage(type, selCamera, command, parameters);


                    if (cmdMutex.WaitOne(500))
                    {
                        byte[] payload = new byte[CmdMessage.FRAME_LENGTH];
                        Array.Copy(msg.GetFrame(), payload, CmdMessage.FRAME_LENGTH);
                        _tcpClient.SendMessage(payload);
                        string sentText = ByteArrayToHexStringViaBitConverter(payload);
                        textLog.AppendText("TX:     " + sentText + "\r\n");
                        cmdMutex.ReleaseMutex();
                    }
                }
            }
        }
示例#2
0
 private void kaTimer_Tick(object sender, EventArgs e)
 {
     if (_Connected == true && disableKA.Checked == false)
     {
         byte value;
         if (byte.TryParse(selectedCamera.Text, out value))
         {
             CmdMessage msg = new CmdMessage(MessageType.KEEP_ALIVE,
                                             value,
                                             0,
                                             0);
             if (cmdMutex.WaitOne(500))
             {
                 byte[] payload = new byte[CmdMessage.FRAME_LENGTH];
                 Array.Copy(msg.GetFrame(), payload, CmdMessage.FRAME_LENGTH);
                 _tcpClient.SendMessage(payload);
                 string sentText = ByteArrayToHexStringViaBitConverter(payload);
                 textLog.AppendText("TX:     " + sentText + "\r\n");
                 cmdMutex.ReleaseMutex();
             }
         }
     }
 }
示例#3
0
        private void sendButton_Click(object sender, EventArgs e)
        {
            MessageType type= MessageType.NONE;

            if (_Connected == true)
            {
                byte selCamera;
                CmdMessage msg;

                if (byte.TryParse(selectedCamera.Text, System.Globalization.NumberStyles.HexNumber, null, out selCamera))
                {
                    Command command = (Command)comboCommand.SelectedIndex;
                    byte parameters = GetParameter();

                    switch(comboType.SelectedIndex)
                    {
                        case 0:
                            type = MessageType.KEEP_ALIVE;
                        break;

                        case 1:
                            type = MessageType.SINGLE_IMG;
                        break;

                        case 2:
                            type = MessageType.ELAB_IMG;
                        break;

                        case 3:
                            type = MessageType.RUN_SCORR;
                        break;

                        case 4:
                            type = MessageType.RST_TV;
                        break;

                        case 5:
                            type = MessageType.CFG_TV;
                        break;

                        case 6:
                            type = MessageType.STATUS_TV;
                        break;
                    }

                    msg = new CmdMessage(type, selCamera, command, parameters);

                    if (cmdMutex.WaitOne(500))
                    {
                        byte[] payload = new byte[CmdMessage.FRAME_LENGTH];
                        Array.Copy(msg.GetFrame(), payload, CmdMessage.FRAME_LENGTH);
                        _tcpClient.SendMessage(payload);
                        string sentText = ByteArrayToHexStringViaBitConverter(payload);
                        textLog.AppendText("TX:     " + sentText + "\r\n");
                        cmdMutex.ReleaseMutex();
                    }
                }
            }
        }
示例#4
0
 private void kaTimer_Tick(object sender, EventArgs e)
 {
     if(_Connected == true && disableKA.Checked == false)
     {
         byte value;
         if(byte.TryParse(selectedCamera.Text, out value))
         {
             CmdMessage msg = new CmdMessage(MessageType.KEEP_ALIVE,
                                             value,
                                             0,
                                             0);
             if(cmdMutex.WaitOne(500))
             {
                 byte[] payload = new byte[CmdMessage.FRAME_LENGTH];
                 Array.Copy(msg.GetFrame(), payload, CmdMessage.FRAME_LENGTH);
                 _tcpClient.SendMessage(payload);
                 string sentText = ByteArrayToHexStringViaBitConverter(payload);
                 textLog.AppendText("TX:     "+sentText+"\r\n");
                 cmdMutex.ReleaseMutex();
             }
         }
     }
 }