 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
12 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
12 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
12 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
12 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
12 hours ago |
|
#include "deviceNodePTZCamControl.h"
#include "../mojo/mojoKernel.h"
#define LOG(X) deviceNode::m_pLog->Log("PTZ_CAM", this, X)
#define LOG_ERROR(X) deviceNode::m_pLog->Log("PTZ_CAM", this, _LOG_ERROR, X)
deviceNodePTZCamControl::deviceNodePTZCamControl(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();}
deviceNodePTZCamControl::deviceNodePTZCamControl(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();}
deviceNodePTZCamControl::~deviceNodePTZCamControl(){ detachEvents(); // stop event delivery before the members are destroyed (see basicEventHandler.h)
stopService();}
bool deviceNodePTZCamControl::startService(){ return create();}
bool deviceNodePTZCamControl::stopService(){ return true;}
bool deviceNodePTZCamControl::dispatchEvent(EVENT_CONTAINER * E){ if (E == NULL) return false; // if( !m_sCamData.online ) return true;
// if( m_bBusy ) return true;
if (m_sCamData.prefered_events_only){#ifdef DEBUG_EXTRA
char tB[200]; sprintf( tB, "comp Evt Dest %ld %ld", E->m_nDestinationNodeID, m_sNodeData.node_id ); LOG( tB );#endif
// Check if we are eligable dest of event
if( E->m_nDestinationNodeID != m_sNodeData.node_id ) return true; };
switch (E->m_eType){ case EVT_ROI_ACTIVE:{ if ( !m_bCameraAIControled ) { TARGET_DATA *tDATA = (TARGET_DATA *)E->m_pEvtData; if( tDATA ) lookAt(E->m_db_id, tDATA->system_target); } break; }; case EVT_CAMERA_AI_MODE_ON:{ if( E->m_nDestinationNodeID == m_sNodeData.node_id ) m_bCameraAIControled = true; break; }; case EVT_CAMERA_AI_MODE_OFF:{ if( E->m_nDestinationNodeID == m_sNodeData.node_id ) m_bCameraAIControled = false; break; }; case EVT_CAMERA_MOVE_TO:{ //Event used by AI Analytics to move camera
TARGET_DATA *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:{ if ( !m_bCameraAIControled ) { TARGET_DATA *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; }; return true;}
bool deviceNodePTZCamControl::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
|