2026-04-22 10:40:19 +08:00
|
|
|
|
#include "PQDIF.h"
|
|
|
|
|
|
#include "pqdsupport.h"
|
|
|
|
|
|
#include "cjson.h"
|
|
|
|
|
|
#include <ctime>
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
CPQDIF::CPQDIF()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Init
|
2026-04-29 13:35:49 +08:00
|
|
|
|
m_percont = (CPQDIF_PC_FlatFile*)theFactory.NewPersistController(PFPC_FlatFile);
|
2026-04-22 10:40:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CPQDIF::~CPQDIF()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Destroy
|
|
|
|
|
|
delete m_percont;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPQDIF::GetTime(DATE dt, time_t* tm)
|
|
|
|
|
|
{
|
|
|
|
|
|
*tm = (time_t)((double)(dt - EXCEL_DAYCOUNT_ADJUST + 1) * (double)SECONDS_PER_DAY - 8 * 60 * 60);//EXCEL_DAYCOUNT_ADJUSTΪ1970<37><30><EFBFBD><EFBFBD>1900<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 8*60*60ΪUTCʱ<43><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPQDIF::put_FlatFileName(string strFileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
// // AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
m_percont->SetFileName(strFileName.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::Read()
|
|
|
|
|
|
{
|
|
|
|
|
|
// QT <20><><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD> ReadHeaders() <20><><EFBFBD><EFBFBD> int ״̬<D7B4><CCAC>
|
|
|
|
|
|
// 0 <20><>ʾ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾʧ<CABE><CAA7>
|
|
|
|
|
|
int rc = m_percont->ReadHeaders();
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
|
printf("[PQDIF] ReadHeaders rc=%d\n", rc);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
return (rc == 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::Close()
|
|
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
return New();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::New()
|
|
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
bool ret = false;
|
|
|
|
|
|
// Destroy & re-create
|
|
|
|
|
|
if (m_percont)
|
|
|
|
|
|
delete m_percont;
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
m_percont = (CPQDIF_PC_FlatFile*)theFactory.NewPersistController(PFPC_FlatFile);
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
if (m_percont)
|
|
|
|
|
|
ret = true;
|
|
|
|
|
|
else
|
|
|
|
|
|
ret = false;
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long CPQDIF::RecordGetCount()
|
|
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
return (long)m_percont->GetRecordCount();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::RecordGetInfo
|
|
|
|
|
|
(
|
|
|
|
|
|
long index,
|
2026-04-29 13:35:49 +08:00
|
|
|
|
GUID* tagRecordType,
|
|
|
|
|
|
string& nameRecordType
|
2026-04-22 10:40:19 +08:00
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIFRecord* prec;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
GUID tagRecord;
|
|
|
|
|
|
string nameTag;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
prec = m_percont->GetRecord(index);
|
|
|
|
|
|
if (prec)
|
|
|
|
|
|
{
|
|
|
|
|
|
//ASSERT_VALID(prec);
|
|
|
|
|
|
|
|
|
|
|
|
// Get header info
|
|
|
|
|
|
prec->HeaderGetTag(tagRecord);
|
|
|
|
|
|
|
|
|
|
|
|
// Return the data...
|
|
|
|
|
|
// The GUID itself
|
2026-04-29 13:35:49 +08:00
|
|
|
|
*tagRecordType = tagRecord;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
// The GUID name
|
|
|
|
|
|
nameTag = theInfo.GetNameOfTag(tagRecord);
|
2026-04-29 13:35:49 +08:00
|
|
|
|
nameRecordType = nameTag;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// catch( ... )
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// // e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
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)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIFRecord* precBase;
|
|
|
|
|
|
CPQDIFRecord* precCurrent = NULL;
|
|
|
|
|
|
CPQDIFRecord* precDS = NULL;
|
|
|
|
|
|
CPQDIFRecord* precSett = NULL;
|
|
|
|
|
|
CPQDIF_R_Observation* pobs = NULL;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
GUID tagRecord;
|
|
|
|
|
|
long idxRec;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// Find the observation and associated data source
|
|
|
|
|
|
precBase = m_percont->GetRecordFull(index);
|
|
|
|
|
|
if (precBase)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Is this an observation?
|
|
|
|
|
|
precBase->HeaderGetTag(tagRecord);
|
|
|
|
|
|
if (PQDIF_IsEqualGUID(tagRecord, tagRecObservation))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Find its data source...
|
|
|
|
|
|
// Search backward through the record list.
|
|
|
|
|
|
for (idxRec = index - 1; idxRec >= 0; idxRec--)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// Are we still looking for the DS?
|
|
|
|
|
|
if (!precDS)
|
|
|
|
|
|
{
|
|
|
|
|
|
precCurrent = m_percont->GetRecord(idxRec);
|
|
|
|
|
|
precCurrent->HeaderGetTag(tagRecord);
|
|
|
|
|
|
if (PQDIF_IsEqualGUID(tagRecord, tagRecDataSource))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Found it!
|
|
|
|
|
|
precDS = m_percont->GetRecordFull(idxRec);
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
// We're cool even if we just find this one. We should break at this point,
|
|
|
|
|
|
// because we won't find any valid settings records *before* it!
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Are we still looking for the settings?
|
|
|
|
|
|
if (!precSett)
|
|
|
|
|
|
{
|
|
|
|
|
|
precCurrent = m_percont->GetRecord(idxRec);
|
|
|
|
|
|
precCurrent->HeaderGetTag(tagRecord);
|
|
|
|
|
|
if (PQDIF_IsEqualGUID(tagRecord, tagRecMonitorSettings))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Found it!
|
|
|
|
|
|
precSett = m_percont->GetRecordFull(idxRec);
|
|
|
|
|
|
// precSett is not required, so we don't change
|
|
|
|
|
|
// the value of status.
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} // for( records )
|
|
|
|
|
|
}
|
|
|
|
|
|
} // if( found obs record )
|
|
|
|
|
|
|
|
|
|
|
|
if (status && precBase && precDS)
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = theFactory.NewObservationWrapper2(precBase, precDS, precSett);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
*pRecordObserv = (long)pobs;
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (precBase)
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = theFactory.NewObservationWrapper2(precBase, precDS, precSett);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
*pRecordObserv = (long)pobs;
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::ObservationGetInfo(long pRecordObserv, DATE& timeStart, string& name, long& countChannels)
|
|
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
TIMESTAMPPQDIF timeStartLocal;
|
|
|
|
|
|
TIMESTAMPPQDIF timeCreateLocal;
|
|
|
|
|
|
// string nameLocal;
|
|
|
|
|
|
string nameLocal;
|
|
|
|
|
|
|
|
|
|
|
|
countChannels = 0;
|
|
|
|
|
|
timeStart = -1;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Get channel count
|
|
|
|
|
|
countChannels = pobs->GetCountChannels();
|
|
|
|
|
|
|
|
|
|
|
|
// Get time & name
|
|
|
|
|
|
status = pobs->GetInfo(timeStartLocal, timeCreateLocal, nameLocal);
|
|
|
|
|
|
|
|
|
|
|
|
// Transfer info over
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
status = SetDateFromTimeStamp(timeStart, timeStartLocal);
|
|
|
|
|
|
//status = theSupport.SetDateFromTimeStamp( *timeCreate, timeCreateLocal );
|
|
|
|
|
|
|
|
|
|
|
|
name = nameLocal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
bool CPQDIF::ObservationGetTriggerInfo(long pRecordObserv, long* idTriggerMethod, DATE* timeTriggered)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
UINT4 idTriggerMethodLocal;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_E_Vector* pvectTriggerChanIdx = NULL;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
TIMESTAMPPQDIF timeTriggeredLocal;
|
|
|
|
|
|
|
|
|
|
|
|
*idTriggerMethod = -1;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
status = pobs->GetTriggerInfo(idTriggerMethodLocal, &pvectTriggerChanIdx, timeTriggeredLocal);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
status = SetDateFromTimeStamp(*timeTriggered, timeTriggeredLocal);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Copy this one anyway...
|
|
|
|
|
|
*idTriggerMethod = (long)idTriggerMethodLocal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
bool CPQDIF::ObservationGetChannelInfo(long pRecordObserv, long idxChannel, string& name, long* countSeries)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
string nameLocal;
|
|
|
|
|
|
UINT4 idPhaseLocal;
|
|
|
|
|
|
GUID idQuantityTypeLocal;
|
|
|
|
|
|
UINT4 idQuantityMeasuredLocal;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Make sure we're in the right range.
|
|
|
|
|
|
if (idxChannel >= 0 && idxChannel < pobs->GetCountChannels())
|
|
|
|
|
|
{
|
|
|
|
|
|
*countSeries = pobs->GetCountSeries(idxChannel);
|
|
|
|
|
|
|
|
|
|
|
|
// Get full channel info
|
|
|
|
|
|
status = pobs->GetChannelInfo(idxChannel, nameLocal, idPhaseLocal, idQuantityTypeLocal, idQuantityMeasuredLocal);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
name = nameLocal;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
bool CPQDIF::ObservationGetSeriesInfo3(long pRecordObserv, long idxChannel, long idxSeries, long* idQuantityUnits, GUID* idQuantityCharacteristic, GUID* idValueType)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
bool status = false;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
UINT4 idQuantityUnitsLocal;
|
|
|
|
|
|
GUID idValueTypeLocal;
|
|
|
|
|
|
GUID idQuantityCharacteristicLocal;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
status = pobs->GetSeriesInfo(idxChannel, idxSeries, idQuantityUnitsLocal, idQuantityCharacteristicLocal, idValueTypeLocal);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Translate information
|
|
|
|
|
|
*idQuantityUnits = (long)idQuantityUnitsLocal;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
*idValueType = idValueTypeLocal;
|
|
|
|
|
|
*idQuantityCharacteristic = idQuantityCharacteristicLocal;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ע<><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>
|
2026-04-29 13:35:49 +08:00
|
|
|
|
bool CPQDIF::ObservationGetSeriesData(long pRecordObserv, long idxChannel, long idxSeries, double** values, long* varCount)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
|
|
|
|
|
double* pvalues;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
long countPoints;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
pvalues = pobs->NewResolvedSeries(idxChannel, idxSeries, countPoints);
|
|
|
|
|
|
if (pvalues)
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
*values = pvalues;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
status = true;
|
|
|
|
|
|
*varCount = countPoints;
|
|
|
|
|
|
//delete[] pvalues;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
bool CPQDIF::ObservationGetChannelFreq(long pRecObs, long idxChannel, double* freq)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecObs);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_E_Collection* pcol = pobs->GetOneChannel(idxChannel);
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
if (pcol)
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_E_Scalar* psc = pobs->FindScalarInCollection(pcol, tagChannelFrequency);
|
2026-04-22 10:40:19 +08:00
|
|
|
|
if (psc)
|
|
|
|
|
|
{
|
|
|
|
|
|
double val;
|
|
|
|
|
|
psc->GetValueREAL8(val);
|
|
|
|
|
|
if (freq)
|
|
|
|
|
|
{
|
|
|
|
|
|
*freq = val;
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
bool CPQDIF::ObservationGetChannelGroupID(long pRecObs, long idxChannel, int* GroupID)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecObs);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_E_Collection* pcol = pobs->GetOneChannel(idxChannel);
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
if (pcol)
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_E_Scalar* psc = pobs->FindScalarInCollection(pcol, tagChannelGroupID);
|
2026-04-22 10:40:19 +08:00
|
|
|
|
if (psc)
|
|
|
|
|
|
{
|
|
|
|
|
|
INT2 val = 0;
|
|
|
|
|
|
bool bOk = psc->GetValueINT2(val);
|
|
|
|
|
|
if (bOk == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GroupID)
|
|
|
|
|
|
{
|
|
|
|
|
|
*GroupID = val;
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
UINT2 val = 0;
|
|
|
|
|
|
psc->GetValueUINT2(val);
|
|
|
|
|
|
if (GroupID)
|
|
|
|
|
|
{
|
|
|
|
|
|
*GroupID = val;
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
bool CPQDIF::ObservationGetSeriesPhasicType(long pRecordObserv, long idxChannel, long idxSeries, long* valuetypes)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
long lvalue = 0;
|
|
|
|
|
|
status = pobs->GetSeriesBaseType(idxChannel, idxSeries, lvalue);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
*valuetypes = lvalue;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
bool CPQDIF::ObservationGetSeriesScale(long pRecObs, long idxChannel, long idxSeries, double* scale, double* offset)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecObs);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
status = pobs->GetSeriesScale(idxChannel, idxSeries, *scale, *offset);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
// e->Delete();
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::RecordReleaseObservation(long pRecordObserv)
|
|
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* pobs;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete pobs;
|
|
|
|
|
|
status = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
//protected <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::SetDateFromTimeStamp(DATE& date, const TIMESTAMPPQDIF& ts)
|
|
|
|
|
|
{
|
|
|
|
|
|
date = (double)ts.day
|
|
|
|
|
|
+ ((double)ts.sec / (double)SECONDS_PER_DAY);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_Element* CPQDIF::ValidateElement(long pElement)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_Element* pel;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
pel = (CPQDIF_Element*)pElement;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(pel);
|
|
|
|
|
|
|
|
|
|
|
|
return pel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_E_Collection* CPQDIF::ValidateCollection(long pElement)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_Element* pel;
|
|
|
|
|
|
CPQDIF_E_Collection* pcoll = NULL;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
pel = (CPQDIF_Element*)pElement;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(pel);
|
|
|
|
|
|
if (pel)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pel->GetElementType() == ID_ELEMENT_TYPE_COLLECTION)
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
pcoll = (CPQDIF_E_Collection*)pel;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(pcoll);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return pcoll;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validates a scalar handle and returns the object pointer.
|
|
|
|
|
|
// For internal use.
|
|
|
|
|
|
//
|
|
|
|
|
|
// Returns
|
|
|
|
|
|
// -------
|
|
|
|
|
|
// Valid object pointer The object is valid and of the correct type
|
|
|
|
|
|
// NULL The object is invalid or has an incorrect type
|
|
|
|
|
|
//
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_E_Scalar* CPQDIF::ValidateScalar(long pElement)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_Element* pel;
|
|
|
|
|
|
CPQDIF_E_Scalar* pscalar = NULL;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
pel = (CPQDIF_Element*)pElement;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(pel);
|
|
|
|
|
|
if (pel)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR)
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
pscalar = (CPQDIF_E_Scalar*)pel;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(pscalar);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return pscalar;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validates a vector handle and returns the object pointer.
|
|
|
|
|
|
// For internal use.
|
|
|
|
|
|
//
|
|
|
|
|
|
// Returns
|
|
|
|
|
|
// -------
|
|
|
|
|
|
// Valid object pointer The object is valid and of the correct type
|
|
|
|
|
|
// NULL The object is invalid or has an incorrect type
|
|
|
|
|
|
//
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_E_Vector* CPQDIF::ValidateVector(long pElement)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_Element* pel;
|
|
|
|
|
|
CPQDIF_E_Vector* pvector = NULL;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
pel = (CPQDIF_Element*)pElement;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(pel);
|
|
|
|
|
|
if (pel)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR)
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
pvector = (CPQDIF_E_Vector*)pel;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(pvector);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return pvector;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validates a observation record handle and returns the object pointer.
|
|
|
|
|
|
// For internal use.
|
|
|
|
|
|
//
|
|
|
|
|
|
// Returns
|
|
|
|
|
|
// -------
|
|
|
|
|
|
// Valid object pointer The object is valid and of the correct type
|
|
|
|
|
|
// NULL The object is invalid or has an incorrect type
|
|
|
|
|
|
//
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIF_R_Observation* CPQDIF::ValidateObservation(long pRecObserv)
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
CPQDIFRecord* prec;
|
|
|
|
|
|
CPQDIF_R_Observation* pobs = NULL;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
GUID tagThisRecord;
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
prec = (CPQDIFRecord*)pRecObserv;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(prec);
|
|
|
|
|
|
if (prec)
|
|
|
|
|
|
{
|
|
|
|
|
|
prec->HeaderGetTag(tagThisRecord);
|
|
|
|
|
|
if (PQDIF_IsEqualGUID(tagThisRecord, tagRecObservation))
|
|
|
|
|
|
{
|
2026-04-29 13:35:49 +08:00
|
|
|
|
pobs = (CPQDIF_R_Observation*)prec;
|
2026-04-22 10:40:19 +08:00
|
|
|
|
//ASSERT_VALID(pobs);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return pobs;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
void testjson()
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
//{ "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>
|
|
|
|
|
|
cJSON* root = cJSON_CreateObject();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>emspq1<71><31><EFBFBD><EFBFBD>
|
|
|
|
|
|
cJSON* emspq1_array = cJSON_CreateArray();
|
|
|
|
|
|
cJSON_AddItemToObject(root, "emspq1", emspq1_array);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>emspq1<71><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
|
|
|
|
|
|
cJSON* emspq1_obj1 = cJSON_CreateObject();
|
|
|
|
|
|
cJSON_AddNumberToObject(emspq1_obj1, "type", 1);
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, "min", "{str}");
|
|
|
|
|
|
cJSON_AddItemToArray(emspq1_array, emspq1_obj1);
|
|
|
|
|
|
|
|
|
|
|
|
cJSON* emspq1_obj2 = cJSON_CreateObject();
|
|
|
|
|
|
cJSON_AddNumberToObject(emspq1_obj2, "type", 2);
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj2, "min", "{str2}");
|
|
|
|
|
|
cJSON_AddItemToArray(emspq1_array, emspq1_obj2);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>emspq2<71><32><EFBFBD><EFBFBD>
|
|
|
|
|
|
cJSON* emspq2_array = cJSON_CreateArray();
|
|
|
|
|
|
cJSON_AddItemToObject(root, "emspq2", emspq2_array);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>emspq2<71><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
|
|
|
|
|
|
cJSON* emspq2_obj1 = cJSON_CreateObject();
|
|
|
|
|
|
cJSON_AddNumberToObject(emspq2_obj1, "type", 3);
|
|
|
|
|
|
cJSON_AddStringToObject(emspq2_obj1, "min", "{str3}");
|
|
|
|
|
|
cJSON_AddItemToArray(emspq2_array, emspq2_obj1);
|
|
|
|
|
|
|
|
|
|
|
|
cJSON* emspq2_obj2 = cJSON_CreateObject();
|
|
|
|
|
|
cJSON_AddNumberToObject(emspq2_obj2, "type", 4);
|
|
|
|
|
|
cJSON_AddStringToObject(emspq2_obj2, "min", "{str4}");
|
|
|
|
|
|
cJSON_AddItemToArray(emspq2_array, emspq2_obj2);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>л<EFBFBD>JSON<4F><4E><EFBFBD><EFBFBD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
char* json_string = cJSON_Print(root);
|
|
|
|
|
|
printf("%s\n", json_string);
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
|
|
|
|
|
free(json_string); // <20>ͷ<EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>ռ<EFBFBD>õ<EFBFBD><C3B5>ڴ<EFBFBD>
|
|
|
|
|
|
cJSON_Delete(root); // <20>ͷ<EFBFBD> cJSON <20><><EFBFBD><EFBFBD>ռ<EFBFBD>õ<EFBFBD><C3B5>ڴ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
printf("testjson \n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char* CDeal::AssJson(char* Id) //<2F><>װjson<6F>ṹ
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
cJSON* root = cJSON_CreateObject();
|
|
|
|
|
|
|
|
|
|
|
|
for (std::list<CTable*>::iterator tableIt = DataTableList.begin(); tableIt != DataTableList.end(); ++tableIt) {
|
|
|
|
|
|
CTable* table = *tableIt;
|
|
|
|
|
|
//printf("TableName = %s || table->DateSeqList siez = %d\n", table->TableName.c_str(), table->DateSeqList.size());
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>emspq1<71><31><EFBFBD><EFBFBD>
|
|
|
|
|
|
cJSON* emspq1_array = cJSON_CreateArray();
|
|
|
|
|
|
cJSON_AddItemToObject(root, table->TableName.c_str(), emspq1_array);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|
|
|
|
|
for (std::list<CSeq*>::iterator seqIt = table->DateSeqList.begin(); seqIt != table->DateSeqList.end(); ++seqIt) {
|
|
|
|
|
|
CSeq* seq = *seqIt;
|
|
|
|
|
|
//printf("telemetryType = %s || seq->DateItemList siez = %d\n", seq->telemetryType.c_str(), seq->DateItemList.size());
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>emspq1<71><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
|
|
|
|
|
|
cJSON* emspq1_obj1 = cJSON_CreateObject();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, seq->jsonname.c_str(), seq->telemetryType.c_str());
|
|
|
|
|
|
// <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;
|
|
|
|
|
|
//printf("KeyName = %s || DateName = %s\n", item->KeyName.c_str(), item->DateName.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
if (item->Type == "Avg")
|
|
|
|
|
|
{
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = AvgData.find(item->DateName);
|
|
|
|
|
|
if (it != AvgData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
if (stringToTimeT(dataDate) != -1) {
|
|
|
|
|
|
std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName);
|
|
|
|
|
|
if (it != aggCydeMinList.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), it->second);
|
|
|
|
|
|
}
|
2026-04-29 13:35:49 +08:00
|
|
|
|
else
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bool isFirst = true; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << "{";
|
|
|
|
|
|
for (std::list<double>::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) {
|
|
|
|
|
|
if (!isFirst) {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
count << ",";
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "\"P" << i++ << "\":" << *itm;
|
|
|
|
|
|
isFirst = false; // <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "}";
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item->Type == "Max")
|
|
|
|
|
|
{
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = MaxData.find(item->DateName);
|
|
|
|
|
|
if (it != MaxData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
if (stringToTimeT(dataDate) != -1) {
|
|
|
|
|
|
std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName);
|
|
|
|
|
|
if (it != aggCydeMinList.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), it->second);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bool isFirst = true; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << "{";
|
|
|
|
|
|
for (std::list<double>::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) {
|
|
|
|
|
|
if (!isFirst) {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
count << ",";
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "\"P" << i++ << "\":" << *itm;
|
|
|
|
|
|
isFirst = false; // <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "}";
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item->Type == "Min")
|
|
|
|
|
|
{
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = MinData.find(item->DateName);
|
|
|
|
|
|
if (it != MinData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
if (stringToTimeT(dataDate) != -1) {
|
|
|
|
|
|
std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName);
|
|
|
|
|
|
if (it != aggCydeMinList.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), it->second);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bool isFirst = true; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << "{";
|
|
|
|
|
|
for (std::list<double>::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) {
|
|
|
|
|
|
if (!isFirst) {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
count << ",";
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "\"P" << i++ << "\":" << *itm;
|
|
|
|
|
|
isFirst = false; // <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "}";
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item->Type == "CP95")
|
|
|
|
|
|
{
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = CP95Data.find(item->DateName);
|
|
|
|
|
|
if (it != CP95Data.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
if (stringToTimeT(dataDate) != -1) {
|
|
|
|
|
|
std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName);
|
|
|
|
|
|
if (it != aggCydeMinList.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), it->second);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bool isFirst = true; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << "{";
|
|
|
|
|
|
for (std::list<double>::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) {
|
|
|
|
|
|
if (!isFirst) {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
count << ",";
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "\"P" << i++ << "\":" << *itm;
|
|
|
|
|
|
isFirst = false; // <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "}";
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item->Type == "Val")
|
|
|
|
|
|
{
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = ValData.find(item->DateName);
|
|
|
|
|
|
if (it != ValData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
if (stringToTimeT(dataDate) != -1) {
|
|
|
|
|
|
std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName);
|
|
|
|
|
|
if (it != aggCydeMinList.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), it->second);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bool isFirst = true; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << "{";
|
|
|
|
|
|
for (std::list<double>::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) {
|
|
|
|
|
|
if (!isFirst) {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
count << ",";
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "\"P" << i++ << "\":" << *itm;
|
|
|
|
|
|
isFirst = false; // <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
count << "}";
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-29 13:35:49 +08:00
|
|
|
|
if (item->Type == "Null")
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (item->DateName == "monitorId") //<2F><><EFBFBD><EFBFBD> ID
|
|
|
|
|
|
{
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), Id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
size_t pos = item->DateName.find("-dataDate-pt");
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), convertToDateOnly(dataDatePT).c_str());
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
pos = item->DateName.find("-dataDate-all");
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), convertToDateOnly(dataDate).c_str());
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
pos = item->DateName.find("-aggCydeMin-pst");
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos && ShortFlag == 1) {
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << aggCycleMinShort;
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
pos = item->DateName.find("-aggCydeMin-plt");
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos && LongFlag == 1) {
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << aggCycleMinLong;
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
pos = item->DateName.find("-aggCydeMin-flu");
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos && FluFlag == 1) {
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << fluCydeMin;
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
pos = item->DateName.find("-aggCydeMin-all");
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << aggCydeMin;
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str());
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
cJSON_AddItemToArray(emspq1_array, emspq1_obj1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>л<EFBFBD>JSON<4F><4E><EFBFBD><EFBFBD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
char* json_string = cJSON_Print(root);
|
|
|
|
|
|
//printf("%s\n", json_string);
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
|
|
|
|
|
//free(json_string); // <20>ͷ<EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>ռ<EFBFBD>õ<EFBFBD><C3B5>ڴ<EFBFBD>
|
|
|
|
|
|
cJSON_Delete(root); // <20>ͷ<EFBFBD> cJSON <20><><EFBFBD><EFBFBD>ռ<EFBFBD>õ<EFBFBD><C3B5>ڴ<EFBFBD>
|
|
|
|
|
|
return json_string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CDeal::ExtractNumbersBetweenPercent(const std::string& str, int& start, int& end) {
|
|
|
|
|
|
size_t pos_start = str.find('%');
|
|
|
|
|
|
if (pos_start == std::string::npos) {
|
|
|
|
|
|
// û<><C3BB><EFBFBD>ҵ<EFBFBD>'%'<27>ַ<EFBFBD>
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t pos_end = str.find('%', pos_start + 1);
|
|
|
|
|
|
if (pos_end == std::string::npos) {
|
|
|
|
|
|
// û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5>ڶ<EFBFBD><DAB6><EFBFBD>'%'<27>ַ<EFBFBD>
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::istringstream iss(str.substr(pos_start + 1, pos_end - pos_start - 1));
|
|
|
|
|
|
char comma;
|
|
|
|
|
|
if (!(iss >> start >> comma >> end)) {
|
|
|
|
|
|
// <20><EFBFBD><DEB7><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CDeal::CheckDataTableList()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (std::list<CTable*>::iterator tableIt = DataTableList.begin(); tableIt != DataTableList.end(); ++tableIt) {
|
|
|
|
|
|
CTable* table = *tableIt;
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|
|
|
|
|
for (std::list<CSeq*>::iterator seqIt = table->DateSeqList.begin(); seqIt != table->DateSeqList.end(); ++seqIt) {
|
|
|
|
|
|
CSeq* seq = *seqIt;
|
|
|
|
|
|
// <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;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
if (item->Type == "Null")
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string str = item->DateName;
|
|
|
|
|
|
std::string substr = "-dataDate-pt";
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
size_t pos = str.find(substr);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
// <20><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>λ<EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5>ַ<EFBFBD>
|
|
|
|
|
|
str.erase(pos, substr.length());
|
|
|
|
|
|
std::map< std::string, std::string >::iterator it = DateData.find(str);
|
|
|
|
|
|
if (it != DateData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << it->second;
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
dataDatePT = count_str;
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string str = item->DateName;
|
|
|
|
|
|
std::string substr = "-dataDate-all";
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
size_t pos = str.find(substr);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
// <20><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>λ<EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5>ַ<EFBFBD>
|
|
|
|
|
|
str.erase(pos, substr.length());
|
|
|
|
|
|
std::map< std::string, std::string >::iterator it = DateData.find(str);
|
|
|
|
|
|
if (it != DateData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << it->second;
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
dataDate = count_str;
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string str = item->DateName;
|
|
|
|
|
|
std::string substr = "-aggCydeMin-pst";
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
size_t pos = str.find(substr);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
// <20><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>λ<EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5>ַ<EFBFBD>
|
|
|
|
|
|
str.erase(pos, substr.length());
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = TimeData.find(str);
|
|
|
|
|
|
if (it != TimeData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
ShortFlag = 1;//<2F><><EFBFBD>ô<EFBFBD><C3B4>ڶ<EFBFBD><DAB6><EFBFBD>
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
const std::list<double>& list_values = it->second;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡlist<73>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
|
std::list<double>::size_type list_size = list_values.size();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>أ<EFBFBD>ȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
|
if (list_size >= 2) {
|
|
|
|
|
|
// ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::list<double>::const_iterator it_first = list_values.begin();
|
|
|
|
|
|
// ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵڶ<CAB5><DAB6><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::list<double>::const_iterator it_second = it_first;
|
|
|
|
|
|
++it_second; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
|
|
|
|
|
|
aggCycleMinShort = *it_second - *it_first;
|
|
|
|
|
|
aggCycleMinShort = aggCycleMinShort / 60;
|
|
|
|
|
|
}
|
|
|
|
|
|
aggCydeMinList[str] = aggCycleMinShort;
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string str = item->DateName;
|
|
|
|
|
|
std::string substr = "-aggCydeMin-plt";
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
size_t pos = str.find(substr);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
// <20><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>λ<EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5>ַ<EFBFBD>
|
|
|
|
|
|
str.erase(pos, substr.length());
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = TimeData.find(str);
|
|
|
|
|
|
if (it != TimeData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
LongFlag = 1;//<2F><><EFBFBD>ô<EFBFBD><C3B4>ڶ<EFBFBD><DAB6><EFBFBD>
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
const std::list<double>& list_values = it->second;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡlist<73>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
|
std::list<double>::size_type list_size = list_values.size();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>أ<EFBFBD>ȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
|
if (list_size >= 2) {
|
|
|
|
|
|
// ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::list<double>::const_iterator it_first = list_values.begin();
|
|
|
|
|
|
// ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵڶ<CAB5><DAB6><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::list<double>::const_iterator it_second = it_first;
|
|
|
|
|
|
++it_second; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
|
|
|
|
|
|
aggCycleMinLong = *it_second - *it_first;
|
|
|
|
|
|
aggCycleMinLong = aggCycleMinLong / 60;
|
|
|
|
|
|
}
|
|
|
|
|
|
aggCydeMinList[str] = aggCycleMinLong;
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string str = item->DateName;
|
|
|
|
|
|
std::string substr = "-aggCydeMin-flu";
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
size_t pos = str.find(substr);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
// <20><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>λ<EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5>ַ<EFBFBD>
|
|
|
|
|
|
str.erase(pos, substr.length());
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = TimeData.find(str);
|
|
|
|
|
|
if (it != TimeData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
FluFlag = 1;//<2F><><EFBFBD>ô<EFBFBD><C3B4>ڶ<EFBFBD><DAB6><EFBFBD>
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
const std::list<double>& list_values = it->second;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡlist<73>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
|
std::list<double>::size_type list_size = list_values.size();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>أ<EFBFBD>ȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
|
if (list_size >= 2) {
|
|
|
|
|
|
// ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::list<double>::const_iterator it_first = list_values.begin();
|
|
|
|
|
|
// ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵڶ<CAB5><DAB6><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::list<double>::const_iterator it_second = it_first;
|
|
|
|
|
|
++it_second; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
|
|
|
|
|
|
fluCydeMin = *it_second - *it_first;
|
|
|
|
|
|
fluCydeMin = fluCydeMin / 60;
|
|
|
|
|
|
}
|
|
|
|
|
|
aggCydeMinList[str] = fluCydeMin;
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string str = item->DateName;
|
|
|
|
|
|
std::string substr = "-aggCydeMin-all";
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
size_t pos = str.find(substr);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
// <20><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>λ<EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5>ַ<EFBFBD>
|
|
|
|
|
|
str.erase(pos, substr.length());
|
|
|
|
|
|
std::map< std::string, std::list<double> >::iterator it = TimeData.find(str);
|
|
|
|
|
|
if (it != TimeData.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
const std::list<double>& list_values = it->second;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡlist<73>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
|
std::list<double>::size_type list_size = list_values.size();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>أ<EFBFBD>ȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
|
if (list_size >= 2) {
|
|
|
|
|
|
// ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::list<double>::const_iterator it_first = list_values.begin();
|
|
|
|
|
|
// ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵڶ<CAB5><DAB6><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
std::list<double>::const_iterator it_second = it_first;
|
|
|
|
|
|
++it_second; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
|
|
|
|
|
|
aggCydeMin = *it_second - *it_first;
|
|
|
|
|
|
aggCydeMin = aggCydeMin / 60;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CDeal::ResJsonCfg(char* json)
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20>ļ<EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
|
std::ifstream file(json);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
if (!file.is_open()) {
|
|
|
|
|
|
printf("can not open file:%s \n", json);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
|
std::ostringstream ss;
|
|
|
|
|
|
ss << file.rdbuf();
|
|
|
|
|
|
std::string json_string = ss.str();
|
|
|
|
|
|
|
|
|
|
|
|
//printf("%s \n", json_string.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ر<EFBFBD><D8B1>ļ<EFBFBD>
|
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
|
|
|
|
cJSON* root = cJSON_Parse(json_string.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
if (root == NULL) {
|
|
|
|
|
|
printf("Error before: [%s]\n", cJSON_GetErrorPtr());
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>JSON<4F><4E><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
int count = cJSON_GetArraySize(root);
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
|
|
cJSON* item = cJSON_GetArrayItem(root, i);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ"table"<22>ֶ<EFBFBD>
|
|
|
|
|
|
const char* table = cJSON_GetObjectItemCaseSensitive(item, "table")->valuestring;
|
|
|
|
|
|
CTable* ctable = new CTable(table);
|
|
|
|
|
|
DataTableList.push_back(ctable);
|
|
|
|
|
|
//printf("Table: %s\n", ctable->TableName.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>"cfg"<22>ֶ<EFBFBD>
|
|
|
|
|
|
cJSON* cfg = cJSON_GetObjectItemCaseSensitive(item, "cfg");
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>"TELEMETRYTYPE"<22><><EFBFBD><EFBFBD>
|
|
|
|
|
|
cJSON* telemetry_types = cJSON_GetObjectItemCaseSensitive(cfg, "TELEMETRYTYPE");
|
|
|
|
|
|
int telemetry_count = cJSON_GetArraySize(telemetry_types);
|
|
|
|
|
|
for (int i = 0; i < telemetry_count; i++) {
|
|
|
|
|
|
cJSON* telemetry = cJSON_GetArrayItem(telemetry_types, i);
|
|
|
|
|
|
const char* seq = cJSON_GetObjectItemCaseSensitive(telemetry, "seq")->valuestring;
|
|
|
|
|
|
const char* key_name = cJSON_GetObjectItemCaseSensitive(telemetry, "KeyName")->valuestring;
|
|
|
|
|
|
const char* json_name = cJSON_GetObjectItemCaseSensitive(telemetry, "JsonName")->valuestring;
|
|
|
|
|
|
CSeq* cseq = new CSeq(seq, key_name, json_name);
|
|
|
|
|
|
ctable->DateSeqList.push_back(cseq);
|
|
|
|
|
|
//printf(" Telemetry: Seq=%s, KeyName=%s\n", seq, key_name);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>"Item"<22><><EFBFBD>飨<EFBFBD><E9A3A8><EFBFBD>Ƶش<C6B5><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<D6B6>
|
|
|
|
|
|
cJSON* items = cJSON_GetObjectItemCaseSensitive(cfg, "Item");
|
|
|
|
|
|
int item_count = cJSON_GetArraySize(items);
|
|
|
|
|
|
for (int i = 0; i < item_count; i++) {
|
|
|
|
|
|
cJSON* item = cJSON_GetArrayItem(items, i);
|
|
|
|
|
|
const char* key_name = cJSON_GetObjectItemCaseSensitive(item, "KeyName")->valuestring;
|
|
|
|
|
|
const char* data_name = cJSON_GetObjectItemCaseSensitive(item, "DataName")->valuestring; //const char* data_name = "V HRMS A[%2,25%]"
|
|
|
|
|
|
const char* type = cJSON_GetObjectItemCaseSensitive(item, "Type")->valuestring;
|
|
|
|
|
|
std::string str_key_name(key_name); // <20><>const char*ת<><D7AA>Ϊstd::string
|
|
|
|
|
|
std::string str_data_name(data_name); // <20><>const char*ת<><D7AA>Ϊstd::string
|
|
|
|
|
|
size_t pos;
|
|
|
|
|
|
while ((pos = str_data_name.find('*')) != std::string::npos) {
|
|
|
|
|
|
str_data_name.replace(pos, 1, seq);
|
|
|
|
|
|
}
|
|
|
|
|
|
int start = 0, end = 0;
|
2026-04-29 13:35:49 +08:00
|
|
|
|
if (ExtractNumbersBetweenPercent(str_data_name, start, end))
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
//printf(" Item: start=%d, end=%d\n", start,end);
|
|
|
|
|
|
for (int i = start; i <= end; i++) {
|
|
|
|
|
|
std::string str_key_name_temp = str_key_name;
|
|
|
|
|
|
std::string str_data_name_temp = str_data_name;
|
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
|
oss << "%" << start << "," << end << "%";
|
|
|
|
|
|
std::string result = oss.str();
|
|
|
|
|
|
|
|
|
|
|
|
std::ostringstream count;
|
|
|
|
|
|
count << i;
|
|
|
|
|
|
std::string count_str = count.str();
|
|
|
|
|
|
|
|
|
|
|
|
size_t pos = str_data_name.find(result);
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
str_data_name_temp.replace(pos, result.length(), count_str); // <20>滻6<E6BBBB><36><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5>Ӵ<EFBFBD>
|
|
|
|
|
|
//str_key_name_temp.replace(pos, result.length(), count_str);
|
|
|
|
|
|
}
|
|
|
|
|
|
pos = str_key_name.find(result);
|
|
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
|
|
//str_data_name_temp.replace(pos, result.length(), count_str); // <20>滻6<E6BBBB><36><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5>Ӵ<EFBFBD>
|
|
|
|
|
|
str_key_name_temp.replace(pos, result.length(), count_str);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CItem* citem = new CItem(str_key_name_temp.c_str(), str_data_name_temp.c_str(), type);
|
|
|
|
|
|
cseq->DateItemList.push_back(citem);
|
|
|
|
|
|
//printf(" Item: KeyName=%s, DataName=%s, Type=%s\n", str_key_name_temp.c_str(), str_data_name_temp.c_str(), type);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-29 13:35:49 +08:00
|
|
|
|
else
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
CItem* citem = new CItem(key_name, str_data_name.c_str(), type);
|
|
|
|
|
|
cseq->DateItemList.push_back(citem);
|
|
|
|
|
|
//printf(" Item: KeyName=%s, DataName=%s, Type=%s\n", key_name, str_data_name.c_str(), type);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD>cJSON<4F><4E><EFBFBD><EFBFBD>ռ<EFBFBD>õ<EFBFBD><C3B5>ڴ<EFBFBD>
|
|
|
|
|
|
cJSON_Delete(root);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cJSON* CDeal::cJSON_GetObjectItemCaseSensitive(cJSON* object, const char* string) {
|
|
|
|
|
|
cJSON* c = object->child;
|
|
|
|
|
|
while (c) {
|
|
|
|
|
|
if (strcmp(c->string, string) == 0) {
|
|
|
|
|
|
return c;
|
|
|
|
|
|
}
|
|
|
|
|
|
c = c->next;
|
|
|
|
|
|
}
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string CDeal::convertToDateOnly(const std::string& dateTime) {
|
|
|
|
|
|
size_t spacePos = dateTime.find(' '); // Ѱ<>ҿո<D2BF><D5B8><EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3>Էָ<D4B7><D6B8><EFBFBD><EFBFBD>ں<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
|
if (spacePos != std::string::npos) {
|
|
|
|
|
|
return dateTime.substr(0, spacePos); // <20><><EFBFBD>ش<EFBFBD><D8B4>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ո<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD>Ӵ<EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
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>
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
int CDeal::getCurrentGroup(const std::time_t& currentTime, int min) {
|
2026-04-22 10:40:19 +08:00
|
|
|
|
// <20><>time_tת<74><D7AA>Ϊtm<74>ṹ<EFBFBD><E1B9B9>
|
|
|
|
|
|
std::tm* localTime = std::localtime(¤tTime);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ<EFBFBD><D2B9>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ǰʱ<C7B0><CAB1><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
int totalMinutes = localTime->tm_hour * 60 + localTime->tm_min;
|
|
|
|
|
|
|
|
|
|
|
|
// ÿ<><C3BF><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
const int groupSize = min;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
// ʹ<><CAB9><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
// <20>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʱ<EFBFBD><CAB1>һ<EFBFBD>飨<EFBFBD><E9A3A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ŀ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>м䣩
|
|
|
|
|
|
int groupNumber = totalMinutes / groupSize;
|
|
|
|
|
|
if (totalMinutes % groupSize != 0) {
|
|
|
|
|
|
groupNumber++; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
|
}
|
|
|
|
|
|
groupNumber++;//<2F><><EFBFBD>ݴ<EFBFBD>0<EFBFBD><30>ʼ <20>±<EFBFBD><C2B1><EFBFBD>1<EFBFBD><31>ʼ <20><><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>ֵ<EFBFBD><D6B5>1
|
|
|
|
|
|
return groupNumber;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::time_t CDeal::stringToTimeT(const std::string& dateTime) {
|
|
|
|
|
|
std::tm tm{};
|
|
|
|
|
|
|
|
|
|
|
|
// strptime is not standard C++ but is available on many systems (POSIX)
|
|
|
|
|
|
strptime(dateTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm);
|
|
|
|
|
|
|
|
|
|
|
|
// Convert tm to time_t
|
|
|
|
|
|
std::time_t currentTime = std::mktime(&tm);
|
|
|
|
|
|
if (currentTime == -1) {
|
|
|
|
|
|
std::cerr << "Error converting string to time_t." << std::endl;
|
|
|
|
|
|
// Handle the error as needed
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return currentTime;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-29 13:35:49 +08:00
|
|
|
|
void CDeal::clear()
|
2026-04-22 10:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
// <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();
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>MaxData
|
|
|
|
|
|
MaxData.clear();
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>MinData
|
|
|
|
|
|
MinData.clear();
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>CP95Data
|
|
|
|
|
|
CP95Data.clear();
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ValData
|
|
|
|
|
|
ValData.clear();
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>TimeData
|
|
|
|
|
|
TimeData.clear();
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>DateData<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>value<75><65>std::string<6E><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ֶ<EFBFBD><D6B6>ͷ<EFBFBD><CDB7>ڴ棩
|
|
|
|
|
|
DateData.clear();
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>aggCydeMinList
|
|
|
|
|
|
aggCydeMinList.clear();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>DataTableList<73><74><EFBFBD>ͷ<EFBFBD>ÿ<EFBFBD><C3BF>CTable<6C><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
|
|
|
|
|
for (std::list<CTable*>::iterator it = DataTableList.begin(); it != DataTableList.end(); ++it) {
|
|
|
|
|
|
delete* it; // <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
DataTableList.clear(); // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1>е<EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::ObservationGetChannelInfoEx(long pRecordObserv, long idxChannel, PqdifChannelInfoEx* out)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (out == nullptr)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
CPQDIF_R_Observation* pobs = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (idxChannel >= 0 && idxChannel < pobs->GetCountChannels())
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string nameLocal;
|
|
|
|
|
|
UINT4 idPhaseLocal = 0;
|
|
|
|
|
|
GUID idQuantityTypeLocal{};
|
|
|
|
|
|
UINT4 idQuantityMeasuredLocal = 0;
|
|
|
|
|
|
|
|
|
|
|
|
out->countSeries = pobs->GetCountSeries(idxChannel);
|
|
|
|
|
|
|
|
|
|
|
|
status = pobs->GetChannelInfo(
|
|
|
|
|
|
idxChannel,
|
|
|
|
|
|
nameLocal,
|
|
|
|
|
|
idPhaseLocal,
|
|
|
|
|
|
idQuantityTypeLocal,
|
|
|
|
|
|
idQuantityMeasuredLocal
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
out->name = nameLocal;
|
|
|
|
|
|
out->phaseId = static_cast<long>(idPhaseLocal);
|
|
|
|
|
|
out->quantityTypeId = idQuantityTypeLocal;
|
|
|
|
|
|
out->quantityMeasuredId = static_cast<long>(idQuantityMeasuredLocal);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CPQDIF::ObservationGetSeriesInfoEx(long pRecordObserv, long idxChannel, long idxSeries, PqdifSeriesInfoEx* out)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (out == nullptr)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
CPQDIF_R_Observation* pobs = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
pobs = ValidateObservation(pRecordObserv);
|
|
|
|
|
|
if (pobs)
|
|
|
|
|
|
{
|
|
|
|
|
|
UINT4 idQuantityUnitsLocal = 0;
|
|
|
|
|
|
GUID idQuantityCharacteristicLocal{};
|
|
|
|
|
|
GUID idValueTypeLocal{};
|
|
|
|
|
|
|
|
|
|
|
|
status = pobs->GetSeriesInfo(
|
|
|
|
|
|
idxChannel,
|
|
|
|
|
|
idxSeries,
|
|
|
|
|
|
idQuantityUnitsLocal,
|
|
|
|
|
|
idQuantityCharacteristicLocal,
|
|
|
|
|
|
idValueTypeLocal
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
out->quantityUnitsId = static_cast<long>(idQuantityUnitsLocal);
|
|
|
|
|
|
out->quantityCharacteristicId = idQuantityCharacteristicLocal;
|
|
|
|
|
|
out->valueTypeId = idValueTypeLocal;
|
|
|
|
|
|
|
|
|
|
|
|
long baseType = -1;
|
|
|
|
|
|
if (pobs->GetSeriesBaseType(idxChannel, idxSeries, baseType))
|
|
|
|
|
|
{
|
|
|
|
|
|
out->seriesBaseType = baseType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double scale = 1.0;
|
|
|
|
|
|
double offset = 0.0;
|
|
|
|
|
|
if (pobs->GetSeriesScale(idxChannel, idxSeries, scale, offset))
|
|
|
|
|
|
{
|
|
|
|
|
|
out->scale = scale;
|
|
|
|
|
|
out->offset = offset;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
{
|
|
|
|
|
|
status = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|