public void SetCurrentPosition(LeverPosition position) { var action = new Action(() => { if (position.LeverType == LeverType.Horizontal) { lblHorizontalCurrent.Text = position.Position.ToString(); } if (position.LeverType == LeverType.Lever1) { lblLever1Current.Text = position.Position.ToString(); } if (position.LeverType == LeverType.Lever2) { lblLever2Current.Text = position.Position.ToString(); } }); if (this.InvokeRequired) { this.Invoke(action); } else { action(); } }
protected void Update() { LeverEngaged = false; LastValue = CurrentValue; LastLeverPosition = CurrentLeverPosition; CurrentValue = GetValue(); CurrentLeverPosition = GetPosition(); if (Mode == WorkingMode.NormallyClosed) { if (LastLeverPosition != LeverPosition.On && CurrentLeverPosition == LeverPosition.On) { LeverEngaged = true; Engage(); if (OnEngaged != null) { OnEngaged(); } } } else if (Mode == WorkingMode.Slider) { if (EmitCompleteEvent) { if (OnAdjustComplete != null) { OnAdjustComplete(); } EmitCompleteEvent = false; } } }
private void Movement_LeverPositionChanged(object sender, LeverPosition e) { currentPositionLoader.SaveCurrentPosition(e.LeverType, e.Position); if (view.IsEditWorkspaceMode) { view.SetCurrentEditWorkspaceModeLeverPosition(e.LeverType, e.Position); } view.SetCurrentPosition(e); }
public void ToggleLeverPosition() { if (leverPosition == LeverPosition.Left) { leverPosition = LeverPosition.Right; } else if (leverPosition == LeverPosition.Right) { leverPosition = LeverPosition.Left; } }
public void OnToggle() { var rectTransform = this.GetComponent <RectTransform> (); if (position == LeverPosition.Left) { rectTransform.Rotate(0, 0, -90); position = LeverPosition.Right; } else if (position == LeverPosition.Right) { rectTransform.Rotate(0, 0, 90); position = LeverPosition.Left; } }
protected override void Update() { base.Update(); LeverEngaged = false; LastValue = CurrentValue; LastLeverPosition = CurrentLeverPosition; CurrentValue = GetValue(); CurrentLeverPosition = GetPosition(); if (LastLeverPosition != LeverPosition.On && CurrentLeverPosition == LeverPosition.On) { LeverEngaged = true; Engage(); } }
private void Movement_LeverPositionChanged(object sender, LeverPosition e) { try { if (isRunningToPoint) { if (!MovementScript.Start.Contains(e) && !MovementScript.End.Contains(e)) { throw new Exception("Ошибка при перемещении робота к " + (path == null ? "начальной" : "конечной") + " точке сценария"); } return; } if (!e.Equals(GetActiveLeverPosition())) { throw new Exception("Ошибка при перемещении робота по сценарию"); } StepPassed(this, active); active = null; if (path.Count > 0) { Run(); return; } if (!movement.IsNowAtPosition(MovementScript.End)) { movement.MoveRobotByPath(MovementScript.End, new Action(() => isRunningToPoint = false)); return; } IsExecuting = false; } catch (Exception ex) { Exception = ex; IsExecuting = false; } }
protected override void Update() { base.Update(); LeverEngaged = false; LastValue = CurrentValue; LastLeverPosition = CurrentLeverPosition; CurrentValue = GetValue(); print("Turn Value is: "); //RANGE OF MOTION: ~ 0 - 0.75 print(CurrentValue); CurrentLeverPosition = GetPosition(); if (LastLeverPosition != LeverPosition.On && CurrentLeverPosition == LeverPosition.On) { LeverEngaged = true; Engage(); } }