void UpdateRealChildrenStateOnPanelState(Device panelDevice, BitArray bitArray) { foreach (var device in panelDevice.GetRealChildren()) { foreach (var metadataDeviceState in MetadataHelper.GetMetadataDeviceStates(device, true)) { if (metadataDeviceState.leave != null) { foreach (var leaveDeviceState in metadataDeviceState.leave) { if (leaveDeviceState.panelState != null) { var pabelBitNo = Int32.Parse(leaveDeviceState.panelState); var hasBit = bitArray[pabelBitNo]; if (!hasBit) { if (device.DeviceState.States.RemoveAll(x => x.DriverState.Code == metadataDeviceState.ID) > 0) { ForseUpdateDeviceStates(device); } } } } } } } }
public MonitoringPanel(Device device) { PanelDevice = device; Requests = new List<Request>(); ResetStateIds = new List<string>(); DevicesToIgnore = new List<Device>(); ZonesToSetGuard = new List<Zone>(); ZonesToResetGuard = new List<Zone>(); CommandItems = new List<CommandItem>(); RealChildren = PanelDevice.GetRealChildren(); DeviceStatesManager = new DeviceStatesManager(); }
public static List<DevicesOnShleif> GetLocalForPanel(Device parentPanel) { var devicesOnShleifs = new List<DevicesOnShleif>(); for (int i = 1; i <= parentPanel.Driver.ShleifCount; i++) { var devicesOnShleif = new DevicesOnShleif() { ShleifNo = i }; devicesOnShleifs.Add(devicesOnShleif); } foreach (var device in parentPanel.GetRealChildren()) { if (device.ParentPanel.UID == parentPanel.UID) { var devicesOnShleif = devicesOnShleifs.FirstOrDefault(x => x.ShleifNo == device.ShleifNo); if (devicesOnShleif != null) { devicesOnShleif.Devices.Add(device); } } } return devicesOnShleifs; }
public bool ReadConfigurationAndUpdateStates(Device panelDevice) { var getConfigurationOperationHelper = new GetConfigurationOperationHelper(true); RemoteDeviceConfiguration = getConfigurationOperationHelper.GetDeviceConfiguration(panelDevice); if (RemoteDeviceConfiguration == null) return false; RemoteDeviceConfiguration.Update(); var isDBMissmatch = !ConfigurationCompareHelper.Compare(panelDevice, RemoteDeviceConfiguration); if (panelDevice.DeviceState.IsDBMissmatch != isDBMissmatch) { panelDevice.DeviceState.IsDBMissmatch = isDBMissmatch; ForseUpdateDeviceStates(panelDevice); } var remoteRealChildren = RemoteDeviceConfiguration.RootDevice.GetRealChildren(); var localRealChildren = panelDevice.GetRealChildren(); foreach (var remoteDevice in remoteRealChildren) { var device = localRealChildren.FirstOrDefault(x => x.IntAddress == remoteDevice.IntAddress); if (device != null) { device.StateWordOffset = remoteDevice.StateWordOffset; device.StateWordBytes = remoteDevice.StateWordBytes; device.RawParametersOffset = remoteDevice.RawParametersOffset; device.RawParametersBytes = remoteDevice.RawParametersBytes; ParseDeviceState(device); } } foreach (var remoteZone in RemoteDeviceConfiguration.Zones) { var zone = ConfigurationManager.Zones.FirstOrDefault(x => x.No == remoteZone.No); if (zone != null) { zone.LocalDeviceNo = remoteZone.LocalDeviceNo; } } return true; }
public void UpdatePanelParameters(Device panel) { HasChanges = false; var faultyCount = panel.GetRealChildren().Where(x => x.DeviceState.States.Any(y => y.DriverState.Name == "Неисправность")).Count(); SetParameter(panel, faultyCount, "Heиcпpaвныx локальных уcтpoйcтв"); var externalCount = 0; SetParameter(panel, externalCount, "Внешних устройств"); var totalCount = panel.GetRealChildren().Count; SetParameter(panel, totalCount, "Всего устройств"); var bypassCount = panel.GetRealChildren().Where(x => x.DeviceState.States.Any(y => y.DriverState.Name == "Аппаратный обход устройства")).Count(); SetParameter(panel, bypassCount, "Обойденных устройств"); var lostCount = panel.GetRealChildren().Where(x => x.DeviceState.States.Any(y => y.DriverState.Name == "Потеря связи")).Count(); SetParameter(panel, lostCount, "Потерянных устройств"); var dustfilledCount = panel.GetRealChildren().Where(x => x.DeviceState.States.Any(y => y.DriverState.Code == "HighDustiness")).Count(); SetParameter(panel, dustfilledCount, "Запыленных устройств"); if (HasChanges) NotifyStateChanged(panel); }