コード例 #1
0
        public static DeviceDictionary Find(UInt16 id, UInt16 version)
        {
            string dir = Directory.GetCurrentDirectory();

            string[] files = Directory.GetFiles(dir, "*.xml");
            foreach (var file in files)
            {
                string cutted_name = file.Replace(dir, "");
                cutted_name = cutted_name.Replace("\\", "");
                cutted_name = cutted_name.Replace(".xml", "");
                var parts = cutted_name.Split('_');
                if (parts.Length == 3)
                {
                    UInt16[] t = new UInt16[3];
                    t[0] = Convert.ToUInt16(parts[0], 16);
                    t[1] = Convert.ToUInt16(parts[1], 16);
                    t[2] = Convert.ToUInt16(parts[2], 16);

                    if ((id == t[0]) && (version >= t[1]) && (version <= t[2]))
                    {
                        XmlSerializer    x          = new XmlSerializer(typeof(DeviceDictionary));
                        TextReader       reader     = new StreamReader(file);
                        DeviceDictionary dictionary = (DeviceDictionary)x.Deserialize(reader);
                        reader.Close();
                        return(dictionary);
                    }
                }
            }
            throw new Exception("Нет подходящего файла с описание устройства");
        }
コード例 #2
0
        void deviceWasChanged(object sender, EventArgs args)
        {
            UInt16[] gendata = _device._gen_data.ReadDeviceData();
            _dictionary = DeviceDictionary.Find(gendata[0], gendata[1]);



            GeneralInfo = new ROTableComposition(_device._gen_data, _dictionary.GenItems, "General info");
            ROInfo      = new ROTableComposition(_device._RO_data, _dictionary.ROItems, "Read-Only");
            RWInfo      = new RWTableComposition(_device._RW_data, _dictionary.RWItems, "Read-Write");
            RWFlashInfo = new RWTableComposition(_device._RW_flash, _dictionary.RWFlashItems, "Read-Write Flash");

            if (TablesWereCreated != null)
            {
                TablesWereCreated(this, null);
            }
        }