Exemplo n.º 1
0
 public void execTelegramSeries()
 {
     waitForDevice();
     if (_mainWin._ioph.getAdtRecord().isSimuation)
     {
         while ((_teleIterator = _telegramSeries.getNextItem()) != null)
         {
             _mainWin.statusBarPanel4.Step();
             if ((_teleIterator.telegram.SenderInfo != null) && (_teleIterator.telegram.SenderInfo.Length > 0))
             {
                 _mainWin.showLocalLog(((string) _teleIterator.telegram.SenderInfo[0]) + "\n");
             }
             if (_teleIterator.telegram.type == TelegramType.ExecuteTclScript)
             {
                 _mainWin.showLocalLog("> " + _teleIterator.telegram.data.BufToStr + "\n");
             }
             else
             {
                 _mainWin.showLocalLog("> " + WDSConverters.ToHexString(_teleIterator.telegram.data.Buf, _teleIterator.telegram.data.NumItems) + "\n");
             }
         }
         _mainWin.statusBarPanel4.Reset();
     }
     else
     {
         _lastReplyPec = LastReplyPrecondition.None;
         _replyPreconditionCnt = 0;
         _gotACKforCommand = false;
         _teleIterator = _telegramSeries.getNextItem();
         if (_teleIterator != null)
         {
             _mainWin.statusBarPanel4.Step();
             _mainWin.showLocalLog("\n");
             if (_teleIterator.telegram.UserDataExt.hasStoredValue("Task"))
             {
                 _mainWin.sbDeviceStatePane.Text = _mainWin.getStatusString((AppWin_SPITool_PRO.Task) _teleIterator.telegram.UserDataExt.StoredUserData["Task"]);
             }
             if (_teleIterator.isTelegram)
             {
                 _teleIterator.telegram.copyEventHandler(out _savedEvent);
                 _teleIterator.telegram.clearEventHandler();
                 _teleIterator.telegram.CallbackEvent += new Telegram.Callback(replyTeleArrived);
                 _lastReplyPec = _teleIterator.telegram.lastReplyPrecondition;
                 _replyPreconditionCnt = _teleIterator.telegram.numOfLastReplyPackets;
                 if (_mainWin._ioph.telegramFromMainWin(_teleIterator.telegram) == 0)
                 {
                     if ((_teleIterator.telegram.SenderInfo != null) && (_teleIterator.telegram.SenderInfo.Length > 0))
                     {
                         _mainWin.showLocalLog(((string) _teleIterator.telegram.SenderInfo[0]) + "\n");
                     }
                     if (_teleIterator.telegram.type == TelegramType.ExecuteTclScript)
                     {
                         _mainWin.showLocalLog("> " + _teleIterator.telegram.data.BufToStr + "\n");
                     }
                     else
                     {
                         _mainWin.showLocalLog("> " + WDSConverters.ToHexString(_teleIterator.telegram.data.Buf, _teleIterator.telegram.data.NumItems) + "\n");
                     }
                 }
                 else
                 {
                     _mainWin.showLocalLog(">! IOPH is busy!\n");
                     AppWin_SPITool_PRO._log.Error("Error at register execution!");
                 }
             }
         }
         else
         {
             _mainWin.statusBarPanel4.Reset();
             _mainWin.sbDeviceStatePane.Text = _mainWin.getStatusString(AppWin_SPITool_PRO.Task.None);
             if (_mainWin.tsrMainToolStrip.IsContCurrentReadOn && !_currentReadDone)
             {
                 _currentReadDone = true;
                 _mainWin.tsrMainToolStrip_AmmeteringRequested(null, null);
             }
             else
             {
                 _currentReadDone = false;
             }
         }
     }
 }
Exemplo n.º 2
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     byte[][] collection = new byte[13][];
     for (int i = 0; i < 13; i++)
     {
         collection[i] = WDSConverters.ToByteArray(this._mtbCommandSet[i].Text.Replace(" ", string.Empty));
     }
     if (!this.chbUseExtXoIfSet.Checked)
     {
         List<byte[]> list = new List<byte[]>(collection);
         list.RemoveAt(this._XOCommandIdx);
         collection = list.ToArray();
     }
     TelegramContainerItem[] itemArray = new TelegramContainerItem[collection.Length];
     for (int j = 0; j < collection.Length; j++)
     {
         Telegram tele = new Telegram(collection[j].Length + 10) {
             uniqId = GlobalServices.uniqTelegramId(),
             parentUniqId = -1,
             type = TelegramType.Command,
             protocol = Protocol.DCP,
             DCPCmdSet = 4,
             lastReplyPrecondition = LastReplyPrecondition.Indication
         };
         tele.data.copy(new byte[] { 0x27, this._Si4012I2CBusAddress, (byte) collection[j].Length });
         tele.data.append(collection[j], collection[j].Length);
         tele.userData = 9;
         tele.portHandler = this._ioph;
         tele.mainWin = this;
         itemArray[j] = new TelegramContainerItem(tele);
     }
     this._series.clear();
     foreach (TelegramContainerItem item in itemArray)
     {
         if (item != null)
         {
             item.telegram.clearEventHandler();
             item.telegram.CallbackEvent += new Telegram.Callback(this.updateEventHandler);
             this._series.addTelegramContainerItem(item);
         }
     }
     if (this._teleProcessor.initSeries(this._series))
     {
         this._teleProcessor.execTelegramSeries();
     }
     else
     {
         MessageBox.Show("Device is BUSY!");
     }
 }
Exemplo n.º 3
0
 public void execTelegramSeries()
 {
     this.waitForDevice();
     if (this._mainWin._ioph.getAdtRecord().isSimuation)
     {
         while ((this._teleIterator = this._telegramSeries.getNextItem()) != null)
         {
             this._mainWin.showLocalLog("> " + WDSConverters.ToHexString(this._teleIterator.telegram.data.Buf, this._teleIterator.telegram.data.NumItems) + "\n");
         }
     }
     else
     {
         this._teleIterator = this._telegramSeries.getNextItem();
         if (this._teleIterator != null)
         {
             this._mainWin.sbDeviceStatePane.Text = this._mainWin.getStatusString((Task)this._teleIterator.telegram.userData);
             if (this._teleIterator.isTelegram)
             {
                 this._teleIterator.telegram.copyEventHandler(out this._savedEvent);
                 this._teleIterator.telegram.clearEventHandler();
                 this._teleIterator.telegram.CallbackEvent += new Telegram.Callback(this.replyTeleArrived);
                 this._lastReplyPec = this._teleIterator.telegram.lastReplyPrecondition;
                 this._replyPreconditionCnt = this._teleIterator.telegram.numOfLastReplyPackets;
                 if (this._mainWin._ioph.telegramFromMainWin(this._teleIterator.telegram) == 0)
                 {
                     this._mainWin._deviceBusy = true;
                     this._mainWin.showLocalLog("> " + WDSConverters.ToHexString(this._teleIterator.telegram.data.Buf, this._teleIterator.telegram.data.NumItems) + "\n");
                 }
                 else
                 {
                     this._mainWin.showLocalLog(">! IOPH is busy!\n");
                     AppWin_Si4012_CP._log.Error("Error at register execution!");
                 }
             }
         }
         else
         {
             this._mainWin.showLocalLog("\n");
             this._mainWin._deviceBusy = false;
             this._mainWin.sbDeviceStatePane.Text = this._mainWin.getStatusString(AppWin_Si4012_CP.Task.None);
             if (this._mainWin.tsrMainToolStrip.IsContCurrentReadOn && !this._currentReadDone)
             {
                 this._currentReadDone = true;
                 this._mainWin.tsrMainToolStrip_AmmeteringRequested(null, null);
             }
             else
             {
                 this._currentReadDone = false;
             }
         }
     }
 }
Exemplo n.º 4
0
 public void execTelegramSeries()
 {
     this.waitForDevice();
     if (this._ioph.getAdtRecord().isSimuation)
     {
         while ((this._teleIterator = this._telegramSeries.getNextItem()) != null)
         {
             if ((this._teleIterator.telegram.SenderInfo != null) && (this._teleIterator.telegram.SenderInfo.Length > 0))
             {
                 this.communicationLog((string) this._teleIterator.telegram.SenderInfo[0]);
             }
             if (this._teleIterator.telegram.type == TelegramType.ExecuteTclScript)
             {
                 this.communicationLog("> " + this._teleIterator.telegram.data.BufToStr);
             }
             else
             {
                 this.communicationLog("> " + WDSConverters.ToHexString(this._teleIterator.telegram.data.Buf, this._teleIterator.telegram.data.NumItems));
             }
             if (this._teleIterator.telegram.UserDataExt.hasStoredValue("Task") && (this.taskBeingProcessed != null))
             {
                 this.taskBeingProcessed(this._teleIterator.telegram.UserDataExt.StoredUserData["Task"]);
             }
             if (this.telegramFinished != null)
             {
                 this.telegramFinished(this, null);
             }
         }
         if (this.telegramSeriesFinished != null)
         {
             this.telegramSeriesFinished(this, null);
         }
     }
     else
     {
         this._teleIterator = this._telegramSeries.getNextItem();
         if (this._teleIterator != null)
         {
             if (this._isFirstTelegram)
             {
                 this._isFirstTelegram = false;
             }
             else if (this.telegramFinished != null)
             {
                 this.telegramFinished(this, null);
             }
             if (this._teleIterator.telegram.UserDataExt.hasStoredValue("Task") && (this.taskBeingProcessed != null))
             {
                 this.taskBeingProcessed(this._teleIterator.telegram.UserDataExt.StoredUserData["Task"]);
             }
             if (this._teleIterator.isTelegram)
             {
                 this._teleIterator.telegram.copyEventHandler(out this._savedEvent);
                 this._teleIterator.telegram.clearEventHandler();
                 this._teleIterator.telegram.CallbackEvent += new Telegram.Callback(this.replyTeleArrived);
                 this._lastReplyPec = this._teleIterator.telegram.lastReplyPrecondition;
                 this._replyPreconditionCnt = this._teleIterator.telegram.numOfLastReplyPackets;
                 if (this._ioph.telegramFromMainWin(this._teleIterator.telegram) == 0)
                 {
                     if ((this._teleIterator.telegram.SenderInfo != null) && (this._teleIterator.telegram.SenderInfo.Length > 0))
                     {
                         this.communicationLog((string) this._teleIterator.telegram.SenderInfo[0]);
                     }
                     if (this._teleIterator.telegram.type == TelegramType.ExecuteTclScript)
                     {
                         this.communicationLog("> " + this._teleIterator.telegram.data.BufToStr);
                     }
                     else
                     {
                         this.communicationLog("> " + WDSConverters.ToHexString(this._teleIterator.telegram.data.Buf, this._teleIterator.telegram.data.NumItems));
                     }
                 }
                 else
                 {
                     this.communicationLog(">! IOPH is busy!");
                 }
             }
         }
         else
         {
             if (this.telegramFinished != null)
             {
                 this.telegramFinished(this, null);
             }
             if (this.telegramSeriesFinished != null)
             {
                 this.telegramSeriesFinished(this, null);
             }
         }
     }
 }