/// <summary> Process the device status. </summary> /// <param name="deviceStatus"> The device status. </param> /// <param name="resendCmd"> The resend command. </param> /// <param name="getter"> True to getter. </param> /// <returns> A StatusResult. </returns> protected override StatusResult ProcessDeviceStatus(DeviceStatus deviceStatus, string resendCmd, bool getter) { switch (deviceStatus.Status) { case DeviceStatus.DeviceStatusValues.Busy: UpdateDeviceStatus(deviceStatus); if (getter) { ELLDevicePort.SendString(Address, resendCmd); } return(StatusResult.Busy); case DeviceStatus.DeviceStatusValues.OK: //_isThermalLocked = false; UpdateDeviceStatus(deviceStatus); if (getter) { ELLDevicePort.SendString(Address, resendCmd); } return(StatusResult.OK); case DeviceStatus.DeviceStatusValues.ModuleIsolated: UpdateDeviceStatus(deviceStatus); return(StatusResult.Fail); default: UpdateDeviceStatus(deviceStatus); Thread.Sleep(500); ELLDevicePort.SendString(Address, resendCmd); break; } return(StatusResult.Error); }
/// <summary> Get the device MotorInfo structure. </summary> /// <returns> Success if the motor info retrieved succesfully. </returns> public bool GetMotorInfo(char motorID) { if (!IsMotorIdValid(motorID)) { return(false); } UpdateOutput(string.Format("Requesting Motor{0} info...", motorID)); ELLDevicePort.SendString(Address, "i" + motorID); try { string msg = ELLDevicePort.WaitForResponse(Address, "I" + motorID, MoveTimeout); if (!string.IsNullOrEmpty(msg)) { MotorInfo info = new MotorInfo(msg); _motorInfo[motorID] = info; UpdateOutput("Get Device Status: ", info.Description()); UpdateParameter(MessageUpdater.UpdateTypes.MotorInfo, Address, info); return(true); } } catch (ELLException) { UpdateOutput(string.Format("Requesting Motor{0}: FAILED", motorID)); } return(false); }
/// <summary> Scans the addresses. </summary> /// <param name="minDeviceAddress"> The minimum device address. </param> /// <param name="maxDeviceAddress"> The maximum device address. </param> /// <returns> Returns a list of available device addresses. </returns> public List <string> ScanAddresses(char minDeviceAddress, char maxDeviceAddress) { List <string> connections = new List <string>(); if (!ELLDevicePort.IsConnected) { return(connections); } _messageUpdater.UpdateOutput("Scanning for devices"); foreach (char address in ELLBaseDevice.ValidAddresses.Where(item => item >= minDeviceAddress && item <= maxDeviceAddress)) { ELLDevicePort.SendString(address, "in"); try { string msg = ELLDevicePort.WaitForResponse(address, "IN", ELLBaseDevice.StatusTimeout); if (!string.IsNullOrEmpty(msg)) { connections.Add(msg); } } catch (ELLException e) { Debug.WriteLine(e.Message); // device address not used } } _messageUpdater.UpdateOutput(connections.Count < 2 ? string.Format("{0} device found", connections.Count) : string.Format("{0} devices found", connections.Count)); return(connections); }
private void StartJogging(string command, string message) { _isJogging = true; UpdateOutput(message); ELLDevicePort.SendString(Address, command); if (_jogTimer == null) { _jogTimer = new Timer(JogTimeUpdate, 0, 100, 0); } }
/// <summary> Starts a forward jog and returns after position value is returned. </summary> /// <returns> True if the device was jogged succesfully. </returns> public bool JogStop() { if (!_isJogging) { return(false); } JogStopInternal(); //Debug.WriteLine($"Stop Set false {_isJogging}"); UpdateOutput("Jog Stop"); ELLDevicePort.SendString(Address, "ms"); return(GetPosition()); }
/// <summary> Saves the user data. </summary> /// <returns> True if the UserData is saved by the device. </returns> public bool SendStopCleaning() { if (!_isCleaning) { return(false); } UpdateOutput("Stop cleaning..."); ELLDevicePort.SendString(Address, "st"); SetSleepDelayCounter(2); ELLDevicePort.SendString(Address, "gs"); return(true); }
/// <summary> Jog the current device backward. </summary> /// <returns> True if the device was jogged succesfully. </returns> /// <seealso cref="JogBackward()"/> /// <seealso cref="SetJogstepSize(decimal)"/> /// <seealso cref="GetJogstepSize()"/> /// <seealso cref="JogForward(List<char>)"/> /// <seealso cref="JogBackward(List<char>)"/> public bool JogBackward() { if (IsDeviceBusy()) { return(false); } UpdateOutput(string.Format("Jog Backward {0}", DeviceInfo.FormatPosition(_jogstepSize, true, true))); ELLDevicePort.SendString(Address, "bw"); if (!WaitForPosition()) { return(false); } return(true); }
/// <summary> Saves the user data. </summary> /// <returns> True if the UserData is saved by the device. </returns> public bool SendCleanMachine() { if (IsDeviceBusy()) { return(false); } SetCleaningState(true); UpdateOutput("Performing clean mechanics..."); ELLDevicePort.SendString(Address, "cm"); bool retval = WaitForCleaning(); SetCleaningState(false);; return(retval); }
/// <summary> Homes the given paddles. </summary> /// <param name="paddles"> (Optional) The paddles. </param> /// <returns> True if it succeeds, false if it fails. </returns> public bool Home(PaddleHomeMask paddles = PaddleHomeMask.All) { if (paddles == PaddleHomeMask.None) { return(false); } UpdateOutput("Homing paddles ..."); ELLDevicePort.SendString(Address, "ho" + (char)('0' + paddles)); if (!WaitForPositions()) { return(false); } return(true); }
/// <summary> Homes the current stage. </summary> /// <param name="direction"> The home direction. </param> /// <returns> True if the device was homed succesfully. </returns> /// <seealso cref="Home(List<char>, ELLDevice.DeviceDirection)"/> public bool Home(DeviceDirection direction = DeviceDirection.Linear) { if (IsDeviceBusy()) { return(false); } UpdateOutput("Homing device ..."); ELLDevicePort.SendString(Address, "ho" + (char)direction); if (!WaitForPosition()) { return(false); } return(true); }
/// <summary> Saves the user data. </summary> /// <returns> True if the UserData is saved by the device. </returns> public bool SendCleanAndOptimize() { if (IsDeviceBusy()) { return(false); } SetCleaningState(true);; UpdateOutput("Performing clean & optimize..."); ELLDevicePort.SendString(Address, "om"); bool retval = WaitForCleaning(); SetCleaningState(false);; return(retval); }
/// <summary> Scan current Curve. </summary> /// <param name="motorID"> Identifier for the motor. </param> /// <returns> True if the function was performed succesfully. </returns> public bool ScanCurrentCurve(char motorID) { if (!IsMotorIdValid(motorID)) { return(false); } UpdateOutput(string.Format("Motor{0} - Scan Current ...", motorID)); ELLDevicePort.SendString(Address, "c" + motorID); if (!WaitForStatus(6000)) { return(false); } GetMotorInfo(motorID); return(true); }
/// <summary> Jog the given stages forward. </summary> /// <param name="addresses"> The addresses of the devices to be jogged. </param> /// <returns> True if the device was jogged succesfully. </returns> /// <seealso cref="Home(List<char>, ELLBaseDevice.DeviceDirection)"/> /// <seealso cref="MoveAbsolute(List<char>, decimal)"/> /// <seealso cref="MoveRelative(List<char>, decimal)"/> /// <seealso cref="JogForward(List<char>)"/> /// <seealso cref="JogBackward(List<char>)"/> public bool JogForward(List <char> addresses) { if (!addresses.Any()) { return(JogForward()); } SetToGroupAddress(addresses); UpdateOutput(string.Format("Jog Forward {0}", DeviceInfo.FormatPosition(_jogstepSize, true, true))); ELLDevicePort.SendString(Address, "fw"); if (!WaitForPositions(addresses)) { return(false); } return(true); }
/// <summary> Search for the device period. </summary> /// <param name="motorID"> Identifier for the motor. </param> /// <param name="permanent"> True to change the period permanently. </param> /// <returns> True if the period is set. </returns> public bool SearchPeriod(char motorID, bool permanent) { if (!IsMotorIdValid(motorID)) { return(false); } UpdateOutput(string.Format("Motor{0} - Search period ...", motorID)); ELLDevicePort.SendString(Address, "s" + motorID); if (!WaitForStatus(SearchTimeout)) { return(false); } GetMotorInfo(motorID); if (permanent) { SaveUserData(); } return(true); }
/// <summary> Homes the given stages. </summary> /// <param name="addresses"> The list of addresses of devices to be homed. </param> /// <param name="direction"> The home direction. </param> /// <returns> Success. </returns> /// <seealso cref="Home(ELLBaseDevice.DeviceDirection)"/> /// <seealso cref="MoveAbsolute(List<char>, decimal)"/> /// <seealso cref="MoveRelative(List<char>, decimal)"/> /// <seealso cref="JogForward(List<char>)"/> /// <seealso cref="JogBackward(List<char>)"/> public bool Home(List <char> addresses, DeviceDirection direction = DeviceDirection.Linear) { if (IsDeviceBusy()) { return(false); } if (!addresses.Any()) { return(Home(direction)); } SetToGroupAddress(addresses); UpdateOutput("Homing device ..."); ELLDevicePort.SendString(Address, "ho" + (int)direction); if (!WaitForPositions(addresses)) { return(false); } return(true); }
/// <summary> Wait for status. </summary> /// <param name="msTimeout"> (Optional) The milliseconds timeout. </param> /// <returns> True if it succeeds, false if it fails. </returns> protected bool WaitForCleaning(int msTimeout = CleanTimeout) { try { int counter = 60; while (true) { string msg = ELLDevicePort.WaitForResponse(Address, "GS", msTimeout); if (!String.IsNullOrEmpty(msg)) { if (msg.Substring(1, 4) == "GS09") { SetSleepDelayCounter(10); while (GetSleepDelayCounter() >= 0) { SetSleepDelayCounter(GetSleepDelayCounter() - 1); Thread.Sleep(1000); } ELLDevicePort.SendString(Address, "gs"); } else { bool returnValue; if (TestStatus(msg, "gs", false, ref counter, out returnValue)) { return(returnValue); } } } } } catch (ELLException ex) { _messageUpdater?.UpdateOutput($"Get Device Status: {ex.Message}", true); } return(false); }
public bool RequestPosition(PaddleIDs paddleID) { UpdateOutput($"Get Position {(char)paddleID}..."); ELLDevicePort.SendString(Address, $"p{(char)paddleID}"); return(WaitForPosition(paddleID)); }
public bool RequestPositions() { UpdateOutput("Get Positions..."); ELLDevicePort.SendString(Address, "gp"); return(WaitForPositions()); }
/// <summary> Gets the current device jogstep size. </summary> /// <remarks> Use <see cref="JogstepSize"/> to obtain the current jog step size</remarks> /// <returns> True if the jogstep was retrieved succesfully. </returns> public bool GetJogstepSize() { UpdateOutput("Get Jogstep Size..."); ELLDevicePort.SendString(Address, "gj"); return(WaitForJogstepSize("gj", true)); }
/// <summary> Gets the current device home offset. </summary> /// <remarks> Use <see cref="HomeOffset"/> to obtain the current home offset</remarks> /// <returns> True if the home offset was retrieved succesfully. </returns> /// <seealso cref="HomeOffset"/> /// <seealso cref="SetHomeOffset(decimal)"/> public bool GetHomeOffset() { UpdateOutput("Get Home Offset..."); ELLDevicePort.SendString(Address, "go"); return(WaitForHomeOffset("go", true)); }
/// <summary> Saves the user data. </summary> /// <returns> True if the UserData is saved by the device. </returns> public bool SaveUserData() { UpdateOutput("Save user status..."); ELLDevicePort.SendString(Address, "us"); return(WaitForStatus()); }
/// <summary> Obtains the device status from the device. </summary> /// <remarks> Use <see cref="DeviceStatus"/> to obtain the current status</remarks> /// <returns> True if the status is retrieved from the device. </returns> /// <seealso cref="DeviceStatus"/> public bool GetDeviceStatus() { UpdateOutput("Get Device Status..."); ELLDevicePort.SendString(Address, "gs"); return(WaitForStatus()); }