108 lines
2.0 KiB
C
108 lines
2.0 KiB
C
|
|
/*********************************************************************
|
|||
|
|
*
|
|||
|
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: DataAdapter.h <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
|
*
|
|||
|
|
* <EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Shanghai Baosight Software Co., Ltd.
|
|||
|
|
*********************************************************************/
|
|||
|
|
#ifndef _H_DATA_ADAPTER_h
|
|||
|
|
#define _H_DATA_ADAPTER_h
|
|||
|
|
|
|||
|
|
#include <zlib/MemTable.hpp>
|
|||
|
|
#include <glob/BinaryTele.h>
|
|||
|
|
#include <zcus/ReadIHDB.h>
|
|||
|
|
//#include <zcus/ProducerMQ.h>
|
|||
|
|
|
|||
|
|
|
|||
|
|
const std::string TAG_HEAD = "ZD122_";
|
|||
|
|
namespace baosight
|
|||
|
|
{
|
|||
|
|
// const string BR_NAMES[16]={"Power Loss",
|
|||
|
|
// "UnderVoltage",
|
|||
|
|
// "Motor OL",
|
|||
|
|
// "Load Loss",
|
|||
|
|
// "InPhaseLoss",
|
|||
|
|
// "OutPhaseLoss",
|
|||
|
|
// "Dec Inhibit",
|
|||
|
|
// "Shear Pin 1",
|
|||
|
|
// "Shear Pin 2",
|
|||
|
|
// "PriFdbkLoss",
|
|||
|
|
// "AltFdbkLoss",
|
|||
|
|
// "AuxFdbKLoss",
|
|||
|
|
// "PosFdbkLoss",
|
|||
|
|
// "Reserved",
|
|||
|
|
// "Gnd Warning",
|
|||
|
|
// "Reserved"};
|
|||
|
|
// struct BR
|
|||
|
|
// {
|
|||
|
|
// short event;
|
|||
|
|
// short index;
|
|||
|
|
// short id;
|
|||
|
|
// int count[16];
|
|||
|
|
// };
|
|||
|
|
//
|
|||
|
|
// const int BR_ALARM_SIZE = 50;
|
|||
|
|
const int STAT_SIZE = 10000;
|
|||
|
|
|
|||
|
|
struct STAT
|
|||
|
|
{
|
|||
|
|
int count;
|
|||
|
|
double sum;
|
|||
|
|
double avg;
|
|||
|
|
double max;
|
|||
|
|
double min;
|
|||
|
|
double std_dev;
|
|||
|
|
double zonetop;
|
|||
|
|
double zonelow;
|
|||
|
|
char tag[100];
|
|||
|
|
char comment[100];
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
typedef STAT STATS[STAT_SIZE];
|
|||
|
|
|
|||
|
|
class DataAdapter
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
DataAdapter();
|
|||
|
|
~DataAdapter();
|
|||
|
|
public:
|
|||
|
|
|
|||
|
|
int Init();
|
|||
|
|
|
|||
|
|
int push(const string& tag, double value);
|
|||
|
|
|
|||
|
|
int push(int index, double value);
|
|||
|
|
|
|||
|
|
int calcAverage(void);
|
|||
|
|
|
|||
|
|
int calcAverage(const string& tag);
|
|||
|
|
|
|||
|
|
int calcDevZone(time_t start,time_t end);
|
|||
|
|
int calcDevZone(const string& tag, time_t start,time_t end);
|
|||
|
|
|
|||
|
|
int calcLimitZone(time_t start,time_t end);
|
|||
|
|
int calcLimitZone(const string& tag, time_t start,time_t end);
|
|||
|
|
|
|||
|
|
STAT* getValue(const string& tag);
|
|||
|
|
|
|||
|
|
STAT* getValue(int index);
|
|||
|
|
|
|||
|
|
void print(int index);
|
|||
|
|
|
|||
|
|
// int BRAlarm(void);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
// int BRAlarmStoreDB(int index,const string& item,const string& chinese,int count);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
|
|||
|
|
BinaryTele* mp_btele;
|
|||
|
|
STATS* mp_stats;
|
|||
|
|
map<string,int> mp_tags;
|
|||
|
|
// map<string,BR> mp_brs;
|
|||
|
|
ReadIHDB* mp_read;
|
|||
|
|
// ProducerMQ* mp_producer;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif
|