generated from zhangwei/Matrixai
1 line
2.8 KiB
C++
1 line
2.8 KiB
C++
#include "ToHttpSrvEngine.h"
|
|
|
|
ToHttpSrvEngine::ToHttpSrvEngine() {}
|
|
ToHttpSrvEngine::~ToHttpSrvEngine() {}
|
|
|
|
APP_ERROR ToHttpSrvEngine::Init()
|
|
{
|
|
strPort0_ = engineName_ + "_" + std::to_string(engineId_) + "_0";
|
|
|
|
this->httpServerConfig_ = Config::getins()->getHttpServerConfig();
|
|
LogInfo << "ToHttpSrvEngine Init ok";
|
|
return APP_ERR_OK;
|
|
}
|
|
|
|
APP_ERROR ToHttpSrvEngine::DeInit()
|
|
{
|
|
LogInfo << "ToHttpSrvEngine DeInit ok";
|
|
return APP_ERR_OK;
|
|
}
|
|
|
|
APP_ERROR ToHttpSrvEngine::Process()
|
|
{
|
|
int iRet = APP_ERR_OK;
|
|
|
|
while (!isStop_)
|
|
{
|
|
std::shared_ptr<void> pVoidData0 = nullptr;
|
|
inputQueMap_[strPort0_]->pop(pVoidData0);
|
|
if (nullptr == pVoidData0)
|
|
{
|
|
usleep(1000); //1ms
|
|
continue;
|
|
}
|
|
|
|
if (!this->httpServerConfig_.bIsUse)
|
|
{
|
|
usleep(1000); //1ms
|
|
continue;
|
|
}
|
|
|
|
std::shared_ptr<VTrainInfo> pTrain = std::static_pointer_cast<VTrainInfo>(pVoidData0);
|
|
|
|
int iCategory = 0;
|
|
if (pTrain->iCategory == 3)
|
|
{
|
|
iCategory = 0;
|
|
}
|
|
else if(pTrain->iCategory == 2)
|
|
{
|
|
iCategory = 1;
|
|
}
|
|
else if (pTrain->iCategory == 6)
|
|
{
|
|
iCategory = 2;
|
|
}
|
|
else if (pTrain->iCategory == 0)
|
|
{
|
|
iCategory = 3;
|
|
}
|
|
|
|
//组装post信息
|
|
Json::Value jvRequest;
|
|
jvRequest["trackName"] = pTrain->strTrackName;
|
|
jvRequest["cameraNumber"] = 0;// 摄像头编号
|
|
jvRequest["comeTime"] = pTrain->strTrainDate + " " + pTrain->strTrainTime;// 来车时间
|
|
jvRequest["direction"] = pTrain->iTDirection;// 来车方向
|
|
jvRequest["carriageOrder"] = pTrain->iCarOrder;// 车节号
|
|
jvRequest["carriageCategory"] = iCategory;// 车厢类别:0敞车,1:漏洞矿车,2:平车,3:车头
|
|
jvRequest["carriageType"] = pTrain->strTType;// 车型
|
|
jvRequest["carriageNumber"] = pTrain->strTNum;// 车厢号
|
|
jvRequest["carriageTareweight"] = pTrain->strTTareWeight;// 皮重
|
|
jvRequest["carriageLoad"] = pTrain->strTLoadWeight;// 载重
|
|
jvRequest["carriageChange"] = pTrain->strTChangeLen;// 换长
|
|
jvRequest["numImageName"] = pTrain->strTNum_image; // 车号图片
|
|
jvRequest["proImageName"] = pTrain->strTPro_image; // 属性图片
|
|
|
|
for (const auto & it : pTrain->vecContainer)
|
|
{
|
|
jvRequest["containerNumber"].append(it.strContainerNo);// 集装箱
|
|
jvRequest["containerImageName"].append(it.strImg); // 集装箱图片
|
|
}
|
|
jvRequest["isTheLast"] = pTrain->bIsTheLast ? 1 : 0;// 是否最后一节: 0:否,1:是
|
|
jvRequest["identifyTime"] = pTrain->strEndTime;//车厢切分的时间
|
|
|
|
if (!ToWeb::getins()->upWeb(jvRequest, 1))
|
|
{
|
|
|
|
}
|
|
}
|
|
return APP_ERR_OK;
|
|
}
|