Beispiel #1
0
        private void SendMessageAndEnqueue(int father, int child, string messgae)
        {
            messgae = FormPackage(father, child, messgae);
            mySerialPort.Write(messgae);

            var tmpHandle = new GetEchoForm(0, messgae);
            _queueEchoControl.Enqueue(tmpHandle);

            if (!timer_Send2GetEcho.Enabled)
                timer_Send2GetEcho.Start();
        }
Beispiel #2
0
        private void DequeueAndSendport()
        {
            if (tmpSendHandle.Flag == 1 && _queueEchoControl.Count > 0)
            {
                var send_message = (GetEchoForm) _queueEchoControl.Dequeue();
                tmpSendHandle = send_message;
            }

            if (tmpSendHandle.Flag == 0)
            {
                mySerialPort.Write(tmpSendHandle.Messgae);
                label28.Text = @"重试:" + retryCount + @" 次," +
                               @"发送队列:" + _queueEchoControl.Count;
                retryCount++;
            }
        }
Beispiel #3
0
        private void button_DIY_Modify_Click(object sender, EventArgs e)
        {
            //=====================================
            //数据头和封包
            var NeedSend = "";
            var head = "#";
            var end = "$";
            //=====================================
            try
            {
                var combinedString = SendCustomParaAll();
                NeedSend = head + combinedString + end;

                mySerialPort.Write(NeedSend);

                var tmpHandle = new GetEchoForm(0, NeedSend);
                _queueEchoControl.Enqueue(tmpHandle);
                timer_Send2GetEcho.Start();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }