📄 dbsfile.h
字号:
#ifndef _CLASS_CDbsFile_H__
#define _CLASS_CDbsFile_H__
#include "AfxHead.h"
#include "Memory.h"
#include "SwpFile.h"
extern unsigned long GetFileDataCrc(const void *aData, const unsigned long aSize);
extern unsigned long int GetPWDLongIntValue(const void *aData,unsigned long aSize);
//内存表结构,不要改变顺序
struct CMemMeter
{
unsigned short int MeterNo; //表号2
unsigned short int uFileIndex; //在文件中索引位置,即第几个192字节,从1开始,第0位置为中继信息
unsigned short int TransformerId; //区号:台变标识
unsigned short int uArea; //片号:片区号,该表所在片区号
unsigned long int ReadingTime; //抄表时间
float Reading; //表读数
short int ReadOK:1; //本批次读表是否成功
short int SpecialMeter:1;
unsigned char uRelay[5]; //中继信息:最高位=0无效,1=有效,低四位为中继水平。
};
class CDbsFile:protected CSwpFile
{
public:
int GetCurMeterCount() const;
int GetErrorCode() const;
CDbsFile();
virtual ~CDbsFile();
protected:
void DeleteMeter(const unsigned short int delMeterNo);
void AppendORModifyMeter(const char *Data);
void EmptyAllMeter();
unsigned short int FindMeterMemoryIndex(unsigned short MeterNo);
struct CMemMeter *GetMeterMemoryAddr(long nMemIndex);
struct CMemMeter *FindMeterMemoryAddr(unsigned short MeterNo);
void ReadDBS();
private:
void WriteBasicMeterDataToFile(unsigned char data[192],int Position);
int CheckDBSFileHead(FILE *fp);//文件错误,0=文件OK;
int CreateNewDbs();//1=失败 0=成功
unsigned char m_HubMsgData[192];//保存数据库的所有信息,使用是先校验一下数据
long m_DataOffset;
unsigned short m_CurMeterCount;
unsigned short m_MaxMeterCount;
char m_ErrorCode;
CMemory<struct CMemMeter> m_Dbs;
FILE *m_DBSFile;
};
inline CDbsFile::CDbsFile()
{
m_ErrorCode=0;
}
inline CDbsFile::~CDbsFile()
{
}
inline int CDbsFile::GetErrorCode() const
{
return m_ErrorCode;
}
inline int CDbsFile::GetCurMeterCount() const
{
return m_CurMeterCount;
}
inline struct CMemMeter *CDbsFile::FindMeterMemoryAddr(unsigned short MeterNo)
{
unsigned short int Index=FindMeterMemoryIndex(MeterNo);
if(Index==0) return NULL;
return m_Dbs.GetAddr(Index);
}
inline struct CMemMeter *CDbsFile::GetMeterMemoryAddr(long nMemIndex)
{
return m_Dbs.GetAddr(nMemIndex);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -