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);
        }
Example #2
0
 public WorkMem(
     IHardwareInfo hardwareInfo,
     IPgSettings pgSettings,
     ILogger <WorkMem> logger) : base(logger)
 {
     this.hardwareInfo = hardwareInfo;
     this.pgSettings   = pgSettings;
 }
Example #3
0
 public static HardwareViewModel AssembleFromModel(IHardwareInfo model)
 {
     return(new HardwareViewModel()
     {
         ShortName = model.ShortName,
         UnitSymbol = model.UnitSymbol,
         MainValue = model.MainValue
     });
 }
        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);
        }
Example #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);
        }
Example #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();
            }
        }
 /// <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();
     }
 }
Example #8
0
 public AutovacuumMaxWorkers(
     IHardwareInfo hardwareInfo,
     ILogger <IntegerParameterBase> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
Example #9
0
 public EffectiveCacheSize(
     IHardwareInfo hardwareInfo,
     ILogger <EffectiveCacheSize> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
Example #10
0
 public CrashHelper()
 {
     hwInfo = new HardwareInfo();
 }
Example #11
0
 /// <param name="hardwareInfo">
 /// Hosting machine hardware info.
 /// </param>
 public HardwareInfoController(IHardwareInfo hardwareInfo) => this.hardwareInfo = hardwareInfo;
Example #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);
        }
 public MaintenanceWorkMem(
     IHardwareInfo hardwareInfo,
     ILogger <MaintenanceWorkMem> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
 public MaxParallelWorkers(
     IHardwareInfo hardwareInfo,
     ILogger <IntegerParameterBase> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
 public MaxWorkerProcesses(
     IHardwareInfo hardwareInfo,
     ILogger <IntegerParameterBase> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;
Example #16
0
 public SharedBuffers(
     IHardwareInfo hardwareInfo,
     ILogger <SharedBuffers> logger) : base(logger)
     => this.hardwareInfo = hardwareInfo;