void CheckObjectLogicOnGK(GKBase gkBase) { var deviceGKDescriptor = GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == gkBase); Assert.IsTrue(deviceGKDescriptor.Formula.FormulaOperations.Count > 1, "На ГК должна присутствовать логика объекта"); Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == gkBase), "На КАУ должен отсутствовать объект"); Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == gkBase), "На КАУ должен отсутствовать объект"); }
public void AddDependentElement(GKBase gkBase) { if (InputDependentElements.All(x => x.UID != gkBase.UID) && gkBase.UID != UID) InputDependentElements.Add(gkBase); if (gkBase.OutputDependentElements.All(x => x.UID != UID) && gkBase.UID != UID) gkBase.OutputDependentElements.Add(this); }
public LogicViewModel(GKBase gkBase, GKLogic logic, bool hasOffClause = false, bool hasOnNowClause = false, bool hasOffNowClause = false, bool hasStopClause = false, bool hasOnClause = true, bool hasOn2Clause = false, bool isIC = false) { if (gkBase != null) Title = "Настройка логики " + gkBase.PresentationName; else Title = "Настройка логики"; if (logic.OnClausesGroup.Clauses.Count == 0 && logic.OnClausesGroup.ClauseGroups.Count == 0 && hasOnClause) { logic.OnClausesGroup.Clauses.Add(new GKClause()); } OnClausesGroup = new ClauseGroupViewModel(gkBase, logic.OnClausesGroup); On2ClausesGroup = new ClauseGroupViewModel(gkBase, logic.On2ClausesGroup); OffClausesGroup = new ClauseGroupViewModel(gkBase, logic.OffClausesGroup); OnNowClausesGroup = new ClauseGroupViewModel(gkBase, logic.OnNowClausesGroup); OffNowClausesGroup = new ClauseGroupViewModel(gkBase, logic.OffNowClausesGroup); StopClausesGroup = new ClauseGroupViewModel(gkBase, logic.StopClausesGroup); RedIndicatorLogic = new ICIndicatorLogicViewModel(gkBase, logic.RedIndicatorLogic); GreenIndicatorLogic = new ICIndicatorLogicViewModel(gkBase, logic.GreenIndicatorLogic); YellowIndicatorLogic = new ICIndicatorLogicViewModel(gkBase, logic.YellowIndicatorLogic); UseOffCounterLogic = logic.UseOffCounterLogic; HasOnClause = hasOnClause; HasOffClause = hasOffClause; HasOnNowClause = hasOnNowClause; HasOffNowClause = hasOffNowClause; HasStopClause = hasStopClause; HasOn2Clause = hasOn2Clause; IsIC = isIC; }
public ClauseGroupViewModel(GKBase gkBase, GKClauseGroup clauseGroup) { AddCommand = new RelayCommand(OnAdd); AddGroupCommand = new RelayCommand(OnAddGroup); RemoveCommand = new RelayCommand<ClauseViewModel>(OnRemove); RemoveGroupCommand2 = new RelayCommand(OnRemoveGroup2, CanRemoveGroup2); RemoveGroupCommand = new RelayCommand<ClauseGroupViewModel>(OnRemoveGroup); ChangeJoinOperatorCommand = new RelayCommand(OnChangeJoinOperator); GKBase = gkBase; Clauses = new ObservableCollection<ClauseViewModel>(); foreach (var clause in clauseGroup.Clauses) { var clauseViewModel = new ClauseViewModel(gkBase, clause); Clauses.Add(clauseViewModel); } ClauseGroups = new ObservableCollection<ClauseGroupViewModel>(); foreach (var clause in clauseGroup.ClauseGroups) { var clauseGroupViewModel = new ClauseGroupViewModel(gkBase, clause); clauseGroupViewModel.Parent = this; ClauseGroups.Add(clauseGroupViewModel); } JoinOperator = clauseGroup.ClauseJounOperationType; }
public ICIndicatorLogicViewModel(GKBase gkBase, ICIndicatorLogic icIndicatorLogic) { Blink1ClausesGroup = new ClauseGroupViewModel(gkBase, icIndicatorLogic.Blink1ClausesGroup); Blink3ClausesGroup = new ClauseGroupViewModel(gkBase, icIndicatorLogic.Blink3ClausesGroup); OffClausesGroup = new ClauseGroupViewModel(gkBase, icIndicatorLogic.OffClausesGroup); UseOffCounterLogic = icIndicatorLogic.UseOffCounterLogic; }
void CheckObjectOnGK(GKBase gkBase) { var gkBaseGkDescriptor = GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == gkBase); var gkBaseKauDescriptor = KauDatabase.Descriptors.FirstOrDefault(x => x.GKBase == gkBase); Assert.IsNotNull(gkBaseGkDescriptor); Assert.IsNull(gkBaseKauDescriptor); }
public ClauseViewModel(GKBase gkBase, GKClause clause) { SelectDevicesCommand = new RelayCommand(OnSelectDevices); SelectZonesCommand = new RelayCommand(OnSelectZones); SelectGuardZonesCommand = new RelayCommand(OnSelectGuardZones); SelectDirectionCommand = new RelayCommand(OnSelectDirections); SelectMPTsCommand = new RelayCommand(OnSelectMPTs); SelectDelaysCommand = new RelayCommand(OnSelectDelays); SelectDoorsCommand = new RelayCommand(OnSelectDoors); SelectPumpStationsCommand = new RelayCommand(OnSelectPumpStations); GKBase = gkBase; ClauseConditionTypes = Enum.GetValues(typeof(ClauseConditionType)).Cast<ClauseConditionType>().ToList(); ClauseOperationTypes = Enum.GetValues(typeof(ClauseOperationType)).Cast<ClauseOperationType>().ToList(); SelectedClauseOperationType = clause.ClauseOperationType; Devices = clause.Devices.ToList(); Zones = clause.Zones.ToList(); GuardZones = clause.GuardZones.ToList(); Directions = clause.Directions.ToList(); MPTs = clause.MPTs.ToList(); Delays = clause.Delays.ToList(); Doors = clause.Doors.ToList(); PumpStations = clause.PumpStations.ToList(); SelectedClauseConditionType = clause.ClauseConditionType; SelectedStateType = StateTypes.FirstOrDefault(x => x.StateBit == clause.StateType); }
public GKBaseModel(GKBase gkObject) { UID = gkObject.UID; Name = gkObject.Name; ImageSource = gkObject.ImageSource.Replace("/Controls;component/", ""); ObjectType = gkObject.ObjectType; StateClass = gkObject.State.StateClass.ToString(); }
public DependencyItemViewModel(GKBase gkBase) { ShowCommand = new RelayCommand(OnShow); this.gkBase = gkBase; Name = gkBase.PresentationName; ImageSource = gkBase.ImageSource; }
void CheckObjectLogicOnKau(GKBase gkBase, int kauNo = 1) { KauDatabase kauDatabase = Kau1Database; if (kauNo == 2) kauDatabase = Kau2Database; var deviceGKDescriptor = GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == gkBase); var deviceKauDescriptor = kauDatabase.Descriptors.FirstOrDefault(x => x.GKBase == gkBase); Assert.IsTrue(deviceGKDescriptor.Formula.FormulaOperations.Count == 1, "На ГК должна отсутствовать логика объекта"); Assert.IsTrue(deviceKauDescriptor.Formula.FormulaOperations.Count > 1, "На КАУ должна присутствовать логика объекта"); }
public static void SendControlCommandMRO(GKBase gkBase, byte code, byte code2) { var bytes = new List<byte>(); var databaseNo = gkBase.GKDescriptorNo; bytes.AddRange(BytesHelper.ShortToBytes(databaseNo)); bytes.Add(code); bytes.Add(code2); if (gkBase.GkDatabaseParent != null) { WatcherManager.Send(OnCompleted, gkBase.GkDatabaseParent, 3, 13, 0, bytes); } }
void TestOneMirror(GKBase gkBase, GKDriverType mirrorType) { var mirrorDevice = AddDevice(reflectionDevice1, mirrorType); GKManager.AddToMirror(gkBase, mirrorDevice); Compile(); Assert.IsTrue(gkBase.OutputDescriptors.Contains(mirrorDevice)); if (mirrorType != GKDriverType.DetectorDevicesMirror) { Assert.IsTrue(gkBase.InputDescriptors.Contains(mirrorDevice)); var rmDevice = AddDevice(kauDevice, GKDriverType.RSR2_RM_1); rmDevice.Logic.OnClausesGroup.Clauses.Add(GetClause(gkBase)); Compile(); CheckDeviceLogicOnGK(rmDevice); } }
public void Parse(List<byte> bytes, GKBase gkBase) { GKBase = gkBase; ushort controllerAddress = BytesHelper.SubstructShort(bytes, 2); AddressOnController = BytesHelper.SubstructShort(bytes, 4); PhysicalAddress = BytesHelper.SubstructShort(bytes, 6); Description = BytesHelper.BytesToStringDescription(bytes); int serialNo = BytesHelper.SubstructInt(bytes, 40); int state = BytesHelper.SubstructInt(bytes, 44); TypeNo = BytesHelper.SubstructShort(bytes, 0); StateBits = GKStatesHelper.StatesFromInt(state); ParseAdditionalParameters(bytes, gkBase); CheckConnectionLost(gkBase); }
public OPCItemViewModel(GKBase device) { Device = device; var _device = device as GKDevice; if (_device != null) { Name = _device.Driver.ShortName; Address = _device.PresentationAddress; } else { Name = device.Name; Address = device.No.ToString(); } }
/// <summary> /// Объект должен зависеть от объектов, присутствующих на одном и только на одном ГК /// </summary> /// <param name="code"></param> bool ValidateObjectOnlyOnOneGK(GKBase gkBase) { if (gkBase is GKDevice && (gkBase as GKDevice).DriverType == GKDriverType.System) return true; if (gkBase.GkParents.Count == 0) { AddError(gkBase, "Не содержится ни в одном ГК", ValidationErrorLevel.CannotWrite); return false; } if (gkBase.GkParents.Count > 1) { AddError(gkBase, "Содержится в нескольких ГК", ValidationErrorLevel.CannotWrite); return false; } return true; }
public static void SendOn2OPKS(GKBase gkBase) { var bytes = new List<byte>(); var databaseNo = gkBase.GKDescriptorNo; bytes.AddRange(BytesHelper.ShortToBytes(databaseNo)); bytes.Add(0x80 + (byte)GKStateBit.TurnOn_InManual); bytes.Add(1); if (gkBase.GkDatabaseParent != null) { WatcherManager.Send(new Action<SendResult>(sendResult => { if (sendResult.HasError) { GKProcessorManager.AddGKMessage(JournalEventNameType.Ошибка_при_выполнении_команды, JournalEventDescriptionType.NULL, "Включить-2", gkBase, null); } }), gkBase.GkDatabaseParent, 4, 13, 0, bytes); } }
public static void SendControlCommand(GKBase gkBase, byte code, string description) { var bytes = new List<byte>(); var databaseNo = gkBase.GKDescriptorNo; bytes.AddRange(BytesHelper.ShortToBytes(databaseNo)); bytes.Add(code); if (gkBase.GkDatabaseParent != null) { WatcherManager.Send(new Action<SendResult>(sendResult => { if (sendResult.HasError) { GKProcessorManager.AddGKMessage(JournalEventNameType.Ошибка_при_выполнении_команды, JournalEventDescriptionType.NULL, description, gkBase, null); } }), gkBase.GkDatabaseParent, 3, 13, 0, bytes); } }
public static string SetSingleParameter(GKBase gkBase, List<byte> parameterBytes) { try { var commonDatabase = GetCommonDatabase(gkBase); if (commonDatabase != null) { var descriptor = commonDatabase.Descriptors.FirstOrDefault(x => x.GKBase.UID == gkBase.UID); if (descriptor != null) { return SetDeviceParameters(commonDatabase, descriptor, parameterBytes); } } } catch (Exception e) { Logger.Error(e, "ParametersHelper.SetSingleParameter"); } return null; }
public static OperationResult<List<GKProperty>> GetSingleParameter(GKBase gkBase) { try { var commonDatabase = GetCommonDatabase(gkBase); if (commonDatabase != null) { var descriptor = commonDatabase.Descriptors.FirstOrDefault(x => x.GKBase.UID == gkBase.UID); if (descriptor != null) { var result = GetDeviceParameters(commonDatabase, descriptor); return result; } } } catch (Exception e) { Logger.Error(e, "ParametersHelper.GetSingleParameter"); } return OperationResult<List<GKProperty>>.FromError("Непредвиденная ошибка"); }
public void InvalidateOneLogic(GKBase gkBase, GKLogic logic) { logic.OnClausesGroup = InvalidateOneClauseGroup(gkBase, logic.OnClausesGroup); logic.On2ClausesGroup = InvalidateOneClauseGroup(gkBase, logic.On2ClausesGroup); logic.OffClausesGroup = InvalidateOneClauseGroup(gkBase, logic.OffClausesGroup); logic.StopClausesGroup = InvalidateOneClauseGroup(gkBase, logic.StopClausesGroup); logic.OnNowClausesGroup = InvalidateOneClauseGroup(gkBase, logic.OnNowClausesGroup); logic.OffNowClausesGroup = InvalidateOneClauseGroup(gkBase, logic.OffNowClausesGroup); InvalidateICIndicatorLogic(gkBase, logic.RedIndicatorLogic); InvalidateICIndicatorLogic(gkBase, logic.GreenIndicatorLogic); InvalidateICIndicatorLogic(gkBase, logic.YellowIndicatorLogic); }
public void SendOn2OPKS(GKBase gkBase, string userName = null) { SafeOperationCall(() => { var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10)); using (rubezhService as IDisposable) rubezhService.SendOn2OPKS(RubezhServiceFactory.UID, gkBase.UID, gkBase.ObjectType, userName); }, "SendOn2OPKS"); }
public void GKTurnOffNowInAutomatic(GKBase gkBase) { SafeOperationCall(() => { var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10)); using (rubezhService as IDisposable) rubezhService.GKTurnOffNowInAutomatic(RubezhServiceFactory.UID, gkBase.UID, gkBase.ObjectType); }, "GKTurnOffNowInAutomatic"); }
public void GKSetIgnoreRegime(GKBase gkBase, string userName = null) { SafeOperationCall(() => { var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10)); using (rubezhService as IDisposable) rubezhService.GKSetIgnoreRegime(RubezhServiceFactory.UID, gkBase.UID, gkBase.ObjectType, userName); }, "GKTurnOn"); }
public OperationResult<List<GKProperty>> GKGetSingleParameter(GKBase gkBase) { return SafeOperationCall(() => { var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10)); using (rubezhService as IDisposable) return rubezhService.GKGetSingleParameter(RubezhServiceFactory.UID, gkBase.UID); }, "GetSingleParameter"); }
public OperationResult<bool> GKSetSingleParameter(GKBase gkBase, List<byte> parameterBytes, List<GKProperty> deviceProperties = null) { return SafeOperationCall(() => { var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10)); using (rubezhService as IDisposable) return rubezhService.GKSetSingleParameter(RubezhServiceFactory.UID, gkBase.UID, parameterBytes, deviceProperties); }, "SetSingleParameter"); }
public static void SendControlCommand(GKBase gkBase, GKStateBit stateBit, string description) { var code = 0x80 + (int)stateBit; SendControlCommand(gkBase, (byte)code, description); }
public BaseDescriptor(GKBase gkBase) { GKBase = gkBase; Formula = new FormulaBuilder(); Parameters = new List<byte>(); }
public GKClauseGroup InvalidateOneClauseGroup(GKBase gkBase, GKClauseGroup clauseGroup) { var result = new GKClauseGroup(); result.ClauseJounOperationType = clauseGroup.ClauseJounOperationType; var groups = new List<GKClauseGroup>(); foreach (var group in clauseGroup.ClauseGroups) { var _clauseGroup = InvalidateOneClauseGroup(gkBase, group); if (_clauseGroup.Clauses.Count + _clauseGroup.ClauseGroups.Count > 0) groups.Add(_clauseGroup); } result.ClauseGroups = groups; foreach (var clause in clauseGroup.Clauses) { clause.Devices = new List<GKDevice>(); clause.Zones = new List<GKZone>(); clause.GuardZones = new List<GKGuardZone>(); clause.Directions = new List<GKDirection>(); clause.MPTs = new List<GKMPT>(); clause.Delays = new List<GKDelay>(); clause.Doors = new List<GKDoor>(); clause.PumpStations = new List<GKPumpStation>(); var deviceUIDs = new List<Guid>(); foreach (var deviceUID in clause.DeviceUIDs) { var device = Devices.FirstOrDefault(x => x.UID == deviceUID); if (device != null) { deviceUIDs.Add(deviceUID); clause.Devices.Add(device); } } clause.DeviceUIDs = deviceUIDs; var zoneUIDs = new List<Guid>(); foreach (var zoneUID in clause.ZoneUIDs) { var zone = Zones.FirstOrDefault(x => x.UID == zoneUID); if (zone != null) { zoneUIDs.Add(zoneUID); clause.Zones.Add(zone); } } clause.ZoneUIDs = zoneUIDs; var guardZoneUIDs = new List<Guid>(); foreach (var guardZoneUID in clause.GuardZoneUIDs) { var guardZone = GuardZones.FirstOrDefault(x => x.UID == guardZoneUID); if (guardZone != null) { guardZoneUIDs.Add(guardZoneUID); clause.GuardZones.Add(guardZone); } } clause.GuardZoneUIDs = guardZoneUIDs; var directionUIDs = new List<Guid>(); foreach (var directionUID in clause.DirectionUIDs) { var direction = Directions.FirstOrDefault(x => x.UID == directionUID); if (direction != null) { directionUIDs.Add(directionUID); clause.Directions.Add(direction); } } clause.DirectionUIDs = directionUIDs; var mptUIDs = new List<Guid>(); foreach (var mptUID in clause.MPTUIDs) { var mpt = MPTs.FirstOrDefault(x => x.UID == mptUID); if (mpt != null) { mptUIDs.Add(mptUID); clause.MPTs.Add(mpt); } } clause.MPTUIDs = mptUIDs; var delayUIDs = new List<Guid>(); foreach (var delayUID in clause.DelayUIDs) { var delay = Delays.FirstOrDefault(x => x.UID == delayUID); if (delay != null) { delayUIDs.Add(delayUID); clause.Delays.Add(delay); } } clause.DelayUIDs = delayUIDs; var doorUIDs = new List<Guid>(); foreach (var doorUID in clause.DoorUIDs) { var door = Doors.FirstOrDefault(x => x.UID == doorUID); if (door != null) { doorUIDs.Add(doorUID); clause.Doors.Add(door); } } clause.DoorUIDs = doorUIDs; var pumpStationsUIDs = new List<Guid>(); foreach (var pumpStationUID in clause.PumpStationsUIDs) { var pumpStation = PumpStations.FirstOrDefault(x => x.UID == pumpStationUID); if (pumpStation != null) { pumpStationsUIDs.Add(pumpStationUID); clause.PumpStations.Add(pumpStation); } } clause.PumpStationsUIDs = pumpStationsUIDs; if (clause.HasObjects()) result.Clauses.Add(clause); } return result; }
public void InvalidateICIndicatorLogic(GKBase gkBase, ICIndicatorLogic icIndicatorLogic) { icIndicatorLogic.Blink1ClausesGroup = InvalidateOneClauseGroup(gkBase, icIndicatorLogic.Blink1ClausesGroup); icIndicatorLogic.Blink3ClausesGroup = InvalidateOneClauseGroup(gkBase, icIndicatorLogic.Blink3ClausesGroup); icIndicatorLogic.OffClausesGroup = InvalidateOneClauseGroup(gkBase, icIndicatorLogic.OffClausesGroup); }
public Alarm(GKAlarmType alarmType, GKBase gkBaseEntity) { AlarmType = alarmType; GkBaseEntity = gkBaseEntity; }