Commit d04b82e5 authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Use a separate counter for dropped frames, remove events member

parent 4083f5e2
......@@ -138,6 +138,7 @@ void tao_camera_info_initialize(
info->temperature = NAN;
get_monotonic_time(&info->origin);
info->frames = 0;
info->droppedframes = 0;
info->overruns = 0;
info->lostframes = 0;
info->overflows = 0;
......@@ -819,6 +820,8 @@ tao_status tao_camera_info_print(
&inf->origin)) ||
0 > fprintf(out, "Number of acquired frames: %" PRId64 "\n",
inf->frames) ||
0 > fprintf(out, "Number of dropped frames: %" PRId64 "\n",
inf->droppedframes) ||
0 > fprintf(out, "Number of overruns: %" PRId64 "\n",
inf->overruns) ||
0 > fprintf(out, "Number of lost frames: %" PRId64 "\n",
......
......@@ -236,8 +236,8 @@ typedef struct tao_camera_info_ {
double temperature;///< Camera temperature (in degrees Celsius).
tao_time origin;///< Origin of time.
tao_serial frames;///< Number of frames acquired so far.
tao_serial overruns;///< Number of frames lost so far because of
/// overruns.
tao_serial droppedframes;///< Number of dropped frames.
tao_serial overruns;///< Number of frames lost because of overruns.
tao_serial lostframes;///< Number of lost frames.
tao_serial overflows;///< Number of overflows.
tao_serial lostsyncs;///< Number of synchronization losts so far.
......
......@@ -42,6 +42,7 @@ static struct command_entry {
{"buffers", ok, NULL},
{"debug", ok, NULL},
{"drop", ok, NULL},
{"droppedframes", ok, NULL},
{"exposuretime", ok, NULL},
{"framerate", ok, NULL},
{"frames", ok, NULL},// Number of frames received so far.
......
......@@ -134,6 +134,7 @@ int main(
fprintf(stdout, "Timeouts: %10ld\n", timeouts);
fprintf(stdout, "Overruns: %10ld\n", (long)cam->info.overruns);
fprintf(stdout, "Overflows: %10ld\n", (long)cam->info.overflows);
fprintf(stdout, "Dropped frames: %10ld\n", (long)cam->info.droppedframes);
fprintf(stdout, "Lost frames: %10ld\n", (long)cam->info.lostframes);
fprintf(stdout, "Lost synchronizations: %5ld\n", (long)cam->info.lostsyncs);
}
......
......@@ -639,9 +639,6 @@ static tao_status on_start(
dev->frame_start = TAO_UNKNOWN_TIME;
dev->frame_end = TAO_UNKNOWN_TIME;
// Clear mask of events.
dev->events = 0;
// Configure frame grabber for continuous acquisition and enable interrupts
// for expected events.
etParamValue events = (PHX_INTRPT_GLOBAL_ENABLE |
......@@ -750,8 +747,8 @@ static tao_status on_wait_buffer(
}
while (dev->buf.data != NULL || dev->pending > max_pending) {
if (dev->buf.data == NULL) {
// Count this as a lost frame.
++dev->base.info.lostframes;
// Count this as a dropped frame.
++dev->base.info.droppedframes;
} else {
// Never automatically release more than once.
dev->buf.data = NULL;
......@@ -839,6 +836,7 @@ static void acquisition_callback(
tao_camera* cam = (tao_camera*)data;
assert(cam->ops == &ops);
phnx_device* dev = (phnx_device*)data;
bool notify = false;
// Get timestamp immediately (before locking because this may block for
// some time) aborting on error.
......@@ -855,9 +853,7 @@ static void acquisition_callback(
// Register the time at the start of the frame using the number of
// seconds to detect overruns.
if (dev->frame_start.sec > 0) {
++cam->info.frames;
++cam->info.overruns;
dev->events |= TAO_EVENT_ERROR;
}
dev->frame_start = now;
}
......@@ -865,9 +861,7 @@ static void acquisition_callback(
// Register the time at the end of the frame using the number of
// seconds to detect overruns.
if (dev->frame_end.sec > 0) {
++cam->info.frames;
++cam->info.overruns;
dev->events |= TAO_EVENT_ERROR;
}
dev->frame_end = now;
}
......@@ -876,7 +870,7 @@ static void acquisition_callback(
// number of last acquirred buffer, and number of pending acquisition
// buffers.
++cam->info.frames;
++dev->serial;
++dev->serial; // FIXME: not needed
if (dev->pending < dev->buffers) {
++dev->pending;
} else {
......@@ -890,25 +884,23 @@ static void acquisition_callback(
// Reset start and end times of next frame to detect overruns.
dev->frame_start = TAO_UNKNOWN_TIME;
dev->frame_end = TAO_UNKNOWN_TIME;
notify = true;
}
if ((PHX_INTRPT_FIFO_OVERFLOW & events) != 0) {
// Fifo overflow.
++cam->info.overflows;
dev->events |= TAO_EVENT_ERROR;
}
if ((PHX_INTRPT_SYNC_LOST & events) != 0) {
// Synchronization lost.
++cam->info.lostsyncs;
dev->events |= TAO_EVENT_ERROR;
}
if ((PHX_INTRPT_FRAME_LOST & events) != 0) {
// Frame lost.
++cam->info.lostframes;
dev->events |= TAO_EVENT_ERROR;
}
if (dev->events != 0) {
if (notify) {
// Signal condition for waiting thread.
tao_camera_broadcast(cam); // FIXME: check status
tao_camera_broadcast(cam);
}
if (tao_camera_unlock(cam) != TAO_OK) {
tao_panic();
......
......@@ -122,7 +122,6 @@ struct phnx_device_ {
const phnx_operations* ops;///< Secondary table of virtual methods.
uint64_t handle;///< Camera handle.
tao_camera_roi roi;///< ROI for the device.
tao_event events;///< Pending events.
tao_serial serial;///< Serial number of last "buffer ready" event.
tao_time frame_start;///< Start time of next frame.
tao_time frame_end;///< End time of next frame.
......
Supports Markdown
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