private bool GetResponse(LedPanel panel, string id)
        {
            bool          flag          = false;
            LedPanelCloud ledPanelCloud = panel as LedPanelCloud;
            DateTime      now           = DateTime.Now;

            while ((DateTime.Now - now).TotalSeconds < 10.0)
            {
                SingleCommandInfo singleCommandInfo = new SingleCommandService().Get(LedGlobal.CloudAccount.SessionID, ledPanelCloud.CloudID, id);
                if (singleCommandInfo != null)
                {
                    byte[] receiveData = singleCommandInfo.ReceiveData;
                    byte[] sendData    = singleCommandInfo.SendData;
                    if (receiveData != null && receiveData.Length > 0 && sendData != null && sendData.Length > 0)
                    {
                        IList <Unpack_Results> list = protocol_single_cmd.Rec_Unpack(receiveData, sendData);
                        if (list != null && list.Count > 0 && list[0].Result_Type == 2 && list[0].Info_Erroneous_Data == info_error_type.Null)
                        {
                            if (list[0].Cmd_Type != LedCmdType.Send_Panel_Parameter)
                            {
                                flag = true;
                                break;
                            }
                            TerminalInfo terminalInfo = new TerminalService().Get(LedGlobal.CloudAccount.SessionID, ledPanelCloud.DeviceID);
                            if (terminalInfo != null && ledPanelCloud.IsEquals(terminalInfo.ToParameterArray()))
                            {
                                flag = true;
                                break;
                            }
                            break;
                        }
                    }
                }
                if (flag)
                {
                    break;
                }
                Thread.Sleep(1000);
            }
            return(flag);
        }
Esempio n. 2
0
        private bool SendParameter()
        {
            int            i      = 0;
            bool           result = false;
            IList <byte[]> list   = protocol_single_cmd.Send_Pack(0, 0, LedCmdType.Read_Panel_Parameter, null, false, null, string.Empty, 52);

            if (list == null || list.Count == 0)
            {
                return(result);
            }
            while (i < 5)
            {
                i++;
                this.parameterID = string.Empty;
                bool flag = new SingleCommandService().Send(LedGlobal.CloudAccount.SessionID, this.terminalID, list[0], "加载", ref this.parameterID);
                if (flag)
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
Esempio n. 3
0
        private void GetParameter()
        {
            DateTime now   = DateTime.Now;
            bool     flag  = false;
            LedPanel panel = null;

            while (!flag && (DateTime.Now - now).TotalSeconds < 60.0)
            {
                IList <SingleCommandInfo> list = new SingleCommandService().GetList(LedGlobal.CloudAccount.SessionID, this.terminalID);
                if (list != null)
                {
                    foreach (SingleCommandInfo current in list)
                    {
                        if (current.ID == this.parameterID && current.ReceiveData != null && current.ReceiveData.Length > 0 && current.SendData != null && current.SendData.Length > 0)
                        {
                            IList <Unpack_Results> list2 = protocol_single_cmd.Rec_Unpack(current.ReceiveData, current.SendData);
                            if (list2 != null && list2.Count > 0 && list2[0].UnpackedData.GetType() == typeof(LedPanel))
                            {
                                panel = (list2[0].UnpackedData as LedPanel);
                                flag  = true;
                                break;
                            }
                        }
                    }
                }
                Thread.Sleep(1000);
            }
            if (flag)
            {
                base.Invoke(new MethodInvoker(delegate
                {
                    this.BindingParameter(panel);
                }));
                Thread.Sleep(200);
            }
        }
        private void SingleSend(object obj)
        {
            int num = (int)obj;

            if (num < 0)
            {
                this.thrCount--;
                return;
            }
            Screen_Display_Class sdc          = formCloudGroupSendingSingle.screenSendGroup[num];
            LedPanel             panel_NO     = sdc.Panel_NO;
            DataGridViewCell     dgvcState    = this.dgvSendState.Rows[num].Cells[4];
            DataGridViewCell     dgvcProgress = this.dgvSendState.Rows[num].Cells[5];
            string empty = string.Empty;
            bool   flag  = false;

            for (int i = 0; i < LedCommunicationConst.ProtocolSendVersionList.Length; i++)
            {
                if (panel_NO.ProtocolVersion == LedCommunicationConst.ProtocolSendVersionList[i])
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                sdc.Send_State    = 3;
                sdc.SendCompleted = true;
                sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_protocolVersionNumberInconsistent");
                this.StateColor   = 2;
                base.Invoke(new MethodInvoker(delegate
                {
                    dgvcState.Value           = sdc.State_Message;
                    dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor);
                }));
                Thread.Sleep(500);
                this.thrCount--;
                return;
            }
            sdc.State_Message = formMain.ML.GetStr("Prompt_NowIsGeneratingData");
            this.StateColor   = 0;
            base.Invoke(new MethodInvoker(delegate
            {
                dgvcProgress.Value        = 0;
                dgvcState.Value           = sdc.State_Message;
                dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor);
                dgvcState.ToolTipText     = string.Empty;
                this.dgvSendState.Refresh();
            }));
            Thread.Sleep(800);
            IList <byte[]> list = protocol_single_cmd.Send_Pack(0, 0, this.command, this.commData, false, null, "", panel_NO.ProtocolVersion);

            if (list == null || list.Count == 0)
            {
                sdc.Send_State    = 3;
                sdc.SendCompleted = true;
                sdc.State_Message = formMain.ML.GetStr("Message_Generate_Data_Failed");
                this.StateColor   = 2;
                base.Invoke(new MethodInvoker(delegate
                {
                    dgvcState.Value           = sdc.State_Message;
                    dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor);
                }));
                Thread.Sleep(500);
                this.thrCount--;
                return;
            }
            sdc.State_Message = formMain.ML.GetStr("Message_Generate_Data_Complete");
            this.StateColor   = 0;
            base.Invoke(new MethodInvoker(delegate
            {
                dgvcProgress.Value        = 100;
                dgvcState.Value           = sdc.State_Message;
                dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor);
                dgvcState.ToolTipText     = string.Empty;
                this.dgvSendState.Refresh();
            }));
            Thread.Sleep(800);
            sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_StartSending");
            this.StateColor   = 0;
            base.Invoke(new MethodInvoker(delegate
            {
                dgvcProgress.Value        = 0;
                dgvcState.Value           = sdc.State_Message;
                dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor);
                dgvcState.ToolTipText     = string.Empty;
                this.dgvSendState.Refresh();
            }));
            Thread.Sleep(800);
            int  j     = 0;
            bool flag2 = false;

            while (j < 5)
            {
                j++;
                empty = string.Empty;
                bool flag3 = new SingleCommandService().Send(LedGlobal.CloudAccount.SessionID, panel_NO.CloudID, list[0], this.operation, ref empty);
                if (flag3)
                {
                    flag2 = true;
                    break;
                }
            }
            if (!flag2)
            {
                this.failureCount++;
                sdc.Send_State    = 3;
                sdc.SendCompleted = true;
                sdc.State_Message = formMain.ML.GetStr("Display_CommunicationFailed");
                this.StateColor   = 2;
            }
            else
            {
                bool flag4 = panel_NO.State != LedPanelState.Online || this.GetResponse(panel_NO, empty);
                if (flag4)
                {
                    sdc.Send_State     = 3;
                    sdc.SendCompleted  = true;
                    sdc.State_Message  = this.Text.Replace(formMain.ML.GetStr("formMain_Menu_Group"), "") + formMain.ML.GetStr("Display_Successed");
                    this.StateColor    = 1;
                    dgvcProgress.Value = 100;
                }
                else
                {
                    this.failureCount++;
                    sdc.Send_State    = 3;
                    sdc.SendCompleted = true;
                    sdc.State_Message = formMain.ML.GetStr("Display_CommunicationFailed");
                    this.StateColor   = 2;
                }
            }
            base.Invoke(new MethodInvoker(delegate
            {
                dgvcState.Value           = sdc.State_Message;
                dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor);
            }));
            Thread.Sleep(500);
            this.thrCount--;
        }
Esempio n. 5
0
        private void StartSend()
        {
            int    i     = 0;
            bool   flag  = false;
            string empty = string.Empty;

            formCloudSendSingle.LastSendResult = false;
            base.Invoke(new MethodInvoker(delegate
            {
                this.Text = this.operation + "     " + formMain.ML.GetStr("Prompt_NowIsGeneratingData");
                this.Refresh();
            }));
            Thread.Sleep(500);
            IList <byte[]> list = protocol_single_cmd.Send_Pack(0, 0, this.command, this.commData, false, null, "", this.panelCloud.ProtocolVersion);

            if (list == null || list.Count == 0)
            {
                base.Invoke(new MethodInvoker(delegate
                {
                    MessageBox.Show(this, this.operation + formMain.ML.GetStr("Display_Failed"));
                    this.needtoClose = true;
                    base.Close();
                }));
                return;
            }
            base.Invoke(new MethodInvoker(delegate
            {
                this.Text            = this.operation + "     " + formMain.ML.GetStr("Message_Generate_Data_Complete");
                this.prgStatus.Value = 50;
                this.Refresh();
            }));
            Thread.Sleep(500);
            base.Invoke(new MethodInvoker(delegate
            {
                this.Text = this.operation + "     " + formMain.ML.GetStr("Prompt_NowIsSendingData");
                this.Refresh();
            }));
            Thread.Sleep(500);
            while (i < 5)
            {
                i++;
                empty = string.Empty;
                bool flag2 = new SingleCommandService().Send(LedGlobal.CloudAccount.SessionID, this.panelCloud.CloudID, list[0], this.operation, ref empty);
                if (flag2)
                {
                    flag = true;
                    break;
                }
            }
            base.Invoke(new MethodInvoker(delegate
            {
                this.Text = this.operation;
                this.Refresh();
            }));
            Thread.Sleep(500);
            if (!flag)
            {
                base.Invoke(new MethodInvoker(delegate
                {
                    this.prgStatus.Value = 100;
                    MessageBox.Show(this, formMain.ML.GetStr("Display_CommunicationFailed"));
                    this.needtoClose = true;
                    base.Close();
                }));
                return;
            }
            bool isResponseOK = false;

            if (this.panelCloud.State == LedPanelState.Online)
            {
                isResponseOK = this.GetResponse(empty);
            }
            else
            {
                isResponseOK = true;
            }
            base.Invoke(new MethodInvoker(delegate
            {
                this.prgStatus.Value = 100;
                if (isResponseOK)
                {
                    formCloudSendSingle.LastSendResult = true;
                    if (this.ShowOK)
                    {
                        MessageBox.Show(this, this.operation + formMain.ML.GetStr("Display_Successed"));
                    }
                    else
                    {
                        Thread.Sleep(1200);
                    }
                }
                else
                {
                    MessageBox.Show(this, formMain.ML.GetStr("Display_CommunicationFailed"));
                }
                this.needtoClose = true;
                this.Close();
            }));
        }