public bool MoveRelative(PaddlePosition displacement) { try { short pulses = (short)(UnitToPulse(displacement.Position, -0x3FF, 0x3FF)); UpdateOutput(string.Format("Move paddle {0} by {1}...", (char)displacement.PaddleId, displacement.PaddleId)); ELLDevicePort.SendStringI16(Address, $"r{(char)displacement.PaddleId}", pulses); return(WaitForPosition(displacement.PaddleId)); } catch (OverflowException) { UpdateOutput(string.Format("Parameter out of range {0}...", displacement.Position)); } return(false); }
public bool MoveAbsolute(PaddlePosition position) { try { short pulses = (short)(UnitToPulse(position.Position, 0, 0x3FF)); UpdateOutput(string.Format("Move paddle {0} to {1}...", (char)position.PaddleId, position.PaddleId)); ELLDevicePort.SendStringI16(Address, $"a{(char)position.PaddleId}", pulses); return(WaitForPosition(position.PaddleId)); } catch (OverflowException) { UpdateOutput(string.Format("Parameter out of range {0}...", position.Position)); } return(false); }
/// <summary> Move microsecond steps. </summary> /// <param name="paddleID"> Identifier for the paddle. </param> /// <param name="timeMS"> The time in milliseconds. </param> /// <param name="backward"> True to backward. </param> /// <returns> True if it succeeds, false if it fails. </returns> public bool MoveMicrosecondSteps(PaddleIDs paddleID, short timeMS, bool backward) { try { if (timeMS < 0 || timeMS > 8000) { throw new ArgumentOutOfRangeException($"Range 0 to 8000"); } if (backward) { timeMS = (short)((timeMS & 0x1FFF) | 0x8000); } UpdateOutput(string.Format("Move paddle {0} for {1} ms...", (char)paddleID, timeMS)); ELLDevicePort.SendStringI16(Address, $"t{(char)paddleID}", timeMS); return(WaitForPosition(paddleID)); } catch (OverflowException) { UpdateOutput(string.Format("Parameter out of range {0}...", timeMS)); } return(false); }
public bool ResetPeriod() { List <char> _motors = _motorInfo.Where(kvp => (kvp.Value != null) && (kvp.Value.IsValid)).Select(kvp => kvp.Key).ToList(); foreach (char motorID in _motors) { UpdateOutput(string.Format("Motor{0} - Reset default period ...", motorID)); UInt16 period = (Int16)(14740 / 100) | 0x8000; ELLDevicePort.SendStringI16(Address, "f" + motorID, period); if (!WaitForStatus(SearchTimeout)) { return(false); } ELLDevicePort.SendStringI16(Address, "b" + motorID, period); if (!WaitForStatus(SearchTimeout)) { return(false); } GetMotorInfo(motorID); } SaveUserData(); return(true); }
/// <summary> Sets the device period. </summary> /// <param name="motorID"> Identifier for the motor. </param> /// <param name="fwd"> The direction the period is applied to, true for forward, false for reverse. </param> /// <param name="frequency"> The device frequency. </param> /// <param name="permanent"> True to change the period permanently. </param> /// <param name="hardSaveFrequencey"> True to hard save frequencey. </param> /// <returns> True if the period is set. </returns> public bool SetPeriod(char motorID, bool fwd, decimal frequency, bool permanent, bool hardSaveFrequencey) { if (!IsMotorIdValid(motorID)) { return(false); } UInt16 period = (UInt16)(14740 / frequency); UpdateOutput(string.Format("Motor{0} - Setting {1} period to {2:X}({3}kHz) ...", motorID, fwd ? "Fwd" : "Bwd", period, frequency)); if (hardSaveFrequencey) { period |= 0x8000; } ELLDevicePort.SendStringI16(Address, (fwd ? "f" : "b") + motorID, period); if (!WaitForStatus()) { return(false); } if (permanent) { SaveUserData(); } return(true); }