Files
coco df489d5640 a
2026-07-03 16:05:30 +08:00

448 lines
13 KiB
C++

// TaskDataOper.h: interface for the CTaskDataOper class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TASKDATAOPER_H__FB04F9EF_988A_468B_8CDE_1C947FC651F9__INCLUDED_)
#define AFX_TASKDATAOPER_H__FB04F9EF_988A_468B_8CDE_1C947FC651F9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "GUCodeCreator.h"
#include <vector>
#include "CtrlProtocolDef.h"
typedef struct ST_1D_TASK_PARAM
{
CString strTDName;
CString strTestPlace;
int iTestType;
int iAR;
int iSptID;
CString strSptName;
int iSptType;
int iStacking;
int iTxWave;
int iTxPeriod;
int iSAInterval;
ST_1D_TASK_PARAM()
{
strTDName.Empty();
strTestPlace.Empty();
iTestType = iAR = iSptID = 0;
strSptName.Empty();
iSptType = iStacking = 0;
iTxWave = iTxPeriod = iSAInterval = 0;
}
}ST1DTaskParam;
typedef struct ST_2D_TASK_PARAM
{
CString strTDName;
CString strTestPlace;
int iTestType;
int iCableLayout;
int iAR;
int iSptID;
CString strSptName;
int iSptType;
int iSkipCable;
int iStartLayer;
int iEndLayer;
int iStartElec;
int iEndElec;
int iStacking;
int iRollCnt;
int iTxWave;
int iTxPeriod;
int iSAInterval;
int iEAmount;
float fEspace;
float fHoleSpace; //孔间距
unsigned int uiDevID;
unsigned int uiTimerTime;
BYTE ucOrgFlg;
BYTE ucTestGRFlag;
ST_2D_TASK_PARAM()
{
strTDName.Empty();
strTestPlace.Empty();
iTestType = iCableLayout = iAR = iSptID = 0;
strSptName.Empty();
iSptType = iSkipCable = 0;
iStartLayer = iEndLayer = iStartElec = iEndElec = 0;
iStacking = iRollCnt = iTxWave = 0;
iTxPeriod = iSAInterval = iEAmount= 0;
fEspace = 0.0;
uiDevID = 0;
fHoleSpace = 0.0;
ucTestGRFlag = 1;
}
}ST2DTaskParam;
typedef struct ST_3D_TASK_PARAM
{
CString strTDName;
CString strTestPlace;
int iTestType;
int iCableLayout;
int iAR;
int iSptID;
CString strSptName;
int iSptType;
int iSkipCable;
int iStacking;
int iTxWave;
int iTxPeriod;
int iSAInterval;
BYTE ucTestGRFlag;
ST_3D_TASK_PARAM()
{
strTDName.Empty();
strTestPlace.Empty();
iTestType = iCableLayout = iAR = iSptID = 0;
strSptName.Empty();
iSptType = iSkipCable = iStacking = 0;
iTxWave = iTxPeriod = iSAInterval = 0;
ucTestGRFlag = 1;
}
}ST3DTaskParam;
typedef struct ST_QUERY_SPT_INFO
{
CString strSptName;
int iSptID;
}STQuerySptInfo;
typedef struct ST_QUERY_MEDIUM_INFO
{
CString strMediumName;
int iMediumID;
}STQueryMediumInfo;
typedef struct ST_QUERY_TASK_BASIC_INFO
{
//CString strTaskName;
char szTaskName[MAX_TASK_NAME_LENGTH];
char ucTaskID[MAX_NAME_LEN];
char szARName[MAX_NAME_LEN];
char szSptName[MAX_NAME_LEN];
int iTaskID;
int iTestType;
int iAR;
int iSptType;
int iStartElec;
int iEndElec;
int iEamount;
int iTestPeriod;
int iCableLayout;
int iSAInterval;
BYTE ucStack;
//float fPoleSpace;
float fXElecDistance; //X方向电极间距
float fYElecDistance; //Y方向电极间距
float fXElecStep; //X方向电极步长
float fYElecStep; //Y方向电极步长
RECT rcGridSize; //网格大小
byte byLineDirection; //测线方向0:X方向 1:Y方向
int iTdChannelID;
BYTE ucOrgFlg;
//char ucTDName[60];
//char ucSciptName[MAX_NAME_LEN];
UINT32 uiStartLayer;
UINT32 uiEndLayer;
UINT32 uiStartTime;
UINT32 uiEndTime;
UINT32 uiTimerTime;
UINT32 uiTotalNum;
BYTE ucLocalStatus;
BYTE ucTestGRFlag;//1:测试接地电阻,0:不测试接地电阻
UINT32 uiCreateTime; //任务创建时间
char ucScriptCN[MAX_NAME_LEN];
ST_QUERY_TASK_BASIC_INFO()
{
iTaskID = -1;
//strTaskName.Empty();
iTestType = -1;
iAR = -1;
iSptType = -1;
iTestPeriod = -1;
iEamount = 0;
iCableLayout = 0;
iStartElec = iEndElec = 0;
ucStack = 1;
iSAInterval = 0;
//fPoleSpace = 0;
fXElecDistance = 0;
fYElecDistance = 0;
fXElecStep = 0;
fYElecStep = 0;
rcGridSize = { 0 };
byLineDirection = 0;
iTdChannelID = 0;
ucOrgFlg = 0;
ucTaskID[0] = { 0 };
uiStartLayer = 0;
uiEndLayer = 0;
uiStartTime = 0;
uiEndTime = 0;
uiTimerTime = 0;
uiTotalNum = 0;
ucLocalStatus = 0;
ucTestGRFlag = 1;
uiCreateTime = 0;
memset(szARName, 0, sizeof(szARName));
memset(szSptName, 0, sizeof(szSptName));
memset(ucScriptCN, 0, sizeof(ucScriptCN));
};
}STQueryTaskBasicInfo;
typedef struct ST_QUERY_CM_INFO
{
CString strCLable;
int iVal;
}STQueryCMInfo;
enum EN_TIMER_TASK_PROC_STEP
{
EN_TIMER_PROC_PLC_POWERON = 0,
EN_TIMER_PROC_ROLLCALL,
EN_TIMER_PROC_CFG_TASK,
EN_TIMER_PROC_MEASU_DATA,
EN_TIMER_PROC_MEASU_FIN,
EN_TIMER_PROC_MEASU_TRMI,
EN_TIMER_PROC_MEASU_SUSPEND,
EN_TIMER_PROC_MEASU_CONTINUE,
EN_TIMER_PROC_MEASU_INITI
};
typedef struct ST_TASK_DETAIL_BASIC_DATA
{
int iID;
int iA;
int iB;
int iM;
int iN;
float fK;
BYTE ucStack;
float fA;
float fB;
float fX;
float fY;
//具体的数据
BYTE ucIsUse;
float fV;
float fI;
float fR0;
float fSP;
}STTaskDetailBasicData,*LPTaskDetailBasicData;
/*电极坐标信息*/
typedef struct ST_ELECTRODE_COORDINATES_INFO_BODY
{
UINT32 uiElecID;
float fX;
float fY;
float fZ;
ST_ELECTRODE_COORDINATES_INFO_BODY()
{
memset(this, 0, sizeof(ST_ELECTRODE_COORDINATES_INFO_BODY));
}
}STElecCoordinatesInfoBody;
/*电极坐标头*/
typedef struct ST_ELECTRODECOORDINATES_INFO_HEAD
{
char szTDID[40]; // 任务ID
char szSCCN[40]; // 脚本CN
float fMaxWellDepth; // 最大井深
UINT32 uiElecNum; // 电极个数
STElecCoordinatesInfoBody* pBody;
ST_ELECTRODECOORDINATES_INFO_HEAD()
{
memset(this, 0, sizeof(ST_ELECTRODECOORDINATES_INFO_HEAD));
}
}STElecCoordinatesInfoHead;
typedef struct ST_TIMER_TASK_INFO
{
UINT32 uiTaskID;
CString strTaskName;
CString strRunTime;
CString strPlcID;
ST_TIMER_TASK_INFO()
{
uiTaskID = 0;
strTaskName.Empty();
strRunTime.Empty();
}
}STTimerTask;
enum EN_DEL_FLAG
{
EN_DEL_ALL =0,
EN_DEL_SIG,
EN_DEL_FROM_ID
};
typedef struct ST_TD_BROWSE_INFO
{
int iTaskID;
CString strTaskName;
ST_TD_BROWSE_INFO()
{
iTaskID = 0;
strTaskName.Empty();
}
}STTdBrowseInfo;
typedef struct ST_PLC_STATUS_INFO
{
float fAnalog[6];
short shCtrl[4];
CString strRepDate;
CString strRepTime;
ST_PLC_STATUS_INFO()
{
memset(fAnalog, 0, sizeof(fAnalog));
memset(shCtrl, 0, sizeof(shCtrl));
strRepDate.Empty();
strRepTime.Empty();
}
}STPlcStatusInfo;
typedef struct ST_TASK_PACKET_ATTR
{
int iLoopTimes;
int iInterval;
CString strPlcID;
ST_TASK_PACKET_ATTR()
{
iLoopTimes = iInterval = 0;
strPlcID.Empty();
}
}STTaskPacketAttr;
class CTaskDataOper
{
public:
CTaskDataOper();
virtual ~CTaskDataOper();
CString CreateTaskCN(int iTestType);
int Create1DTask(const ST1DTaskParam& stTaskParam, CString strTaskCN);
int Create2DTask(const ST2DTaskParam& stTaskParam, CString strTaskCN);
int Create3DTask(const ST3DTaskParam& stTaskParam, CString strTaskCN);
void QuerySptByAR(int iAR, std::vector<STQuerySptInfo>& vtQuerySptRes, int iSptType);
void QuerySptRectByARandSCname(int iAR, CString strSCname, CString& vtQuerySptRes, CString& strPoleStep, CString& strPoleDistance, CString& strLineDirection, BYTE& ucSptType);
void QueryMediumInfo(int iSptType, std::vector<STQueryMediumInfo>& vtQueryAR);
void QueryCmInfo(CString strCName, std::vector<STQueryCMInfo>& vtQueryCM);
bool DeleteTask(int iTaskID);
bool DeleteTaskArray(std::vector<int> vtTaskID);
bool DeleteTaskArray(std::vector<CString> vtTaskID);
bool Query2DSptInfo(int iSptID, int &iMinLayer,int &iMaxLayer);
bool QuerySptElecTpMount(int iSptID, int &iEAmount, int &iTpMount);
bool QueryTdBasicInfo(int iTaskID, STQueryTaskBasicInfo* pTaskBasicInfo,CString strTaskCN=_T(""));
//bool QueryTdBasicInfoByTDCN(CString strTaskCN, STQueryTaskBasicInfo* pTaskBasicInfo);
bool UpdateGrData(int iTaskID, const char* pData,int iSptType,int iAddedVal = 0);
bool InsertGrData(int iTaskID, WORD wGrNum, const char* pData, int iSptType=1);
bool InsertCoordinatesData(CString strTaskID, WORD wGrNum, const char* pData,float fMaxWellDepth, int iSptType = 1); //新增电极坐标信息
bool DeleteGrInfo(int iTaskID, WORD wElecID, BYTE ucDelFlag);
bool DeleteTdDataInfo(BYTE ucTdType, int iTaskID, WORD wTsn, BYTE ucDelFlag);
bool OpenTdData(int iTaskID, BYTE ucTdType, WORD wStartTSN = 0, WORD wMaxChannel = 1);
void CloseTdData(){m_pRecTdData->Close();m_iTdType = -1;}
int QueryNextTdBasicData(std::vector<STSigSndDataInfo>& vtTestData);
bool QueryTdSigBasicData(int iTaskID, BYTE ucTdType, WORD wTSN, LPSTSigSndDataInfo pMeasuBasicReq);
bool UpdateTdBasicData(BYTE ucTdType, BYTE ucTestType,int iTdChannelID, int iTsn, LPSTMeasuBasicDataRes pMeasuBasicData,void *pAttachData);
bool UpdateTdBasicData(BYTE ucTdType, BYTE ucTestType, int iTdChannelID, int iTsn, LPSTMeasuBasicDataResEx pMeasuBasicData, void *pAttachData);
bool OnlineDownloadRes2DData(BYTE ucTdType, STTaskDataRes *ptTaskData, DWORD dwChID);//在线下载Res-2D任务
bool OnlineUploadRes2DTask(DWORD dwChID);//上传Res-2D任务
bool OnlineUploadRes2DArg(DWORD dwChID, STQueryTaskBasicInfo stQueryTdInfo);//上传Res-2D任务参数
bool OnlineUploadRes2DRg(DWORD dwChID, STQueryTaskBasicInfo stQueryTdInfo);//上传Res-2D任务接地电阻
bool OnlineUploadRes2DData(DWORD dwChID, STQueryTaskBasicInfo stQueryTdInfo);//上传Res-2D任务点数据
bool UploadElecCoordinatesInfo(DWORD dwTdID, STQueryTaskBasicInfo stQueryTdInfo); //上传电极坐标信息
//bool DownloadOnLineTdArray(std::vector<int> vtTaskpt);
//bool DownloadOnLineTd(STTaskListItem& iTaskPt);
int GetCurSelTdTestType(){return m_iTestType;}
bool QueryTdDataFromTsn(int iTaskID, BYTE ucTdType, WORD wStartTSN, int iCnt, std::vector<STTaskDetailBasicData>& vtRes);
//根据起始、结束电极编号,查找脚本中对应的测点
bool QueryTdDataByElec(int iSptID, BYTE ucTdType, int iStartElec, int iEndElec, std::vector<STTaskDetailBasicData>& vtRes);
bool QueryElecMaxWellDepthByCN(CString strScriptCN, BYTE ucTdType, STElecCoordinatesInfoHead& stElecInfoHead);
bool QueryElecCoordinatesDataByCN(CString strScriptCN, BYTE ucTdType, WORD wStartTSN, int iCnt, std::vector<STElecCoordinatesInfoBody>& vtRes);
//以下为任务管理器的操作集合
// void InitialTaskTreeCtrl(CTreeCtrl& taskTree,int iSptType);
void QueryTdAttrToCtrl(CListCtrl& listAttr, int iTaskID);
void QueryTdDataToCtrl(CListCtrl& listData, int iTaskID, int iSptType, int iTestType);
void QueryOnLineTdAttrToCtrl(CListCtrl& listAttr, STTaskListItem taskItem, STRemTaskArg *pstTaskArg);
bool QueryOnLineTdAttrFromSev(STRemTaskTable stTaskTable, STRemTaskArg *pstTaskArg);
bool QueryOnLineTdRgFromSev(STRemTaskArg stTaskArg, char *pRg);
bool QueryOnLineElecInfoFromSev(STRemTaskArg stTaskArg, char* pElecInfo);
bool QueryOnLineTdDataFromSev(STRemTaskArg stTaskArg, UINT32 uiStartPoint, UINT32 uiEndPoint, char *pData);
void QueryOnLineTdDataToCtrl(STRemTaskArg stTaskArg, std::vector<STTaskDetailBasicData>& vtData);
//一期
void InitialTaskTreeCtrl(CTreeCtrl& taskTree,int iSptType);
//二期之前的版本
//void InitialOnLineTaskTreeCtrl(CTreeCtrl& taskTree, int iSptType, UINT32 uiTaskNum, STRemTaskTable *ptTaskTable,HWND hWnd);
//void AppendOnLineTaskTreeCtrl(CTreeCtrl& taskTree, int iSptType, UINT32 uiTaskNum, STRemTaskTable *ptTaskTable, HWND hWnd);
//在线二期,初始化任务列表,从保存的集合中全部取出
void InitOnLineTaskTreeCtrl(CTreeCtrl& taskTree, int iSptType, std::map<CString, STRemTaskTable> mapTaskList, HWND hWnd);
//查询从当前时间之后的有效定时任务
void QueryTimerTaskValiad(std::vector<STTimerTask>& vtTimerTask, const SYSTEMTIME &sysCurTime);
int GetDefaultTzID();
bool DeleteTimerTask(const std::vector<int>& vtTask);
bool DeleteTimerTask(UINT32 uiTDID);
//查询任务的基本信息,bIsQueryTimerTd表示是否查询由定时任务自动产生的任务信息
void QueryTdBrowseInfo(std::vector<STTdBrowseInfo>& vtTdBrowseInfo, bool bIsQueryTimerTd=false);
void QueryTdBrowseInfo(std::vector<STTdBrowseInfo>& vtTdBrowseInfo, int iSptType, int iType ,bool bIsQueryTimerTd=false);
bool AddTimerTask(int iTaskID, CString strTaskName, CString strTime,CString strPlcID);
bool InsertPlcStatusData(const STRemPlcDataInfo* pRemPlcData);
bool QueryPlcStatusData(std::vector<STPlcStatusInfo>& vtPlcStatus);
void DeleteOldPlcStatusData();//删除十天前的数据
bool QueryTaskPacketAttr(int& iLoopTime, int& iInterval, CString& strPlcID);
bool QueryTaskPacketInfo(std::vector<STTdBrowseInfo>& vtTdBrowseInfo);
bool InsertTaskPacketInfo(const std::vector<STTdBrowseInfo>& vtTdBrowseInfo, const STTaskPacketAttr& stAttr);
bool CreateSigTaskByAuto(const STTdBrowseInfo& stBasicTask, CString strTime, STTdBrowseInfo& stNewTask);
bool CreateTaskPacket(const std::vector<STTdBrowseInfo>& vtBasicTaskPacket, CString strSysTime, std::vector<STTdBrowseInfo>& vtNewTaskPacket);
int QueryARByTdID(DWORD dwTdID);
//
void AdjustParam();
void SetCurrentTimeRange(time_t tStartTime, time_t tEndTime)
{
m_tStartTime = tStartTime;
m_tEndTime = tEndTime;
}
unsigned int m_uiDevID;
protected:
CGUCodeCreator m_guCodeCreator;
_RecordsetPtr m_pRecTdData;
// int m_iTdType;
bool m_bIsOpenTdData;
BYTE m_iTdType;
int m_iTestType;
WORD m_wMaxChannel;
//vector<CString> m_vtLocalTaskID;
time_t m_tStartTime;
time_t m_tEndTime;
};
#endif // !defined(AFX_TASKDATAOPER_H__FB04F9EF_988A_468B_8CDE_1C947FC651F9__INCLUDED_)