void MsgPacket::createUid() { std::lock_guard<std::mutex> lock(uidmutex); uint32_t uid = globalUID++; setUID(uid); clear(); m_freezed = false; }
Response::Response(std::string curlData) { std::istringstream data(curlData); std::string iLine; std::string statusStr; headers.clear(); status = 0; // Grab Headers First while(getline(data, iLine)) { if(iLine == "\r\n\r\n") break; headers.push_back(iLine); } // parse content while(getline(data, iLine)) content += iLine; for (std::vector<std::string>::iterator it = headers.begin(); it != headers.end(); ++it) if((*it).find("HTTP/1.1") != std::string::npos) { statusStr = (*it).substr(9, 3); status = atoi(statusStr.c_str()); break; } if(!status) { std::cout << "Error parsing status code!\n"; exit(1); } setUID(); }
CClientNet::CClientNet() : m_seq(1) , m_agent(NULL) , m_timeDiff(0) , m_replay(NULL) { QTime time = QTime::currentTime(); qsrand(time.msec() + time.second() * 1000); m_Connect = dynamic_cast<CReliableConnection*> (pConnect); m_ds = DataSingleton::getInstance(); setUID(qrand()); }
void set_uid(int val) { setUID(val); // NOTIFY MY ID TO SLAVES sendData(std::make_shared<protocol::Invoke>("set_master_uid", val)); // NOTIFY MY UID TO MASTER // Call Master::SlaveSystem::construct() auto xml = toXML(); { xml->clear(); xml->setTag("system"); } getParent()->sendData(std::make_shared<protocol::Invoke>("construct", xml)); };
void MsgPacket::Init(uint16_t msgid, uint16_t type, uint32_t uid) { m_packet = (uint8_t*)malloc(m_size); if(m_packet == NULL) { return; } std::lock_guard<std::mutex> lock(uidmutex); if(uid <= 0) { uid = globalUID++; } else if(uid > globalUID) { globalUID = uid + 1; } memset(m_packet, 0, HeaderLength); writePacket<uint32_t>(SyncPos, htobe32(0xAAAAAA)); // sync setUID(uid); // packet serial number setMsgID(msgid); // message id setType(type); // message type }
void OrbSysGpsC_30::loadData(const PackedNavBits& msg) throw(InvalidParameter) { setUID(msg); if (UID!=30) { char errStr[80]; std::string msgString("Expected GPS CNAV MT 30. Found unique ID "); msgString += StringUtils::asString(UID); InvalidParameter exc(msgString); GPSTK_THROW(exc); } obsID = msg.getobsID(); satID = msg.getsatSys(); beginValid = msg.getTransmitTime(); // Message Type 30 data unsigned long testAvail = 4096; // Pattern in message of 0x1000 // if data quantity not available unsigned long avail = msg.asUnsignedLong(127,13,1); avail_Tgd = false; if (avail!=testAvail) { avail_Tgd = true; Tgd = msg.asSignedDouble(127, 13, -35); } avail = msg.asUnsignedLong(140,13,1); avail_L1CA = false; if (avail!=testAvail) { avail_L1CA = true; ISC_L1CA = msg.asSignedDouble(140, 13, -35); } avail = msg.asUnsignedLong(153,13,1); avail_L2C = false; if (avail!=testAvail) { avail_L2C = true; ISC_L2C = msg.asSignedDouble(153, 13, -35); } avail = msg.asUnsignedLong(166,13,1); avail_L5I5 = false; if (avail!=testAvail) { avail_L5I5 = true; ISC_L5I5 = msg.asSignedDouble(166, 13, -35); } avail = msg.asUnsignedLong(179,13,1); avail_L5Q5 = false; if (avail!=testAvail) { avail_L5Q5 = true; ISC_L5Q5 = msg.asSignedDouble(179, 13, -35); } alpha[0] = msg.asSignedDouble(192, 8, -30); alpha[1] = msg.asSignedDouble(200, 8, -27); alpha[2] = msg.asSignedDouble(208, 8, -24); alpha[3] = msg.asSignedDouble(216, 8, -24); beta[0] = msg.asSignedDouble(224, 8, 11); beta[1] = msg.asSignedDouble(232, 8, 14); beta[2] = msg.asSignedDouble(240, 8, 16); beta[3] = msg.asSignedDouble(248, 8, 16); // Need to convert from sec/semi-circle to sec/rad double conversion = 1.0 / PI; alpha[1] *= conversion; beta[1] *= conversion; alpha[2] *= conversion * conversion; beta[2] *= conversion * conversion; alpha[3] *= conversion * conversion * conversion; beta[3] *= conversion * conversion * conversion; dataLoadedFlag = true; } // end of loadData()