map/das-dn/hostadsbf/hostadsbf.h
2024-12-24 11:37:05 +08:00

98 lines
2.7 KiB
C++

#ifndef _ISS_ADSBF_PROCESS_H_
#define _ISS_ADSBF_PROCESS_H_
#include "ryFileDef.h"
#include "process.h"
#include <thread>
#include "Log.h"
#include "AdsLib.h"
#include "AdsVariable.h"
#include "RouterAccess.h"
using namespace Beckhoff::Ads;
//using namespace bhf::ads;
typedef std::unordered_map<short, short> register2typemap;
typedef struct
{
BOOLEAN inuse;
WORD adsDataMemAddr;
WORD adsDataMaxAddr;
register2typemap adsDataBlocks;
} struADSData;
typedef std::vector<struADSData> adsReadDataVector;
class CHostADSBFProcess : public CProcess
{
public:
CHostADSBFProcess();
virtual ~CHostADSBFProcess();
virtual BOOLEAN OnPreCreate(int id);
virtual BOOLEAN Run(void);
virtual BOOLEAN OnTimer(void);
private:
struRYADSOption m_nOptions;
//增加websocket连接
pthread_t m_cpid;
std::string m_localIp; //本机IP地址
std::string m_localNetId; //本机IP地址
std::string m_remoteIp; //PLC设备ip地址
std::string m_remoteNetId;
std::string m_user;
std::string m_password;
AdsDevice *m_turbine;
BOOLEAN m_bRouteAdded; //路由是否添加成功
DWORD m_apdu_t0_begin;
int m_total_length;
DWORD last_sec;
BOOLEAN m_threadRun;
std::thread m_startup;
void tryStartup();
struADSData m_adsDatas[4];
public:
std::string m_pidName;
BOOLEAN m_bHaveFTP; //存在FTP协议
//ftp参数信息
char m_user[64];
char m_password[64];
char m_remotePath[128];
char m_localPath[128];
WORD m_remotePort;
//文件信息
int m_iv;
LONG m_currentDirNo; //当前目录编号
LONG m_currentFileNo; //当前文件编号
LONG m_lastDirNo; //上一目录编号
LONG m_lastFileNo; //上一文件编号
LONG m_currentDirStartFileNo; //当前目录文件开始编号
LONG m_lastReadDirNo; //最后获取的目录编号
LONG m_lastReadFileNo; //最后获取的文件编号
LONG m_lastReadDirStartFileNo; //最后获取的目录文件开始编号
LONG m_curStartDirNo; //当前获取的目录编号
LONG m_curStartFileNo; //当前获取的文件编号
BOOLEAN m_bHaveUnReadFile; //存在未读的文件
BOOLEAN m_bFtpRun;
const char* getRemoteIp(void) {return m_remoteIp.c_str(); }
private:
BOOLEAN calc(void);
BOOLEAN readRealData(void);
BOOLEAN readFileID(void);
};
#endif //_ISS_ADSBF_PROCESS_H_