コード例 #1
0
ファイル: DeviceType.cs プロジェクト: x893/WDS
 public DeviceType(DeviceTypeID a_typeID)
 {
     this._licenseList = new List<LicenseItem>();
     this._compatibleComponentDescriptor = new CompatibleDeviceDescriptor();
     this._deviceVersionList = new List<DeviceVersion>();
     this._typeID = a_typeID;
 }
コード例 #2
0
ファイル: ADCRRecord.cs プロジェクト: x893/WDS
 public ADCRRecord(WDS_Extension.ApplicationDescriptor app, CompatibleDeviceDescriptor devices, CompatibleChipDescriptor chips, CompatibleLicenseDescriptor licenses)
 {
     this._applicationDescriptor = app;
     this._compatibleDevices = devices;
     this._compatibleChips = chips;
     this._compatibleLicenses = licenses;
 }
コード例 #3
0
ファイル: DeviceType.cs プロジェクト: x893/WDS
 public DeviceType(string a_typeName)
 {
     this._licenseList = new List<LicenseItem>();
     this._compatibleComponentDescriptor = new CompatibleDeviceDescriptor();
     this._deviceVersionList = new List<DeviceVersion>();
     try
     {
         Enum.GetNames(typeof(DeviceTypeID));
         this._typeID = (DeviceTypeID) Enum.Parse(typeof(DeviceTypeID), a_typeName);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Incompatible Device Type Name");
     }
 }
コード例 #4
0
 private void BrowseFirmwareButton_Click(object sender, EventArgs e)
 {
     OpenFileDialog dialog = new OpenFileDialog {
         Filter = "WDS hex files (*.whf)|*.whf|Intel hex files (*.hex)|*.hex",
         RestoreDirectory = true
     };
     int index = -1;
     if (this.lstSelectFirmware.SelectedItems.Count > 0)
     {
         index = this.lstSelectFirmware.SelectedItems[0].Index;
     }
     try
     {
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             FirmwareItem firmwareItem = IO_FD_Main.GetFirmwareItem(dialog.FileName);
             if (firmwareItem.type == null)
             {
                 CompatibleDeviceDescriptor item = new CompatibleDeviceDescriptor();
                 item.addDeviceType(this._adtRec.DeviceInfo.DeviceType.TypeID);
                 firmwareItem.supportedDeviceList.Add(item);
                 if ((this.lstSelectMcu.SelectedItems.Count > 0) && (this._adtRec.DeviceInfo.DeviceType.TypeID.ToString() != this.lstSelectMcu.SelectedItems[0].Text))
                 {
                     firmwareItem.supportedDeviceList[firmwareItem.supportedDeviceList.Count - 1].DeviceList[0].CompatibleComponentDescriptor.addDeviceType(this.lstSelectMcu.SelectedItems[0].Text);
                 }
                 firmwareItem.name = Path.GetFileNameWithoutExtension(dialog.FileName);
                 firmwareItem.date = DateTime.Now;
                 firmwareItem.version = new FirmwareVersion("0.1r");
                 firmwareItem.type = new FirmwareType("Unknown");
             }
             DeviceDescriptor deviceInfo = this._adtRec.DeviceInfo;
             if (!firmwareItem.supportedDeviceList[firmwareItem.supportedDeviceList.Count - 1].IsCompatible(deviceInfo, HwVersion.Upper, FwVersion.Lower, true))
             {
                 throw new Exception("The selected firmware does not compatible with the board attached.");
             }
             ArrayList list = new ArrayList(this._firmwareItems);
             list.Add(firmwareItem);
             this._firmwareItems = (FirmwareItem[]) list.ToArray(typeof(FirmwareItem));
             this.lstSelectFirmware.Items.Add(firmwareItem.getFWDownloadListViewItem());
             this.lstSelectFirmware.Items[this.lstSelectFirmware.Items.Count - 1].Selected = true;
             this.DownloadButton.Enabled = true;
         }
     }
     catch (Exception exception)
     {
         if ((index < this.lstSelectFirmware.Items.Count) && (index >= 0))
         {
             this.lstSelectFirmware.Items[index].Selected = true;
         }
         this.firmwareUpdateCallback(0, true, "The file " + dialog.FileName + " is not a valid firmware. \n\r" + exception.Message, MessageBoxButtons.OK);
     }
 }
コード例 #5
0
ファイル: DDI_USB.cs プロジェクト: x893/WDS
 private void Polling()
 {
     ADTManager manager = ADTManager.instance();
     List<IOPortAddress> list = new List<IOPortAddress>();
     IOPortAddress item = new IOPortAddress();
     int nrOfDevices = 0;
     int count = 0;
     int locationID = 0;
     StringBuilder description = new StringBuilder();
     StringBuilder serialNumber = new StringBuilder();
     while (!this._isPollerRunEnabled)
     {
         Thread.Sleep(0x3e8);
     }
     WDSFrameWindow window = WDS_MainProg.frameWin();
     while (true)
     {
         while (!this._isPollerRunEnabled)
         {
             Thread.Sleep(0x3e8);
         }
         count = manager.getADTRecords(PortType.USB_FTDI, true).Count;
         uint num3 = FTDIWrapper.GetNrOfDevices(ref nrOfDevices);
         if (count != nrOfDevices)
         {
             list.Clear();
             for (int i = 0; i < nrOfDevices; i++)
             {
                 item = new IOPortAddress {
                     portType = PortType.USB_FTDI
                 };
                 item.usbFtdiAddr.DeviceIdx = i;
                 num3 = FTDIWrapper.GetLocationID(i, ref locationID);
                 while ((num3 != 0) && (num3 != 1))
                 {
                     GlobalServices.LogMsg(i.ToString() + " " + num3.ToString(), "asdf");
                     num3 = FTDIWrapper.GetLocationID(i, ref locationID);
                     Thread.Sleep(500);
                 }
                 item.usbFtdiAddr.LocationId = locationID;
                 num3 = FTDIWrapper.GetSerialNumber(i, serialNumber);
                 item.usbFtdiAddr.SerialNo = serialNumber.ToString();
                 num3 = FTDIWrapper.GetDescription(i, description);
                 item.usbFtdiAddr.Description = description.ToString();
                 list.Add(item);
             }
             if (count < nrOfDevices)
             {
                 foreach (IOPortAddress address2 in list)
                 {
                     if (manager.findADTRecord(address2) == null)
                     {
                         try
                         {
                             object[] args = new object[5];
                             args[0] = "Add Device (found by USB_FTDI Plug & Play handler)";
                             args[1] = address2;
                             args[3] = "Exclude Device";
                             args[4] = new CompatibleDeviceDescriptor();
                             if (((AddDeviceResult) window.Invoke(new AddDevice(window.addDevice), args)) == AddDeviceResult.ExcludeOrCancel)
                             {
                             }
                         }
                         catch
                         {
                             GlobalServices.ErrMsg("DDI_USB_FTDI", "Invoking AddDevice failed");
                         }
                     }
                 }
             }
             else
             {
                 bool flag = false;
                 foreach (ADTRecord record in manager.getADTRecords(PortType.USB_FTDI, true))
                 {
                     foreach (IOPortAddress address3 in list)
                     {
                         if (record.PortAddress.isEqual(address3))
                         {
                             flag = true;
                         }
                     }
                     if (!flag && (manager.removeADTRecord(record) != -1))
                     {
                         try
                         {
                             WDSApplicationManager.instance().closeApplications(record);
                         }
                         catch
                         {
                             GlobalServices.ErrMsg("DDI_USB_FTDI", "Invoking RemoveDevice failed");
                         }
                     }
                     flag = false;
                 }
             }
         }
         else
         {
             Thread.Sleep(0x3e8);
         }
     }
 }
コード例 #6
0
ファイル: ADCRManager.cs プロジェクト: x893/WDS
        private void loadADCRRecordsFromXml()
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            executingAssembly.GetManifestResourceNames();
            Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("NewWDS.WDS_Resources.ADCR.xml");
            List<ADCRRecord> list = new List<ADCRRecord>();
            try
            {
                XmlDocument document = new XmlDocument();
                document.Load(manifestResourceStream);
                foreach (XmlNode node in document.GetElementsByTagName("ADCR_Record"))
                {
                    ApplicationDescriptor app = new ApplicationDescriptor();
                    CompatibleDeviceDescriptor comaptibleDevices = new CompatibleDeviceDescriptor();
                    CompatibleChipDescriptor chips = new CompatibleChipDescriptor();
                    CompatibleLicenseDescriptor licenses = new CompatibleLicenseDescriptor();
                    foreach (XmlNode node2 in node.ChildNodes)
                    {
                        string name = node2.Name;
                        if (name != null)
                        {
                            if (!(name == "Application"))
                            {
                                if (name == "Chips")
                                {
                                    goto Label_0377;
                                }
                                if (name == "Devices")
                                {
                                    goto Label_053F;
                                }
                            }
                            else
                            {
                                foreach (XmlNode node3 in node2.ChildNodes)
                                {
                                    switch (node3.Name)
                                    {
                                        case "Type":
                                            app.AppType = this.getAppTypeItemByName(node3.InnerText);
                                            break;

                                        case "Class":
                                            app.AppClass = this.getAppClassItemByName(node3.InnerText);
                                            break;

                                        case "Name":
                                            app.AppName = node3.InnerText;
                                            break;

                                        case "Description":
                                            app.ApplicationDescription = node3.InnerText;
                                            break;

                                        case "Simulation":
                                            app.SimulationCapable = bool.Parse(node3.InnerText);
                                            break;

                                        case "Advanced":
                                            app.Advanced = bool.Parse(node3.InnerText);
                                            break;

                                        case "StartupApplication":
                                            app.StartupApplication = node3.InnerText;
                                            break;

                                        case "EBIDRequired":
                                            app.EBIDRequired = bool.Parse(node3.InnerText);
                                            break;

                                        case "AllowedToRunOnDifferentFwType":
                                            app.AllowedToRunOnDifferentFwType = bool.Parse(node3.InnerText);
                                            break;

                                        case "TopOnAppList":
                                            app.TopOnAppList = bool.Parse(node3.InnerText);
                                            break;

                                        case "Licenses":
                                            foreach (XmlNode node4 in node3.ChildNodes)
                                            {
                                                if ((node4.NodeType != XmlNodeType.Comment) && (node4.Name == "Name"))
                                                {
                                                    LicenseItem item = new LicenseItem {
                                                        Name = node4.InnerText
                                                    };
                                                    licenses.LicenseList.Add(item);
                                                }
                                            }
                                            break;
                                    }
                                }
                            }
                        }
                        continue;
                    Label_0377:
                        foreach (XmlNode node5 in node2.ChildNodes)
                        {
                            CDTRecord record = new CDTRecord();
                            foreach (XmlNode node6 in node5.ChildNodes)
                            {
                                string str3 = node6.Name;
                                if (str3 != null)
                                {
                                    if (!(str3 == "Type"))
                                    {
                                        if (str3 == "Revision")
                                        {
                                            goto Label_042D;
                                        }
                                        if (str3 == "DefaultRev")
                                        {
                                            goto Label_0440;
                                        }
                                        if (str3 == "Advanced")
                                        {
                                            goto Label_0458;
                                        }
                                        if (str3 == "Licenses")
                                        {
                                            goto Label_046D;
                                        }
                                    }
                                    else
                                    {
                                        record.ChipType = node6.InnerText;
                                    }
                                }
                                continue;
                            Label_042D:
                                record.ChipRevision = node6.InnerText;
                                continue;
                            Label_0440:
                                record.DefaultRev = bool.Parse(node6.InnerText);
                                continue;
                            Label_0458:
                                record.Advanced = bool.Parse(node6.InnerText);
                                continue;
                            Label_046D:
                                foreach (XmlNode node7 in node6.ChildNodes)
                                {
                                    if ((node7.NodeType != XmlNodeType.Comment) && (node7.Name == "Name"))
                                    {
                                        LicenseItem item2 = new LicenseItem {
                                            Name = node7.InnerText
                                        };
                                        record.LicenseList.Add(item2);
                                    }
                                }
                            }
                            chips.ChipList.Add(record);
                        }
                        continue;
                    Label_053F:
                        this.parseCompatibleDevices(comaptibleDevices, node2);
                    }
                    list.Add(new ADCRRecord(app, comaptibleDevices, chips, licenses));
                }
                this._adcrRecordSet = list.ToArray();
            }
            catch (Exception exception)
            {
                MessageBox.Show("ADCR XML Reading error! \n" + exception.Message, "ADCRManager.loadADCRRecordsFromXml()");
            }
        }
コード例 #7
0
ファイル: ADCRManager.cs プロジェクト: x893/WDS
 public void parseCompatibleDevices(List<CompatibleDeviceDescriptor> comaptibleDeviceList, XmlNode subNode)
 {
     foreach (XmlNode node in subNode.ChildNodes)
     {
         if ((node.NodeType != XmlNodeType.Comment) && (node.Attributes != null))
         {
             CompatibleDeviceDescriptor descriptor = new CompatibleDeviceDescriptor();
             descriptor.addDeviceType(node.Attributes[0].InnerText);
             foreach (XmlNode node2 in node.ChildNodes)
             {
                 string name = node2.Name;
                 if (name != null)
                 {
                     if (!(name == "DeviceVersion"))
                     {
                         if (name == "DeviceComponents")
                         {
                             goto Label_0221;
                         }
                         if (name == "Licenses")
                         {
                             goto Label_029E;
                         }
                     }
                     else if (node2.Attributes != null)
                     {
                         descriptor.addDeviceVersion(node.Attributes[0].InnerText, node2.Attributes[0].InnerText);
                         foreach (XmlNode node3 in node2.ChildNodes)
                         {
                             string str2;
                             if ((((str2 = node3.Name) != null) && (str2 == "FirmwareType")) && (node3.Attributes != null))
                             {
                                 descriptor.addFirmwareType(node.Attributes[0].InnerText, node2.Attributes[0].InnerText, node3.Attributes[0].InnerText);
                                 foreach (XmlNode node4 in node3.ChildNodes)
                                 {
                                     if (node4.Attributes != null)
                                     {
                                         descriptor.addFirmwareVersion(node.Attributes[0].InnerText, node2.Attributes[0].InnerText, node3.Attributes[0].InnerText, node4.Attributes[0].InnerText);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 continue;
             Label_0221:
                 foreach (XmlNode node5 in node2.ChildNodes)
                 {
                     if ((node5.NodeType != XmlNodeType.Comment) && (node5.Name == "DeviceType"))
                     {
                         this.parseCompatibleDevices(descriptor.getCompatibleComponentDescriptor(node.Attributes[0].InnerText), node2);
                         break;
                     }
                 }
                 continue;
             Label_029E:
                 foreach (XmlNode node6 in node2.ChildNodes)
                 {
                     if ((node6.NodeType != XmlNodeType.Comment) && (node6.Name == "Name"))
                     {
                         LicenseItem license = new LicenseItem {
                             Name = node6.InnerText
                         };
                         descriptor.addLicense(node.Attributes[0].InnerText, license);
                     }
                 }
             }
             comaptibleDeviceList.Add(descriptor);
         }
     }
 }