private void InitializeContent() { EventLogger.RecordEvent(EventLogger.EventType.Info, "0x0001", "Start intializing the FORM"); notifiDisplayer = new Notification(); notifiDisplayer.btnOK.Click += new RoutedEventHandler(CloseNotification_ButtonClick); uEye_Handler.InitializeCamera(); if (uEye_Handler.CameraResult.Status != "Initialized") { EventLogger.RecordEvent(EventLogger.EventType.Warning, uEye_Handler.CameraResult.ErrorCode, uEye_Handler.CameraResult.ErrorDescription); } else { EventLogger.RecordEvent(EventLogger.EventType.Info, "0x0002", "Camera status is: " + uEye_Handler.CameraResult.Status); } mainPage = new Assets.MainPage(); manualPage = new Assets.ManualPage(); settingsPage = new Assets.SettingsPage(); historyPage = new Assets.HistoryPage(); LoginDialog = new Assets.LoginDialogBox(); WindowViewModel = new MainWindowViewModel(this); mainPage.tbDate.Text = DateTime.Now.ToShortDateString(); mainPage.tbCurrentTime.Text = DateTime.Now.ToShortTimeString(); ReferenceHandler.ConnectRoutineADS(TwinCat3Client_AdsNotificationEx); WindowViewModel.DisplayPage(mainPage); WindowViewModel.InitialLanguage(); }
private void InitData() { SpeedBar.Value = AdsCommunication.ReadLongReal(ReferenceHandler.GetReferenceAdress("continousOverride")); switch (AdsCommunication.ReadLongReal(ReferenceHandler.GetReferenceAdress("StepSize")) * 10) { case 1: StepSize.SelectedIndex = 0; break; case 2: StepSize.SelectedIndex = 1; break; case 5: StepSize.SelectedIndex = 2; break; case 10: StepSize.SelectedIndex = 3; break; default: break; } }
private void SpeedBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (SpeedBox != null) { SpeedBox.Text = Math.Round((decimal)SpeedBar.Value, 0).ToString() + " %"; AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("Override"), (Double)Math.Round((decimal)SpeedBar.Value, 2)); } }
///------------------------------------------------------------------------------------------------- /// <summary> /// Méthode appelée dans le processus de création que celle ci soit faite par new ou par /// sérialisation. /// </summary> /// <param name="schemaElement"> /// The metadata. /// </param> /// <param name="domainModel"> /// The domain model. /// </param> ///------------------------------------------------------------------------------------------------- protected override void Initialize(ISchemaElement schemaElement, IDomainModel domainModel) { base.Initialize(schemaElement, domainModel); _superClassHandler = new ReferenceHandler(this, domainModel.Store.PrimitivesSchema.SchemaElementReferencesSuperElementSchema); _properties = new ModelElementCollection <ISchemaProperty>(this, domainModel.Store.PrimitivesSchema.SchemaElementHasPropertiesSchema); _propertiesByName = PlatformServices.Current.CreateConcurrentDictionary <string, ISchemaProperty>(); }
private void GoTo_Click(object sender, RoutedEventArgs e) { if (Selector.Text != "") { AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress(axisName + Selector.Text), SaveTempPos); ComboBoxItem comboBoxItem = Selector.SelectedItem as ComboBoxItem; TargetPos.Text = Math.Round(AdsCommunication.ReadLongReal(ReferenceHandler.GetReferenceAdress(axisName + comboBoxItem.Content.ToString())), 2).ToString(); } }
private void MovementModeSelect_Click(object sender, RoutedEventArgs e) { if (AdsCommunication.ReadBit(ReferenceHandler.GetReferenceAdress("ManualMovementMode"))) { SetStatement(false); } else { SetStatement(true); } }
private void CloseNotification_ButtonClick(object sender, RoutedEventArgs e) { if (notifiDisplayer.btnOK.Opacity == 100) { AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("confirm"), true); //if(AdsCommunication.ReadInt(GetReferenceAdress("message_number", NotificationData)) == 0) //{ // CloseNotification(); //} } }
private void btnMode_Click(object sender, RoutedEventArgs e) { if (!AdsCommunication.ReadBit(ReferenceHandler.GetReferenceAdress("mode"))) { AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("mode"), true); } else { AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("mode"), false); } }
public void Function_xElementsRefernceInPredicate_CorrectIndexing(string[] elements, string id, int expected) { AST ast = Utilities.GetAstSkeleton(); var condition = Utilities.GetConditionNode(elements, id); Utilities.AddFunctionNode(ast, Utilities.GetFunctionNode("func", elements.ToList(), condition)); ReferenceHandler referenceHandler = Utilities.GetReferenceHandler(); referenceHandler.InsertReferences(ast); var res = (IdentifierExpression)condition.Condition; Assert.AreEqual(expected, res.Reference); }
public void Function_xElements_CorrectIndexing(string[] elements) { AST ast = Utilities.GetAstSkeleton(); var condition = Utilities.GetConditionNode(elements); Utilities.AddFunctionNode(ast, Utilities.GetFunctionNode("func", elements.ToList(), condition)); ReferenceHandler referenceHandler = Utilities.GetReferenceHandler(); referenceHandler.InsertReferences(ast); for (int i = 0; i < elements.Length; i++) { Assert.AreEqual(i, condition.Elements[i].Reference); } }
public void Set_xBounds_AccesibleInPredicate(string elementId, string[] indecies, string id, int expected) { AST ast = Utilities.GetAstSkeleton(); var predicate = Utilities.GetIdentifierExpr(id); var setExpr = Utilities.GetSetExpr(elementId, indecies.ToList(), indecies.ToList(), predicate); var condition = Utilities.GetConditionNode(setExpr); Utilities.AddFunctionNode(ast, Utilities.GetFunctionNode("func", condition)); ReferenceHandler referenceHandler = Utilities.GetReferenceHandler(); referenceHandler.InsertReferences(ast); var res = (IdentifierExpression)setExpr.Predicate; Assert.AreEqual(expected, res.Reference); }
public void FunctionCall_VariableNumberOfLocalReferences_CorrectIndexing(string[] functionNames, string functionId, int index) { AST ast = Utilities.GetAstSkeleton(); var condition = Utilities.GetConditionNode(Utilities.GetFunctionCallExpression(functionId)); var func = Utilities.GetFunctionNode("Global", functionNames.ToList(), condition); Utilities.AddFunctionNode(ast, func); ReferenceHandler referenceHandler = Utilities.GetReferenceHandler(); referenceHandler.InsertReferences(ast); var res = (FunctionCallExpression)condition.ReturnExpression; Assert.AreEqual(index, res.LocalReference); Assert.AreEqual(0, res.GlobalReferences.Count); }
private static void AnonymousTests(string[] parameters, string[] anonymIds, string id, int expected) { AST ast = Utilities.GetAstSkeleton(); var anonym = Utilities.GetAnonymousFunction(anonymIds, id); var cond = Utilities.GetConditionNode(anonym); var func = Utilities.GetFunctionNode("func", parameters.ToList(), cond); Utilities.AddFunctionNode(ast, func); ReferenceHandler referenceHandler = Utilities.GetReferenceHandler(); referenceHandler.InsertReferences(ast); var res = (IdentifierExpression)anonym.ReturnValue; Assert.AreEqual(expected, res.Reference); }
/// <summary> /// Sets the value. /// </summary> /// <param name="target">The target to set the value on.</param> /// <param name="value">The value to set on the target.</param> public void SetValue(object target, object value) { try { if (_setter == null) { _setter = DynamicReflectionDelegateFactory.Instance.CreateSet <object>(_memberInfo); } Type underlyingType = ReflectionUtils.GetMemberUnderlyingType(_memberInfo); if (!UnityUtilities.IsNull(value)) { if (ReferenceHandler.IsTypeReference(value.GetType()) && typeof(UnityEngine.Object).IsAssignableFrom(underlyingType)) { ReferenceHandler.AssignObjectValue(value, underlyingType, x => { _setter(target, x); }); return; } } #if DEBUG // dynamic method doesn't check whether the type is 'legal' to set // add this check for unit tests if (value == null) { if (!ReflectionUtils.IsNullable(ReflectionUtils.GetMemberUnderlyingType(_memberInfo))) { throw new JsonSerializationException("Incompatible value. Cannot set {0} to null.".FormatWith(CultureInfo.InvariantCulture, _memberInfo)); } } else if (!ReflectionUtils.GetMemberUnderlyingType(_memberInfo).IsAssignableFrom(value.GetType())) { throw new JsonSerializationException("Incompatible value. Cannot set {0} to type {1}.".FormatWith(CultureInfo.InvariantCulture, _memberInfo, value.GetType())); } #endif _setter(target, value); } catch (Exception ex) { throw new JsonSerializationException("Error setting value to '{0}' on '{1}'.".FormatWith(CultureInfo.InvariantCulture, _memberInfo.Name, target.GetType()), ex); } }
public void FunctionCall_VariableNumberOfGlobalReferencesWithSameName_CorrectIndexing(string[] functionNames, string functionId, int expected) { AST ast = Utilities.GetAstSkeleton(); FunctionCallExpression funcCallExpr = Utilities.GetFunctionCallExpression(functionId); Utilities.AddExportNode(ast, Utilities.GetExportNode(funcCallExpr)); foreach (var functionName in functionNames) { Utilities.AddFunctionNode(ast, Utilities.GetFunctionNode(functionName)); } ReferenceHandler referenceHandler = Utilities.GetReferenceHandler(); referenceHandler.InsertReferences(ast); Assert.AreEqual(expected, funcCallExpr.GlobalReferences.Count); }
public void Set_xBounds_SortBounds(string[] indecies, string[] bounds, bool doNotUse) { AST ast = Utilities.GetAstSkeleton(); var setExpr = Utilities.GetSetExpr(indecies.ToList(), bounds.ToList()); var condition = Utilities.GetConditionNode(setExpr); Utilities.AddFunctionNode(ast, Utilities.GetFunctionNode("func", condition)); ReferenceHandler referenceHandler = Utilities.GetReferenceHandler(); referenceHandler.InsertReferences(ast); var res = setExpr.Bounds; for (int i = 0; i < indecies.Length; i++) { Assert.AreEqual(indecies[i], res[i].Identifier); } }
public void Dispatch_FunctionCallExprAndStringList_CorrectFunctionCallExprPassed() { FunctionCallExpression expected = new FunctionCallExpression("func", null, 0, 0); FunctionCallExpression input1 = expected; List <string> input2 = new List <string>() { "id" }; IReferenceHelper helper = Substitute.For <IReferenceHelper>(); ReferenceHandler refHandler = new ReferenceHandler(helper); FunctionCallExpression res = null; helper.VisitFunctionCall(Arg.Do <FunctionCallExpression>(x => res = x), Arg.Any <List <string> >()); refHandler.Dispatch(input1, input2); res.Should().BeEquivalentTo(expected); }
public void Dispatch_INonIdentifierAndStringList_CorrectIdentifierExpPassed() { PowerExpression expected = new PowerExpression(null, null, 1, 1); PowerExpression input1 = expected; List <string> input2 = new List <string>() { "id" }; IReferenceHelper helper = Substitute.For <IReferenceHelper>(); ReferenceHandler refHandler = new ReferenceHandler(helper); INonIdentifierExpression res = null; helper.VisitNonIdentifier(Arg.Do <INonIdentifierExpression>(x => res = x), Arg.Any <List <string> >()); refHandler.Dispatch(input1, input2); res.Should().BeEquivalentTo(expected); }
public void TwinCat3Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { Application.Current.Dispatcher.Invoke (new Action(() => { if (e.UserData == ReferenceHandler.GetReferenceObject("controll")) { if ((Boolean)e.Value) { } } if (e.UserData == ReferenceHandler.GetReferenceObject("mode")) { Screens[0].IsEnabled = !(bool)e.Value; Screens[1].IsEnabled = !(bool)e.Value; Screens[2].IsEnabled = (bool)e.Value; Screens[3].IsEnabled = !(bool)e.Value; } })); }
public void InsertReferences_AST_CorrectNumberOfCallsToBuildTable() { List <ExportNode> exports = new List <ExportNode> { new ExportNode(null, 0, 0), new ExportNode(null, 0, 0), new ExportNode(null, 0, 0) }; List <FunctionNode> functions = new List <FunctionNode> { new FunctionNode("", null, null, null, 0, 0), new FunctionNode("", null, null, null, 0, 0), new FunctionNode("", null, null, null, 0, 0), new FunctionNode("", null, null, null, 0, 0) }; AST ast = new AST(functions, exports, 0, 0); IReferenceHelper helper = Substitute.For <IReferenceHelper>(); ReferenceHandler refHandler = new ReferenceHandler(helper); refHandler.InsertReferences(ast); // helper.Received(1).BuildTable(Arg.Any<List<FunctionNode>>()); }
public void FunctionCall_VariableNumberOfBothReferences_CorrectCountIndexing(string[] global, string[] local, string functionId, int globalCount, bool hasLocal) { AST ast = Utilities.GetAstSkeleton(); foreach (var functionName in global) { Utilities.AddFunctionNode(ast, Utilities.GetFunctionNode(functionName)); } var condition = Utilities.GetConditionNode(Utilities.GetFunctionCallExpression(functionId)); var func = Utilities.GetFunctionNode("Global", local.ToList(), condition); Utilities.AddFunctionNode(ast, func); ReferenceHandler referenceHandler = Utilities.GetReferenceHandler(); referenceHandler.InsertReferences(ast); var res = (FunctionCallExpression)condition.ReturnExpression; Assert.AreEqual(globalCount, res.GlobalReferences.Count); Assert.AreEqual(hasLocal, res.LocalReference != FunctionCallExpression.NO_LOCAL_REF); }
public void Dispatch_IdentifierExpAndStringList_CorrectListPassedToVisitIdentifier() { List <string> expected = new List <string>() { "id" }; IdentifierExpression input1 = new IdentifierExpression("id", 1, 1); List <string> input2 = new List <string>() { "id" }; IReferenceHelper helper = Substitute.For <IReferenceHelper>(); ReferenceHandler refHandler = new ReferenceHandler(helper); List <string> res = new List <string>(); helper.VisitIdentifier(Arg.Any <IdentifierExpression>(), Arg.Do <List <string> >(x => res = x)); refHandler.Dispatch(input1, input2); res.Should().BeEquivalentTo(expected); }
public void SetStatement(bool state) { if (state) { MovementModeSelect.Content = LanguageHandler.GetMessageResource("btnContinous"); SpeedBox.Foreground = (FindResource("AccentColorBrush") as SolidColorBrush); StepSizeText.Foreground = (FindResource("PrimaryHueLightBrush") as SolidColorBrush); StepSize.Foreground = (FindResource("PrimaryHueLightBrush") as SolidColorBrush); SpeedBar.IsEnabled = true; StepSize.IsEnabled = false; } else { MovementModeSelect.Content = LanguageHandler.GetMessageResource("btnStep"); SpeedBox.Foreground = (FindResource("PrimaryHueLightBrush") as SolidColorBrush); StepSizeText.Foreground = (FindResource("AccentColorBrush") as SolidColorBrush); StepSize.Foreground = (FindResource("AccentColorBrush") as SolidColorBrush); SpeedBar.IsEnabled = false; StepSize.IsEnabled = true; } AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("ManualMovementMode"), state); }
private void SavePos_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if ((DateTime.Now - click_Started).TotalSeconds > 10) { if (CurrentlySelected != -1) { coordinate[CurrentlySelected] = PositionSyncronizer.CurrentPosition; PositionSyncronizer.TargetPosition = coordinate[CurrentlySelected]; AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("PositionArray"), coordinate); } DisplayData(coordinate[CurrentlySelected], C_Axis_Exists); SetGridStlye(C_Axis_Exists); dispatcherTimer.Stop(); SavePos.Content = "Save"; SavePos.Foreground = FindResource("AccentColorBrush") as SolidColorBrush; } else { dispatcherTimer.Stop(); SavePos.Content = "Save"; } }
public async Task <bool> TryUpdateReferenceAsync(string projectPath, string targetFrameworkMoniker, ReferenceUpdate referenceUpdate, CancellationToken cancellationToken) { bool wasUpdated = false; if (referenceUpdate.Action == UpdateAction.None) { return(wasUpdated); } ConfiguredProject activeConfiguredProject = await GetActiveConfiguredProjectByPathAsync(projectPath); ReferenceHandler referenceHandler = FindReferenceHandler(referenceUpdate); if (referenceUpdate.Action == UpdateAction.TreatAsUsed || referenceUpdate.Action == UpdateAction.TreatAsUnused) { wasUpdated = await referenceHandler.UpdateReferenceAsync(activeConfiguredProject, referenceUpdate, cancellationToken); } else { wasUpdated = await referenceHandler.RemoveReferenceAsync(activeConfiguredProject, referenceUpdate.ReferenceInfo); } return(wasUpdated); }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initializes the specified metadata. /// </summary> /// <param name="schemaElement"> /// The metadata. /// </param> /// <param name="domainModel"> /// The domain model. /// </param> ///------------------------------------------------------------------------------------------------- protected override void Initialize(ISchemaElement schemaElement, IDomainModel domainModel) { base.Initialize(schemaElement, domainModel); _propertyMetadataReference = new ReferenceHandler(this, Schema.Store.PrimitivesSchema.SchemaPropertyReferencesSchemaEntitySchema); _defaultValueProperty = ((IModelElement)this).SchemaInfo.GetProperty("DefaultValue"); }
private void OnDestroy() { Instance = null; }
private void SyncCoord() { coordinate = AdsCommunication.CoordinateArrayRead(MaxCoordinateNR, ReferenceHandler.GetReferenceAdress("PositionArray")); }
private void Awake() { Instance = this; }
public ReferenceController() { _referenceHandler = new ReferenceHandler(new DataContext()); }