Commit aaf188f4 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Add RoutineOnCanOpenBootUp

parent 609ad0b3
......@@ -370,6 +370,46 @@ void RoutineOnCanOpenSdoReadReply::onRecvSdoReadReply (const CanOpenNodeId nodeI
execute ();
}
RoutineOnCanOpenBootUp::RoutineOnCanOpenBootUp (QObject * parent)
: AbstractCanOpenRoutine (Triggers::CANOPEN_BOOTUP, parent)
, m_canMgr (Q_NULLPTR)
, m_currNodeId (0)
{
Manager::instance ().registerObject (this);
}
RoutineOnCanOpenBootUp::~RoutineOnCanOpenBootUp (void) {
Manager::instance ().unregisterObject (this);
}
void RoutineOnCanOpenBootUp::prepare (void) {
if (get_canOpen () && !m_canMgr) {
if ((m_canMgr = get_canOpen ()->getProtocolManager ())) {
connect (m_canMgr.data (), &CanOpenProtocolManager::recvNodeHeartBeat, this, &RoutineOnCanOpenBootUp::onRecvHeartbeatState, Qt::UniqueConnection);
}
}
}
void RoutineOnCanOpenBootUp::cleanup (void) {
if (m_canMgr) {
disconnect (m_canMgr.data (), Q_NULLPTR, this, Q_NULLPTR);
m_canMgr.clear ();
}
}
void RoutineOnCanOpenBootUp::trigger (void) {
if (m_canMgr) {
emit triggered (m_currNodeId);
}
}
void RoutineOnCanOpenBootUp::onRecvHeartbeatState (const CanOpenNodeId nodeId, const CanOpenHeartBeatState state) {
if (state == CanOpenHeartBeatStates::Initializing) {
m_currNodeId = nodeId;
execute ();
}
}
RoutineOnSerialFrame::RoutineOnSerialFrame (QObject * parent)
: AbstractRoutine (Triggers::SERIAL_FRAME_RECV, parent)
, m_serialBus (Q_NULLPTR)
......
......@@ -23,6 +23,7 @@ QML_ENUM_CLASS (Triggers,
CANOPEN_OBD_VAL_CHANGE,
CANOPEN_SDO_READ_REPLY,
CANOPEN_SDO_WRITE_REQUEST,
CANOPEN_BOOTUP,
SERIAL_FRAME_RECV,
NB_TRIGGERS)
......@@ -282,4 +283,28 @@ private:
ByteArrayWrapper * m_currBuffer;
};
class RoutineOnCanOpenBootUp : public AbstractCanOpenRoutine {
Q_OBJECT
public:
explicit RoutineOnCanOpenBootUp (QObject * parent = Q_NULLPTR);
virtual ~RoutineOnCanOpenBootUp (void);
void prepare (void) Q_DECL_FINAL;
void cleanup (void) Q_DECL_FINAL;
protected:
void trigger (void) Q_DECL_FINAL;
signals:
void triggered (const int nodeId);
protected slots:
void onRecvHeartbeatState (const CanOpenNodeId nodeId,
const CanOpenHeartBeatState state);
private:
QPointer<CanOpenProtocolManager> m_canMgr;
CanOpenNodeId m_currNodeId;
};
#endif // ABSTRACTROUTINE_H
......@@ -195,6 +195,7 @@ void SharedObject::registerQmlTypes (QQmlEngine * qmlEngine) {
qmlRegisterType<RoutineOnCanOpenObdValChange> (uri, maj, min, "RoutineOnCanOpenObdValChange");
qmlRegisterType<RoutineOnCanOpenSdoReadReply> (uri, maj, min, "RoutineOnCanOpenSdoReadReply");
qmlRegisterType<RoutineOnCanOpenSdoWriteRequest> (uri, maj, min, "RoutineOnCanOpenSdoWriteRequest");
qmlRegisterType<RoutineOnCanOpenBootUp> (uri, maj, min, "RoutineOnCanOpenBootUp");
qmlRegisterType<SensorsList> (uri, maj, min, "SensorsList");
qmlRegisterType<SerialBus> (uri, maj, min, "SerialBus");
qmlRegisterType<AffineTransformer> (uri, maj, min, "AffineTransformer");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment