예제 #1
0
 private int send_CWTransmitSetup(string[] commandSet, int delay, string commandName)
 {
     try
     {
         this._series.clear();
         for (int i = 0; i < commandSet.Length; i++)
         {
             this._tele = new Telegram(commandSet[i].Length);
             this._tele.uniqId = GlobalServices.uniqTelegramId();
             this._tele.parentUniqId = -1;
             this._tele.type = TelegramType.Command;
             this._tele.protocol = Protocol.WriteRead;
             string reply = null;
             this._tele.replySize = GlobalServices.calculateExpextedReplyLen(commandSet[i], ref reply);
             if (this._tele.replySize == -1)
             {
                 throw new Exception("Not supported command.");
             }
             this._tele.data.copy(commandSet[i]);
             this._tele.userData = -1;
             this._tele.portHandler = this._ioph;
             this._tele.mainWin = this;
             this._series.addTelegram(this._tele);
         }
         if (delay > 0)
         {
             this._series.addDelay(delay);
         }
         if (this._ioph.telegramSeriesFromMainWin(this._series, SeriesExecutionState.Run, true) == 0)
         {
             this._isDeviceBusy = true;
             this._task_id = Task.CWTransmitSetupSeries;
             this.lockDeviceButtons(ExceptedBtn.CWTransmit);
             GlobalServices.LogMsg(this._appId, commandName + " Series started");
             return 0;
         }
         this._cwTxWaitingTasks.Clear();
         this._cwTxTaskId = CWTxTask.None;
         return -1;
     }
     catch (Exception exception)
     {
         GlobalServices.ErrMsg(this._appId, "Error at sending " + commandName + " Commands!\n" + exception.Message);
         GlobalServices.msgBox("Error at sending " + commandName + " Commands!\n" + exception.Message, "Error!");
         return -1;
     }
 }
예제 #2
0
        private void processCWTxWaitingTasks()
        {
            if (!this._isDeviceBusy)
            {
                if (this._cwTxWaitingTasks.Count > 0)
                {
                    this._cwTxTaskId = this._cwTxWaitingTasks[0];
                    this._cwTxWaitingTasks.RemoveAt(0);
                    switch (this._cwTxTaskId)
                    {
                        case CWTxTask.StartManual:
                            this.send_CWTransmitSetup(this._startCWTxManual_Commands, 0, this._startCWTxManual_Command_Name);
                            this.sbDeviceStatePane.Text = "Status: Manual CW test is in progress";
                            return;

                        case CWTxTask.StopManual:
                            this.send_CWTransmitSetup(this._stopCWTxManual_Commands, 0, this._stopCWTxManual_Command_Name);
                            return;

                        case CWTxTask.ManualModulateBy0:
                            if (this.send_CWTransmitSetup(this._cwTxModulateBy0_Commands, 0, this._cwTxModulateBy0_Command_Name) == 0)
                            {
                                this.pnlCWTx_Led_L.BackColor = this._cwLedColor_H;
                                this.pnlCWTx_Led_H.BackColor = this._cwLedColor_L;
                            }
                            return;

                        case CWTxTask.ManualModulateBy1:
                            if (this.send_CWTransmitSetup(this._cwTxModulateBy1_Commands, 0, this._cwTxModulateBy1_Command_Name) == 0)
                            {
                                this.pnlCWTx_Led_L.BackColor = this._cwLedColor_L;
                                this.pnlCWTx_Led_H.BackColor = this._cwLedColor_H;
                            }
                            return;

                        case CWTxTask.StartAstabil:
                            this.send_CWTransmitSetup(this._startCWTxAstabil_Commands, 0, this._startCWTxAstabil_Command_Name);
                            this.sbDeviceStatePane.Text = "Status: Astable CW test is in progress";
                            return;

                        case CWTxTask.StopAstabil:
                            this.send_CWTransmitSetup(this._stopCWTxAstabil_Commands, 0, this._stopCWTxAstabil_Command_Name);
                            return;

                        case CWTxTask.AstabilModulateBy0:
                            if (this.send_CWTransmitSetup(this._cwTxModulateBy0_Commands, this.get_cwTx_AstabilModDelay(), this._cwTxModulateBy0_Command_Name) == 0)
                            {
                                this.pnlCWTx_Led_L.BackColor = this._cwLedColor_H;
                                this.pnlCWTx_Led_H.BackColor = this._cwLedColor_L;
                            }
                            return;

                        case CWTxTask.AstabilModulateBy1:
                            if (this.send_CWTransmitSetup(this._cwTxModulateBy1_Commands, this.get_cwTx_AstabilModDelay(), this._cwTxModulateBy1_Command_Name) == 0)
                            {
                                this.pnlCWTx_Led_L.BackColor = this._cwLedColor_L;
                                this.pnlCWTx_Led_H.BackColor = this._cwLedColor_H;
                            }
                            return;

                        case CWTxTask.StartPN15Sequence:
                            this.send_CWTransmitSetup(this._startCWTxPN15Sequence_Commands, 0, this._startCWTxPN15Sequence_Command_Name);
                            this.sbDeviceStatePane.Text = "Status: TX test with PN15 modulation is in progress";
                            return;

                        case CWTxTask.StopPN15Sequence:
                            this.send_CWTransmitSetup(this._stopCWTxPN15Sequence_Commands, 0, this._stopCWTxPN15Sequence_Command_Name);
                            return;
                    }
                }
                else
                {
                    if (((this._cwTxTaskId == CWTxTask.StopManual) || (this._cwTxTaskId == CWTxTask.StopAstabil)) || (this._cwTxTaskId == CWTxTask.StopPN15Sequence))
                    {
                        this.unLockDeviceButtons();
                    }
                    this._cwTxTaskId = CWTxTask.None;
                    this._task_id = Task.None;
                }
            }
        }