event reporting format change and make report only specific device
r1261 | dcl | 2006-11-09 11:04:10 +1100 (Thu, 09 Nov 2006) | 2 lines
This commit is contained in:
@@ -120,10 +120,10 @@ void device_read(DEVICE* device, int n)
|
|||||||
buffer.length = 0;
|
buffer.length = 0;
|
||||||
snprintf(buffer.body, sizeof(buffer.body),
|
snprintf(buffer.body, sizeof(buffer.body),
|
||||||
"READ %c%c%c%c %s %.6f %10llu %8.2f\r\n",
|
"READ %c%c%c%c %s %.6f %10llu %8.2f\r\n",
|
||||||
device->state == counter_idle ? 'I' :
|
device->state == device_idle ? 'I' :
|
||||||
device->state == counter_stopped ? 'S' :
|
device->state == device_stopped ? 'S' :
|
||||||
device->state == counter_running ? 'R' :
|
device->state == device_running ? 'R' :
|
||||||
device->state == counter_paused ? 'P' : '?',
|
device->state == device_paused ? 'P' : '?',
|
||||||
device->terminal_due ? 'T' : ' ',
|
device->terminal_due ? 'T' : ' ',
|
||||||
device->range_error == 0 ? ' ' : 'R',
|
device->range_error == 0 ? ' ' : 'R',
|
||||||
device->range_gated ? 'G' : ' ',
|
device->range_gated ? 'G' : ' ',
|
||||||
@@ -206,7 +206,7 @@ void device_report(DEVICE* device)
|
|||||||
sp->maximum_rate);
|
sp->maximum_rate);
|
||||||
buffer.length = strlen(buffer.body);
|
buffer.length = strlen(buffer.body);
|
||||||
//fputs(buffer.body, stdout);
|
//fputs(buffer.body, stdout);
|
||||||
sock_report(&buffer, 1);
|
sock_report(&buffer, 1, device);
|
||||||
snprintf(buffer.body, sizeof(buffer.body),
|
snprintf(buffer.body, sizeof(buffer.body),
|
||||||
"REPORT %s %10llu %8.2f (%8.2f,%8.2f,%8.2f)\r\n",
|
"REPORT %s %10llu %8.2f (%8.2f,%8.2f,%8.2f)\r\n",
|
||||||
str,
|
str,
|
||||||
@@ -217,7 +217,7 @@ void device_report(DEVICE* device)
|
|||||||
sp->maximum_rate);
|
sp->maximum_rate);
|
||||||
buffer.length = strlen(buffer.body);
|
buffer.length = strlen(buffer.body);
|
||||||
//fputs(buffer.body, stdout);
|
//fputs(buffer.body, stdout);
|
||||||
sock_report(&buffer, 2);
|
sock_report(&buffer, 2, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,7 +239,7 @@ int device_init(DEVICE** cpp, char* name)
|
|||||||
device->params.poll_period = 1000; /* milliseconds between polls */
|
device->params.poll_period = 1000; /* milliseconds between polls */
|
||||||
device->params.sample_period = 10; /* polls between sample calcs */
|
device->params.sample_period = 10; /* polls between sample calcs */
|
||||||
device->params.report_period = 3; /* samples between reports */
|
device->params.report_period = 3; /* samples between reports */
|
||||||
device->state = counter_stopped;
|
device->state = device_stopped;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
device->current_time = now;
|
device->current_time = now;
|
||||||
@@ -284,7 +284,7 @@ int device_start(DEVICE *device)
|
|||||||
device->poll_counter = 0;
|
device->poll_counter = 0;
|
||||||
device->sample_counter = 0;
|
device->sample_counter = 0;
|
||||||
device->terminal_due = false;
|
device->terminal_due = false;
|
||||||
device->state = counter_running;
|
device->state = device_running;
|
||||||
device->previous_time = device->current_time;
|
device->previous_time = device->current_time;
|
||||||
dbg_printf(0, "Setting input line to %d\n", pp->source);
|
dbg_printf(0, "Setting input line to %d\n", pp->source);
|
||||||
HWARE_TEST(hware_source(device->private_data, pp->source));
|
HWARE_TEST(hware_source(device->private_data, pp->source));
|
||||||
@@ -319,7 +319,7 @@ int device_stop(DEVICE *device)
|
|||||||
PARAMETERS* pp = &device->params;
|
PARAMETERS* pp = &device->params;
|
||||||
int value;
|
int value;
|
||||||
device->stop_time = device->current_time;
|
device->stop_time = device->current_time;
|
||||||
device->state = counter_stopped;
|
device->state = device_stopped;
|
||||||
if (pp->output_line == 1)
|
if (pp->output_line == 1)
|
||||||
value = 0;
|
value = 0;
|
||||||
else if (pp->output_line == 2)
|
else if (pp->output_line == 2)
|
||||||
@@ -340,15 +340,15 @@ Error:
|
|||||||
|
|
||||||
int device_pause(DEVICE *device)
|
int device_pause(DEVICE *device)
|
||||||
{
|
{
|
||||||
if (device->state == counter_running)
|
if (device->state == device_running)
|
||||||
device->state = counter_paused;
|
device->state = device_paused;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int device_resume(DEVICE *device)
|
int device_resume(DEVICE *device)
|
||||||
{
|
{
|
||||||
if (device->state == counter_paused)
|
if (device->state == device_paused)
|
||||||
device->state = counter_running;
|
device->state = device_running;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,13 +372,13 @@ static void device_event(DEVICE *device, char* event)
|
|||||||
{
|
{
|
||||||
BUFFER buffer;
|
BUFFER buffer;
|
||||||
sprintf(buffer.body, "EVENT %s %s\r\n",
|
sprintf(buffer.body, "EVENT %s %s\r\n",
|
||||||
event,
|
make_timestamp(&device->current_time),
|
||||||
make_timestamp(&device->current_time));
|
event);
|
||||||
buffer.length = strlen(buffer.body);
|
buffer.length = strlen(buffer.body);
|
||||||
dbg_printf(0, "%s", buffer.body);
|
dbg_printf(0, "%s", buffer.body);
|
||||||
//sock_report(&buffer, 0);
|
//sock_report(&buffer, 0);
|
||||||
sock_report(&buffer, 1);
|
sock_report(&buffer, 1, device);
|
||||||
sock_report(&buffer, 2);
|
sock_report(&buffer, 2, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_range_check(DEVICE* device, int mode)
|
static void device_range_check(DEVICE* device, int mode)
|
||||||
@@ -524,7 +524,7 @@ int device_poll(DEVICE* device)
|
|||||||
/*
|
/*
|
||||||
* If the counter is running and not gated increment the count and runtime
|
* If the counter is running and not gated increment the count and runtime
|
||||||
*/
|
*/
|
||||||
if (device->state == counter_running &&
|
if (device->state == device_running &&
|
||||||
!(device->params.range_gate_enable && device->range_gated))
|
!(device->params.range_gate_enable && device->range_gated))
|
||||||
{
|
{
|
||||||
if (device->params.direction == COUNT_DOWN)
|
if (device->params.direction == COUNT_DOWN)
|
||||||
@@ -602,14 +602,14 @@ int device_poll(DEVICE* device)
|
|||||||
device->output_line = pp->output_line;
|
device->output_line = pp->output_line;
|
||||||
if (pp->output_line == 1)
|
if (pp->output_line == 1)
|
||||||
{
|
{
|
||||||
if (device->state == counter_running || device->state == counter_paused)
|
if (device->state == device_running || device->state == device_paused)
|
||||||
value = 1;
|
value = 1;
|
||||||
else
|
else
|
||||||
value = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
else if (pp->output_line == 2)
|
else if (pp->output_line == 2)
|
||||||
{
|
{
|
||||||
if (device->state == counter_running || device->state == counter_paused)
|
if (device->state == device_running || device->state == device_paused)
|
||||||
value = 0;
|
value = 0;
|
||||||
else
|
else
|
||||||
value = 1;
|
value = 1;
|
||||||
@@ -632,7 +632,7 @@ void device_term(DEVICE* device)
|
|||||||
hware_dtor(&device->private_data);
|
hware_dtor(&device->private_data);
|
||||||
device->private_data = NULL;
|
device->private_data = NULL;
|
||||||
}
|
}
|
||||||
device->state = counter_idle;
|
device->state = device_idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool device_fatal(int error)
|
bool device_fatal(int error)
|
||||||
|
|||||||
@@ -8,16 +8,16 @@
|
|||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "params.h"
|
#include "params.h"
|
||||||
|
|
||||||
typedef enum counter_state_t
|
typedef enum device_state_t
|
||||||
{
|
{
|
||||||
/** The counter has not yet been created or has been destroyed */
|
/** The counter has not yet been created or has been destroyed */
|
||||||
counter_idle = 0,
|
device_idle = 0,
|
||||||
/** The counter has not yet been started or has been stopped */
|
/** The counter has not yet been started or has been stopped */
|
||||||
counter_stopped,
|
device_stopped,
|
||||||
/** The counter is counting */
|
/** The counter is counting */
|
||||||
counter_running,
|
device_running,
|
||||||
/** the counter has been paused */
|
/** the counter has been paused */
|
||||||
counter_paused
|
device_paused
|
||||||
} DEVICE_STATE;
|
} DEVICE_STATE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user