Ejemplo n.º 1
0
 private void LoadOffsets()
 {
     _spdIntv  = null;
     _altIntv  = null;
     _rate10   = null;
     _rate15   = null;
     _rate20   = null;
     _rate25   = null;
     _rate30   = null;
     _rateMode = false;
     _rate     = 0;
     try
     {
         if (DeviceConfiguration is simPROJECT.Configuration.MCP737Configuration)
         {
             string configFile = ((simPROJECT.Configuration.MCP737Configuration)DeviceConfiguration).ProsimConfigFile;
             if (!string.IsNullOrEmpty(configFile) && File.Exists(configFile))
             {
                 XmlDocument xml = new XmlDocument();
                 xml.Load(configFile);
                 _spdIntv = ProsimOffset.Load(xml.SelectSingleNode("//config/mappings/mapping[@connection='MCP Speed Int Pushed']"));
                 _altIntv = ProsimOffset.Load(xml.SelectSingleNode("//config/mappings/mapping[@connection='MCP Alt Int Pushed']"));
                 _rate10  = ProsimOffset.Load(xml.SelectSingleNode("//config/mappings/mapping[@connection='MCP Bank limit 10']"));
                 _rate15  = ProsimOffset.Load(xml.SelectSingleNode("//config/mappings/mapping[@connection='MCP Bank limit 15']"));
                 _rate20  = ProsimOffset.Load(xml.SelectSingleNode("//config/mappings/mapping[@connection='MCP Bank limit 20']"));
                 _rate25  = ProsimOffset.Load(xml.SelectSingleNode("//config/mappings/mapping[@connection='MCP Bank limit 25']"));
                 _rate30  = ProsimOffset.Load(xml.SelectSingleNode("//config/mappings/mapping[@connection='MCP Bank limit 30']"));
             }
         }
     }
     catch { }
 }
Ejemplo n.º 2
0
        public static ProsimOffset Load(XmlNode node)
        {
            try
            {
                ProsimOffset result = null;
                node = node.SelectSingleNode("fsuipc");
                if (node != null)
                {
                    string serial = node.Attributes["serial"].Value;
                    int    port   = int.Parse(node.Attributes["port"].Value);
                    byte   type   = (byte)(port >> 16 & 3);
                    if (type == 2)
                    {
                        int off = port & 0xffff;
                        int val = port >> 18;
                        FS.SimpleVariable offset      = new simPROJECT.FS.SimpleVariable(off);
                        FS.SimpleVariable offsetReset = new simPROJECT.FS.SimpleVariable(off);
                        offset.ForWriting      = true;
                        offsetReset.ForWriting = true;
                        switch (serial)
                        {
                        case "8 bit U":
                            offset.ValueSize      = 1;
                            offsetReset.ValueSize = 1;
                            offset.Value1         = (byte)val;
                            break;

                        case "16 bit U":
                        case "16 bit S":
                            offset.ValueSize      = 2;
                            offsetReset.ValueSize = 2;
                            offset.Value2         = (short)val;
                            break;

                        case "32 bit U":
                        case "32 bit S":
                            offset.ValueSize      = 4;
                            offsetReset.ValueSize = 4;
                            offset.Value4         = val;
                            break;

                        default:
                            return(null);
                        }
                        result              = new ProsimOffset();
                        result._offset      = offset;
                        result._offsetReset = offsetReset;
                    }
                }
                return(result);
            }
            catch
            {
                return(null);
            }
        }