Esempio n. 1
0
 public int addADTRecord(ADTRecord adtRecord)
 {
     lock (_soADT)
     {
         bool flag = false;
         foreach (ADTRecord record in _ADTRecords)
         {
             if (record.PortAddress.isEqual(adtRecord.PortAddress))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             _ADTRecords.Add(adtRecord);
             if ((adtRecord.PortAddress != null) && (adtRecord.PortAddress.portType == PortType.USB_EZLink))
             {
                 setToUsed(adtRecord.PortAddress.usbEzLinkAddr.devIdx);
             }
             return 0;
         }
         return -1;
     }
 }
Esempio n. 2
0
 public IOPH_EZLinkDongle(ADTRecord adtRec, IAppMainWindow mainWin)
 {
     this._adtRec = adtRec;
     this._mainWin = mainWin;
     this._teleFromWin = new Telegram(0x3e8);
     this._teleToWin = new Telegram(0x3e8);
     this._replyData = new DataBuffer(0x3e8);
     this._isSeries = false;
     this._seriesExecStat = SeriesExecutionState.Stop;
     this._taskEvent = new AutoResetEvent(false);
     this._taskState = TaskState.TaskReady_OK;
     if (adtRec.isUsbEZLinkDevice())
     {
         this._ddi = DDI_EZLinkDongle.instance();
     }
     else if (adtRec.isTESTDevice())
     {
         this._ddi = DDI_TEST.instance();
     }
     else
     {
         GlobalServices.ErrMsg("FATAL ERROR: IOPH_EZLinkDongle", "I/O port type not supported, exit WDS!");
         Application.Exit();
     }
     this._iot = new Thread(new ThreadStart(this.doDeviceIO));
     this._iot.IsBackground = true;
     this._iot.Name = "IOPH_EZLink thread";
     this._isTelegramRequest = false;
     this._isRxTimerRequest = false;
     this._isReadRxPacketEnabled = false;
     this._iot.Start();
 }
Esempio n. 3
0
 public IOPH_DATA(ADTRecord adtRec, IAppMainWindow mainWin)
 {
     _adtRec = adtRec;
     _mainWin = mainWin;
     _teleToWin = new Telegram(GlobalServices.maxReplyDataLen);
     _teleFromWin = new Telegram(GlobalServices.maxReplyDataLen);
 }
Esempio n. 4
0
 public Dlg_FirmwareDownloadMultiMCU(ADTRecord adtRecord)
 {
     this.InitializeComponent();
     this.downloadProgressBar.Visible = false;
     this.MyCancelButton.Visible = true;
     this.DownloadButton.Visible = true;
     this._adtRec = adtRecord;
 }
Esempio n. 5
0
 public Dlg_SelectApplication(ADTRecord a_adt, bool a_startOnlyOneApp)
 {
     InitializeComponent();
     _adt = a_adt;
     _isSimulation = _adt.isSimuation;
     _startOnlyOneApp = a_startOnlyOneApp;
     _isFWUpdReq = false;
 }
Esempio n. 6
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (this.dgADTRecords.CurrentRow != null)
     {
         this._selectedADTRecord = this._adtRecords[this.dgADTRecords.CurrentCell.RowIndex];
         base.DialogResult = System.Windows.Forms.DialogResult.OK;
         base.Close();
     }
 }
Esempio n. 7
0
 public IO_FD_HID_DCP2(ADTRecord adtRecord)
 {
     _adtRecord = adtRecord;
     if (adtRecord.PortAddress.portType == PortType.RS232)
         _ddi = DDI_RS232.instance();
     else if (adtRecord.PortAddress.portType == PortType.HID)
         _ddi = DDI_HID.instance();
     else
     {
         _log.Error("IO_FD_HID.IO_FD_HID() FATAL ERROR: Unknown I/O port type, exit WDS!");
         Application.Exit();
     }
 }
Esempio n. 8
0
 public Dlg_SelectChipDialog(ADTRecord a_adt, List<GenListBoxItem<ADCRRecord>> a_selectedAppList)
 {
     InitializeComponent();
     _adt = a_adt;
     _selectedAppList = a_selectedAppList;
     _appname = _selectedAppList[0].ItemData.ApplicationDescriptor.AppName.ToString();
     _compatibleChipList = CDTManager.instance().getCompatibleChips(_selectedAppList);
     InitDialogStrings(a_adt);
     filterChipFamilyChanged(null, null);
     rbnShowAll.Checked = true;
     fillChipTypeTable();
     grpNickname.Enabled = true;
 }
Esempio n. 9
0
 public IO_FD_HID_ToolStick(ADTRecord adtRecord)
 {
     this._adtRecord = adtRecord;
     if (adtRecord.PortAddress.portType == PortType.TOOLSTICK)
     {
         this._ddi = DDI_TOOLSTICK.instance();
     }
     else
     {
         _log.Error("IO_FD_HID.IO_FD_HID() FATAL ERROR: Unknown I/O port type, exit WDS!");
         Application.Exit();
     }
 }
Esempio n. 10
0
 public IO_FD_SUB8051(ADTRecord adtRecord)
 {
     _adtRecord = adtRecord;
     if (adtRecord.PortAddress.portType == PortType.RS232)
     {
         _ddi = DDI_RS232.instance();
     }
     else
     {
         GlobalServices.ErrMsg("IO_FD_SUB8051.IO_FD_SUB8051()", "FATAL ERROR: Unknown I/O port type, exit WDS!");
         GlobalServices.msgBox("FATAL ERROR: Unknown I/O port type, exit WDS!", "IO_FD_SUB8051.IO_FD_SUB8051()");
         Application.Exit();
     }
 }
Esempio n. 11
0
File: IOPH_DCP.cs Progetto: x893/WDS
 public IOPH_DCP(ADTRecord adtRec, IAppMainWindow mainWin)
 {
     _adtRec = adtRec;
     _mainWin = mainWin;
     _teleFromWin = new Telegram(GlobalServices.maxCommandDataLen);
     _teleToWin = new Telegram(GlobalServices.maxReplyDataLen);
     _replyData = new DataBuffer(GlobalServices.maxReplyDataLen);
     _isSeries = false;
     _seriesExecStat = SeriesExecutionState.Stop;
     _taskState = TaskState.TaskReady_OK;
     int num = int.Parse(ConfigurationManager.AppSettings["DCPMaxDataLen"]);
     int num2 = int.Parse(ConfigurationManager.AppSettings["DCPMsgRepeatNr"]);
     int num3 = int.Parse(ConfigurationManager.AppSettings["DCPRecTimeout"]);
     byte num4 = byte.Parse(ConfigurationManager.AppSettings["DCPSOFByte"]);
     _dcpProtocolEngine = new DCPProtocol(this, num, num2, num3, 10, num4);
     _DCPRXMsg = new DCPFrame(num, num4);
     _DCPAnswerMsg = new DCPFrame(num, num4);
     _DCPTXMsg = new DCPFrame(num, num4);
     _DCPTXBuf = new DCPFrame(num, num4);
     if (adtRec.isUsbFtdiDevice())
     {
         _ddi = DDI_USB.instance();
     }
     else if (adtRec.isRS232Device())
     {
         _ddi = DDI_RS232.instance();
     }
     else if (adtRec.isTESTDevice())
     {
         _ddi = DDI_TEST.instance();
     }
     else if (adtRec.isHIDDevice())
     {
         _ddi = DDI_HID.instance();
     }
     else
     {
         GlobalServices.ErrMsg("IOPH_DCP.IOPH_DCP()", "FATAL ERROR: Unknown I/O port type, exit WDS!");
         Application.Exit();
     }
     _iot = new Thread(new ThreadStart(doDeviceIO));
     _iot.IsBackground = true;
     _iot.Name = "IOPH_DCP thread";
     _isTelegramRequest = false;
     _iot.Start();
 }
Esempio n. 12
0
 public IOPH_LoadBoard(ADTRecord adtRec, IAppMainWindow mainWin)
 {
     this._adtRec = adtRec;
     this._mainWin = mainWin;
     this._teleFromWin = new Telegram(GlobalServices.maxCommandDataLen);
     this._teleToWin = new Telegram(GlobalServices.maxReplyDataLen);
     this._replyData = new DataBuffer(GlobalServices.maxReplyDataLen, Data_Type.ASCII);
     this._isSeries = false;
     this._seriesExecStat = SeriesExecutionState.Stop;
     this._taskEvent = new AutoResetEvent(false);
     this._taskState = TaskState.TaskReady_OK;
     if (adtRec.isUsbFtdiDevice())
     {
         this._ddi = DDI_USB.instance();
         this._isTestDevice = false;
     }
     else if (adtRec.isRS232Device())
     {
         this._ddi = DDI_RS232.instance();
         this._isTestDevice = false;
     }
     else if (adtRec.isTESTDevice())
     {
         this._ddi = DDI_TEST.instance();
         this._isTestDevice = true;
     }
     else if (adtRec.isHIDDevice())
     {
         this._ddi = DDI_HID.instance();
         this._isTestDevice = false;
     }
     else
     {
         GlobalServices.ErrMsg("IOPH_LoadBoard.IOPH_LoadBoard()", "FATAL ERROR: Unknown I/O port type, exit WDS!");
         GlobalServices.msgBox("FATAL ERROR: Unknown I/O port type, exit WDS!", "IOPH_LoadBoard.IOPH_LoadBoard()");
         Application.Exit();
     }
     this.ReadReplytimerDelegate = new TimerCallback(this.rxReadReplyTimerTickHandler);
     this._iot = new Thread(new ThreadStart(this.doDeviceIO));
     this._iot.IsBackground = true;
     this._iot.Name = "IOPH_LoadBoard thread";
     this._iot.Start();
 }
Esempio n. 13
0
 public IO_FD_Main(ADTRecord adtRecord)
 {
     this._adtRecord = adtRecord;
     if (adtRecord.PortAddress.portType == PortType.USB_FTDI)
         this._ddi = DDI_USB.instance();
     else if (adtRecord.PortAddress.portType == PortType.RS232)
         this._ddi = DDI_RS232.instance();
     else if (adtRecord.PortAddress.portType == PortType.HID)
         this._ddi = DDI_HID.instance();
     else if (adtRecord.PortAddress.portType == PortType.TOOLSTICK)
         this._ddi = DDI_TOOLSTICK.instance();
     else if (adtRecord.PortAddress.portType == PortType.SIMULATION)
         this._ddi = DDI_TEST.instance();
     else
     {
         GlobalServices.ErrMsg("IO_FD_Main.IO_FD_Main()", "FATAL ERROR: Unknown I/O port type, exit WDS!");
         GlobalServices.msgBox("FATAL ERROR: Unknown I/O port type, exit WDS!", "IO_FD_Main.IO_FD_Main()");
         Application.Exit();
     }
 }
Esempio n. 14
0
 private void tsrMainToolStrip_SwitchRequested(object sender, EventArgs e)
 {
     ADTRecord[] adtRec = new ADTRecord[] { _adtRec };
     if (_frameWin.GetNrApplication(adtRec) == -1)
     {
         WDSApplication application = WDSApplicationManager.instance().findApplicationExcludeSPITool(_adtRec);
         if (application != null)
         {
             ((Form) application.MainWin).Focus();
         }
     }
 }
Esempio n. 15
0
        public int SetSwitchApplicationBtnToolTip()
        {
            ADTRecord[] adtRec = new ADTRecord[] { _adtRec };
            int nrApplication = _frameWin.GetNrApplication(adtRec);
            tsrMainToolStrip.setSwitchAppToolTipText("Switch between Applications");
            tsrMainToolStrip.SwitchEnabled = false;
            switch (nrApplication)
            {
                case -2:
                    tsrMainToolStrip.setSwitchAppToolTipText("Switch between Applications");
                    return nrApplication;

                case -1:
                    tsrMainToolStrip.setSwitchAppToolTipText("Switch between Applications");
                    tsrMainToolStrip.SwitchEnabled = true;
                    return nrApplication;

                case 0:
                    tsrMainToolStrip.setSwitchAppToolTipText("Add Applications");
                    return nrApplication;
            }
            return nrApplication;
        }
Esempio n. 16
0
 public bool hasDevice(ADTRecord adtRec)
 {
     return this._ioph.hasDevice(adtRec);
 }
Esempio n. 17
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] adtRecs)
 {
     if (adtRecs.Length != 1)
     {
         GlobalServices.ErrMsg(this._appId, "Error: unexpected number of I/O devices (ADT records)");
         GlobalServices.msgBox("Error: unexpected number of I/O devices (ADT records)", "Error!");
         return null;
     }
     this._chipType = adtRecs[0].DeviceInfo.ShowChipName;
     this._chipRev = adtRecs[0].DeviceInfo.ShowChipRevision;
     string str = this._appId.Substring(this._appId.Length - 3);
     string[] strArray = this._appId.Split(new char[] { '_' });
     this.sbDeviceTypePane.Text = " Device: " + adtRecs[0].DeviceInfo.ShowChipName + adtRecs[0].PortAddress.objectInfo();
     this.sbChipRevPane.Text = "Chip Revision: " + adtRecs[0].DeviceInfo.ShowChipRevision;
     this.Text = strArray[0] + " Radio Control Panel";
     if (adtRecs[0].PortAddress.Nickname != null)
     {
         this.tsrMainToolStrip.Nickname = adtRecs[0].PortAddress.Nickname;
     }
     else
     {
         this.tsrMainToolStrip.Nickname = "Device" + str;
     }
     this._WdsChipRevForConfigFiles = "WDS3_" + strArray[0] + "_" + adtRecs[0].DeviceInfo.ShowChipRevision;
     this._ioph = new IOPH_LoadBoard(adtRecs[0], this);
     this._portHandlerTerminated = false;
     return new IIOPortHandler[] { this._ioph };
 }
Esempio n. 18
0
 public bool hasDevice(ADTRecord adtRec)
 {
     if (this._portHandlers != null)
         foreach (IIOPortHandler handler in this._portHandlers)
             if (handler.hasDevice(adtRec))
                 return true;
     return false;
 }
Esempio n. 19
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] adtRecs)
 {
     if (adtRecs.Length != 1)
     {
         _log.Error("Unexpected number of I/O devices (ADT records)");
         return null;
     }
     this._adtRec = adtRecs[0];
     this._ioph = new IOPH_DATA(adtRecs[0], this);
     this._portHandlerTerminated = false;
     return new IIOPortHandler[] { this._ioph };
 }
Esempio n. 20
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     this._adtRec = devices[0];
     this._ioph = new IOPH_DATA(this._adtRec, this);
     if ((this._adtRec.PortAddress.Nickname != null) && (this._adtRec.PortAddress.Nickname != string.Empty))
     {
         this.tsrMainToolStrip.Nickname = this._adtRec.PortAddress.Nickname;
     }
     else
     {
         this.tsrMainToolStrip.Nickname = "Device [" + this._adtRec.UniqId + "]";
     }
     this.sbDeviceType.Text = " Device: " + this._adtRec.DeviceInfo.ShowChipName + " " + this._adtRec.PortAddress.objectInfo();
     this.sbChipRevPane.Text = "Chip Revision: " + this._adtRec.DeviceInfo.ShowChipRevision;
     return new IIOPortHandler[] { this._ioph };
 }
Esempio n. 21
0
 public Dlg_UnAssignedDevice(ADTRecord adt)
 {
     this.InitializeComponent();
     this._adt = adt;
 }
Esempio n. 22
0
 public void AllowDeviceHandover(ADTRecord adt)
 {
     _pauseBgProcessing = true;
     Thread.Sleep(50);
 }
Esempio n. 23
0
 public DeviceHandle open(ADTRecord adtRecord, char a_handsake)
 {
     return open(adtRecord.PortAddress, adtRecord.PortAddress.comAddr.baudRate, a_handsake);
 }
Esempio n. 24
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     this._adtRec = devices[0];
     this.Text = this.Text + "   [Device: " + this._adtRec.PortAddress.objectInfo() + "]";
     this._ioph = new IOPH_EZLinkDongle(this._adtRec, this);
     this._tele.portHandler = this._ioph;
     this._tele.mainWin = this;
     return new IIOPortHandler[] { this._ioph };
 }
Esempio n. 25
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     _adtRec = devices[0];
     if ((_adtRec.PortAddress.Nickname != null) && (_adtRec.PortAddress.Nickname != string.Empty))
     {
         tsrMainToolStrip.Nickname = _adtRec.PortAddress.Nickname;
     }
     else
     {
         tsrMainToolStrip.Nickname = "Device [" + _adtRec.UniqId + "]";
     }
     if (_adtRec.DeviceInfo.DeviceType.TypeID == DeviceTypeID.UDP001)
     {
         _ioph = new IOPH_DATA(_adtRec, this);
     }
     else
     {
         _ioph = new IOPH_DCP(_adtRec, this);
         _teleProcessor = new TelegramSeriesLocalProcessor(this);
     }
     return new IIOPortHandler[] { _ioph };
 }
Esempio n. 26
0
        private void PollingAddDevice()
        {
            ADTManager manager = ADTManager.instance();
            IOPortAddress portAddress = new IOPortAddress
            {
                portType = PortType.RS232
            };
            int pollingAddDeviceDelay = int.Parse(ConfigurationManager.AppSettings["PollingAddDeviceDelay"]);

            _log.Debug("DDI_RS232 PollingAddDevice thread started");
            while (!_isPollerRunEnabled)
                Thread.Sleep(250);

            WDSFrameWindow window = WDS_MainProg.frameWin();
            while (!_isPollerStopped)
            {
                if (!_isPollerRunEnabled)
                    Thread.Sleep(250);
                else
                {
                    Thread.Sleep(pollingAddDeviceDelay);
                    string[] portNames = SerialPort.GetPortNames();
                    List<string> list = ADTManager.instance().syncRS232PortLists(portNames);
                    if (list != null)
                    {
                        string str = "";
                        foreach (string str2 in list)
                            str = str + str2 + " ";
                        _log.Debug("Excluded attributes are cleared for port(s): " + str);
                    }

                    List<IOPortAddress> newKnownPorts = new List<IOPortAddress>();
                    newKnownPorts = GetNewKnownPorts(portNames);
                    for (int i = 0; i < newKnownPorts.Count; i++)
                    {
                        portAddress = newKnownPorts[i];
                        if (manager.findADTRecord(portAddress) == null &&
                            !manager.isRS232PortExcluded("COM" + newKnownPorts[i].comAddr.COMPortId.ToString())
                            )
                        {
                            DeviceHandle handle = open(portAddress, 19200, 'D');
                            portAddress.handle = handle;
                            if (!manager.restoreFreezedDevice(portAddress))
                            {
                                if (!handle.isInvalid())
                                {
                                    bool bootLoaderMode;
                                    DeviceTypeID deviceType;
                                    if (isDeviceAlive(portAddress, out bootLoaderMode, out deviceType))
                                    {
                                        DeviceDescriptor devInfo = new DeviceDescriptor
                                        {
                                            BootloaderMode = bootLoaderMode
                                        };
                                        if (!bootLoaderMode)
                                        {
                                            queryDeviceInfo(portAddress.handle, devInfo);
                                            queryEBID(portAddress.handle, devInfo);
                                        }
                                        else
                                        {
                                            queryDeviceInfo(portAddress.handle, devInfo);
                                            if (devInfo.DeviceType == null)
                                            {
                                                devInfo.DeviceType = new DeviceType(deviceType);
                                                devInfo.DeviceVersion = new DeviceVersion("Unknown");
                                            }
                                        }
                                        ADTRecord record = new ADTRecord(portAddress, devInfo);
                                        if (!bootLoaderMode)
                                            InitDeviceSettings(portAddress.handle, devInfo);

                                        try
                                        {
                                            switch (((AddDeviceResult)window.Invoke(new AddDevice(window.addDevice), new object[] { record })))
                                            {
                                                case AddDeviceResult.AppStarted:
                                                    continue;
                                                case AddDeviceResult.FirmwareReplaced:
                                                case AddDeviceResult.Aborted:
                                                    close(record.PortAddress.handle);
                                                    continue;
                                                case AddDeviceResult.ExcludeOrCancel:
                                                    _log.Debug("COM" + portAddress.comAddr.COMPortId.ToString() + " port permanently excluded from WDS.");
                                                    CloseDeviceSettings(record.PortAddress.handle, devInfo);
                                                    manager.excludeRS232Port("COM" + newKnownPorts[i].comAddr.COMPortId.ToString());
                                                    close(record.PortAddress.handle);
                                                    continue;
                                            }
                                        }
                                        catch (Exception exception)
                                        {
                                            _log.Error("PollingAddDevice() - Invoking AddDevice failed " + exception.Message);
                                            close(record.PortAddress.handle);
                                        }
                                    }
                                    else
                                    {
                                        close(portAddress.handle);
                                        _log.Error("Could not communicate with device COM" + portAddress.comAddr.COMPortId.ToString() + ". The device will be excluded!");
                                        manager.excludeRS232Port("COM" + portAddress.comAddr.COMPortId.ToString());
                                    }
                                }
                                else
                                    _log.Error("PollingAddDevice() - Cannot open port: " + newKnownPorts[i]);
                            }
                        }
                    }
                }
            }
            _log.Debug("DDI_RS232 PollingAddDevice thread finished");
        }
Esempio n. 27
0
 public bool hasDevice(ADTRecord adtRecort)
 {
     return false;
 }
Esempio n. 28
0
 public bool hasDevice(ADTRecord adtRec)
 {
     return (adtRec == _adtRec);
 }
Esempio n. 29
0
 public bool hasDevice(ADTRecord adtRec)
 {
     return ((this._ioph != null) && this._ioph.hasDevice(adtRec));
 }
Esempio n. 30
0
 public void ReconnectDevice(ADTRecord adt)
 {
     _handlerReleased = false;
     _pauseBgProcessing = false;
 }