Пример #1
0
        public bool parseXml(string xml)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(xml);

                XmlNodeList mbeds = doc.SelectNodes("/mbedsimulator/mbed");
                if (mbeds != null)
                {
                    foreach (XmlNode node in mbeds)
                    {
                        MbedProgramInfo info = new MbedProgramInfo();

                        XmlElement elm = (XmlElement)node;
                        info.name    = elm.GetAttribute("name");
                        info.dllname = elm.GetAttribute("dll");
                        info.vizname = elm.GetAttribute("viz");
                        if (!string.IsNullOrEmpty(info.vizname))
                        {
                            if (!Path.IsPathRooted(info.vizname))
                            {
                                info.vizname = Path.Combine(Path.GetDirectoryName(xml), info.vizname);
                            }
                        }
                        info.has_display = false;
                        info.has_serial  = false;
                        if (elm.SelectSingleNode("./textlcd") != null)
                        {
                            info.has_display = true;
                        }
                        if (elm.SelectSingleNode("./serial") != null)
                        {
                            info.has_serial = true;
                        }
                        List <Device> devices  = new List <Device>();
                        XmlNodeList   subnodes = elm.ChildNodes;
                        if (subnodes != null)
                        {
                            devices.AddRange((from XmlNode n in subnodes select createDevice((XmlElement)n)).Where(d => d.type != DeviceType.Unknown));
                        }

                        info.devices = devices.ToArray();
                        Model.add_info(info);
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Пример #2
0
 private mbedsimulatorctr.MbedEmulator createModel(MbedProgramInfo info, IMbedEmulatorCB cb)
 {
     mbedsimulatorctr.MbedEmulator emu = new MbedEmulator(info, cb);
     return(emu);
 }
Пример #3
0
 public void add_info(MbedProgramInfo mpi)
 {
     _infos.Add(mpi);
 }