int vzsdk::VzRecognition::GetImage(int image_id, char* image_data, int& image_size) { Json::Value req_json; commandanalysis::GeneratGetImageByIdCmd(image_id, req_json); Message::Ptr _msg = SyncProcessReqTask(req_json); if (!_msg || _msg->phandler == NULL) { return REQ_FAILED; } //解析图片 ResponseData *response = static_cast<ResponseData *>(_msg->pdata.get()); Json::Value result = response->res_json(); RECORD_RESPONSE responese; commandanalysis::ParseRecordResponse(result, &responese); if (responese.id != image_id) return REQ_FAILED; int len = strlen(response->res_data().c_str()); const char* res_data = response->res_data().c_str(); const char* get_image_data = res_data + len + 1; image_size = responese.size; memcpy(image_data, get_image_data, responese.size); return REQ_SUCCEED; }
bool ReqTask::HandleResponse(Message *msg) { ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); const std::string res_cmd = response->res_json()[JSON_REQ_CMD].asString(); if(res_cmd == req_cmd_) { task_thread_->Post(this, task_id_, msg->pdata); return true; } return false; }
int vzsdk::VzRecognition::GetMaxRecordID(){ Json::Value req_json; commandanalysis::GeneraGetMaxRecordID(req_json); Message::Ptr _msg = SyncProcessReqTask(req_json); if (!_msg || _msg->phandler == NULL) { return REQ_FAILED; } ResponseData *response = static_cast<ResponseData *>(_msg->pdata.get()); Json::Value result = response->res_json(); MAX_REC_RESPONSE max_rec; commandanalysis::ParseMaxRecResponse(result, max_rec); return max_rec.max_id; }
bool PushManagerTask::HandleResponse(Message *msg) { if (task_thread_ == NULL) { return false; } CritScope cs(&crit_); ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); const std::string res_cmd = response->res_json()[JSON_REQ_CMD].asString(); PushHandleKeys::iterator iter = push_handle_keys_.find(res_cmd); if(iter != push_handle_keys_.end()) { task_thread_->Post(this, task_id_, msg->pdata); return true; } return false; }
bool ReqRecordTask::HandleResponse(Message *msg) { if (task_thread_ == NULL) { return false; } //»ñÈ¡¼Ç¼ ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); const std::string res_cmd = response->res_json()[JSON_REQ_CMD].asString(); if (res_cmd == "ivs_result" && req_cmd_ == "get_record") { task_thread_->Post(this, task_id_, msg->pdata); return true; } return false; }
void WebServerInstance::sendResponse() { WebPage page; ResponseData response; page.setTitle("Das ist ein Titel"); page.setContents("<h1>test</h1><p>test test test</p>"); page.build(); response.setContentType("text/html"); response.setContentLength(page.length()); //QByteArray array; //array.append(text); //m_socket->write(array); m_socket->write(response.data().toLatin1()); m_socket->write("\r\n"); // OK? m_socket->write(page.source().toLatin1()); m_socket->waitForBytesWritten(); m_socket->flush(); }
int VzIODev::SetOfflineCheck() { Json::Value req_json; commandanalysis::GeneratOfflineCheckCmd(2, req_json); Message::Ptr msg = SyncProcessReqTask(req_json); if (!msg || msg->phandler == NULL) { return REQ_FAILED; } int ret = REQ_FAILED; ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); if (response != NULL) { Json::Value res_value = response->res_json(); OFFLINE_RESPONSE offline = { 0 }; commandanalysis::ParseOfflineResponse(res_value, &offline); if (strcmp(offline.response, "ok") == 0) { ret = REQ_SUCCEED; } } return ret; }
int VzIODev::GetGPIOValue(int gpioIn, int *value) { int ret = REQ_FAILED; Json::Value req_json; commandanalysis::GeneratGetGPIOValueCmd(gpioIn, req_json); Message::Ptr msg = SyncProcessReqTask(req_json); if (!msg || msg->phandler == NULL) { return REQ_FAILED; } ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); if (response != NULL) { Json::Value res_value = response->res_json(); GPIO_RESPONSE gpio = { 0 }; commandanalysis::ParseGPIOResponse(res_value, &gpio); *value = gpio.val; ret = REQ_SUCCEED; } return ret; }
int vzsdk::VzRecognition::GetRecord(int record_id, bool need_image , TH_PlateResult& plate_result , int& full_size, void* fullimage , int& clip_size, void* clipimage) { Json::Value req_json; int session_id = sdk_service_->GetSessionID(); commandanalysis::GeneratGetRecordByIdCmd(record_id, need_image, req_json); std::string result; if (session_id == 0) { LOG(LS_WARNING) << "The session is is zero, is not a right session"; return SESSION_ID_INVALUE; } Task::Ptr req_task(new ReqRecordTask(sdk_service_->GetQueueLayer().get(), DEFAULT_TIMEOUT, session_id, req_json)); Message::Ptr msg = req_task->SyncProcessTask(); if (!msg || msg->phandler == NULL) { return REQ_FAILED; } //解析车牌 ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); Json::Value value = response->res_json(); commandanalysis::ParsePlateResultResponse(value, plate_result, full_size, clip_size); int len = strlen(response->res_data().c_str()); if (fullimage != NULL) memcpy(fullimage, response->res_data().c_str() + len + 1, full_size); if (clipimage != NULL) memcpy(clipimage, response->res_data().c_str() + len + full_size + 1, clip_size); return REQ_SUCCEED; }
inline void COMap::CallResponse(long id[], long nType[], CrestObjects *pObjects) { int nCollisionType=-1; vertex velocity[2]; tCRNode* pCRNodes, *pCRNodes1; CrestInstrumentInfo *pIInfo;//tInstrumentLink* pInstrument1; ResponseData *pResponse; long nWhichI, nWhichR, nWhichT, nWhichN, nWhichS; bool bMedial; vertex loc; long i; //vertex adjust0, adjust1, loc; // vertex v[3][2]; // float dx[3][3]; CalcNormal(m_tp[0].pos, m_tp[0].pos+1, m_tp[0].pos+2, &(m_tp[0].n)); CalcNormal(m_tp[1].pos, m_tp[1].pos+1, m_tp[1].pos+2, &(m_tp[1].n)); // Instrument involved if(nType[0] == INSTRUMENT_TYPE || nType[1] == INSTRUMENT_TYPE) { if(nType[0] == INSTRUMENT_TYPE && nType[1] == INSTRUMENT_TYPE) { nCollisionType=I2I; } else if(nType[0] == INSTRUMENT_TYPE && nType[1] == TISSUE_TYPE) { nWhichI=0; nWhichT=1; nCollisionType=I2T; } else if(nType[0] == TISSUE_TYPE && nType[1] == INSTRUMENT_TYPE) { nWhichI=1; nWhichT=0; nCollisionType=I2T; } }// Tissue to tissue else if(nType[0] == TISSUE_TYPE && nType[1] == TISSUE_TYPE) { nCollisionType=T2T; } switch(nCollisionType) { case I2T: { if(INSTRUMENT_TYPE != pObjects->GetObjectInfo(id[nWhichI])->nObjectType) return; else pIInfo = &(pObjects->GetObjectInfo(id[nWhichI])->IInfo); if(TISSUE_TYPE != pObjects->GetObjectInfo(id[nWhichT])->nObjectType) return; else pResponse = &(pObjects->GetObjectInfo(id[nWhichT])->Response); //if( NULL == (pIInfo = pObjects->GetObjectInfo(id[nWhichI])->pIInfo) ) return; //if( NULL == (pResponse = pObjects->GetObjectInfo(id[nWhichT])->pResponse) ) return; //pInstrument1->geoModel.GetDisplacement(m_tp[nWhichI].id[0], m_tp[nWhichI].v); //pInstrument1->geoModel.GetDisplacement(m_tp[nWhichI].id[1], m_tp[nWhichI].v+1); //pInstrument1->geoModel.GetDisplacement(m_tp[nWhichI].id[2], m_tp[nWhichI].v+2); // //m_tp[nWhichI].v[0]=pInstrument1->velocity; // //m_tp[nWhichI].v[1]=pInstrument1->velocity; // //m_tp[nWhichI].v[2]=pInstrument1->velocity; //m_tp[nWhichT].v[0]=(pD[nWhichT]->m_CurrentSys)[m_tp[nWhichT].id[0]].v; //m_tp[nWhichT].v[1]=(pD[nWhichT]->m_CurrentSys)[m_tp[nWhichT].id[1]].v; //m_tp[nWhichT].v[2]=(pD[nWhichT]->m_CurrentSys)[m_tp[nWhichT].id[2]].v; bMedial = pIInfo->IsMedial(m_tp[nWhichI].id[0]); bMedial |= pIInfo->IsMedial(m_tp[nWhichI].id[1]); bMedial |= pIInfo->IsMedial(m_tp[nWhichI].id[2]); if(bMedial && pIInfo->GetStatus()==1) { long &nCount=pResponse->nCPos[id[nWhichI]]; pCRNodes=pResponse->CPos[id[nWhichI]]; for(i=0;i<3;i++) { if( nCount< CNODES_MAX && pResponse->IsNewCRNode(m_tp[nWhichT].id[i], FALSE)) { //VectorDifference(m_tp[nWhichT].pos+i, m_tp[nWhichI].pos+i, &(pCRNodes[nCount].vector)); pCRNodes[nCount].vector=*(m_tp[nWhichI].pos+i); pCRNodes[nCount].id=m_tp[nWhichT].id[i]; pCRNodes[nCount].id_instrument=id[nWhichI]; pCRNodes[nCount++].id_iNode=m_tp[nWhichI].id[i]; } } } else{ long &nCount=pResponse->nRVelocity; pCRNodes=pResponse->RVelocity; long &nCount1=pResponse->nPPos[id[nWhichI]]; pCRNodes1=pResponse->PPos[id[nWhichI]]; float fLength; vertex vn, vt, v; for(i=0;i<3;i++) { if(nCount1 < RNODES_MAX && pResponse->IsNewCRNode(m_tp[nWhichT].id[i], pCRNodes1, nCount1)) { pCRNodes1[nCount1].id_instrument=id[nWhichI]; //pCRNodes1[nCount1].id_iNode=m_tp[nWhichI].id[i]; //pCRNodes1[nCount1].vector=m_tp[nWhichI].pos[i]; pCRNodes1[nCount1++].id=m_tp[nWhichT].id[i]; } } } //CColliResp::CollisionResponse(I2T, nWhichI, nWhichR, nWhichT); break; } //case T2T: //{ // if(!CR_TT) break; // float fLength; // vertex vn, vt, v, vs; // vertex* pvs; // nWhichN=0; // nWhichS=1; // // long &nCount0=pD[nWhichN]->m_response_b.nRVelocity; // pCRNodes=pD[nWhichN]->m_response_b.RVelocity; // pvs=m_tp[nWhichS].v; // vs=*(pvs); // VectorSum(&vs,pvs+1,&vs); // VectorSum(&vs,pvs+2,&vs); // ScaleVector(&vs,1.0/3.0f,&vs); // // for(i=0;i<3;i++) // { // if(nCount0 < RNODES_MAX && IsNewCRNode(m_tp[nWhichN].id[i], TRUE, pD[nWhichN])) // { // v=m_tp[nWhichN].v[i]; // vn=m_tp[nWhichS].n; // VectorDifference(&v, &vs, &loc); // fLength=DotProduct(&loc, &vn); // if(0.0f<=fLength) continue; // ScaleVector(&vn, fLength, &vn); // VectorDifference(&v, &vn, &vt); // ScaleVector(&vn, 0.1f, &vn); // VectorDifference(&vt, &vn, &loc); //VectorDifference(&loc, &v, &loc); // //ScaleVector(&vt, 0.6f, &loc); // ScaleVector(&loc, 0.1f, &loc); //0.1f // pCRNodes[nCount0].vector=loc; //VectorSum(&(pCRNodes[nCount].vector),&loc,&(pCRNodes[nCount].vector)); // pCRNodes[nCount0++].id=m_tp[nWhichN].id[i]; // } // } // nWhichN=1; // nWhichS=0; // // long &nCount1=pD[nWhichN]->m_response_b.nRVelocity; // pCRNodes=pD[nWhichN]->m_response_b.RVelocity; // pvs=m_tp[nWhichS].v; // vs=*(pvs); // VectorSum(&vs,pvs+1,&vs); // VectorSum(&vs,pvs+2,&vs); // ScaleVector(&vs,1.0/3.0f,&vs); // // for(i=0;i<3;i++) // { // if(nCount1 < RNODES_MAX && IsNewCRNode(m_tp[nWhichN].id[i], TRUE, pD[nWhichN])) // { // v=m_tp[nWhichN].v[i]; // vn=m_tp[nWhichS].n; // VectorDifference(&v, &vs, &loc); // fLength=DotProduct(&loc, &vn); // if(0.0f<=fLength) continue; // ScaleVector(&vn, fLength, &vn); // VectorDifference(&v, &vn, &vt); // ScaleVector(&vn, 0.5f, &vn); // VectorDifference(&vt, &vn, &loc); //VectorDifference(&loc, &v, &loc); // //ScaleVector(&vt, 0.6f, &loc); // ScaleVector(&loc, 0.1f, &loc); //0.1f // pCRNodes[nCount1].vector=loc; //VectorSum(&(pCRNodes[nCount].vector),&loc,&(pCRNodes[nCount].vector)); // pCRNodes[nCount1++].id=m_tp[nWhichN].id[i]; // } // } // break; //} } }