コード例 #1
0
        public Dictionary <LedId, Pin> GetPins(IHardwareInfo hardwareInfo)
        {
            var pins = new Dictionary <LedId, Pin>();

            foreach (DeviceInfo device in hardwareInfo.Devices)
            {
                try
                {
                    IDevice concreteDevice = _hardwareDeviceFactory.Create(device);

                    foreach (MapInfo mapInfo in device.Map)
                    {
                        pins.Add(mapInfo.Id, new Pin(mapInfo.Pin, concreteDevice));
                    }
                }
                catch (Exception e)
                {
                    // Here we just log that a device was not created properly. Maybe communication failed or maybe
                    // the device is not physically connected even though it is configured in the hardware configuration.
                    // We catch the exception and then we move on to try to create the other devices in the configuration.
                    // TODO: Implement some sort of status over devices. Maybe a NotConnectedDevice or ErrorDevice.
                    // Some sort of status that can be reported back to the client.
                    _logger.LogError($"Error creating and mapping Device {device.DeviceType} {device.DeviceId}", e);
                }
            }

            return(pins);
        }
コード例 #2
0
ファイル: WorkMem.cs プロジェクト: zadykian/postgres-marula
 public WorkMem(
     IHardwareInfo hardwareInfo,
     IPgSettings pgSettings,
     ILogger <WorkMem> logger) : base(logger)
 {
     this.hardwareInfo = hardwareInfo;
     this.pgSettings   = pgSettings;
 }
コード例 #3
0
 public static HardwareViewModel AssembleFromModel(IHardwareInfo model)
 {
     return(new HardwareViewModel()
     {
         ShortName = model.ShortName,
         UnitSymbol = model.UnitSymbol,
         MainValue = model.MainValue
     });
 }
コード例 #4
0
        public void GivenSupportedTarget_WhenGetCalculatedValue_ThenItReturnsProperValue()
        {
            IHardwareManager manager = GivenHardwareManager();
            IEnumerable <MonitoringTarget> initial = manager.GetInitialTargets();

            IHardwareInfo hardwareInfo = manager.GetCalculatedValue(initial.First());

            Assert.NotNull(hardwareInfo);
            Assert.NotNull(hardwareInfo.MainValue);
            Assert.NotEmpty(hardwareInfo.ShortName);
            Assert.NotEmpty(hardwareInfo.UnitSymbol);
        }
コード例 #5
0
        public void GivenViewModel_WhenAssemble_ThenItAssembleToModel()
        {
            Mock <HardwareViewModel> viewModel = new Mock <HardwareViewModel>();

            viewModel.SetupGet(m => m.ShortName).Returns(ShortName);
            viewModel.SetupGet(m => m.UnitSymbol).Returns(Unit);
            viewModel.SetupGet(m => m.MainValue).Returns(MainValue);

            IHardwareInfo model = HardwareAssembler.AssembleFromViewModel(viewModel.Object);

            Assert.NotNull(model);
            Assert.Equal(ShortName, model.ShortName);
            Assert.Equal(Unit, model.UnitSymbol);
            Assert.Equal(MainValue, model.MainValue);
        }
コード例 #6
0
        public HardwareInfo()
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                hardwareInfo = new Hardware.Info.Windows.HardwareInfo();
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) // Environment.OSVersion.Platform == PlatformID.MacOSX)
            {
                hardwareInfo = new Hardware.Info.Mac.HardwareInfo();
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) // Environment.OSVersion.Platform == PlatformID.Unix)
            {
                hardwareInfo = new Hardware.Info.Linux.HardwareInfo();
            }
        }
コード例 #7
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public HardwareInfo()
 {
     // 判断当前系统
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
     {
         _hardwareInfo = new LinuxHardwareInfoRetrieval();
     }
     else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
     {
         _hardwareInfo = new OSXHardwareInfoRetrieval();
     }
     else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         _hardwareInfo = new WindowsHardwareInfoRetrieval();
     }
     else
     {
         _hardwareInfo = new WindowsHardwareInfoRetrieval();
     }
 }
コード例 #8
0
 public AutovacuumMaxWorkers(
     IHardwareInfo hardwareInfo,
     ILogger <IntegerParameterBase> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
コード例 #9
0
 public EffectiveCacheSize(
     IHardwareInfo hardwareInfo,
     ILogger <EffectiveCacheSize> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
コード例 #10
0
 public CrashHelper()
 {
     hwInfo = new HardwareInfo();
 }
コード例 #11
0
 /// <param name="hardwareInfo">
 /// Hosting machine hardware info.
 /// </param>
 public HardwareInfoController(IHardwareInfo hardwareInfo) => this.hardwareInfo = hardwareInfo;
コード例 #12
0
        public MainViewModel(IAppInfo app, IBatteryInfo battery, INetworkInfo network, IHardwareInfo hardware)
        {
            this.App      = app;
            this.Battery  = battery;
            this.Network  = network;
            this.Hardware = hardware;

            this.ClearApp     = new Command(this.AppEvents.Clear);
            this.ClearBattery = new Command(this.BatteryEvents.Clear);
            this.ClearNetwork = new Command(this.NetworkEvents.Clear);
        }
コード例 #13
0
 public MaintenanceWorkMem(
     IHardwareInfo hardwareInfo,
     ILogger <MaintenanceWorkMem> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
コード例 #14
0
 public MaxParallelWorkers(
     IHardwareInfo hardwareInfo,
     ILogger <IntegerParameterBase> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
コード例 #15
0
 public MaxWorkerProcesses(
     IHardwareInfo hardwareInfo,
     ILogger <IntegerParameterBase> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
コード例 #16
0
 public SharedBuffers(
     IHardwareInfo hardwareInfo,
     ILogger <SharedBuffers> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;