Browse Source

la_mojo cameras: send EVT_CAMERA_ON_POSITION only when the move is done

Target-driven moves of deviceNodePTZCamControl (AbsoluteMove) and
deviceNodePresetCamControl (preset for the ROI) both end in
CAM_WS_WAIT_ONPOS, which waits for the end of the move and then
broadcasts EVT_CAMERA_ON_POSITION (EVT_CLASS_CAMERA_CTRL).

- AbsoluteMove: with video output enabled (m_bSkeepPositioningWait) the
  event was broadcast right after the command, before the camera moved.
  It now always goes through CAM_WS_WAIT_ONPOS, like the preset path.
- New m_bNoMoveDoneReport: set when the protocol cannot report the end
  of a move (waitMoveIsDone() returns false). Then a fixed
  CAM_MOVE_FIXED_WAIT_MS (3 s) wait is used before the event. Before, the
  same failure set m_bSkeepPositioningWait, which made every later
  AbsoluteMove broadcast the event immediately. Reset when the protocol
  is (re)created.
- protocolPTZ_ONVIF::goPreset: forget the last AbsoluteMove target so
  waitMoveIsDone() cannot end early by comparing with it.

Homing, init go-home and web/IR/wiper presets are unchanged (no event).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
pull/12/head
Claude 3 days ago
parent
commit
7f1ce51cef
Failed to extract signature
  1. 57
      lib/App/common/deviceNodeCamera.cpp
  2. 4
      lib/App/common/deviceNodeCamera.h
  3. 2
      lib/data/protocol/protocolPTZ_ONVIF.cpp

57
lib/App/common/deviceNodeCamera.cpp

@ -45,6 +45,7 @@ deviceNodeCamera::deviceNodeCamera(uint32_t NodeID) :
// m_pLog = basicLogCollection::getInstance();
m_pBEH = basicEventHeap::getInstance();
m_bSkeepPositioningWait = true;
m_bNoMoveDoneReport = false;
m_bNoAbsPositionning = false;
m_bCameraOnHomePosition = false;
m_tTimeTSeconds = 0;
@ -77,6 +78,7 @@ deviceNodeCamera::deviceNodeCamera(DBC_NODE_DATA * Data) :
// m_pLog = basicLogCollection::getInstance();
m_pBEH = basicEventHeap::getInstance();
m_bSkeepPositioningWait = true;
m_bNoMoveDoneReport = false;
m_bNoAbsPositionning = false;
m_bCameraOnHomePosition = false;
m_tTimeTSeconds = 0;
@ -578,6 +580,7 @@ bool deviceNodeCamera::create()
load_presets();
mojoKernel * tKRNL = mojoKernel::getInstance();
m_bNoMoveDoneReport = false;
if (tKRNL)
{
m_bSkeepPositioningWait = ((tKRNL->getMediaMode() & EVE_OUTPUT_VIDEO) == EVE_OUTPUT_VIDEO);
@ -1342,6 +1345,7 @@ void deviceNodeCamera::m_fThreadProc(void)
load_presets();
mojoKernel * tKRNL = mojoKernel::getInstance();
m_bNoMoveDoneReport = false;
if (tKRNL)
{
m_bSkeepPositioningWait = ((tKRNL->getMediaMode() & EVE_OUTPUT_VIDEO) == EVE_OUTPUT_VIDEO);
@ -1740,45 +1744,9 @@ void deviceNodeCamera::m_fThreadProc(void)
}
else
{
// Waiting Movement finish
if (m_bSkeepPositioningWait)
{
#ifdef DEBUG_EXTRA
LOG("INSTANT BCAST CAM ONPOS");
#endif
// Send Capture event
#ifndef NO_CAMERA_FUSION_ENGINE
DBC_SNAPSHOT_DATA * tData = fusion_translate_ROI(m_pCurrentROI);
#else
DBC_SNAPSHOT_DATA * tData = NULL;
#endif
if (tData != NULL)
{
if (m_pBEH)
{
EVENT_CONTAINER * tEVT = createBasicEvent(m_sNodeData.node_id, EVT_CLASS_CAMERA_CTRL, EVT_CAMERA_ON_POSITION, NULL, NULL, tData);
if (tEVT)
{
m_pBEH->broadcast(tEVT);
}
else
{
//free(tData);
delete(tData);
};
}
else
{
//free(tData);
delete(tData);
};
};
setWM(CAM_WS_READY);
}
else
{
setWM(CAM_WS_WAIT_ONPOS);
};
// EVT_CAMERA_ON_POSITION is sent from CAM_WS_WAIT_ONPOS once the move is done
// (before, with video output it was sent right after the command).
setWM(CAM_WS_WAIT_ONPOS);
};
};
}
@ -1806,16 +1774,19 @@ void deviceNodeCamera::m_fThreadProc(void)
#ifdef DEBUG_EXTRA
LOG("Start Waiting Cam On Position!");
#endif
if (! m_bSkeepPositioningWait)
// Target-driven ABS / preset move: EVT_CAMERA_ON_POSITION only after the move is done.
// Protocols that cannot report the end of a move get a fixed wait.
if (! m_bNoMoveDoneReport)
{
if (! m_pProtocol->waitMoveIsDone())
{
m_bSkeepPositioningWait = true;
LOG("Protocol cannot report the end of a move -> fixed wait");
m_bNoMoveDoneReport = true;
}
};
if (m_bSkeepPositioningWait)
if (m_bNoMoveDoneReport)
{
SLEEP(3000);
SLEEP(CAM_MOVE_FIXED_WAIT_MS);
}
#ifdef DEBUG_EXTRA
LOG("Done Waiting Cam On Position!");

4
lib/App/common/deviceNodeCamera.h

@ -42,6 +42,9 @@
#define CAM_CTRL_PROTO_T28181 5
#define CAM_CTRL_PROTO_BRCP 6
// Wait before EVT_CAMERA_ON_POSITION when the protocol cannot report the end of a move
#define CAM_MOVE_FIXED_WAIT_MS 3000
#define UART_TYPE_HARDWARE 1
#define UART_TYPE_SOL 2
@ -186,6 +189,7 @@ class deviceNodeCamera : public deviceNode, public basicThread
float m_fCP_Zoom;
bool m_bSkeepPositioningWait;
bool m_bNoMoveDoneReport; // protocol cannot report the end of a move -> fixed wait before EVT_CAMERA_ON_POSITION
bool m_bNoAbsPositionning;
bool m_bCameraIsStatic;
// IR functionality

2
lib/data/protocol/protocolPTZ_ONVIF.cpp

@ -640,6 +640,8 @@ bool protocolPTZ_ONVIF::goPreset(char * PresetToken)
LOG_ERROR("No PTZ Profile!!");
return false;
};
// A preset move has no known target: waitMoveIsDone() must not compare with an old AbsoluteMove target
m_bTargetValid = false;
if (! m_pOnVif->ptz_GotoPreset(m_pProfile->profiletoken, PresetToken, 1.0f, 1.0f, 1.0f))
{
m_bStatus = 0;

Loading…
Cancel
Save