 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
59 minutes 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
59 minutes 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
59 minutes 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
59 minutes 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
59 minutes ago |
|
#include "deviceNodeStaticCamControl.h"
#define LOG(X) deviceNode::m_pLog->Log("STATIC_CAM", this, X)
#define LOG_ERROR(X) deviceNode::m_pLog->Log("STATIC_CAM", this, _LOG_ERROR, X)
deviceNodeStaticCamControl::deviceNodeStaticCamControl(DBC_NODE_DATA * Data) : deviceNodeCamera(Data), basicEventHandler(false) // registered at the end of the constructor
{ // m_pLog = basicLogCollection::getInstance();
/*
DBC_CAM_DATA * tData = m_pDBC->getCamData( m_sNodeData.aux_id );
m_fMaxRange = m_fMinHFov = m_fMaxHFov = m_fMinVFov = m_fMaxVFov = .0f;
if( tData != NULL ) { memcpy( &m_sCamData, tData, sizeof(DBC_CAM_DATA) ); free( tData ); }; memset( &m_sCtrlData, 0, sizeof(CAMERA_CTRL_DATA) ); if( m_sCamData.max_range == .0f ){ m_fMaxRange = calcMaxDistance_mm( AC_imager_diag[m_sCamData.imager_type], m_sCamData.max_f, 1280 ); } else { m_fMaxRange = m_sCamData.max_range; }; m_fMinHFov = calcFOV_mm( AC_imager_width[m_sCamData.imager_type], m_sCamData.min_f ); m_fMaxHFov = calcFOV_mm( AC_imager_width[m_sCamData.imager_type], m_sCamData.max_f ); m_fMinVFov = calcFOV_mm( AC_imager_height[m_sCamData.imager_type], m_sCamData.min_f ); m_fMaxVFov = calcFOV_mm( AC_imager_height[m_sCamData.imager_type], m_sCamData.max_f ); #ifdef DEBUG
char tB[128]; LOG("Camera Info:"); sprintf( tB, "Maximal Range: %0.2f m. ", m_fMaxRange); LOG(tB); sprintf( tB, "Maximal FOVs, Horizontal: %0.2f Vertical: %0.2f", m_fMinHFov, m_fMinVFov ); LOG(tB); sprintf( tB, "Minimal FOVs, Horizontal: %0.2f Vertical: %0.2f", m_fMaxHFov, m_fMaxVFov ); LOG(tB); #endif
m_pPosition = new basicPosition( m_sCamData.lat, m_sCamData.lon, m_sCamData.alt, m_sCamData.roll, m_sCamData.pitch, m_sCamData.yaw ); */ // Receive events only now that the object is completely constructed
attachEvents();}
deviceNodeStaticCamControl::deviceNodeStaticCamControl(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();}
deviceNodeStaticCamControl::~deviceNodeStaticCamControl(){ detachEvents(); // stop event delivery before the members are destroyed (see basicEventHandler.h)
LOG("Destructor"); stopService();}
bool deviceNodeStaticCamControl::startService(){ return create();}
bool deviceNodeStaticCamControl::stopService(){ return true;}
bool deviceNodeStaticCamControl::dispatchEvent(EVENT_CONTAINER * E){ if (E == NULL) { return false; } // if( !m_bSourceConnected ) 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; LOG("ROI"); if (tDATA) { // makeSnap(E->m_db_id);
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) { // For Static Camera Just Checking if Target In A FOV!
#ifdef DEBUG_EXTRA
LOG("CHECK CAMERA FOV");#endif
if (testFOV(tDATA->system_target)) {#ifdef DEBUG_EXTRA
LOG("TARGET IN CAMERA FOV");#endif
makeSnap(E->m_db_id); }; }; break; }; default: break; }; break; }; default: break; }; return true;}
bool deviceNodeStaticCamControl::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 Encooder
/*
{ if( m_sNodeData.aux_parameter ) { //LOG("VALIDATE Stream");
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
|