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); }
public WorkMem( IHardwareInfo hardwareInfo, IPgSettings pgSettings, ILogger <WorkMem> logger) : base(logger) { this.hardwareInfo = hardwareInfo; this.pgSettings = pgSettings; }
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); }
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); }
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(); } }
public AutovacuumMaxWorkers( IHardwareInfo hardwareInfo, ILogger <IntegerParameterBase> logger) : base(logger) => this.hardwareInfo = hardwareInfo;
public EffectiveCacheSize( IHardwareInfo hardwareInfo, ILogger <EffectiveCacheSize> logger) : base(logger) => this.hardwareInfo = hardwareInfo;
public CrashHelper() { hwInfo = new HardwareInfo(); }
/// <param name="hardwareInfo"> /// Hosting machine hardware info. /// </param> public HardwareInfoController(IHardwareInfo hardwareInfo) => this.hardwareInfo = hardwareInfo;
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;
public SharedBuffers( IHardwareInfo hardwareInfo, ILogger <SharedBuffers> logger) : base(logger) => this.hardwareInfo = hardwareInfo;