新增PQDIF解析线程,新增各项PQDIF解析逻辑

This commit is contained in:
2026-04-29 13:35:49 +08:00
parent 33de63cdc6
commit ebefd6b2ae
9 changed files with 9228 additions and 463 deletions

View File

@@ -10,7 +10,7 @@
CPQDIF::CPQDIF()
{
// Init
m_percont = (CPQDIF_PC_FlatFile *)theFactory.NewPersistController(PFPC_FlatFile);
m_percont = (CPQDIF_PC_FlatFile*)theFactory.NewPersistController(PFPC_FlatFile);
}
CPQDIF::~CPQDIF()
@@ -61,7 +61,7 @@ bool CPQDIF::New()
if (m_percont)
delete m_percont;
m_percont = (CPQDIF_PC_FlatFile *)theFactory.NewPersistController(PFPC_FlatFile);
m_percont = (CPQDIF_PC_FlatFile*)theFactory.NewPersistController(PFPC_FlatFile);
if (m_percont)
ret = true;
@@ -83,15 +83,15 @@ long CPQDIF::RecordGetCount()
bool CPQDIF::RecordGetInfo
(
long index,
GUID * tagRecordType,
string & nameRecordType
GUID* tagRecordType,
string& nameRecordType
)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
bool status = false;
CPQDIFRecord * prec;
CPQDIFRecord* prec;
GUID tagRecord;
string nameTag;
@@ -107,11 +107,11 @@ bool CPQDIF::RecordGetInfo
// Return the data...
// The GUID itself
*tagRecordType=tagRecord;
*tagRecordType = tagRecord;
// The GUID name
nameTag = theInfo.GetNameOfTag(tagRecord);
nameRecordType=nameTag;
nameRecordType = nameTag;
status = true;
@@ -127,15 +127,38 @@ bool CPQDIF::RecordGetInfo
return status;
}
bool CPQDIF::RecordRequestObservation(long index, long * pRecordObserv)
bool CPQDIF::RecordRequestRecord(long index, long* pRecord)
{
if (pRecord == nullptr)
return false;
bool status = false;
try
{
CPQDIFRecord* prec = m_percont->GetRecordFull(index);
if (prec)
{
*pRecord = (long)prec;
status = true;
}
}
catch (...)
{
status = false;
}
return status;
}
bool CPQDIF::RecordRequestObservation(long index, long* pRecordObserv)
{
bool status = false;
CPQDIFRecord * precBase;
CPQDIFRecord * precCurrent = NULL;
CPQDIFRecord * precDS = NULL;
CPQDIFRecord * precSett = NULL;
CPQDIF_R_Observation * pobs = NULL;
CPQDIFRecord* precBase;
CPQDIFRecord* precCurrent = NULL;
CPQDIFRecord* precDS = NULL;
CPQDIFRecord* precSett = NULL;
CPQDIF_R_Observation* pobs = NULL;
GUID tagRecord;
long idxRec;
@@ -225,7 +248,7 @@ bool CPQDIF::ObservationGetInfo(long pRecordObserv, DATE& timeStart, string& nam
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
TIMESTAMPPQDIF timeStartLocal;
TIMESTAMPPQDIF timeCreateLocal;
// string nameLocal;
@@ -267,15 +290,15 @@ bool CPQDIF::ObservationGetInfo(long pRecordObserv, DATE& timeStart, string& nam
return status;
}
bool CPQDIF::ObservationGetTriggerInfo(long pRecordObserv, long * idTriggerMethod, DATE * timeTriggered)
bool CPQDIF::ObservationGetTriggerInfo(long pRecordObserv, long* idTriggerMethod, DATE* timeTriggered)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
UINT4 idTriggerMethodLocal;
CPQDIF_E_Vector * pvectTriggerChanIdx = NULL;
CPQDIF_E_Vector* pvectTriggerChanIdx = NULL;
TIMESTAMPPQDIF timeTriggeredLocal;
*idTriggerMethod = -1;
@@ -305,12 +328,12 @@ bool CPQDIF::ObservationGetTriggerInfo(long pRecordObserv, long * idTriggerMetho
return status;
}
bool CPQDIF::ObservationGetChannelInfo(long pRecordObserv, long idxChannel, string &name, long * countSeries)
bool CPQDIF::ObservationGetChannelInfo(long pRecordObserv, long idxChannel, string& name, long* countSeries)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
string nameLocal;
UINT4 idPhaseLocal;
@@ -348,10 +371,10 @@ bool CPQDIF::ObservationGetChannelInfo(long pRecordObserv, long idxChannel, stri
return status;
}
bool CPQDIF::ObservationGetSeriesInfo3(long pRecordObserv, long idxChannel, long idxSeries, long * idQuantityUnits, GUID * idQuantityCharacteristic, GUID * idValueType)
bool CPQDIF::ObservationGetSeriesInfo3(long pRecordObserv, long idxChannel, long idxSeries, long* idQuantityUnits, GUID* idQuantityCharacteristic, GUID* idValueType)
{
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
UINT4 idQuantityUnitsLocal;
GUID idValueTypeLocal;
@@ -367,8 +390,8 @@ bool CPQDIF::ObservationGetSeriesInfo3(long pRecordObserv, long idxChannel, long
{
// Translate information
*idQuantityUnits = (long)idQuantityUnitsLocal;
*idValueType=idValueTypeLocal;
*idQuantityCharacteristic=idQuantityCharacteristicLocal;
*idValueType = idValueTypeLocal;
*idQuantityCharacteristic = idQuantityCharacteristicLocal;
}
}
@@ -384,13 +407,13 @@ bool CPQDIF::ObservationGetSeriesInfo3(long pRecordObserv, long idxChannel, long
}
//ע<><D7A2><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>double* <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ棬ʹ<E6A3AC><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ͷ<EFBFBD>
bool CPQDIF::ObservationGetSeriesData(long pRecordObserv, long idxChannel, long idxSeries, double ** values,long* varCount)
bool CPQDIF::ObservationGetSeriesData(long pRecordObserv, long idxChannel, long idxSeries, double** values, long* varCount)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
bool status = false;
CPQDIF_R_Observation * pobs;
double * pvalues;
CPQDIF_R_Observation* pobs;
double* pvalues;
long countPoints;
try
@@ -401,7 +424,7 @@ bool CPQDIF::ObservationGetSeriesData(long pRecordObserv, long idxChannel, long
pvalues = pobs->NewResolvedSeries(idxChannel, idxSeries, countPoints);
if (pvalues)
{
*values= pvalues;
*values = pvalues;
status = true;
*varCount = countPoints;
//delete[] pvalues;
@@ -419,22 +442,22 @@ bool CPQDIF::ObservationGetSeriesData(long pRecordObserv, long idxChannel, long
return status;
}
bool CPQDIF::ObservationGetChannelFreq(long pRecObs, long idxChannel, double * freq)
bool CPQDIF::ObservationGetChannelFreq(long pRecObs, long idxChannel, double* freq)
{
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
try
{
pobs = ValidateObservation(pRecObs);
if (pobs)
{
CPQDIF_E_Collection * pcol = pobs->GetOneChannel(idxChannel);
CPQDIF_E_Collection* pcol = pobs->GetOneChannel(idxChannel);
if (pcol)
{
CPQDIF_E_Scalar * psc = pobs->FindScalarInCollection(pcol, tagChannelFrequency);
CPQDIF_E_Scalar* psc = pobs->FindScalarInCollection(pcol, tagChannelFrequency);
if (psc)
{
double val;
@@ -457,23 +480,23 @@ bool CPQDIF::ObservationGetChannelFreq(long pRecObs, long idxChannel, double * f
return status;
}
bool CPQDIF::ObservationGetChannelGroupID(long pRecObs, long idxChannel, int *GroupID)
bool CPQDIF::ObservationGetChannelGroupID(long pRecObs, long idxChannel, int* GroupID)
{
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
try
{
pobs = ValidateObservation(pRecObs);
if (pobs)
{
CPQDIF_E_Collection * pcol = pobs->GetOneChannel(idxChannel);
CPQDIF_E_Collection* pcol = pobs->GetOneChannel(idxChannel);
if (pcol)
{
CPQDIF_E_Scalar * psc = pobs->FindScalarInCollection(pcol, tagChannelGroupID);
CPQDIF_E_Scalar* psc = pobs->FindScalarInCollection(pcol, tagChannelGroupID);
if (psc)
{
INT2 val = 0;
@@ -511,11 +534,11 @@ bool CPQDIF::ObservationGetChannelGroupID(long pRecObs, long idxChannel, int *Gr
}
bool CPQDIF::ObservationGetSeriesPhasicType(long pRecordObserv, long idxChannel, long idxSeries, long *valuetypes)
bool CPQDIF::ObservationGetSeriesPhasicType(long pRecordObserv, long idxChannel, long idxSeries, long* valuetypes)
{
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
try
{
@@ -541,13 +564,13 @@ bool CPQDIF::ObservationGetSeriesPhasicType(long pRecordObserv, long idxChannel,
}
bool CPQDIF::ObservationGetSeriesScale(long pRecObs, long idxChannel, long idxSeries, double * scale, double * offset)
bool CPQDIF::ObservationGetSeriesScale(long pRecObs, long idxChannel, long idxSeries, double* scale, double* offset)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
try
{
@@ -573,7 +596,7 @@ bool CPQDIF::RecordReleaseObservation(long pRecordObserv)
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
bool status = false;
CPQDIF_R_Observation * pobs;
CPQDIF_R_Observation* pobs;
pobs = ValidateObservation(pRecordObserv);
if (pobs)
@@ -594,33 +617,33 @@ bool CPQDIF::SetDateFromTimeStamp(DATE& date, const TIMESTAMPPQDIF& ts)
return true;
}
CPQDIF_Element * CPQDIF::ValidateElement(long pElement)
CPQDIF_Element* CPQDIF::ValidateElement(long pElement)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
CPQDIF_Element * pel;
CPQDIF_Element* pel;
pel = (CPQDIF_Element *)pElement;
pel = (CPQDIF_Element*)pElement;
//ASSERT_VALID(pel);
return pel;
}
CPQDIF_E_Collection * CPQDIF::ValidateCollection(long pElement)
CPQDIF_E_Collection* CPQDIF::ValidateCollection(long pElement)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
CPQDIF_Element * pel;
CPQDIF_E_Collection * pcoll = NULL;
CPQDIF_Element* pel;
CPQDIF_E_Collection* pcoll = NULL;
pel = (CPQDIF_Element *)pElement;
pel = (CPQDIF_Element*)pElement;
//ASSERT_VALID(pel);
if (pel)
{
if (pel->GetElementType() == ID_ELEMENT_TYPE_COLLECTION)
{
pcoll = (CPQDIF_E_Collection *)pel;
pcoll = (CPQDIF_E_Collection*)pel;
//ASSERT_VALID(pcoll);
}
}
@@ -637,20 +660,20 @@ CPQDIF_E_Collection * CPQDIF::ValidateCollection(long pElement)
// Valid object pointer The object is valid and of the correct type
// NULL The object is invalid or has an incorrect type
//
CPQDIF_E_Scalar * CPQDIF::ValidateScalar(long pElement)
CPQDIF_E_Scalar* CPQDIF::ValidateScalar(long pElement)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
CPQDIF_Element * pel;
CPQDIF_E_Scalar * pscalar = NULL;
CPQDIF_Element* pel;
CPQDIF_E_Scalar* pscalar = NULL;
pel = (CPQDIF_Element *)pElement;
pel = (CPQDIF_Element*)pElement;
//ASSERT_VALID(pel);
if (pel)
{
if (pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR)
{
pscalar = (CPQDIF_E_Scalar *)pel;
pscalar = (CPQDIF_E_Scalar*)pel;
//ASSERT_VALID(pscalar);
}
}
@@ -667,20 +690,20 @@ CPQDIF_E_Scalar * CPQDIF::ValidateScalar(long pElement)
// Valid object pointer The object is valid and of the correct type
// NULL The object is invalid or has an incorrect type
//
CPQDIF_E_Vector * CPQDIF::ValidateVector(long pElement)
CPQDIF_E_Vector* CPQDIF::ValidateVector(long pElement)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
CPQDIF_Element * pel;
CPQDIF_E_Vector * pvector = NULL;
CPQDIF_Element* pel;
CPQDIF_E_Vector* pvector = NULL;
pel = (CPQDIF_Element *)pElement;
pel = (CPQDIF_Element*)pElement;
//ASSERT_VALID(pel);
if (pel)
{
if (pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR)
{
pvector = (CPQDIF_E_Vector *)pel;
pvector = (CPQDIF_E_Vector*)pel;
//ASSERT_VALID(pvector);
}
}
@@ -697,22 +720,22 @@ CPQDIF_E_Vector * CPQDIF::ValidateVector(long pElement)
// Valid object pointer The object is valid and of the correct type
// NULL The object is invalid or has an incorrect type
//
CPQDIF_R_Observation * CPQDIF::ValidateObservation(long pRecObserv)
CPQDIF_R_Observation* CPQDIF::ValidateObservation(long pRecObserv)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
CPQDIFRecord * prec;
CPQDIF_R_Observation * pobs = NULL;
CPQDIFRecord* prec;
CPQDIF_R_Observation* pobs = NULL;
GUID tagThisRecord;
prec = (CPQDIFRecord *)pRecObserv;
prec = (CPQDIFRecord*)pRecObserv;
//ASSERT_VALID(prec);
if (prec)
{
prec->HeaderGetTag(tagThisRecord);
if (PQDIF_IsEqualGUID(tagThisRecord, tagRecObservation))
{
pobs = (CPQDIF_R_Observation *)prec;
pobs = (CPQDIF_R_Observation*)prec;
//ASSERT_VALID(pobs);
}
}
@@ -720,7 +743,7 @@ CPQDIF_R_Observation * CPQDIF::ValidateObservation(long pRecObserv)
return pobs;
}
void testjson()
void testjson()
{
//{ "emspq1":[{ "type":1,"min":"{str}" },{ "type":2,"min":"{str2}" }],"emspq2":[{ "type":3,"min":"{str3}" },{ "type":4,"min":"{str4}" }] }
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -806,7 +829,7 @@ char* CDeal::AssJson(char* Id) //
{
i = getCurrentGroup(stringToTimeT(dataDate), it->second);
}
else
else
{
i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin);
}
@@ -959,7 +982,7 @@ char* CDeal::AssJson(char* Id) //
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
}
}
if (item->Type == "Null")
if (item->Type == "Null")
{
if (item->DateName == "monitorId") //<2F><><EFBFBD><EFBFBD> ID
{
@@ -1064,7 +1087,7 @@ void CDeal::CheckDataTableList()
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
for (std::list<CItem*>::iterator itemIt = seq->DateItemList.begin(); itemIt != seq->DateItemList.end(); ++itemIt) {
CItem* item = *itemIt;
if (item->Type == "Null")
if (item->Type == "Null")
{
{
std::string str = item->DateName;
@@ -1331,7 +1354,7 @@ void CDeal::ResJsonCfg(char* json)
str_data_name.replace(pos, 1, seq);
}
int start = 0, end = 0;
if (ExtractNumbersBetweenPercent(str_data_name,start,end))
if (ExtractNumbersBetweenPercent(str_data_name, start, end))
{
//printf(" Item: start=%d, end=%d\n", start,end);
for (int i = start; i <= end; i++) {
@@ -1361,7 +1384,7 @@ void CDeal::ResJsonCfg(char* json)
//printf(" Item: KeyName=%s, DataName=%s, Type=%s\n", str_key_name_temp.c_str(), str_data_name_temp.c_str(), type);
}
}
else
else
{
CItem* citem = new CItem(key_name, str_data_name.c_str(), type);
cseq->DateItemList.push_back(citem);
@@ -1395,7 +1418,7 @@ std::string CDeal::convertToDateOnly(const std::string& dateTime) {
return dateTime; // <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5>ո񣬷<D5B8><F1A3ACB7><EFBFBD>ԭ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD>̫<EFBFBD><CCAB><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD>
}
int CDeal::getCurrentGroup(const std::time_t& currentTime,int min) {
int CDeal::getCurrentGroup(const std::time_t& currentTime, int min) {
// <20><>time_tת<74><D7AA>Ϊtm<74><EFBFBD><E1B9B9>
std::tm* localTime = std::localtime(&currentTime);
@@ -1432,7 +1455,7 @@ std::time_t CDeal::stringToTimeT(const std::string& dateTime) {
return currentTime;
}
void CDeal::clear()
void CDeal::clear()
{
// <20><><EFBFBD><EFBFBD>AvgData<74><61>ͬʱ<CDAC>ͷ<EFBFBD>list<double><3E>е<EFBFBD><D0B5>ڴ棨<DAB4><E6A3A8><EFBFBD><EFBFBD><EFBFBD>еĻ<D0B5><C4BB><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>list<double><3E><><EFBFBD><EFBFBD>Ҫ<EFBFBD>ֶ<EFBFBD><D6B6>ͷţ<CDB7>
AvgData.clear();