PDR/1.Software/PDR 1.02/include/buffer.h

77 lines
2.2 KiB
C
Raw Permalink Normal View History

2022-09-15 16:35:25 +08:00
#ifndef _PDR_BUFFER_H_
#define _PDR_BUFFER_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Header File Including ------------------------------------------------------------------------ */
/* Macro Declaration ---------------------------------------------------------------------------- */
#define BUFFER_LONG_LENGTH 256
#define BUFFER_SHORT_LENGTH 10
#define BUFFER_TYPE_STACK 0
#define BUFFER_TYPE_QUEUE 1
#define BUFFER_NO_ERROR 0
#define BUFFER_WRONG_PARAMETER 1
#define BUFFER_OUT_OF_MEMORY 2
/* Structure Declaration ------------------------------------------------------------------------ */
#pragma pack (4)
typedef struct BUFFER {
char name[20];
int type;
int length;
int _bottom;
int _top;
int reserved;
double sum;
double mean;
float data[BUFFER_LONG_LENGTH + 1];
} BUFFER;
typedef struct BUFFER_LONG {
char name[20];
int type;
int length;
int _bottom;
int _top;
int reserved;
double sum;
double mean;
float data[BUFFER_LONG_LENGTH + 1];
} BUFFER_LONG;
typedef struct BUFFER_SHORT {
char name[20];
int type;
int length;
int _bottom;
int _top;
int reserved;
double sum;
double mean;
float data[BUFFER_SHORT_LENGTH + 1];
} BUFFER_SHORT;
#pragma pack ()
/* Global Variable Declaration ------------------------------------------------------------------ */
/* Function Declaration ------------------------------------------------------------------------- */
int Buffer_initialize(BUFFER *buffer, const char *name, int type, int length);
int Buffer_clear(BUFFER *buffer);
int Buffer_count(BUFFER *buffer, int *count);
int Buffer_top(BUFFER *buffer, float *value);
int Buffer_bottom(BUFFER *buffer, float *value);
int Buffer_pop(BUFFER *buffer, float *value);
int buffer_push(BUFFER *buffer, float value);
int Buffer_get(BUFFER *buffer, float *value, int index);
int Buffer_mean(BUFFER *buffer, float *mean);
int Buffer_var(BUFFER *buffer, float *var);
int Buffer_std(BUFFER *buffer, float *std);
#ifdef __cplusplus
}
#endif
#endif