|
@@ -5,6 +5,9 @@
|
|
|
|
|
|
#include "modulecomm.h"
|
|
#include "modulecomm.h"
|
|
#include "gpsimu.pb.h"
|
|
#include "gpsimu.pb.h"
|
|
|
|
+#include "licenseplate.pb.h"
|
|
|
|
+#include "startturnstile.pb.h"
|
|
|
|
+#include "turnstile.pb.h"
|
|
|
|
|
|
extern std::string gstrserverip;
|
|
extern std::string gstrserverip;
|
|
extern std::string gstrpatrolPort;
|
|
extern std::string gstrpatrolPort;
|
|
@@ -25,6 +28,10 @@ VehiclePatrolExceptionClient::VehiclePatrolExceptionClient(std::shared_ptr<Chann
|
|
|
|
|
|
ModuleFun funupdate = std::bind(&VehiclePatrolExceptionClient::ListenGPSIMUMsg,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
ModuleFun funupdate = std::bind(&VehiclePatrolExceptionClient::ListenGPSIMUMsg,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
shmGPSIMU.mpa = iv::modulecomm::RegisterRecvPlus(shmGPSIMU.mstrmsgname,funupdate);
|
|
shmGPSIMU.mpa = iv::modulecomm::RegisterRecvPlus(shmGPSIMU.mstrmsgname,funupdate);
|
|
|
|
+ funupdate = std::bind(&VehiclePatrolExceptionClient::ListenTurnstileMsg,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
|
+ shmTurnstile.mpa = iv::modulecomm::RegisterRecvPlus(shmTurnstile.mstrmsgname,funupdate);
|
|
|
|
+
|
|
|
|
+ shmStartTurnstile.mpa = iv::modulecomm::RegisterSend(shmStartTurnstile.mstrmsgname,shmStartTurnstile.mnBufferSize,shmStartTurnstile.mnBufferCount);
|
|
}
|
|
}
|
|
|
|
|
|
VehiclePatrolExceptionClient::~VehiclePatrolExceptionClient(void)
|
|
VehiclePatrolExceptionClient::~VehiclePatrolExceptionClient(void)
|
|
@@ -75,6 +82,120 @@ void VehiclePatrolExceptionClient::dec_yaml(const char *stryamlpath)
|
|
shmGPSIMU.mnBufferCount = 1;
|
|
shmGPSIMU.mnBufferCount = 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(config["pic_front"])
|
|
|
|
+ {
|
|
|
|
+ if(config["pic_front"]["msgname"]&&config["pic_front"]["buffersize"]&&config["pic_front"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["pic_front"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmPicFront.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicFront.mnBufferSize = config["pic_front"]["buffersize"].as<int>();
|
|
|
|
+ shmPicFront.mnBufferCount = config["pic_front"]["buffercount"].as<int>();
|
|
|
|
+ std::cout << "pic_front:" << shmPicFront.mstrmsgname << "," << shmPicFront.mnBufferSize << "," << shmPicFront.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "picfront";
|
|
|
|
+ strncpy(shmPicFront.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicFront.mnBufferSize = 10000000;
|
|
|
|
+ shmPicFront.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["pic_rear"])
|
|
|
|
+ {
|
|
|
|
+ if(config["pic_rear"]["msgname"]&&config["pic_rear"]["buffersize"]&&config["pic_rear"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["pic_rear"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmPicRear.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicRear.mnBufferSize = config["pic_rear"]["buffersize"].as<int>();
|
|
|
|
+ shmPicRear.mnBufferCount = config["pic_rear"]["buffercount"].as<int>();
|
|
|
|
+ std::cout << "pic_rear:" << shmPicRear.mstrmsgname << "," << shmPicRear.mnBufferSize << "," << shmPicRear.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "picrear";
|
|
|
|
+ strncpy(shmPicRear.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicRear.mnBufferSize = 10000000;
|
|
|
|
+ shmPicRear.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["pic_left"])
|
|
|
|
+ {
|
|
|
|
+ if(config["pic_left"]["msgname"]&&config["pic_left"]["buffersize"]&&config["pic_left"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["pic_left"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmPicLeft.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicLeft.mnBufferSize = config["pic_left"]["buffersize"].as<int>();
|
|
|
|
+ shmPicLeft.mnBufferCount = config["pic_left"]["buffercount"].as<int>();
|
|
|
|
+ std::cout << "pic_left:" << shmPicLeft.mstrmsgname << "," << shmPicLeft.mnBufferSize << "," << shmPicLeft.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "picleft";
|
|
|
|
+ strncpy(shmPicLeft.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicLeft.mnBufferSize = 10000000;
|
|
|
|
+ shmPicLeft.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["pic_right"])
|
|
|
|
+ {
|
|
|
|
+ if(config["pic_right"]["msgname"]&&config["pic_right"]["buffersize"]&&config["pic_right"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["pic_right"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmPicRight.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicRight.mnBufferSize = config["pic_right"]["buffersize"].as<int>();
|
|
|
|
+ shmPicRight.mnBufferCount = config["pic_right"]["buffercount"].as<int>();
|
|
|
|
+ std::cout << "pic_right:" << shmPicRight.mstrmsgname << "," << shmPicRight.mnBufferSize << "," << shmPicRight.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "picright";
|
|
|
|
+ strncpy(shmPicRight.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicRight.mnBufferSize = 10000000;
|
|
|
|
+ shmPicRight.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["start_turnstile"])
|
|
|
|
+ {
|
|
|
|
+ if(config["start_turnstile"]["msgname"]&&config["start_turnstile"]["buffersize"]&&config["start_turnstile"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["start_turnstile"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmStartTurnstile.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmStartTurnstile.mnBufferSize = config["start_turnstile"]["buffersize"].as<int>();
|
|
|
|
+ shmStartTurnstile.mnBufferCount = config["start_turnstile"]["buffercount"].as<int>();
|
|
|
|
+ std::cout << "start_turnstile:" << shmStartTurnstile.mstrmsgname << "," << shmStartTurnstile.mnBufferSize << "," << shmStartTurnstile.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "startturnstile";
|
|
|
|
+ strncpy(shmStartTurnstile.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmStartTurnstile.mnBufferSize = 10000;
|
|
|
|
+ shmStartTurnstile.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["turnstile"])
|
|
|
|
+ {
|
|
|
|
+ if(config["turnstile"]["msgname"]&&config["turnstile"]["buffersize"]&&config["turnstile"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["turnstile"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmTurnstile.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmTurnstile.mnBufferSize = config["turnstile"]["buffersize"].as<int>();
|
|
|
|
+ shmTurnstile.mnBufferCount = config["turnstile"]["buffercount"].as<int>();
|
|
|
|
+ std::cout << "turnstile:" << shmTurnstile.mstrmsgname << "," << shmTurnstile.mnBufferSize << "," << shmTurnstile.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "turnstile";
|
|
|
|
+ strncpy(shmTurnstile.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmTurnstile.mnBufferSize = 10000000;
|
|
|
|
+ shmTurnstile.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -87,14 +208,45 @@ void VehiclePatrolExceptionClient::ListenGPSIMUMsg(const char * strdata,const un
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- gMutex_GPSIMU.lock();
|
|
|
|
|
|
+ double speed = sqrt(xdata.ve()*xdata.ve() + xdata.vn()*xdata.vn() + xdata.vd()*xdata.vd());
|
|
|
|
+
|
|
|
|
+ mutex_GPSIMU.lock();
|
|
currentPosition.set_latitude(xdata.lat());
|
|
currentPosition.set_latitude(xdata.lat());
|
|
currentPosition.set_longitude(xdata.lon());
|
|
currentPosition.set_longitude(xdata.lon());
|
|
currentPosition.set_height(xdata.height());
|
|
currentPosition.set_height(xdata.height());
|
|
- gMutex_GPSIMU.unlock();
|
|
|
|
|
|
+ currentSpeed = speed;
|
|
|
|
+ mutex_GPSIMU.unlock();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void VehiclePatrolExceptionClient::ListenTurnstileMsg(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname) // need a lock
|
|
|
|
+{
|
|
|
|
+ iv::vision::turnstile xdata;
|
|
|
|
+ if(!xdata.ParseFromArray(strdata,nSize))
|
|
|
|
+ {
|
|
|
|
+ std::cout<<" ListenTurnstileMsg parese error."<<std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(statusTSGM == 1)
|
|
|
|
+ {
|
|
|
|
+ //set TSGM resul
|
|
|
|
+ isTSGM = true;
|
|
|
|
+ if(xdata.state() == false)
|
|
|
|
+ gateStatus = 1; //0 no gate 1 gate close 2 gate open
|
|
|
|
+ else
|
|
|
|
+ gateStatus = 2;
|
|
|
|
+ gateImage.clear();
|
|
|
|
+ gateImage.append(xdata.pic().picdata().data(),xdata.pic().picdata().size());
|
|
|
|
+ gateTime = QDateTime::currentMSecsSinceEpoch(); //time when get gateImage
|
|
|
|
+ mutex_GPSIMU.lock();
|
|
|
|
+ gatePosition.CopyFrom(currentPosition); //positon when get gateImage
|
|
|
|
+ mutex_GPSIMU.unlock();
|
|
|
|
+
|
|
|
|
+ timerTSGM.restart();
|
|
|
|
+ statusTSGM = 2;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
std::string VehiclePatrolExceptionClient::uploadVehiclePatrolInfo(void)
|
|
std::string VehiclePatrolExceptionClient::uploadVehiclePatrolInfo(void)
|
|
{
|
|
{
|
|
@@ -212,10 +364,101 @@ void VehiclePatrolExceptionClient::run()
|
|
xTime.start();
|
|
xTime.start();
|
|
int lastTime = xTime.elapsed();
|
|
int lastTime = xTime.elapsed();
|
|
uint64_t interval = std::atoi(gstrpatrolInterval.c_str());
|
|
uint64_t interval = std::atoi(gstrpatrolInterval.c_str());
|
|
|
|
+ //set isNeedTSGM
|
|
|
|
+ //set gateDestination
|
|
|
|
+ timerTSGM.start();
|
|
while (!QThread::isInterruptionRequested())
|
|
while (!QThread::isInterruptionRequested())
|
|
{
|
|
{
|
|
if(abs(xTime.elapsed() - lastTime)>=interval)
|
|
if(abs(xTime.elapsed() - lastTime)>=interval)
|
|
{
|
|
{
|
|
|
|
+ // do something
|
|
|
|
+ mutex_GPSIMU.lock();
|
|
|
|
+ org::jeecg::defsPatrol::grpc::GPSPoint tempPosition;
|
|
|
|
+ tempPosition.CopyFrom(currentPosition);
|
|
|
|
+ double tempSpeed = currentSpeed;
|
|
|
|
+ mutex_GPSIMU.unlock();
|
|
|
|
+
|
|
|
|
+ if(fabs(tempPosition.latitude()-gateDestination.latitude()) < 0.0001 && fabs(tempPosition.longitude()-gateDestination.longitude()) < 0.0001)
|
|
|
|
+ {
|
|
|
|
+ if(tempSpeed < 0.1 && statusTSGM == 0 && isNeedTSGM == true)
|
|
|
|
+ {
|
|
|
|
+ iv::vision::startturnstile xmsg;
|
|
|
|
+
|
|
|
|
+ xmsg.set_time(QDateTime::currentMSecsSinceEpoch());
|
|
|
|
+ xmsg.set_cameraname(shmPicLeft.mstrmsgname);
|
|
|
|
+ xmsg.set_start(true);
|
|
|
|
+
|
|
|
|
+ int ndatasize = xmsg.ByteSize();
|
|
|
|
+ char * str = new char[ndatasize];
|
|
|
|
+ std::shared_ptr<char> pstr;pstr.reset(str);
|
|
|
|
+ if(!xmsg.SerializeToArray(str,ndatasize))
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"StartTurnstile serialize error."<<std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ iv::modulecomm::ModuleSendMsg(shmStartTurnstile.mpa,str,ndatasize);
|
|
|
|
+ statusTSGM = 1;
|
|
|
|
+ timerTSGM.restart();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(statusTSGM == 1 && timerTSGM.elapsed() > 60000)
|
|
|
|
+ {
|
|
|
|
+ //timeout
|
|
|
|
+ iv::vision::startturnstile xmsg;
|
|
|
|
+
|
|
|
|
+ xmsg.set_time(QDateTime::currentMSecsSinceEpoch());
|
|
|
|
+ xmsg.set_cameraname(shmPicLeft.mstrmsgname);
|
|
|
|
+ xmsg.set_start(false);
|
|
|
|
+
|
|
|
|
+ int ndatasize = xmsg.ByteSize();
|
|
|
|
+ char * str = new char[ndatasize];
|
|
|
|
+ std::shared_ptr<char> pstr;pstr.reset(str);
|
|
|
|
+ if(!xmsg.SerializeToArray(str,ndatasize))
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"StartTurnstile serialize error."<<std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ iv::modulecomm::ModuleSendMsg(shmStartTurnstile.mpa,str,ndatasize);
|
|
|
|
+
|
|
|
|
+ isTSGM = false;
|
|
|
|
+ gateStatus = 0;
|
|
|
|
+ gateImage.clear();
|
|
|
|
+ gateTime = QDateTime::currentMSecsSinceEpoch();
|
|
|
|
+ mutex_GPSIMU.lock();
|
|
|
|
+ gatePosition.CopyFrom(currentPosition);
|
|
|
|
+ mutex_GPSIMU.unlock();
|
|
|
|
+
|
|
|
|
+ timerTSGM.restart();
|
|
|
|
+ statusTSGM = 3;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(statusTSGM == 2 || statusTSGM == 3)
|
|
|
|
+ {
|
|
|
|
+ if(fabs(tempPosition.latitude()-gateDestination.latitude()) > 0.0001 && fabs(tempPosition.longitude()-gateDestination.longitude()) > 0.0001)
|
|
|
|
+ {
|
|
|
|
+ iv::vision::startturnstile xmsg;
|
|
|
|
+
|
|
|
|
+ xmsg.set_time(QDateTime::currentMSecsSinceEpoch());
|
|
|
|
+ xmsg.set_cameraname(shmPicLeft.mstrmsgname);
|
|
|
|
+ xmsg.set_start(false);
|
|
|
|
+
|
|
|
|
+ int ndatasize = xmsg.ByteSize();
|
|
|
|
+ char * str = new char[ndatasize];
|
|
|
|
+ std::shared_ptr<char> pstr;pstr.reset(str);
|
|
|
|
+ if(!xmsg.SerializeToArray(str,ndatasize))
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"StartTurnstile serialize error."<<std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ iv::modulecomm::ModuleSendMsg(shmStartTurnstile.mpa,str,ndatasize);
|
|
|
|
+
|
|
|
|
+ timerTSGM.restart();
|
|
|
|
+ statusTSGM = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
updatePatrolData();
|
|
updatePatrolData();
|
|
std::string reply = uploadVehiclePatrolInfo();
|
|
std::string reply = uploadVehiclePatrolInfo();
|
|
std::cout<< reply <<std::endl;
|
|
std::cout<< reply <<std::endl;
|