Esempio n. 1
0
        protected override void ProcessRecord()
        {
            string Name = _dictionary[PARAM_Name].Value as string;

            List <InterfaceConfig> icList = new List <InterfaceConfig>();

            if (string.IsNullOrEmpty(Name))
            {
                foreach (ManagementObject mo in new ManagementClass("Win32_NetworkAdapter").
                         GetInstances().
                         OfType <ManagementObject>().
                         Where(x => x["NetConnectionID"] != null))
                {
                    icList.Add(InterfaceConfig.Load(mo["NetConnectionID"] as string));
                }
            }
            else
            {
                icList.Add(InterfaceConfig.Load(Name));
            }

            WriteObject(icList, true);

            _interfaceNames = null;
        }
        protected override void ProcessRecord()
        {
            List <InterfaceConfig> icList = new List <InterfaceConfig>();

            foreach (ManagementObject mo in new ManagementClass("Win32_NetworkAdapter").GetInstances())
            {
                if (IsPhysicalInterface(mo))
                {
                    icList.Add(InterfaceConfig.Load(mo["NetConnectionID"] as string));
                }
            }
            WriteObject(icList);
        }
Esempio n. 3
0
        private Configuration(string path = "")
        {
            mbase_path = (string.IsNullOrEmpty(path)) ? Mobile.GetPath() : path;

            device = "PC";
            Config config = new Config();

            mtuTypes   = config.GetMtu(Path.Combine(mbase_path, XML_MTUS));
            meterTypes = config.GetMeters(Path.Combine(mbase_path, XML_METERS));
            global     = config.GetGlobal(Path.Combine(mbase_path, XML_GLOBAL));
            interfaces = config.GetInterfaces(Path.Combine(mbase_path, XML_INTERFACE));
            alarms     = config.GetAlarms(Path.Combine(mbase_path, XML_ALARMS));
            demands    = config.GetDemandConf(Path.Combine(mbase_path, XML_DEMANDS));
            users      = config.GetUsers(Path.Combine(mbase_path, XML_USERS)).List;
            errors     = config.GetErrors(Path.Combine(mbase_path, XML_ERRORS)).List;
        }
Esempio n. 4
0
        private void ReadEnvironmentAsync()
        {
            Task.Run(() =>
            {
                try
                {
                    _environmentConfig = GlobalData.Instance.AggregatedConfig.InterfaceTypes;

                    IsTestEnvChecked   = GlobalData.Instance.AggregatedConfig.InterfaceType == InterfaceTypeStrings.Internal;
                    IsFormalEnvChecked = !IsTestEnvChecked;
                }
                catch (Exception ex)
                {
                    Log.Logger.Error($"【read environment config exception】:{ex}");
                }
            });
        }
Esempio n. 5
0
        private static Interface GetInterfaceBytMtuId(Mtu mtu)
        {
            Configuration   config        = Singleton.Get.Configuration;
            InterfaceConfig xmlInterfaces = config.interfaces;
            bool            meterIdIsNumeric;
            List <string>   portTypes = mtu.Ports[0].GetPortTypes(out meterIdIsNumeric);

            int interfaceIndex;

            // Gas MTUs of family 33xx should use family 31xx32xx memorymap
            if (mtu.IsFamilly33xx &&
                mtu.Port1.IsForPulse &&
                (mtu.Ports[0].Type.Contains("M") ||
                 mtu.Ports[0].Type.Contains("R") ||
                 (meterIdIsNumeric &&
                  config.getMeterTypeById(int.Parse(portTypes[0])).IsForGas)))
            {
                interfaceIndex = 1;  // Family 31xx32xx
            }
            else
            {
                MtuInterface iInfoMtu = xmlInterfaces.MtuInterfaces.Find(x => x.Id == mtu.Id);

                if (iInfoMtu == null)
                {
                    throw new InterfaceNotFoundException_Internal();
                }
                else
                {
                    interfaceIndex = iInfoMtu.Interface;
                }
            }

            Interface iInfo = xmlInterfaces.Interfaces.Find(x => x.Id == interfaceIndex);

            if (iInfo == null)
            {
                throw new InterfaceNotFoundException_Internal();
            }

            InterfaceConfig.currentIndexType = interfaceIndex;

            return(iInfo);
        }
Esempio n. 6
0
        public PolicyConfig LoadDefaults()
        {
            ClassConfig.LoadDefaults();
            StructConfig.LoadDefaults();
            InterfaceConfig.LoadDefaults();
            DelegateConfig.LoadDefaults();
            MethodConfig.LoadDefaults();
            EventConfig.LoadDefaults();
            FieldConfig.LoadDefaults();
            PropertyConfig.LoadDefaults();
            EnumConfig.LoadDefaults();

            SkipMerges    = true;
            SkipBranches  = true;
            SkipRollbacks = true;
            SkipUndeletes = true;

            return(this);
        }
Esempio n. 7
0
        void InitScanner()
        {
            if (emdkManager != null)
            {
                if (barcodeManager == null)
                {
                    try
                    {
                        //Get the feature object such as BarcodeManager object for accessing the feature.
                        barcodeManager = (BarcodeManager)emdkManager.GetInstance(EMDKManager.FEATURE_TYPE.Barcode);

                        scanner = barcodeManager.GetDevice(BarcodeManager.DeviceIdentifier.Default);

                        if (scanner != null)
                        {
                            //EMDK: Configure the scanner settings

                            /*ScannerConfig config = scanner.GetConfig();
                             * config.SkipOnUnsupported = ScannerConfig.SkipOnUnSupported.None;
                             * config.ScanParams.DecodeLEDFeedback = true;
                             * config.ReaderParams.ReaderSpecific.ImagerSpecific.PickList = ScannerConfig.PickList.Enabled;
                             * config.DecoderParams.Code39.Enabled = true;
                             * config.DecoderParams.Code128.Enabled = false;
                             * scanner.SetConfig(config); */
                            InterfaceConfig t = scanner.GetInterfaceConfig();
                            t.DisplayBluetoothAddressBarcode = true;
                        }
                        else
                        {
                            //TODO log status here
                        }
                    }
                    catch (ScannerException e)
                    {
                        //TODO log error here
                    }
                    catch (Exception ex)
                    {
                        //TODO log error here
                    }
                }
            }
        }
Esempio n. 8
0
        private static Interface GetInterfaceBytMtuId(Mtu mtu)
        {
            Configuration   config        = Configuration.GetInstance();
            InterfaceConfig xmlInterfaces = config.interfaces;
            bool            meterIdIsNumeric;
            List <string>   portTypes = mtu.Ports[0].GetPortTypes(out meterIdIsNumeric);

            int interfaceIndex;

            // Gas MTUs of family 33xx should use family 31xx32xx memorymap
            if (!mtu.Ecoder &&
                (mtu.Ports[0].Type.Contains("M") ||
                 mtu.Ports[0].Type.Contains("R") ||
                 (meterIdIsNumeric && config.getMeterTypeById(int.Parse(portTypes[0])).Utility.ToLower().Equals("gas"))))
            {
                interfaceIndex = 1;  // Family 31xx32xx
            }
            else
            {
                MtuInterface iInfoMtu = xmlInterfaces.MtuInterfaces.Find(x => x.Id == mtu.Id);

                if (iInfoMtu == null)
                {
                    throw new MtuNotFoundException("Mtu not found");
                }
                else
                {
                    interfaceIndex = iInfoMtu.Interface;
                }
            }

            Interface iInfo = xmlInterfaces.Interfaces.Find(x => x.Id == interfaceIndex);

            if (iInfo == null)
            {
                throw new InterfaceNotFoundException("Meter not found");
            }

            return(iInfo);
        }
Esempio n. 9
0
        public void ToggleRuleActivation(bool activate, bool recursive = true)
        {
            SkipMerges    = activate;
            SkipBranches  = activate;
            SkipRollbacks = activate;
            SkipUndeletes = activate;

            if (!recursive)
            {
                return;
            }

            ClassConfig.ToggleRuleActivation(activate);
            StructConfig.ToggleRuleActivation(activate);
            InterfaceConfig.ToggleRuleActivation(activate);
            DelegateConfig.ToggleRuleActivation(activate);
            MethodConfig.ToggleRuleActivation(activate);
            EventConfig.ToggleRuleActivation(activate);
            FieldConfig.ToggleRuleActivation(activate);
            PropertyConfig.ToggleRuleActivation(activate);
            EnumConfig.ToggleRuleActivation(activate);
        }
Esempio n. 10
0
        private static void LoadConfig()
        {
            string configPath = Path.Combine(Paths.ConfigDirectoryPath, "Interface.toml");

            var tomlSettings = TomlSettings.Create(builder => builder
                                                   .ConfigureType <Version>(type => type
                                                                            .WithConversionFor <TomlString>(convert => convert
                                                                                                            .ToToml(tt => tt.ToString())
                                                                                                            .FromToml(ft => Version.Parse(ft.Value)))));

            var oldConfig = File.Exists(configPath) ? Toml.ReadFile <InterfaceConfig>(configPath, tomlSettings) : null;

            var version       = oldConfig?.Version ?? AmoebaEnvironment.Version;
            var communication = oldConfig?.Communication ?? CreateDefaultCommunicationConfig();

            Toml.WriteFile(new InterfaceConfig(AmoebaEnvironment.Version, communication), configPath, tomlSettings);
            Config = new InterfaceConfig(version, communication);

            InterfaceConfig.CommunicationConfig CreateDefaultCommunicationConfig()
            {
                return(new InterfaceConfig.CommunicationConfig("tcp:127.0.0.1:4040"));
            }
        }
Esempio n. 11
0
        private Configuration(string path = "", bool avoidXmlError = false)
        {
            string configPath = Mobile.ConfigPath;

            device = "PC";

            try
            {
                // Load configuration files ( xml's )
                mtuTypes   = Utils.DeserializeXml <MtuTypes>        (Path.Combine(configPath, XML_MTUS));
                meterTypes = Utils.DeserializeXml <MeterTypes>      (Path.Combine(configPath, XML_METERS));
                Global     = Utils.DeserializeXml <Global>          (Path.Combine(configPath, XML_GLOBAL));
                alarms     = Utils.DeserializeXml <AlarmList>       (Path.Combine(configPath, XML_ALARMS));
                demands    = Utils.DeserializeXml <DemandConf>      (Path.Combine(configPath, XML_DEMANDS));
                users      = Utils.DeserializeXml <UserList>        (Path.Combine(configPath, XML_USERS)).List;
                interfaces = Utils.DeserializeXml <InterfaceConfig> (XML_INTERFACE, true);  // From resources

                // Preload port types, because some ports use a letter but other a list of Meter IDs
                // Done here because Xml project has no reference to MTUComm ( cross references )
                List <string> portTypes;
                foreach (Mtu mtu in mtuTypes.Mtus)
                {
                    foreach (Port port in mtu.Ports)
                    {
                        bool isNumeric = MeterAux.GetPortTypes(port.Type, out portTypes);

                        if (!isNumeric)
                        {
                            port.TypeString = portTypes[0];
                        }
                        else
                        {
                            port.TypeString = meterTypes.FindByMterId(int.Parse(portTypes[0])).Type;
                        }

                        Utils.Print("MTU " + mtu.Id + ": Type " + port.TypeString);
                    }
                }

                // Regenerate certificate from base64 string
                Mobile.configData.GenerateCert();
                //Mobile.configData.LoadCertFromKeychain ();

                // Check global min date allowed
                if (!string.IsNullOrEmpty(Global.MinDate) &&
                    DateTime.Compare(DateTime.ParseExact(Global.MinDate, "MM/dd/yyyy", null), DateTime.Today) < 0)
                {
                    throw new DeviceMinDateAllowedException();
                }
            }
            catch (Exception e)
            {
                if (!avoidXmlError)
                {
                    if (Errors.IsOwnException(e))
                    {
                        throw e;
                    }
                    else if (e is FileNotFoundException)
                    {
                        throw new ConfigurationFilesNotFoundException();
                    }
                    else
                    {
                        throw new ConfigurationFilesCorruptedException();
                    }
                }
            }
        }
Esempio n. 12
0
 public InterfaceController(InterfaceMaster interfaceMaster, InterfaceConfig interfaceConfig, InterfaceData interfaceData)
 {
     this.interfaceMaster = interfaceMaster;
     this.interfaceConfig = interfaceConfig;
     this.interfaceData   = interfaceData;
 }