void VSCDeviceList::CameraTreeUpdated() { //RemoveAllCamera(); DeviceParamMap pMap; gFactory->GetDeviceParamMap(pMap); DeviceParamMap::iterator it = pMap.begin(); for(; it!=pMap.end(); ++it) { u32 nId = (*it).first; DeviceParam pParam = (*it).second; switch (pParam.m_Conf.data.conf.nType) { case VSC_DEVICE_CAM: { AddIPCameraByGroup(pParam); break; } default: { break; } } } ui.treeWidget->topLevelItem(VSC_DEVICE_INDEX_IPC)->setExpanded(true); }
BOOL OAPIServer::ProcessGetDevice(s32 len) { #if 0 if (len == 0) { return FALSE; } char *pRecv = new char[len + 1]; s32 nRetBody = m_pSocket->Recv((void *)pRecv, len); oapi::OAPICameraListReq req; if (nRetBody == len) { autojsoncxx::ParsingResult result; if (!autojsoncxx::from_json_string(pRecv, req, result)) { std::cerr << result << '\n'; delete [] pRecv; return FALSE; } } oapi::DeviceListRsp dataList; dataList.Num = 0; DeviceParamMap pDeviceMap; DeviceOnlineMap pDeviceOnlineMap; m_pFactory.GetDeviceParamMap(pDeviceMap); m_pFactory.GetDeviceOnlineMap(pDeviceOnlineMap); DeviceParamMap::iterator it = pDeviceMap.begin(); for(; it!=pDeviceMap.end(); ++it) { oapi::Device data; OAPIConverter::Converter(((*it).second).m_Conf.data.conf, data); data.Online = pDeviceOnlineMap[(*it).first]; dataList.list.push_back(data); dataList.Num ++; } //autojsoncxx::to_json_string std::string strJson = autojsoncxx::to_pretty_json_string(dataList); s32 nJsonLen = strJson.length(); if (nJsonLen <= 0) { return FALSE; } OAPIHeader header; header.cmd = htonl(OAPI_CMD_DEVICE_LIST_RSP); header.length = htonl(nJsonLen + 1); m_pSocket->Send((void *)&header, sizeof(header)); m_pSocket->Send((void *)strJson.c_str(), nJsonLen + 1); #endif return TRUE; }
inline BOOL Factory::StartHdfsRecordAll() { Lock(); DeviceParamMap DeviceMap = m_DeviceParamMap; UnLock(); DeviceParamMap::iterator it = DeviceMap.begin(); for(; it!=DeviceMap.end(); ++it) { StartHdfsRecord((*it).second.m_Conf.data.conf.nId); } return TRUE; }
inline void Factory::run() { DeviceParamMap paramMap; /* Create the thread to update the Disk status */ while (1) { paramMap.clear(); { /* Got all the device param */ Lock(); DeviceMap::iterator it = m_DeviceMap.begin(); for(; it!=m_DeviceMap.end(); ++it) { s32 nIndex = (*it).first; DeviceParam pParam; m_DeviceMap[nIndex]->GetDeviceParam(pParam); paramMap[nIndex] = pParam; } UnLock(); } { /* Loop all the deviceparam */ DeviceParamMap::iterator it = paramMap.begin(); for(; it!=paramMap.end(); ++it) { /* Loop to check the device and update the url */ s32 nIndex = (*it).first; (*it).second.m_wipOnline = (*it).second.CheckOnline(); if ((*it).second.m_OnlineUrl == FALSE) { (*it).second.m_wipOnlineUrl = (*it).second.UpdateUrl(); } } } { /* Loop all the deviceparam result and set to device */ DeviceParamMap::iterator it = paramMap.begin(); for(; it!=paramMap.end(); ++it) { /* Loop to check the device and update the url */ s32 nIndex = (*it).first; Lock(); DeviceMap::iterator it1 = m_DeviceMap.find(nIndex), ite1 = m_DeviceMap.end(); if (it1 == ite1) { /* the id may be delete */ UnLock(); continue; } DeviceStatus bCheck = m_DeviceMap[nIndex]->CheckDevice( (*it).second.m_strUrl, (*it).second.m_strUrlSubStream, (*it).second.m_bHasSubStream, (*it).second.m_wipOnline, (*it).second.m_wipOnlineUrl); FactoryDeviceChangeData change; change.id = nIndex; switch (bCheck) { case DEV_OFF2ON: { change.type = FACTORY_DEVICE_ONLINE; UnLock(); CallDeviceChange(change); Lock(); break; } case DEV_ON2OFF: { change.type = FACTORY_DEVICE_OFFLINE; UnLock(); CallDeviceChange(change); Lock(); break; } default: { break; } } UnLock(); } } ve_sleep(1000 * 20); } }