Example #1
0
        public int telegramFromPortHandler(Telegram telegram)
        {
            if (telegram.type == TelegramType.PortHandlerTerminated)
            {
                this._closeCtrl.portHandlerClosed(telegram.portHandler);
                return 0;
            }
            GlobalServices.LogMsg(this._uniqAppId, telegram.objectInfo());
            this.txtReplyTele.Text = telegram.objectInfo();
            switch (telegram.type)
            {
                case TelegramType.AcknowledgeOK:
                    this.txtTelegramData.Text = telegram.data.objectInfo(true);
                    break;

                case TelegramType.AcknowledgeERROR:
                    this.txtTelegramData.Text = telegram.data.objectInfo(true);
                    break;

                case TelegramType.DataAcknowledgeOK:
                    this.txtDataPacket.Text = telegram.data.objectInfo(telegram.data.NumItems - 12, telegram.data.NumItems - 9, true);
                    this.txtTelegramData.Text = telegram.data.objectInfo(true);
                    break;

                case TelegramType.DataAcknowledgeERROR:
                    this.txtTelegramData.Text = telegram.data.objectInfo(true);
                    break;

                case TelegramType.SeriesEndOK:
                case TelegramType.SeriesEndERROR:
                    this.txtCommandTele.Text = "Series execution finished";
                    break;

                case TelegramType.DeviceFailure:
                    GlobalServices.ErrMsg("telegramFromPortHandler()", "DeviceFailure telegram type received: " + ((TelegramType) telegram.type).ToString());
                    break;

                default:
                    GlobalServices.ErrMsg("telegramFromPortHandler()", "Unexpected telegram type received: " + ((TelegramType) telegram.type).ToString());
                    break;
            }
            return 0;
        }
Example #2
0
        public int telegramFromPortHandler(Telegram telegram)
        {
            if (telegram.type == TelegramType.PortHandlerTerminated)
            {
                this._closeCtrl.portHandlerClosed(telegram.portHandler);
                return 0;
            }
            switch (telegram.userData)
            {
                case 2:
                {
                    this.ButtonWrite2.Enabled = true;
                    object obj2 = this.textBoxWrite2Result.Text;
                    this.textBoxWrite2Result.Text = string.Concat(new object[] {
                        obj2, "Telegram received: uniqId: '", ((int) telegram.uniqId).ToString(), "'  parentUniqId: '", ((int) telegram.parentUniqId).ToString(), "'  type: '", ((TelegramType) telegram.type).ToString(), "'  protocol: '", telegram.protocol.ToString(), "'  expectedReplySize: '", ((int) telegram.replySize).ToString(), "'  receivedSize: '", telegram.data.NumItems, "'  usedData: '", ((UsrAppID) telegram.userData).ToString(), "'  data:--|",
                        telegram.data.objectInfo(true), "|--\r\n"
                     });
                    this.textBoxWrite2.Clear();
                    goto Label_02D7;
                }
                case 3:
                    switch (telegram.type)
                    {
                        case TelegramType.AcknowledgeOK:
                        case TelegramType.DataAcknowledgeOK:
                            if (this.btnLED2.Text == "LED")
                            {
                                this.btnLED2.Text = "LED C";
                            }
                            else
                            {
                                this.btnLED2.Text = "LED";
                            }
                            goto Label_0097;
                    }
                    break;

                default:
                    GlobalServices.ErrMsg(this._appId, "telegramFromPortHandler(): Unexpected telegram received: " + telegram.objectInfo());
                    goto Label_02D7;
            }
            Label_0097:
            this.btnLED2.Enabled = true;
            string text = this.textBoxWrite2Result.Text;
            this.textBoxWrite2Result.Text = text + "Telegram received: uniqId: '" + ((int) telegram.uniqId).ToString() + "'  parentUniqId: '" + ((int) telegram.parentUniqId).ToString() + "'  type: '" + ((TelegramType) telegram.type).ToString() + "'  protocol: '" + telegram.protocol.ToString() + "'  replySize: '" + ((int) telegram.replySize).ToString() + "'  usedData: '" + ((UsrAppID) telegram.userData).ToString() + "'  data:--|" + telegram.data.objectInfo(true) + "|--\r\n";
            Label_02D7:
            switch (telegram.type)
            {
                case TelegramType.AcknowledgeOK:
                case TelegramType.AcknowledgeERROR:
                case TelegramType.DataAcknowledgeOK:
                case TelegramType.DataAcknowledgeERROR:
                case TelegramType.SeriesEndOK:
                case TelegramType.SeriesEndERROR:
                    break;

                case TelegramType.DeviceFailure:
                    GlobalServices.ErrMsg("DeviceFailure telegram type received: " + ((TelegramType) telegram.type).ToString(), "telegramFromPortHandler()");
                    break;

                default:
                    GlobalServices.ErrMsg(this._appId, "telegramFromPortHandler(): Unexpected telegram type received: " + ((TelegramType) telegram.type).ToString());
                    break;
            }
            return 0;
        }