51 lines
847 B
C
51 lines
847 B
C
#ifndef __FLOW_H
|
|
#define __FLOW_H
|
|
|
|
#include <stdint.h>
|
|
|
|
typedef struct
|
|
{
|
|
uint16_t magic;
|
|
struct _ch
|
|
{
|
|
uint16_t ad_4ma;
|
|
uint16_t ad_20ma;
|
|
} ch[2];
|
|
} cal_4_20ma_t;
|
|
|
|
typedef struct
|
|
{
|
|
int16_t flow_min;
|
|
int16_t flow_max;
|
|
} ad_flow_cal_t; //存储ad转换的最大流量和最小流量
|
|
|
|
typedef struct
|
|
{
|
|
uint16_t magic;
|
|
uint16_t input_type; // 1: 4~20ma 2: 0~3.6K
|
|
int16_t min_flow[2]; // 小流量切除
|
|
ad_flow_cal_t ad_cal[2];
|
|
uint16_t pulse_coef[2];
|
|
uint16_t rsv[6];
|
|
} flow_config_t;
|
|
|
|
typedef struct
|
|
{
|
|
int16_t flow_;
|
|
int16_t flow;
|
|
int32_t total_flow;
|
|
uint32_t update_time;
|
|
} flow_t;
|
|
|
|
|
|
extern cal_4_20ma_t *cal_4_20ma;
|
|
extern flow_config_t *flow_config;
|
|
extern flow_t *pflow;
|
|
|
|
void flow_init(void);
|
|
void zero_totalflow(int ch);
|
|
void flow_zero(void);
|
|
int get_total_flow_by_time(int ch, uint32_t time);
|
|
|
|
|
|
#endif |