diff --git a/src/hal/user_comps/xhc-whb04b-6/hal.cc b/src/hal/user_comps/xhc-whb04b-6/hal.cc index 878df18e7..101759455 100644 --- a/src/hal/user_comps/xhc-whb04b-6/hal.cc +++ b/src/hal/user_comps/xhc-whb04b-6/hal.cc @@ -26,6 +26,7 @@ #include #include #include +#include // local library includes #include "./pendant.h" @@ -457,6 +458,32 @@ void Hal::init(const MetaButtonCodes* metaButtons, const KeyCodes& keyCodes) newHalBit(HAL_OUT, &(memory->out.lubeStop), mHalCompId, "%s.halui.lube.off", mComponentPrefix); newHalBit(HAL_OUT, &(memory->out.lubeStart), mHalCompId, "%s.halui.lube.on", mComponentPrefix); +////// mrec + newHalSigned32(HAL_OUT, &(memory->out.joint0JogCounts), mHalCompId, "%s.joint.0.jog-counts", mComponentPrefix); + newHalFloat(HAL_OUT, &(memory->out.joint0JogScale), mHalCompId, "%s.joint.0.jog-scale", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint0JogEnable), mHalCompId, "%s.joint.0.jog-enable", mComponentPrefix); + + newHalSigned32(HAL_OUT, &(memory->out.joint1JogCounts), mHalCompId, "%s.joint.1.jog-counts", mComponentPrefix); + newHalFloat(HAL_OUT, &(memory->out.joint1JogScale), mHalCompId, "%s.joint.1.jog-scale", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint1JogEnable), mHalCompId, "%s.joint.1.jog-enable", mComponentPrefix); + + newHalSigned32(HAL_OUT, &(memory->out.joint2JogCounts), mHalCompId, "%s.joint.2.jog-counts", mComponentPrefix); + newHalFloat(HAL_OUT, &(memory->out.joint2JogScale), mHalCompId, "%s.joint.2.jog-scale", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint2JogEnable), mHalCompId, "%s.joint.2.jog-enable", mComponentPrefix); + + newHalSigned32(HAL_OUT, &(memory->out.joint3JogCounts), mHalCompId, "%s.joint.3.jog-counts", mComponentPrefix); + newHalFloat(HAL_OUT, &(memory->out.joint3JogScale), mHalCompId, "%s.joint.3.jog-scale", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint3JogEnable), mHalCompId, "%s.joint.3.jog-enable", mComponentPrefix); + + newHalSigned32(HAL_OUT, &(memory->out.joint4JogCounts), mHalCompId, "%s.joint.4.jog-counts", mComponentPrefix); + newHalFloat(HAL_OUT, &(memory->out.joint4JogScale), mHalCompId, "%s.joint.4.jog-scale", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint4JogEnable), mHalCompId, "%s.joint.4.jog-enable", mComponentPrefix); + + newHalSigned32(HAL_OUT, &(memory->out.joint5JogCounts), mHalCompId, "%s.joint.5.jog-counts", mComponentPrefix); + newHalFloat(HAL_OUT, &(memory->out.joint5JogScale), mHalCompId, "%s.joint.5.jog-scale", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint5JogEnable), mHalCompId, "%s.joint.5.jog-enable", mComponentPrefix); +///// + newHalSigned32(HAL_OUT, &(memory->out.axisXJogCounts), mHalCompId, "%s.axis.x.jog-counts", mComponentPrefix); newHalBit(HAL_OUT, &(memory->out.axisXJogEnable), mHalCompId, "%s.axis.x.jog-enable", mComponentPrefix); newHalFloat(HAL_OUT, &(memory->out.axisXJogScale), mHalCompId, "%s.axis.x.jog-scale", mComponentPrefix); @@ -564,6 +591,20 @@ void Hal::init(const MetaButtonCodes* metaButtons, const KeyCodes& keyCodes) newHalBit(HAL_IN, &(memory->in.JointCisHomed), mHalCompId, "%s.halui.joint.c.is-homed", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint0Home), mHalCompId, "%s.joint.0.home", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint1Home), mHalCompId, "%s.joint.1.home", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint2Home), mHalCompId, "%s.joint.2.home", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint3Home), mHalCompId, "%s.joint.3.home", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint4Home), mHalCompId, "%s.joint.4.home", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint5Home), mHalCompId, "%s.joint.5.home", mComponentPrefix); + + newHalBit(HAL_OUT, &(memory->out.joint0Unhome), mHalCompId, "%s.joint.0.unhome", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint1Unhome), mHalCompId, "%s.joint.1.unhome", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint2Unhome), mHalCompId, "%s.joint.2.unhome", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint3Unhome), mHalCompId, "%s.joint.3.unhome", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint4Unhome), mHalCompId, "%s.joint.4.unhome", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.joint5Unhome), mHalCompId, "%s.joint.5.unhome", mComponentPrefix); + newHalBit(HAL_OUT, &(memory->out.doModeAuto), mHalCompId, "%s.halui.mode.auto", mComponentPrefix); newHalBit(HAL_OUT, &(memory->out.doModeJoint), mHalCompId, "%s.halui.mode.joint", mComponentPrefix); newHalBit(HAL_OUT, &(memory->out.doModeManual), mHalCompId, "%s.halui.mode.manual", mComponentPrefix); @@ -641,6 +682,8 @@ hal_float_t Hal::getAxisCPosition(bool absolute) const // ---------------------------------------------------------------------- void Hal::enableVerbose(bool enable) { + enable=true; + if (enable) { mHalCout = &std::cout; @@ -659,53 +702,53 @@ void Hal::setNoAxisActive(bool enabled) void Hal::setAxisXActive(bool enabled) { *memory->out.axisXSelect = enabled; - *memory->out.axisXJogEnable = enabled; + *memory->out.joint0JogEnable = *memory->out.axisXJogEnable = enabled; *mHalCout << "hal X axis active" << endl; } // ---------------------------------------------------------------------- void Hal::setAxisYActive(bool enabled) { *memory->out.axisYSelect = enabled; - *memory->out.axisYJogEnable = enabled; + *memory->out.joint1JogEnable = *memory->out.axisYJogEnable = enabled; *mHalCout << "hal Y axis active" << endl; } // ---------------------------------------------------------------------- void Hal::setAxisZActive(bool enabled) { *memory->out.axisZSelect = enabled; - *memory->out.axisZJogEnable = enabled; + *memory->out.joint2JogEnable = *memory->out.axisZJogEnable = enabled; *mHalCout << "hal Z axis active" << endl; } // ---------------------------------------------------------------------- void Hal::setAxisAActive(bool enabled) { *memory->out.axisASelect = enabled; - *memory->out.axisAJogEnable = enabled; + *memory->out.joint3JogEnable = *memory->out.axisAJogEnable = enabled; *mHalCout << "hal A axis active" << endl; } // ---------------------------------------------------------------------- void Hal::setAxisBActive(bool enabled) { *memory->out.axisBSelect = enabled; - *memory->out.axisBJogEnable = enabled; + *memory->out.joint4JogEnable = *memory->out.axisBJogEnable = enabled; *mHalCout << "hal B axis active" << endl; } // ---------------------------------------------------------------------- void Hal::setAxisCActive(bool enabled) { *memory->out.axisCSelect = enabled; - *memory->out.axisCJogEnable = enabled; + *memory->out.joint5JogEnable = *memory->out.axisCJogEnable = enabled; *mHalCout << "hal C axis active" << endl; } // ---------------------------------------------------------------------- void Hal::setStepSize(const hal_float_t stepSize) { - *memory->out.axisXJogScale = stepSize; - *memory->out.axisYJogScale = stepSize; - *memory->out.axisZJogScale = stepSize; - *memory->out.axisAJogScale = stepSize; - *memory->out.axisBJogScale = stepSize; - *memory->out.axisCJogScale = stepSize; + *memory->out.joint0JogScale = *memory->out.axisXJogScale = stepSize; + *memory->out.joint1JogScale = *memory->out.axisYJogScale = stepSize; + *memory->out.joint2JogScale = *memory->out.axisZJogScale = stepSize; + *memory->out.joint3JogScale = *memory->out.axisAJogScale = stepSize; + *memory->out.joint4JogScale = *memory->out.axisBJogScale = stepSize; + *memory->out.joint5JogScale = *memory->out.axisCJogScale = stepSize; *mHalCout << "hal step size " << stepSize << endl; } // ---------------------------------------------------------------------- @@ -749,11 +792,11 @@ void Hal::setStart(bool enabled) if (requestAutoMode(enabled)) { if (enabled) - { - toggleStartResumeProgram(); + { + toggleStartResumeProgram(); + } + setPin(enabled, KeyCodes::Buttons.start.text); } - setPin(enabled, KeyCodes::Buttons.start.text); -} if (!enabled) { @@ -795,6 +838,23 @@ void Hal::clearStartResumeProgramStates() *memory->out.doRunProgram = false; *memory->out.doResumeProgram = false; } + +void Hal::checkState(bool state, hal_bit_t *pin) { + // 500 milliseconds timeout + unsigned int timeouts=500; + unsigned int timeoutMs=1; + do + { + if (state == *pin) + { + usleep(timeoutMs * 1000); + } + else + { + break; + } + } while ((state == *pin) && (--timeouts) > 0); +} // ---------------------------------------------------------------------- void Hal::toggleStartResumeProgram() { @@ -803,17 +863,21 @@ void Hal::toggleStartResumeProgram() *memory->out.doPauseProgram = false; *memory->out.doRunProgram = false; *memory->out.doResumeProgram = true; - } - if (*memory->in.isProgramRunning) + checkState(true, memory->in.isProgramPaused); + *memory->out.doResumeProgram = false; + } else if (*memory->in.isProgramRunning) { *memory->out.doPauseProgram = true; + checkState(false, memory->in.isProgramPaused); + *memory->out.doPauseProgram = false; *memory->out.doRunProgram = false; *memory->out.doResumeProgram = false; - } - if (*memory->in.isProgramIdle) + } else if (*memory->in.isProgramIdle) { *memory->out.doPauseProgram = false; *memory->out.doRunProgram = true; + checkState(false, memory->in.isProgramRunning); + *memory->out.doRunProgram = false; *memory->out.doResumeProgram = false; } } @@ -936,7 +1000,98 @@ void Hal::setSpindleOverrideMinus(bool enabled) */ void Hal::setMachineHomingAll(bool enabled) { -// if (requestManualMode(enabled)) + if (enabled) { + /* pushing the button for 1 second will cause an unhome on the selected axis */ + if (*memory->out.joint0JogEnable) { + //*memory->out.joint0Home = true; + mjoint0HomeDoHome=true; + mjoint0HomeStamp=now()+1000; + } + if (*memory->out.joint1JogEnable) { + //*memory->out.joint1Home = true; + mjoint1HomeDoHome=true; + mjoint1HomeStamp=now()+1000; + } + if (*memory->out.joint2JogEnable) { + //*memory->out.joint2Home = true; + mjoint2HomeDoHome=true; + mjoint2HomeStamp=now()+1000; + } + if (*memory->out.joint3JogEnable) { + *memory->out.joint3Home = true; + mjoint3HomeDoHome=true; + mjoint3HomeStamp=now()+1000; + } + if (*memory->out.joint4JogEnable) { + *memory->out.joint4Home = true; + mjoint4HomeDoHome=true; + mjoint4HomeStamp=now()+1000; + } + if (*memory->out.joint5JogEnable) { + *memory->out.joint5Home = true; + mjoint5HomeDoHome=true; + mjoint5HomeStamp=now()+1000; + } + } else { + if (mjoint0HomeDoHome) { + //*memory->out.joint0Home = false; + mjoint0HomeDoHome=false; + if (expired(mjoint0HomeStamp)) { + *memory->out.joint0Unhome = true; + mjoint0UnhomeStamp=now()+50; + } else { + *memory->out.joint0Home = true; + mjoint0HomeStamp=now()+50; + } + } + if (mjoint1HomeDoHome) { + //*memory->out.joint1Home = false; + mjoint1HomeDoHome=false; + if (expired(mjoint1HomeStamp)) { + *memory->out.joint1Unhome = true; + mjoint1UnhomeStamp=now()+50; + } else { + *memory->out.joint1Home = true; + mjoint1HomeStamp=now()+50; + } + } + if (mjoint2HomeDoHome) { + //*memory->out.joint2Home = false; + mjoint2HomeDoHome=false; + if (expired(mjoint2HomeStamp)) { + *memory->out.joint2Unhome = true; + mjoint2UnhomeStamp=now()+50; + } else { + *memory->out.joint2Home = true; + mjoint2HomeStamp=now()+50; + } + } + if (mjoint3HomeDoHome) { + *memory->out.joint3Home = false; + mjoint3HomeDoHome=false; + if (expired(mjoint3HomeStamp)) { + *memory->out.joint3Unhome = true; + mjoint3UnhomeStamp=now()+50; + } + } + if (mjoint4HomeDoHome) { + *memory->out.joint4Home = false; + mjoint4HomeDoHome=false; + if (expired(mjoint4HomeStamp)) { + *memory->out.joint4Unhome = true; + mjoint4UnhomeStamp=now()+50; + } + } + if (mjoint5HomeDoHome) { + *memory->out.joint5Home = false; + mjoint5HomeDoHome=false; + if (expired(mjoint5HomeStamp)) { + *memory->out.joint5Unhome = true; + mjoint5UnhomeStamp=now()+50; + } + } + } + if (requestJointMode(enabled)) { if (enabled) @@ -945,9 +1100,9 @@ void Hal::setMachineHomingAll(bool enabled) } } if (!enabled) -{ - setPin(enabled, KeyCodes::Buttons.machine_home.text); -} + { + setPin(enabled, KeyCodes::Buttons.machine_home.text); + } } // ---------------------------------------------------------------------- /** @@ -1316,28 +1471,18 @@ void Hal::setPin(bool enabled, const char* pinName) size_t pinNumber = mButtonNameToIdx[fullyQualifiedPinName]; setPin(enabled, pinNumber, pinName); } + // ---------------------------------------------------------------------- void Hal::setJogCounts(const HandWheelCounters& counters) { - // If axis is not homed we need to ask Teleop mode but we need to bypass that if machine is homed - // https://forum.linuxcnc.org/49-basic-configuration/40581-how-to-configure-a-xhc-whb04b-pendant - if (*memory->out.axisXSelect && false == *memory->in.JointXisHomed) {requestTeleopMode(true);} - else if (*memory->out.axisYSelect && false == *memory->in.JointYisHomed) {requestTeleopMode(true);} - else if (*memory->out.axisZSelect && false == *memory->in.JointZisHomed) {requestTeleopMode(true);} - else if (*memory->out.axisASelect && false == *memory->in.JointAisHomed) {requestTeleopMode(true);} - else if (*memory->out.axisBSelect && false == *memory->in.JointBisHomed) {requestTeleopMode(true);} - else if (*memory->out.axisCSelect && false == *memory->in.JointCisHomed) {requestTeleopMode(true);} - {requestManualMode(true);} - - *memory->out.axisXJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_X); - *memory->out.axisYJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_Y); - *memory->out.axisZJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_Z); - *memory->out.axisAJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_A); - *memory->out.axisBJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_B); - *memory->out.axisCJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_C); - requestManualMode(false); - requestTeleopMode(false); + *memory->out.joint0JogCounts = *memory->out.axisXJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_X); + *memory->out.joint1JogCounts = *memory->out.axisYJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_Y); + *memory->out.joint2JogCounts = *memory->out.axisZJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_Z); + *memory->out.joint3JogCounts = *memory->out.axisAJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_A); + *memory->out.joint4JogCounts = *memory->out.axisBJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_B); + *memory->out.joint5JogCounts = *memory->out.axisCJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_C); } + // ---------------------------------------------------------------------- void Hal::setFunction(bool enabled) { @@ -1373,6 +1518,7 @@ bool Hal::requestMode(bool isRisingEdge, hal_bit_t *requestPin, hal_bit_t * mode { if (isRisingEdge) { + bool rv; if (true == *modeFeedbackPin) { // shortcut for mode request which is already active @@ -1381,9 +1527,10 @@ bool Hal::requestMode(bool isRisingEdge, hal_bit_t *requestPin, hal_bit_t * mode // request mode *requestPin = true; usleep(mHalRequestProfile.mode.holdMs * 1000); + rv = waitForRequestedMode(modeFeedbackPin); *requestPin = false; usleep(mHalRequestProfile.mode.spaceMs * 1000); - return waitForRequestedMode(modeFeedbackPin); + return rv; //waitForRequestedMode(modeFeedbackPin); } else { @@ -1403,6 +1550,7 @@ bool Hal::waitForRequestedMode(volatile hal_bit_t * condition) useconds_t timeoutMs = mHalRequestProfile.mode.modeCheckLoopTimeoutMs; unsigned int maxTimeouts = mHalRequestProfile.mode.modeCheckLoops; unsigned int timeouts = maxTimeouts; + do { if (false == *condition) @@ -1427,29 +1575,63 @@ bool Hal::waitForRequestedMode(volatile hal_bit_t * condition) return false; } // ---------------------------------------------------------------------- +void Hal::monitorResetState() { + if (*memory->out.spindleOverrideDoIncrease && expired(mToggleSpindleOverrideIncreaseStamp)) + *memory->out.spindleOverrideDoIncrease=false; + if (*memory->out.spindleOverrideDoDecrease && expired(mToggleSpindleOverrideDecreaseStamp)) + *memory->out.spindleOverrideDoDecrease=false; + if (*memory->out.joint0Unhome && expired (mjoint0UnhomeStamp)) + *memory->out.joint0Unhome=false; + if (*memory->out.joint1Unhome && expired (mjoint1UnhomeStamp)) + *memory->out.joint1Unhome=false; + if (*memory->out.joint2Unhome && expired (mjoint2UnhomeStamp)) + *memory->out.joint2Unhome=false; + if (*memory->out.joint3Unhome && expired (mjoint3UnhomeStamp)) + *memory->out.joint3Unhome=false; + if (*memory->out.joint4Unhome && expired (mjoint4UnhomeStamp)) + *memory->out.joint4Unhome=false; + if (*memory->out.joint5Unhome && expired (mjoint5UnhomeStamp)) + *memory->out.joint5Unhome=false; + if (mjoint0HomeDoHome==false && *memory->out.joint0Home && expired(mjoint0HomeStamp)) + *memory->out.joint0Home=false; + if (mjoint1HomeDoHome==false && *memory->out.joint1Home && expired(mjoint1HomeStamp)) + *memory->out.joint1Home=false; + if (mjoint2HomeDoHome==false && *memory->out.joint2Home && expired(mjoint1HomeStamp)) + *memory->out.joint2Home=false; +} + +bool Hal::expired(int64_t t) { + int64_t timestamp; + timestamp = now(); + if (tout.spindleOverrideDoIncrease) - { - *memory->out.spindleOverrideDoIncrease = false; - } - else - { - *memory->out.spindleOverrideScale = 0.01; - *memory->out.spindleOverrideDoIncrease = true; + if (!*memory->out.spindleOverrideDoIncrease) { + mToggleSpindleOverrideIncreaseStamp=now()+50; + *memory->out.spindleOverrideDoIncrease=true; + *memory->out.spindleOverrideScale = 0.01; } } // ---------------------------------------------------------------------- void Hal::toggleSpindleOverrideDecrease() { - if (*memory->out.spindleOverrideDoDecrease) - { - *memory->out.spindleOverrideDoDecrease = false; - } - else - { - *memory->out.spindleOverrideScale = 0.01; - *memory->out.spindleOverrideDoDecrease = true; + if (!*memory->out.spindleOverrideDoDecrease) { + mToggleSpindleOverrideDecreaseStamp=now()+50; + *memory->out.spindleOverrideDoDecrease=true; + *memory->out.spindleOverrideScale = 0.01; } } // ---------------------------------------------------------------------- diff --git a/src/hal/user_comps/xhc-whb04b-6/hal.h b/src/hal/user_comps/xhc-whb04b-6/hal.h index 173d2b89b..a4349d232 100644 --- a/src/hal/user_comps/xhc-whb04b-6/hal.h +++ b/src/hal/user_comps/xhc-whb04b-6/hal.h @@ -209,6 +209,45 @@ public: hal_s32_t* axisBJogCounts{nullptr}; //! to be connected to \ref axis.c.jog-counts hal_s32_t* axisCJogCounts{nullptr}; + + //! to be connected to \ref joint.0.jog-counts + hal_s32_t* joint0JogCounts{nullptr}; + //! to be connected to \ref joint.1.jog-counts + hal_s32_t* joint1JogCounts{nullptr}; + //! to be connected to \ref joint.2.jog-counts + hal_s32_t* joint2JogCounts{nullptr}; + //! to be connected to \ref joint.3.jog-counts + hal_s32_t* joint3JogCounts{nullptr}; + //! to be connected to \ref joint.4.jog-counts + hal_s32_t* joint4JogCounts{nullptr}; + //! to be connected to \ref joint.5.jog-counts + hal_s32_t* joint5JogCounts{nullptr}; + + //! to be connected to \ref axis.x.jog-scale + hal_float_t* joint0JogScale{nullptr}; + //! to be connected to \ref axis.y.jog-scale + hal_float_t* joint1JogScale{nullptr}; + //! to be connected to \ref axis.z.jog-scale + hal_float_t* joint2JogScale{nullptr}; + //! to be connected to \ref axis.a.jog-scale + hal_float_t* joint3JogScale{nullptr}; + //! to be connected to \ref axis.b.jog-scale + hal_float_t* joint4JogScale{nullptr}; + //! to be connected to \ref axis.c.jog-scale + hal_float_t* joint5JogScale{nullptr}; + + //! to be connected to \ref axis.x.jog-enable + hal_bit_t* joint0JogEnable{nullptr}; + //! to be connected to \ref axis.y.jog-enable + hal_bit_t* joint1JogEnable{nullptr}; + //! to be connected to \ref axis.z.jog-enable + hal_bit_t* joint2JogEnable{nullptr}; + //! to be connected to \ref axis.a.jog-enable + hal_bit_t* joint3JogEnable{nullptr}; + //! to be connected to \ref axis.b.jog-enable + hal_bit_t* joint4JogEnable{nullptr}; + //! to be connected to \ref axis.c.jog-enable + hal_bit_t* joint5JogEnable{nullptr}; //! to be connected to \ref axis.x.jog-enable hal_bit_t* axisXJogEnable{nullptr}; @@ -223,6 +262,20 @@ public: //! to be connected to \ref axis.c.jog-enable hal_bit_t* axisCJogEnable{nullptr}; + hal_bit_t* joint0Home{nullptr}; + hal_bit_t* joint1Home{nullptr}; + hal_bit_t* joint2Home{nullptr}; + hal_bit_t* joint3Home{nullptr}; + hal_bit_t* joint4Home{nullptr}; + hal_bit_t* joint5Home{nullptr}; + + hal_bit_t* joint0Unhome{nullptr}; + hal_bit_t* joint1Unhome{nullptr}; + hal_bit_t* joint2Unhome{nullptr}; + hal_bit_t* joint3Unhome{nullptr}; + hal_bit_t* joint4Unhome{nullptr}; + hal_bit_t* joint5Unhome{nullptr}; + //! to be connected to \ref axis.x.jog-scale hal_float_t* axisXJogScale{nullptr}; //! to be connected to \ref axis.y.jog-scale @@ -549,6 +602,10 @@ public: //! Writes the corresponding counter to to each axis' count. //! \param counters values to propagate to each axis void setJogCounts(const HandWheelCounters& counters); + //! waits until a given pin is set to a requested state + //! \param state requested state + //! \param pin requested pin to compare with + void checkState(bool state, hal_bit_t *pin); //! Returns the axis position. //! \param absolute true absolute, false relative @@ -565,7 +622,12 @@ public: //! \xrefitem getAxisXPosition(bool) hal_float_t getAxisCPosition(bool absolute) const; - + //! monitors signals which have to be reset + void monitorResetState(); + //! checks if the counter has expired + bool expired(int64_t t); + //! retrieves the current monotonic timestamp + int64_t now(); private: HalMemory* memory{nullptr}; std::map mButtonNameToIdx; @@ -579,6 +641,26 @@ private: HandwheelStepmodes::Mode mStepMode; bool mIsSpindleDirectionForward{true}; Profiles::HalRequestProfile mHalRequestProfile; + int64_t mToggleSpindleOverrideIncreaseStamp{0}; + int64_t mToggleSpindleOverrideDecreaseStamp{0}; + int64_t mjoint0HomeStamp{0}; + int64_t mjoint1HomeStamp{0}; + int64_t mjoint2HomeStamp{0}; + int64_t mjoint3HomeStamp{0}; + int64_t mjoint4HomeStamp{0}; + int64_t mjoint5HomeStamp{0}; + int64_t mjoint0UnhomeStamp={0}; + int64_t mjoint1UnhomeStamp={0}; + int64_t mjoint2UnhomeStamp={0}; + int64_t mjoint3UnhomeStamp={0}; + int64_t mjoint4UnhomeStamp={0}; + int64_t mjoint5UnhomeStamp={0}; + bool mjoint0HomeDoHome{false}; + bool mjoint1HomeDoHome{false}; + bool mjoint2HomeDoHome{false}; + bool mjoint3HomeDoHome{false}; + bool mjoint4HomeDoHome{false}; + bool mjoint5HomeDoHome{false}; //! //! Allocates new hal_bit_t pin according to \ref mIsSimulationMode. If \ref mIsSimulationMode then //! mallocs memory, hal_pin_bit_new allocation otherwise. diff --git a/src/hal/user_comps/xhc-whb04b-6/pendant.cc b/src/hal/user_comps/xhc-whb04b-6/pendant.cc index 4c280bfc9..093376138 100644 --- a/src/hal/user_comps/xhc-whb04b-6/pendant.cc +++ b/src/hal/user_comps/xhc-whb04b-6/pendant.cc @@ -1450,6 +1450,7 @@ bool Pendant::onJogDialEvent(const HandWheelCounters& counters, int8_t delta) FeedRotaryButton& feedButton = mCurrentButtonsState.feedButton(); + printf("onjogdial event\n"); if (HandWheelCounters::CounterNameToIndex::UNDEFINED != counters.activeCounter()) // && 0 != counters.counts()) { *mPendantCout << mPrefix << "wheel event " << counters.counts() << endl; @@ -1480,6 +1481,7 @@ bool Pendant::onJogDialEvent(const HandWheelCounters& counters, int8_t delta) } else if (!counters.isLeadCounterActive() && (feedButton.stepMode() == HandwheelStepmodes::Mode::CON || feedButton.stepMode() == HandwheelStepmodes::Mode::STEP)) { // Normal Mode + printf("set jog counts\n"); mHal.setJogCounts(counters); } } diff --git a/src/hal/user_comps/xhc-whb04b-6/xhc-whb04b6.cc b/src/hal/user_comps/xhc-whb04b-6/xhc-whb04b6.cc index 5cd64d283..4a18476e8 100644 --- a/src/hal/user_comps/xhc-whb04b-6/xhc-whb04b6.cc +++ b/src/hal/user_comps/xhc-whb04b-6/xhc-whb04b6.cc @@ -512,6 +512,7 @@ void XhcWhb04b6Component::process() linuxcncSimulate(); } updateDisplay(); + mHal.monitorResetState(); } updateDisplay();