public CreateProfileDialog(string title, DevicesManager devicesManager) { ViewModel = new CreateProfileDialogViewModel(title, devicesManager); DataContext = ViewModel; InitializeComponent(); Loaded += OnLoaded; }
public CreateProfileDialogViewModel(string title, DevicesManager devicesManager) { Title = title; DevicesManager = devicesManager; var inputDevices = devicesManager.GetAvailableDeviceList(DeviceIoType.Input); var outputDevices = devicesManager.GetAvailableDeviceList(DeviceIoType.Output); InputControl = new DeviceSelectControlViewModel("Input Devices", inputDevices); OutputControl = new DeviceSelectControlViewModel("Output Devices", outputDevices); }
public MainForm() { InitializeComponent(); SetVersionInformation(); _writeButtonState = WriteButtonState.WRITE; _deiceManager = new DevicesManager(); DevicesManager.DeviceNumber = Convert.ToByte(_deviceNumberTextBox.Text); _moduleManager = new ModuleManager(); _queryProgress = new Progress <QueryReport>(OnQueryProgressChanged); ConnectionManager.Progress = _queryProgress; }
public MainForm() { InitializeComponent(); SetVersionInformation(); _writeButtonState = WriteButtonState.WRITE; _deiceManager = new DevicesManager(); DevicesManager.DeviceNumber = Convert.ToByte(_deviceNumberTextBox.Text); _moduleManager = new ModuleManager(); _queryProgress = new Progress <QueryReport>(OnQueryProgressChanged); ConnectionManager.SelectedPort = Settings.Default.Port.ToString(); ConnectionManager.Progress = _queryProgress; _comportLable.Text = "COM" + ConnectionManager.SelectedPort; }
private void Init() { IsNotSaved = false; Profiles = new List <Profile>(); InputGroups = new List <DeviceGroup>(); OutputGroups = new List <DeviceGroup>(); IOController = new IOController(); ProfilesManager = new ProfilesManager(this, Profiles); DevicesManager = new DevicesManager(this); DeviceGroupsManager = new DeviceGroupsManager(this, InputGroups, OutputGroups); SubscriptionsManager = new SubscriptionsManager(this); PluginManager = new PluginsManager(PluginPath); }
/// <summary> /// 初始化缓存 /// </summary> /// <returns>设备集合</returns> private List <FlowDevice> InitCache() { _logger.LogInformation((int)LogEvent.系统, "初始化缓存"); IMemoryCache memoryCache = _serviceProvider.GetRequiredService <IMemoryCache>(); using (IServiceScope serviceScope = _serviceProvider.CreateScope()) { CodesManager codesManager = serviceScope.ServiceProvider.GetRequiredService <CodesManager>(); memoryCache.InitSystemCache(codesManager.GetList()); DevicesManager devicesManager = serviceScope.ServiceProvider.GetRequiredService <DevicesManager>(); List <FlowDevice> devices = devicesManager.GetList(null, 0, 0, null, null, null, 0, 0).Datas; memoryCache.InitDeviceCache(devices); RoadCrossingsManager roadCrossingsManager = serviceScope.ServiceProvider.GetRequiredService <RoadCrossingsManager>(); memoryCache.InitCrossingCache(roadCrossingsManager.GetList(null, 0, 0).Datas); RoadSectionsManager roadSectionsManager = serviceScope.ServiceProvider.GetRequiredService <RoadSectionsManager>(); memoryCache.InitSectionCache(roadSectionsManager.GetList(null, 0, 0, 0).Datas); return(devices); } }
private void Init() { IsNotSaved = false; Profiles = new List <Profile>(); try { IOController = new IOController(); } catch (DirectoryNotFoundException e) { Logger.Error("IOWrapper provider directory not found", e); } ProfilesManager = new ProfilesManager(this, Profiles); DevicesManager = new DevicesManager(this); SubscriptionsManager = new SubscriptionsManager(this); PluginManager = new PluginsManager(PluginPath); BindingManager = new BindingManager(this); }
private async Task <int> SendMessageToHubAsync(bool _state, RequestType _requestType, string deviceId) { Message message = new Message { messageType = MessageType.REQUEST, state = _state, requestType = _requestType, returnCode = 0 }; string jsonObject = JsonConvert.SerializeObject(message); configuration.DeviceId = deviceId; DevicesManager deviceManager = new DevicesManager(configuration); configuration.DeviceKey = await deviceManager.AddDeviceOrGetKeyAsync(deviceId); MessageSender messageSender = new MessageSender(configuration); messageSender.SendMessageAsync(jsonObject); return(0); }
/// <summary> /// 初始化缓存 /// </summary> /// <returns>设备集合</returns> private List <DensityDevice> InitCache() { _logger.LogInformation((int)LogEvent.系统, "初始化缓存"); DensityCache.DensitiesCache.Clear(); EventCache.LastEventsCache.Clear(); WebSocketMiddleware.ClearUrl(); WebSocketMiddleware.AddUrl(EventWebSocketBlock.EventUrl); DateTime now = DateTime.Now; DateTime yesterday = now.Date.AddDays(-1); IMemoryCache memoryCache = _serviceProvider.GetRequiredService <IMemoryCache>(); using (IServiceScope serviceScope = _serviceProvider.CreateScope()) { CodesManager codesManager = serviceScope.ServiceProvider.GetRequiredService <CodesManager>(); memoryCache.InitSystemCache(codesManager.GetList()); DevicesManager devicesManager = serviceScope.ServiceProvider.GetRequiredService <DevicesManager>(); List <DensityDevice> devices = devicesManager.GetList(null, 0, 0, null, null, 0, 0).Datas; memoryCache.InitDeviceCache(devices); RoadCrossingsManager roadCrossingsManager = serviceScope.ServiceProvider.GetRequiredService <RoadCrossingsManager>(); memoryCache.InitCrossingCache(roadCrossingsManager.GetList(null, 0, 0).Datas); DensitiesManager densitiesManager = serviceScope.ServiceProvider.GetRequiredService <DensitiesManager>(); foreach (DensityDevice device in devices) { foreach (var relation in device.DensityDevice_DensityChannels) { foreach (TrafficRegion region in relation.Channel.Regions) { DensityCache.DensitiesCache.TryAdd(region.DataId, new ConcurrentQueue <TrafficDensity>(densitiesManager.QueryList(region.DataId, DateTimeLevel.Minute, yesterday, now))); WebSocketMiddleware.AddUrl($"{DensityWebSocketBlock.DensityUrl}{region.DataId}"); } } } return(devices); } }
public Workspace(bool suppressMapping) { DevicesManager = new DevicesManager(App.Current.Dispatcher, suppressMapping); }
public Workspace() { DevicesManager = new DevicesManager(App.Current.Dispatcher); }
private void DevicesComboBox_Format(object sender, ListControlConvertEventArgs e) { e.Value = DevicesManager.GetDevicePath((IDiscRecorder2)e.ListItem); }
public Form1() { InitializeComponent(); devicesManger = new DevicesManager(); filesManager = new FileManager(backgroundBurnWorker); }
/// <summary> /// Constructs a Service1 instance. /// </summary> /// <param name="devicesManager">Singleton istance of devices manager.</param> public DataReceiverFactory(DevicesManager devicesManager) { this.devicesManager = devicesManager; }
public override void Handle(DateTime lastTime, DateTime currentTime, DateTime nextTime) { HttpClient client = _httpClientFactory.CreateClient(); List <DensityDevice> devices = _memoryCache.GetDevices(); using (IServiceScope serviceScope = _serviceProvider.CreateScope()) { DevicesManager devicesManager = serviceScope.ServiceProvider.GetRequiredService <DevicesManager>(); ChannelsManager channelsManager = serviceScope.ServiceProvider.GetRequiredService <ChannelsManager>(); foreach (DensityDevice device in devices) { int oldDeviceStatus = device.DeviceStatus; List <int> oldChannelStatuses = device.DensityDevice_DensityChannels .Select(c => c.Channel.ChannelStatus) .ToList(); DensityChannelList statusModel = client.Get <DensityChannelList>($"http://{device.Ip}:{device.Port}/api/channel/list"); if (statusModel != null && statusModel.Code == 0) { device.DeviceStatus = (int)DeviceStatus.正常; _logger.LogDebug((int)LogEvent.设备检查, $"设备正常 {device.Ip}"); foreach (var relation in device.DensityDevice_DensityChannels) { var model = statusModel.Data.FirstOrDefault(c => c.ChannelId == relation.Channel.ChannelIndex); if (model == null) { relation.Channel.ChannelStatus = (int)DeviceStatus.异常; _logger.LogDebug((int)LogEvent.设备检查, $"通道异常 {device.Ip}_{relation.Channel.ChannelName} 未找到通道"); } else { if (model.Status == 1) { relation.Channel.ChannelStatus = (int)DeviceStatus.正常; _logger.LogDebug((int)LogEvent.设备检查, $"通道正常 {device.Ip}_{relation.Channel.ChannelName}"); } else { relation.Channel.ChannelStatus = (int)DeviceStatus.异常; _logger.LogDebug((int)LogEvent.设备检查, $"通道异常 {device.Ip}_{relation.Channel.ChannelName} 状态值:{model.Status}"); } } } } else { device.DeviceStatus = (int)DeviceStatus.异常; foreach (var relation in device.DensityDevice_DensityChannels) { relation.Channel.ChannelStatus = (int)DeviceStatus.异常; } _logger.LogDebug((int)LogEvent.设备检查, $"设备异常 {device.Ip} 接口返回错误 {statusModel?.Code}"); } if (oldDeviceStatus != device.DeviceStatus) { IStatusCodeActionResult deviceResult = devicesManager.UpdateStatus(new DensityDeviceUpdateStatus { DeviceId = device.DeviceId, DeviceStatus = device.DeviceStatus }); _logger.LogDebug((int)LogEvent.设备检查, $"设备 {device.Ip} 更新结果:{deviceResult.StatusCode}"); } for (int i = 0; i < oldChannelStatuses.Count; ++i) { if (oldChannelStatuses[i] != device.DensityDevice_DensityChannels[i].Channel.ChannelStatus) { IStatusCodeActionResult channelResult = channelsManager.UpdateStatus(new DensityChannelUpdateStatus { ChannelId = device.DensityDevice_DensityChannels[i].Channel.ChannelId, ChannelStatus = device.DensityDevice_DensityChannels[i].Channel.ChannelStatus }); _logger.LogDebug((int)LogEvent.设备检查, $"通道 {device.Ip}_{device.DensityDevice_DensityChannels[i].Channel.ChannelName} 状态:{device.DensityDevice_DensityChannels[i].Channel.ChannelStatus} 结果:{channelResult.StatusCode}"); } } } _result.Clear(); foreach (DensityDevice device in devices) { _result.TryAdd($"设备-{device.DeviceName}_{device.Ip}", ((DeviceStatus)device.DeviceStatus).ToString()); foreach (var relation in device.DensityDevice_DensityChannels) { _result.TryAdd($"通道-{relation.Channel.ChannelName}_{relation.Channel.ChannelIndex}", ((DeviceStatus)relation.Channel.ChannelStatus).ToString()); } } } }
public UserDevicesController(DevicesManager devicesManager, IMapper mapper) { _devicesManager = devicesManager; _mapper = mapper; }
/// <summary> /// Constructs a Service1 instance. /// </summary> public Service1() { devicesManager = new DevicesManager(); devicesManager.ConnectAllDevices(); dataReceiverFactory = new DataReceiverFactory(devicesManager); }
public override void Handle(DateTime lastTime, DateTime currentTime, DateTime nextTime) { HttpClient client = _httpClientFactory.CreateClient(); List <FlowDevice> devices = _memoryCache.GetDevices(); using (IServiceScope serviceScope = _serviceProvider.CreateScope()) { DevicesManager devicesManager = serviceScope.ServiceProvider.GetRequiredService <DevicesManager>(); ChannelsManager channelsManager = serviceScope.ServiceProvider.GetRequiredService <ChannelsManager>(); foreach (var device in devices) { List <int> oldChannelStatuses = device.FlowDevice_FlowChannels .Select(r => r.Channel.ChannelStatus) .ToList(); FlowChannellistClass statusModel = client.Get <FlowChannellistClass>( $"http://{device.Ip}:{device.Port}/app/aiboxManagerAPI/config_handler/channelparams"); if (statusModel != null && statusModel.Code == 0) { device.DeviceStatus = (int)DeviceStatus.正常; DeviceClass deviceInfo = client.Get <DeviceClass>( $"http://{device.Ip}:{device.Port}/app/aiboxManagerAPI/config_handler/get_systemparam"); if (deviceInfo != null && deviceInfo.Code == 0) { device.License = deviceInfo.Data.Licstatus; device.Space = deviceInfo.Data.Space; device.Systime = deviceInfo.Data.Systime; device.Runtime = deviceInfo.Data.Runtime; } else { device.License = null; device.Space = null; device.Systime = null; device.Runtime = null; } _logger.LogDebug((int)LogEvent.设备检查, $"设备正常 {device.Ip}"); foreach (var relation in device.FlowDevice_FlowChannels) { var model = statusModel.Data.Channelinfolist .FirstOrDefault(c => c.ChannelId == relation.Channel.ChannelId); if (model == null) { relation.Channel.ChannelStatus = (int)DeviceStatus.异常; _logger.LogDebug((int)LogEvent.设备检查, $"通道异常 {device.Ip}_{relation.Channel.ChannelName} 未找到该通道"); } else { if (model.ChannelStatus == 1) { relation.Channel.ChannelStatus = (int)DeviceStatus.正常; _logger.LogDebug((int)LogEvent.设备检查, $"通道正常 {device.Ip}_{relation.Channel.ChannelName}"); } else { relation.Channel.ChannelStatus = (int)DeviceStatus.异常; _logger.LogDebug((int)LogEvent.设备检查, $"通道异常 {device.Ip}_{relation.Channel.ChannelName} 状态值:{model.ChannelStatus}"); } } } } else { device.DeviceStatus = (int)DeviceStatus.异常; device.License = null; device.Space = null; device.Systime = null; device.Runtime = null; _logger.LogDebug((int)LogEvent.设备检查, $"设备异常 {device.Ip} 接口返回错误 {statusModel?.Code}"); foreach (var relation in device.FlowDevice_FlowChannels) { relation.Channel.ChannelStatus = (int)DeviceStatus.异常; } } IStatusCodeActionResult deviceResult = devicesManager.UpdateStatus(new FlowDeviceUpdateStatus { DeviceId = device.DeviceId, DeviceStatus = device.DeviceStatus, License = device.License, Space = device.Space, Systime = device.Systime, Runtime = device.Runtime }); _logger.LogDebug((int)LogEvent.设备检查, $"设备:{device.Ip} 状态:{device.DeviceStatus} 更新结果:{deviceResult.StatusCode}"); for (int i = 0; i < oldChannelStatuses.Count; ++i) { if (oldChannelStatuses[i] != device.FlowDevice_FlowChannels[i].Channel.ChannelStatus) { IStatusCodeActionResult channelResult = channelsManager.UpdateStatus(new FlowChannelUpdateStatus { ChannelId = device.FlowDevice_FlowChannels[i].Channel.ChannelId, ChannelStatus = device.FlowDevice_FlowChannels[i].Channel.ChannelStatus }); _logger.LogDebug((int)LogEvent.设备检查, $"通道 {device.Ip}_{device.FlowDevice_FlowChannels[i].Channel.ChannelName} 状态:{device.FlowDevice_FlowChannels[i].Channel.ChannelStatus} 结果:{channelResult.StatusCode}"); } } } } _result.Clear(); foreach (var device in devices) { _result.TryAdd($"设备-{device.DeviceName}_{device.Ip}", ((DeviceStatus)device.DeviceStatus).ToString()); foreach (var relation in device.FlowDevice_FlowChannels) { _result.TryAdd($"通道-{relation.Channel.ChannelName}_{relation.Channel.ChannelIndex}", ((DeviceStatus)relation.Channel.ChannelStatus).ToString()); } } }
public void Initialize(ChangeManager changeManager, DevicesManager devicesManager) { ChangeManager = changeManager; }
/// <summary> /// 数据库实例 /// </summary> /// <param name="manager">设备数据库操作实例</param> public DevicesController(DevicesManager manager) { _manager = manager; }