Initial
r1113 | dcl | 2006-09-12 15:00:46 +1000 (Tue, 12 Sep 2006) | 2 lines
This commit is contained in:
118
site_ansto/hardsup/Digital/dio.h
Normal file
118
site_ansto/hardsup/Digital/dio.h
Normal file
@@ -0,0 +1,118 @@
|
||||
#ifndef _COUNTER_H_
|
||||
#define _COUNTER_H_
|
||||
|
||||
#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
|
||||
} COUNTER_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];
|
||||
COUNTER_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 output_line */
|
||||
int output_line;
|
||||
struct counter_private_t* private_data;
|
||||
} COUNTER, *pCOUNTER;
|
||||
|
||||
extern COUNTER counter;
|
||||
|
||||
void make_report(COUNTER* cp);
|
||||
void cntr_sample(COUNTER* cp);
|
||||
void cntr_send(COUNTER* cp, int n);
|
||||
void cntr_read(COUNTER* cp, int n);
|
||||
void cntr_print(COUNTER* cp, FILE* fd);
|
||||
void cntr_report(COUNTER* cp);
|
||||
int cntr_init(COUNTER* cp, char* name);
|
||||
int cntr_start(COUNTER *cp);
|
||||
int cntr_stop(COUNTER *cp);
|
||||
int cntr_pause(COUNTER *cp);
|
||||
int cntr_resume(COUNTER *cp);
|
||||
int cntr_poll(COUNTER* cp);
|
||||
void cntr_term(COUNTER* cp);
|
||||
bool cntr_fatal(int error);
|
||||
void cntr_errmsg(char* buff, int len);
|
||||
double cntr_time_to_next_sample(COUNTER* cp);
|
||||
double cntr_time_to_next_report(COUNTER* cp);
|
||||
#endif
|
||||
Reference in New Issue
Block a user