renamed from cntr.[hc] tp be consistent with digital input driver
r1201 | dcl | 2006-10-30 12:21:01 +1100 (Mon, 30 Oct 2006) | 2 lines
This commit is contained in:
122
site_ansto/hardsup/Monitor/device.h
Normal file
122
site_ansto/hardsup/Monitor/device.h
Normal file
@@ -0,0 +1,122 @@
|
||||
#ifndef _DEVICE_H_
|
||||
#define _DEVICE_H_
|
||||
|
||||
#define MAX_DEVICES 8
|
||||
|
||||
#define SAMPLE_ARRAY_SZ 1000
|
||||
|
||||
#include "utility.h"
|
||||
#include "params.h"
|
||||
|
||||
typedef enum counter_state_t
|
||||
{
|
||||
/** The counter has not yet been created or has been destroyed */
|
||||
counter_idle = 0,
|
||||
/** The counter has not yet been started or has been stopped */
|
||||
counter_stopped,
|
||||
/** The counter is counting */
|
||||
counter_running,
|
||||
/** the counter has been paused */
|
||||
counter_paused
|
||||
} DEVICE_STATE;
|
||||
|
||||
/**
|
||||
* Logical counter sample
|
||||
*/
|
||||
typedef struct sample_t
|
||||
{
|
||||
/** sample number */
|
||||
int sample_counter;
|
||||
/** poll number */
|
||||
int poll_counter;
|
||||
/** time of last read */
|
||||
struct timeval timestamp;
|
||||
/** logical counter value */
|
||||
uint64 counter_value;
|
||||
/** extended physical counter value */
|
||||
uint64 count64;
|
||||
/** counts between current and previous */
|
||||
int count_delta;
|
||||
/** number of polls */
|
||||
int num_polls;
|
||||
/** this data is valid */
|
||||
bool valid;
|
||||
/** time between current and previous */
|
||||
double time_delta;
|
||||
/** computed */
|
||||
double counter_rate;
|
||||
/** computed */
|
||||
double average_rate;
|
||||
/** computed */
|
||||
double minimum_rate;
|
||||
/** computed */
|
||||
double maximum_rate;
|
||||
} SAMPLE, *pSAMPLE;
|
||||
|
||||
typedef struct counter_t
|
||||
{
|
||||
char name[64];
|
||||
DEVICE_STATE state;
|
||||
/** time of last start */
|
||||
struct timeval start_time;
|
||||
/** time of last stop */
|
||||
struct timeval stop_time;
|
||||
/** time of this read */
|
||||
struct timeval current_time;
|
||||
/** time of last read */
|
||||
struct timeval previous_time;
|
||||
/** time of next sample closure */
|
||||
struct timeval sample_timer;
|
||||
/** time of next report generation */
|
||||
struct timeval report_timer;
|
||||
/** accumulated runtime */
|
||||
struct timeval accumulated;
|
||||
/** Current value of logical 64-bit counter */
|
||||
uint64 current_count;
|
||||
/** an array of samples to be used for reporting */
|
||||
SAMPLE sample_array[SAMPLE_ARRAY_SZ];
|
||||
/** calculated values for reporting */
|
||||
SAMPLE report;
|
||||
/** index into the sample array of the current sample */
|
||||
int sample_index;
|
||||
/** number of polls */
|
||||
int poll_counter;
|
||||
/** number of samples */
|
||||
int sample_counter;
|
||||
/** is a terminal count exception due */
|
||||
bool terminal_due;
|
||||
/** error: 0:none, 1:low, 2:high */
|
||||
int range_error;
|
||||
/** is a range exception gate active */
|
||||
bool range_gated;
|
||||
/** Extended physical counter value */
|
||||
uint64 count64;
|
||||
/** Control parameters */
|
||||
PARAMETERS params;
|
||||
/** active value of parameter source */
|
||||
int source;
|
||||
/** active value of parameter output_line */
|
||||
int output_line;
|
||||
struct device_private_t* private_data;
|
||||
} DEVICE, *pDEVICE;
|
||||
|
||||
void make_report(DEVICE* device);
|
||||
void device_sample(DEVICE* device);
|
||||
void device_send(DEVICE* device, int n);
|
||||
void device_read(DEVICE* device, int n);
|
||||
void device_print(DEVICE* device, FILE* fd);
|
||||
void device_report(DEVICE* device);
|
||||
int device_init(DEVICE** cpp, char* name);
|
||||
int device_start(DEVICE* device);
|
||||
int device_stop(DEVICE* device);
|
||||
int device_pause(DEVICE* device);
|
||||
int device_resume(DEVICE* device);
|
||||
int device_command(void* device, const char* cmd);
|
||||
int device_poll(DEVICE* device);
|
||||
void device_term(DEVICE* device);
|
||||
bool device_fatal(int error);
|
||||
void device_errmsg(char* buff, int len);
|
||||
double device_time_to_next_sample(DEVICE* device);
|
||||
double device_time_to_next_report(DEVICE* device);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user