private int GetMinMaxPosFromAll(Enums.CtrlEgdeType ctrlEgdeType, Enums.StepsType stepsType) { int retValue = 0, pos = 0; int min = int.MaxValue; int max = int.MinValue; switch (ctrlEgdeType) { case Enums.CtrlEgdeType.Min: for (int i = 0; i < Actuators.Count; i++) { ChangeContext(i); if (stepsType == Enums.StepsType.Steps) { pos = ActuatorInContext.GetCurrentPositionSteps(ActuatorInContext.DeviceID); } else if (stepsType == Enums.StepsType.MicroSteps) { pos = ActuatorInContext.GetCurrentPositionMicroSteps(ActuatorInContext.DeviceID); } if (min > pos) { min = pos; } } retValue = pos; break; case Enums.CtrlEgdeType.Max: for (int i = 0; i < Actuators.Count; i++) { ChangeContext(i); if (stepsType == Enums.StepsType.Steps) { pos = ActuatorInContext.GetCurrentPositionSteps(ActuatorInContext.DeviceID); } else if (stepsType == Enums.StepsType.MicroSteps) { pos = ActuatorInContext.GetCurrentPositionMicroSteps(ActuatorInContext.DeviceID); } if (pos > max) { max = pos; } } retValue = pos; break; default: break; } return(retValue); }
/// <summary> /// Moves actuator to a specified position in steps and microsteps <br/> /// Higher level wrapper method, called from the user interface. Calls Controller.ActuatorController.MoveToPosition() <br/> /// </summary> /// <param name="deviceID">identifies actuator, of type int</param> /// <param name="positionSteps">absolute value in actuator steps, of type int</param> /// <param name="positionMicrosteps">absolute value in actuator microsteps, of type int</param> public void ActuatorMoveToPosition(int deviceID, int positionSteps, int positionMicrosteps) { if (ActuatorInContext.MoveToPosition(deviceID, positionSteps, positionMicrosteps) == Result.ok) { //Task asyncTask = Task.Run(() => //{ // if (ActuatorInContext.WaitForStopWhile(deviceID, 0) == Result.ok) // logController.LogActuatorInfo(Enums.ActuatorLog.MoveToPosition, ActuatorInContext, Enums.ActuatorLogTiming.Finish); //}); } }
/// <summary> /// Move the actuator continuously to the right (expanding motion) <br/> ///Note that Controller.ActuatorController.MoveContinuouslyRight() is not called because it is marked as unsafe <br/> ///Higher level wrapper method, called from the user interface. Calls Controller.ActuatorController.MoveToPosition() /// </summary> /// <param name="deviceID">identifies actuator, of type int</param> /// <param name="maxEdgeSoftware">represents maximum steps value to which an actuator can move, refers to /// View.ActuatorPositionSoftwareLimits.MaxEdgePositionStepsAllDevices, of type int</param> // MoveContinuouslyRight is unsafe! Using MoveToPosition instead public void ActuatorMoveContinuouslyRight(int deviceID, int maxEdgeSoftware) { if (ActuatorInContext.MoveToPosition(deviceID, maxEdgeSoftware, 0) == Result.ok) { //Task asyncTask = Task.Run(() => //{ // if (ActuatorInContext.WaitForStopWhile(deviceID, 0) == Result.ok) // logController.LogActuatorInfo(Enums.ActuatorLog.MoveToPosition, ActuatorInContext, Enums.ActuatorLogTiming.Finish); //}); } }
/// <summary> /// Moves the actuator by a specified delta in steps and microsteps <br/> ///Higher level wrapper method, called from the user interface. Calls Controller.ActuatorController.MoveRelatively() /// </summary> /// <param name="deviceID">identifies actuator, of type int</param> /// <param name="deltaSteps">relative actuator steps value, of type int</param> /// <param name="deltaMicrosteps">relative actuator microsteps value, of type int</param> public void ActuatorMoveRelatively(int deviceID, int deltaSteps, int deltaMicrosteps) { if (ActuatorInContext.MoveRelatively(deviceID, deltaSteps, deltaMicrosteps) == Result.ok) { //Task asyncTask = Task.Run(() => //{ // if (ActuatorInContext.WaitForStopWhile(deviceID, 0) == Result.ok) // logController.LogActuatorInfo(Enums.ActuatorLog.MoveRelatively, ActuatorInContext, Enums.ActuatorLogTiming.Finish); //}); } }
/// <summary> /// Moves the actuator to its home position <br/> /// Higher level wrapper method, called from the user interface. Calls Controller.ActuatorController.MoveToHomePosition() /// </summary> /// <param name="deviceID">identifies actuator, of type int</param> public void MoveHome(int deviceID) { if (ActuatorInContext.MoveToHomePosition(deviceID) == Result.ok) { //Task asyncTask = Task.Run(() => //{ // if (ActuatorInContext.WaitForStopWhile(deviceID, 0) == Result.ok) // logController.LogActuatorInfo(Enums.ActuatorLog.MoveHome, ActuatorInContext, Enums.ActuatorLogTiming.Finish); //}); } }
/// <summary> /// Performs an instant stop of the actuator <br/> ///Not recommended because of potential hardware stress. Consider using Controller.MainController.ActuatorSoftStop() instead <br/> ///Higher level wrapper method, called from the user interface. Calls Controller.ActuatorController.HardStop() /// </summary> /// <param name="deviceID">identifies actuator, of type int</param> public void ActuatorHardStop(int deviceID) { if (ActuatorInContext.GetStatus(ActuatorInContext.DeviceID).CurSpeed != 0 || ActuatorInContext.GetStatus(ActuatorInContext.DeviceID).uCurSpeed != 0) { if (ActuatorInContext.HardStop(deviceID) == Result.ok) { //Task asyncTask = Task.Run(() => //{ // if (ActuatorInContext.WaitForStopWhile(deviceID, 0) == Result.ok) // logController.LogActuatorInfo(Enums.ActuatorLog.HardStop, ActuatorInContext, Enums.ActuatorLogTiming.Finish); //}); } } }
public int GetActuatorPositionByAxis(Enums.Axis axis) { switch (axis) { case Enums.Axis.X: ChangeContextByAxis(Enums.Axis.X); break; case Enums.Axis.Y: ChangeContextByAxis(Enums.Axis.Y); break; } return(ActuatorInContext.GetCurrentPositionSteps(ActuatorInContext.DeviceID)); }
/// <summary> /// Deprecated. Thread was tasked with executing work used for checking for newly connected actuators. /// by calling Controller.ActuatorErrorHandler.CheckForActuatorErrors() /// </summary> /// <param name="obj"></param> /// <param name="e"></param> // TO DELETE void bgWorkerErrorPollingProgressChanged(object obj, ProgressChangedEventArgs e) { if (ActuatorInContext.DeviceID != -1) { actuatorErrorHandler.CheckForActuatorErrors(ActuatorInContext.GetStatus(ActuatorInContext.DeviceID)); } // If device is -1, meaning that actuator got disconncted else { // Try to get another actuator in context, the first one found in the list if (Actuators.Count > 0) { ChangeContext(Actuators.List[0].DeviceID); } // Await actuator connection else { } } }
public void ActuatorSetZero(int deviceID) { ActuatorInContext.SetZeroPosition(deviceID); }
/// <summary> /// Powers off selected actuator <br/> ///Higher level wrapper method, called from the user interface. Calls Controller.ActuatorController.PowerOff() /// </summary> /// <param name="deviceID">identifies actuator, of type int</param> public void ActuatorPowerOff(int deviceID) { ActuatorInContext.PowerOff(deviceID); }
/// <summary> /// Hazardous. Calibrates the position of connected actuators <br/> /// Higher level wrapper method, called from the user interface. Calls Controller.ActuatorController.CalibrateMovement() /// </summary> /// <param name="deviceID">identifies actuator, of type int</param> /// <returns></returns> public List <int> ActuatorCalibrateMovement(int deviceID) { return(ActuatorInContext.CalibrateMovement(deviceID)); }
/// <summary> /// Closes the connection to an actuator <br/> /// Higher level wrapper method, called from the user interface. Calls Controller.ActuatorController.CloseDevice() /// </summary> /// <param name="deviceID">identifies actuator, of type int</param> public void ActuatorCloseDevice(int deviceID) { ActuatorInContext.CloseDevice(ref deviceID); }