 la_mojo nodes and modules: register for events only when fully built
A handler was registered in the basicEventHandler constructor (before
the derived members existed) and removed in its destructor (after they
were destroyed): the event heap could call dispatchEvent() on a half-
built or half-destroyed node or module when one was created or deleted
while la_mojo runs (node / module reload).
- Camera nodes (deviceNodePTZCamControl, deviceNodePresetCamControl,
deviceNodeStaticCamControl): basicEventHandler(false), attachEvents()
at the end of both constructors, detachEvents() first thing in the
destructor.
- Kernel modules: kernelModule no longer registers in its constructor;
kernelModuleFactory attaches a module right after creating it (all
modules are created there), before startService(). Every module
destructor (USB relay, Kafka, FlyHunter, SSDP, ONVIF observer, embed
video (both variants), modem manager, Bosch, attention cloud, report
backupper) calls detachEvents() first.
- basicEventHeap::moveHandlerTop/Bottom no longer register a handler
that is not registered (would have registered an object twice once
attachEvents() runs).
Sensor nodes are not event handlers and are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
18 hours ago  la_mojo nodes and modules: register for events only when fully built
A handler was registered in the basicEventHandler constructor (before
the derived members existed) and removed in its destructor (after they
were destroyed): the event heap could call dispatchEvent() on a half-
built or half-destroyed node or module when one was created or deleted
while la_mojo runs (node / module reload).
- Camera nodes (deviceNodePTZCamControl, deviceNodePresetCamControl,
deviceNodeStaticCamControl): basicEventHandler(false), attachEvents()
at the end of both constructors, detachEvents() first thing in the
destructor.
- Kernel modules: kernelModule no longer registers in its constructor;
kernelModuleFactory attaches a module right after creating it (all
modules are created there), before startService(). Every module
destructor (USB relay, Kafka, FlyHunter, SSDP, ONVIF observer, embed
video (both variants), modem manager, Bosch, attention cloud, report
backupper) calls detachEvents() first.
- basicEventHeap::moveHandlerTop/Bottom no longer register a handler
that is not registered (would have registered an object twice once
attachEvents() runs).
Sensor nodes are not event handlers and are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
18 hours ago  la_mojo nodes and modules: register for events only when fully built
A handler was registered in the basicEventHandler constructor (before
the derived members existed) and removed in its destructor (after they
were destroyed): the event heap could call dispatchEvent() on a half-
built or half-destroyed node or module when one was created or deleted
while la_mojo runs (node / module reload).
- Camera nodes (deviceNodePTZCamControl, deviceNodePresetCamControl,
deviceNodeStaticCamControl): basicEventHandler(false), attachEvents()
at the end of both constructors, detachEvents() first thing in the
destructor.
- Kernel modules: kernelModule no longer registers in its constructor;
kernelModuleFactory attaches a module right after creating it (all
modules are created there), before startService(). Every module
destructor (USB relay, Kafka, FlyHunter, SSDP, ONVIF observer, embed
video (both variants), modem manager, Bosch, attention cloud, report
backupper) calls detachEvents() first.
- basicEventHeap::moveHandlerTop/Bottom no longer register a handler
that is not registered (would have registered an object twice once
attachEvents() runs).
Sensor nodes are not event handlers and are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
18 hours ago  la_mojo nodes and modules: register for events only when fully built
A handler was registered in the basicEventHandler constructor (before
the derived members existed) and removed in its destructor (after they
were destroyed): the event heap could call dispatchEvent() on a half-
built or half-destroyed node or module when one was created or deleted
while la_mojo runs (node / module reload).
- Camera nodes (deviceNodePTZCamControl, deviceNodePresetCamControl,
deviceNodeStaticCamControl): basicEventHandler(false), attachEvents()
at the end of both constructors, detachEvents() first thing in the
destructor.
- Kernel modules: kernelModule no longer registers in its constructor;
kernelModuleFactory attaches a module right after creating it (all
modules are created there), before startService(). Every module
destructor (USB relay, Kafka, FlyHunter, SSDP, ONVIF observer, embed
video (both variants), modem manager, Bosch, attention cloud, report
backupper) calls detachEvents() first.
- basicEventHeap::moveHandlerTop/Bottom no longer register a handler
that is not registered (would have registered an object twice once
attachEvents() runs).
Sensor nodes are not event handlers and are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
18 hours ago  la_mojo nodes and modules: register for events only when fully built
A handler was registered in the basicEventHandler constructor (before
the derived members existed) and removed in its destructor (after they
were destroyed): the event heap could call dispatchEvent() on a half-
built or half-destroyed node or module when one was created or deleted
while la_mojo runs (node / module reload).
- Camera nodes (deviceNodePTZCamControl, deviceNodePresetCamControl,
deviceNodeStaticCamControl): basicEventHandler(false), attachEvents()
at the end of both constructors, detachEvents() first thing in the
destructor.
- Kernel modules: kernelModule no longer registers in its constructor;
kernelModuleFactory attaches a module right after creating it (all
modules are created there), before startService(). Every module
destructor (USB relay, Kafka, FlyHunter, SSDP, ONVIF observer, embed
video (both variants), modem manager, Bosch, attention cloud, report
backupper) calls detachEvents() first.
- basicEventHeap::moveHandlerTop/Bottom no longer register a handler
that is not registered (would have registered an object twice once
attachEvents() runs).
Sensor nodes are not event handlers and are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
18 hours ago |
|
#include "deviceNodePresetCamControl.h"
#include "../mojo/mojoKernel.h"
#define LOG(X) deviceNode::m_pLog->Log("PRST_CAM", this, X)
#define LOG_ERROR(X) deviceNode::m_pLog->Log("PRST_CAM", this, _LOG_ERROR, X)
deviceNodePresetCamControl::deviceNodePresetCamControl(DBC_NODE_DATA * Data) : deviceNodeCamera(Data), basicEventHandler(false) // registered at the end of the constructor
{ // Receive events only now that the object is completely constructed
attachEvents();}
deviceNodePresetCamControl::deviceNodePresetCamControl(uint32_t id) : deviceNodeCamera(id), basicEventHandler(false) // registered at the end of the constructor
{ m_sMediaSource.mediaSourceId = m_sNodeData.aux_id; strncpy(m_sMediaSource.mediaName, m_sNodeData.name, 128); m_sMediaSource.mediaName[127] = (char) 0; memset(&m_sCtrlData, 0, sizeof(CAMERA_CTRL_DATA)); // Receive events only now that the object is completely constructed
attachEvents();}
deviceNodePresetCamControl::~deviceNodePresetCamControl(){ detachEvents(); // stop event delivery before the members are destroyed (see basicEventHandler.h)
stopService();}
bool deviceNodePresetCamControl::startService(){ return create();}
bool deviceNodePresetCamControl::stopService(){ return true;}
bool deviceNodePresetCamControl::dispatchEvent(EVENT_CONTAINER * E){ if (E == NULL) { return false; } // if( !m_sCamData.online ) return;
// if( m_bBusy ) return;
if (m_sCamData.prefered_events_only) { // Check if we eligable dest of event
if (E->m_nDestinationNodeID != m_sNodeData.node_id) { return true; } }; switch (E->m_eClass) { case EVT_CLASS_SENSOR_CLD: case EVT_CLASS_SENSOR_LGS: case EVT_CLASS_SENSOR_LFS: case EVT_CLASS_SENSOR_MND: case EVT_CLASS_SENSOR_PLS_210: case EVT_CLASS_SENSOR_PLS_360: case EVT_CLASS_SENSOR_ALS: case EVT_CLASS_SENSOR_3D: case EVT_CLASS_SENSOR_ACC: { switch (E->m_eType) { case EVT_ROI_ACTIVE: { TARGET_DATA * tDATA; tDATA = (TARGET_DATA *) E->m_pEvtData; if (tDATA) { lookAt(E->m_db_id, tDATA->system_target); }; break; }; case EVT_TARGET_1D: case EVT_TARGET_2D_BLACK: case EVT_TARGET_2D_WHITE: case EVT_TARGET_3D_BLACK: case EVT_TARGET_3D_WHITE: { TARGET_DATA * tDATA; tDATA = (TARGET_DATA *) E->m_pEvtData; if (tDATA) {#ifdef DEBUG_EXTRA
LOG("CHECK CAMERA FOV");#endif
if (testFOV(tDATA->system_target)) {#ifdef DEBUG_EXTRA
LOG("TARGET IN CAMERA FOV");#endif
lookAt(E->m_db_id, tDATA->system_target); }; }; break; }; default: break; }; break; }; default: break; }; return true; // Propogate Event
}
bool deviceNodePresetCamControl::validate(){#ifdef DEBUG_EXTRA
LOG("VALIDATE");#endif
if (CAM_WS_END == getWM()) { return false; } // Validate Camera Settings
/*{
DBC_CAM_DATA *tDATA = argusNetNode::m_pDBC->getCamData( m_sNodeData.aux_id ); if( tDATA ) { if( memcmp( &m_sCamData, tDATA, sizeof(DBC_CAM_DATA)) != 0 ){ free( tDATA ); LOG("Cam Settings Changed!"); return false; }; free( tDATA ); } else{ LOG("Cam Deleted!"); return false; }; }*/ // Validate Stream - > moved to Video Encoder!
/*
{ if( m_sNodeData.aux_parameter ) {#ifdef DEBUG_EXTRA
LOG("VALIDATE Stream");#endif
if( !m_bSourceConnected ) { if( connectToStream( m_sNodeData.aux_parameter ) ) { argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter ); } else { argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter, false ); }; } else { validateStream(); }; }; } */ return deviceNodeCamera::validate();}
#undef LOG
#undef LOG_ERROR
|