public ArgumentViewModel(Variable argument) { Argument = argument; ExplicitValue = new ExplicitValueViewModel((ExplicitValue)argument, true); ChangeCommand = new RelayCommand<ExplicitValueViewModel>(OnChange); Name = argument.Name; IsList = argument.IsList; }
Argument InitializeArgumemt(Variable variable) { var argument = new Argument(); argument.VariableScope = VariableScope.GlobalVariable; argument.ExplicitType = variable.ExplicitType; argument.EnumType = variable.EnumType; argument.ObjectType = variable.ObjectType; argument.Value = variable.Value; return argument; }
bool CheckSignature(Argument argument, Variable variable) { if (argument.ExplicitType != variable.ExplicitType) return false; if (argument.ExplicitType != ExplicitType.Object && argument.ExplicitType != ExplicitType.Enum) return true; if (argument.ExplicitType != ExplicitType.Object) return (argument.ObjectType == variable.ObjectType); if (argument.ExplicitType != ExplicitType.Enum) return (argument.EnumType == variable.EnumType); return false; }
public static ResearchDependencyResult GetDependency(Variable variable) { ResearchDependencyResult result; result.Variables = null; result.Procedures = ClientManager.SystemConfiguration.AutomationConfiguration.Procedures .Where(x => x.Steps.Any(y => y.Arguments.Any(a => a.VariableUid == variable.Uid))).ToArray(); result.Plans = ClientManager.PlansConfiguration.AllPlans .Where(x => x.AllElements.Any(z => result.Procedures.Any(m => m.PlanElementUIDs.Contains(z.UID)))).ToArray(); result.OpcDaTagFilters = ClientManager.SystemConfiguration.AutomationConfiguration.OpcDaTagFilters .Where(x => result.Procedures.Any(z => z.OpcDaTagFiltersUids.Any(m => m == x.UID))).ToArray(); result.OpcDaTags = (from tag in ClientManager.SystemConfiguration.AutomationConfiguration.OpcDaTsServers.SelectMany(x => x.Tags) join filter in result.OpcDaTagFilters on tag.Uid equals filter.TagUID select tag).ToArray(); result.OpcDaServers = ClientManager.SystemConfiguration.AutomationConfiguration.OpcDaTsServers .Where(x => x.Tags.Any(y => result.OpcDaTags.Contains(y))).Distinct().ToArray(); result.Filters = ClientManager.SystemConfiguration.JournalFilters .Where(x => result.Procedures.Any(z => z.FiltersUids.Any(m => m == x.UID))).ToArray(); return result; }
public VariableDetailsViewModel(Variable variable, List<Variable> availableVariables, string title = "", bool isGlobal = false) { automationChanged = ServiceFactory.SaveService.AutomationChanged; _availableVariables = availableVariables; Variable = new Variable { IsGlobal = isGlobal }; if (variable == null) { ExplicitTypes = new ObservableCollection<ExplicitTypeViewModel>(ProcedureHelper.BuildExplicitTypes(AutomationHelper.GetEnumList<ExplicitType>(), AutomationHelper.GetEnumList<EnumType>(), AutomationHelper.GetEnumList<ObjectType>())); _selectedExplicitType = ExplicitTypes.FirstOrDefault(); } else { Variable.Uid = variable.Uid; Variable.Value = variable.Value; Variable.IsReference = variable.IsReference; Variable.IsGlobal = variable.IsGlobal; Variable.IsList = variable.IsList; Variable.ObjectType = variable.ObjectType; Name = variable.Name; IsEditMode = true; _isNameEdited = true; ExplicitTypes = new ObservableCollection<ExplicitTypeViewModel>(ProcedureHelper.BuildExplicitTypes(new List<ExplicitType> { variable.ExplicitType }, new List<EnumType> { variable.EnumType }, new List<ObjectType> { variable.ObjectType })); var explicitTypeViewModel = ExplicitTypes.FirstOrDefault(); if (explicitTypeViewModel != null) { _selectedExplicitType = explicitTypeViewModel.GetAllChildren().LastOrDefault(); if (_selectedExplicitType != null) _selectedExplicitType.ExpandToThis(); } } SelectedContextType = Variable.ContextType; Title = title; IsGlobal = isGlobal; ContextTypes = AutomationHelper.GetEnumObs<ContextType>(); ExplicitValueViewModel = new ExplicitValueViewModel((ExplicitValue)Variable); }
public static void SetVariableValue(Variable target, object value, Guid? initialClientUID) { if (target == null) return; target.Value = value; if (ContextType == ContextType.Server && target.IsGlobal && target.ContextType == ContextType.Server) SendCallback(new AutomationCallbackResult { CallbackUID = Guid.NewGuid(), ContextType = ContextType.Server, AutomationCallbackType = AutomationCallbackType.GlobalVariable, Data = new GlobalVariableCallBackData { InitialClientUID = initialClientUID, VariableUID = target.Uid, ExplicitValue = (ExplicitValue)target } }, null); else SynchronizeVariable(target, initialClientUID); //target.OnValueChanged(); }
public VariableViewModel(Variable variable) { Variable = variable; }
private void OnSynchronizeVariable(Guid clientUID, Variable variable) { ClientManager.RubezhService.SetVariableValue(variable.Uid, variable.Value); }
Argument InitializeArgumemt(Variable variable) { var argument = new Argument(); argument.VariableScope = VariableScope.GlobalVariable; argument.Value = variable.Value; return argument; }
void FindObjectsAnd(Variable result, IEnumerable<FindObjectCondition> findObjectConditions) { var list = result.Value as IList; if (list != null) { var items = GetObjects(result.ObjectType); list.Clear(); bool allTrue; foreach (var item in items) { allTrue = true; var itemUid = GetObjectUid(item); foreach (var findObjectCondition in findObjectConditions) { var propertyValue = GetPropertyValue(findObjectCondition.Property, item); var conditionValue = GetValue(findObjectCondition.SourceArgument); var comparer = Compare(propertyValue, conditionValue, findObjectCondition.ConditionType); if (comparer == null || !comparer.Value) { allTrue = false; break; } } if (allTrue) result.AddToList(item); } } }
void FindObjectsOr(Variable result, IEnumerable<FindObjectCondition> findObjectConditions) { var list = result.Value as List<object>; if (list != null) { var items = GetObjects(result.ObjectType); list.Clear(); foreach (var item in items) { var itemUid = GetObjectUid(item); foreach (var findObjectCondition in findObjectConditions) { var propertyValue = GetPropertyValue(findObjectCondition.Property, item); var conditionValue = GetValue(findObjectCondition.SourceArgument); var comparer = Compare(propertyValue, conditionValue, findObjectCondition.ConditionType); if (comparer != null && comparer.Value) { result.AddToList(item); break; } } } } }
public static void SynchronizeVariable(Variable variable, Guid? initialClientUID) { if (initialClientUID.HasValue && variable.IsGlobal && variable.ContextType == ContextType.Server && OnSynchronizeVariable != null) OnSynchronizeVariable(initialClientUID.Value, variable); }