bool CUndoObjectInterface::setUuid(const std::string & uuid) { xg::Guid UUID(uuid); if (!UUID.isValid()) { return false; } return setUuid(UUID); }
UUID ASIOSocketWrapper::massageUUID(const UUID&uuid) { unsigned char data[UUID::static_size]; for (int i=0; i<UUID::static_size; ++i) { unsigned char tmp=*(uuid.getArray().begin()+i); tmp&=127; if (tmp==0) tmp=1; data[i]=tmp; } return UUID(data,UUID::static_size); }
UUID CreateLocalUUID() //-------------------- { #if _WIN32_WINNT >= 0x0501 // Available since Win2000, but we check for WinXP in order to not use this // function in Win32old builds. It is not available on some non-fully // patched Win98SE installs in the wild. UUID uuid = UUID(); RPC_STATUS status = ::UuidCreateSequential(&uuid); if(status != RPC_S_OK && status != RPC_S_UUID_LOCAL_ONLY) { return UUID(); } return uuid; #else // Fallback to ::UuidCreate is safe as ::UuidCreateSequential is only a // tiny performance optimization. return CreateUUID(); #endif }
void IndoorLocalizationService::addRssiCharacteristic() { _rssiCharac = new Characteristic<int8_t>(); addCharacteristic(_rssiCharac); _rssiCharac->setUUID(UUID(getUUID(), RSSI_UUID)); //! there is no BLE_UUID for rssi level(?) _rssiCharac->setName(BLE_CHAR_RSSI); _rssiCharac->setDefaultValue(1); _rssiCharac->setNotifies(true); #ifdef PWM_ON_RSSI _averageRssi = -90; // Start with something.. #endif }
void IndoorLocalizationService::addScanControlCharacteristic() { _scanControlCharac = new Characteristic<uint8_t>(); addCharacteristic(_scanControlCharac); _scanControlCharac->setUUID(UUID(getUUID(), SCAN_CONTROL_UUID)); _scanControlCharac->setName(BLE_CHAR_SCAN_CONTROL); _scanControlCharac->setDefaultValue(255); _scanControlCharac->setWritable(true); _scanControlCharac->onWrite([&](const uint8_t accessLevel, const uint8_t& value, uint16_t length) -> void { CommandHandler::getInstance().handleCommand(CMD_SCAN_DEVICES, (buffer_ptr_t)&value, 1); }); }
UUID Entity::generateID() { static const char alphanum[] = "0123456789" "abcdef"; std::string s; for (int i = 0; i < 32; ++i) { int n = rand() / (RAND_MAX / (sizeof(alphanum) - 1) + 1); s += alphanum[n]; } return UUID(s); }
IndoorLocalizationService::IndoorLocalizationService() : EventListener(), _rssiCharac(NULL), _scannedDeviceListCharac(NULL), _trackedDeviceListCharac(NULL), _trackedDeviceCharac(NULL) { //#if (NORDIC_SDK_VERSION >= 11) // _appTimerData = { {0} }; // _appTimerId = &_appTimerData; //#endif EventDispatcher::getInstance().addListener(this); setUUID(UUID(INDOORLOCALISATION_UUID)); setName(BLE_SERVICE_INDOOR_LOCALIZATION); }
void BuiltinResources::generateTextures() { StringStream ss; SPtr<PixelData> blackPixelData = PixelData::create(2, 2, 1, PF_RGBA8); blackPixelData->setColorAt(Color::Black, 0, 0); blackPixelData->setColorAt(Color::Black, 0, 1); blackPixelData->setColorAt(Color::Black, 1, 0); blackPixelData->setColorAt(Color::Black, 1, 1); SPtr<Texture> blackTexture = Texture::_createPtr(blackPixelData); SPtr<PixelData> whitePixelData = PixelData::create(2, 2, 1, PF_RGBA8); whitePixelData->setColorAt(Color::White, 0, 0); whitePixelData->setColorAt(Color::White, 0, 1); whitePixelData->setColorAt(Color::White, 1, 0); whitePixelData->setColorAt(Color::White, 1, 1); SPtr<Texture> whiteTexture = Texture::_createPtr(whitePixelData); SPtr<PixelData> normalPixelData = PixelData::create(2, 2, 1, PF_RGBA8); Color encodedNormal(0.5f, 0.5f, 1.0f); normalPixelData->setColorAt(encodedNormal, 0, 0); normalPixelData->setColorAt(encodedNormal, 0, 1); normalPixelData->setColorAt(encodedNormal, 1, 0); normalPixelData->setColorAt(encodedNormal, 1, 1); SPtr<Texture> normalTexture = Texture::_createPtr(normalPixelData); // Save all textures Path outputDir = mBuiltinDataFolder + TEXTURE_FOLDER; auto saveTexture = [&](const Path& path, const SPtr<Texture>& texture, const String& uuid) { HResource textureResource = gResources()._createResourceHandle(texture, UUID(uuid)); gResources().save(textureResource, path, true); mResourceManifest->registerResource(textureResource.getUUID(), path); }; Path whitePath = outputDir + TextureWhiteFile; saveTexture(whitePath, whiteTexture, "1f7d0e3f-d81b-42ee-9d31-cb6c6fc55824"); Path blackPath = outputDir + TextureBlackFile; saveTexture(blackPath, blackTexture, "149a5c05-9570-4915-9dbd-69acf88b865b"); Path normalPath = outputDir + TextureNormalFile; saveTexture(normalPath, normalTexture, "afb29163-1ef0-4440-9cfb-c1ebb3b3d452"); }
std::ostream& ASDCP::ATMOS::operator << (std::ostream& strm, const AtmosDescriptor& ADesc) { char str_buf[40]; strm << " EditRate: " << ADesc.EditRate.Numerator << "/" << ADesc.EditRate.Denominator << std::endl; strm << " ContainerDuration: " << (unsigned) ADesc.ContainerDuration << std::endl; strm << " DataEssenceCoding: " << UL(ADesc.DataEssenceCoding).EncodeString(str_buf, 40) << std::endl; strm << " AtmosVersion: " << (unsigned) ADesc.AtmosVersion << std::endl; strm << " MaxChannelCount: " << (unsigned) ADesc.MaxChannelCount << std::endl; strm << " MaxObjectCount: " << (unsigned) ADesc.MaxObjectCount << std::endl; strm << " AtmosID: " << UUID(ADesc.AtmosID).EncodeString(str_buf, 40) << std::endl; strm << " FirstFrame: " << (unsigned) ADesc.FirstFrame << std::endl; return strm; }
bool LinuxIPCHost::OnCreateService(const std::string& service_uuid) { gatt_servers_[service_uuid] = std::unique_ptr<Server>(new Server); int gattfd; bool status = gatt_servers_[service_uuid]->Initialize( UUID(service_uuid), &gattfd); if (!status) { LOG_ERROR(LOG_TAG, "Failed to initialize bluetooth"); return false; } pfds_.resize(kPossibleFds); pfds_[kFdGatt] = {gattfd, POLLIN, 0}; return true; }
bool LinuxIPCHost::OnAddCharacteristic(const std::string& service_uuid, const std::string& characteristic_uuid, const std::string& control_uuid, const std::string& options) { std::vector<std::string> option_tokens; base::SplitString(options, '.', &option_tokens); int properties_mask = 0; int permissions_mask = 0; if (std::find(option_tokens.begin(), option_tokens.end(), "notify") != option_tokens.end()) { permissions_mask |= kPermissionRead; properties_mask |= kPropertyRead; properties_mask |= kPropertyNotify; } if (std::find(option_tokens.begin(), option_tokens.end(), "read") != option_tokens.end()) { permissions_mask |= kPermissionRead; properties_mask |= kPropertyRead; } if (std::find(option_tokens.begin(), option_tokens.end(), "write") != option_tokens.end()) { permissions_mask |= kPermissionWrite; properties_mask |= kPropertyWrite; } if (control_uuid.empty()) { gatt_servers_[service_uuid]->AddCharacteristic( UUID(characteristic_uuid), properties_mask, permissions_mask); } else { gatt_servers_[service_uuid]->AddBlob(UUID(characteristic_uuid), UUID(control_uuid), properties_mask, permissions_mask); } return true; }
void SQLiteObjectFactory::generate() { SQLiteDBPtr db = SQLite::getSingleton().open(mDBFilename); sqlite3_busy_timeout(db->db(), 1000); String value_query = "SELECT object, script_type, script_args, script_contents FROM "; value_query += "\"" TABLE_NAME "\""; int rc; char* remain; sqlite3_stmt* value_query_stmt; rc = sqlite3_prepare_v2(db->db(), value_query.c_str(), -1, &value_query_stmt, (const char**)&remain); SQLite::check_sql_error(db->db(), rc, NULL, "Error preparing value query statement"); if (rc==SQLITE_OK) { int step_rc = sqlite3_step(value_query_stmt); while(step_rc == SQLITE_ROW) { String object_str( (const char*)sqlite3_column_text(value_query_stmt, 0), sqlite3_column_bytes(value_query_stmt, 0) ); String script_type( (const char*)sqlite3_column_text(value_query_stmt, 1), sqlite3_column_bytes(value_query_stmt, 1) ); String script_args( (const char*)sqlite3_column_text(value_query_stmt, 2), sqlite3_column_bytes(value_query_stmt, 2) ); String script_contents( (const char*)sqlite3_column_text(value_query_stmt, 3), sqlite3_column_bytes(value_query_stmt, 3) ); HostedObjectPtr obj = mOH->createObject( UUID(object_str, UUID::HexString()), script_type, script_args, script_contents ); step_rc = sqlite3_step(value_query_stmt); } if (step_rc != SQLITE_DONE) { // reset the statement so it'll clean up properly rc = sqlite3_reset(value_query_stmt); SQLite::check_sql_error(db->db(), rc, NULL, "Error finalizing value query statement"); } } rc = sqlite3_finalize(value_query_stmt); SQLite::check_sql_error(db->db(), rc, NULL, "Error finalizing value query statement"); }
std::ostream& ASDCP::operator << (std::ostream& strm, const WriterInfo& Info) { char str_buf[40]; strm << " ProductUUID: " << UUID(Info.ProductUUID).EncodeHex(str_buf, 40) << std::endl; strm << " ProductVersion: " << Info.ProductVersion << std::endl; strm << " CompanyName: " << Info.CompanyName << std::endl; strm << " ProductName: " << Info.ProductName << std::endl; strm << " EncryptedEssence: " << (Info.EncryptedEssence ? "Yes" : "No") << std::endl; if ( Info.EncryptedEssence ) { strm << " HMAC: " << (Info.UsesHMAC ? "Yes" : "No") << std::endl; strm << " ContextID: " << UUID(Info.ContextID).EncodeHex(str_buf, 40) << std::endl; strm << "CryptographicKeyID: " << UUID(Info.CryptographicKeyID).EncodeHex(str_buf, 40) << std::endl; } strm << " AssetUUID: " << UUID(Info.AssetUUID).EncodeHex(str_buf, 40) << std::endl; strm << " Label Set Type: " << (Info.LabelSetType == LS_MXF_SMPTE ? "SMPTE" : (Info.LabelSetType == LS_MXF_INTEROP ? "MXF Interop" : "Unknown")) << std::endl; return strm; }
UUID UUID:: time() { static int fd = 0; if (!fd) { fd = open("/proc/sys/kernel/random/uuid", O_RDONLY); SLICK_CHECK_ERRNO(fd >= 0, "UUID.time.kernel"); } if (fd < 0) throw std::runtime_error("kernel uuid source unavailable"); char buffer[32 + 4]; slick::read(fd, buffer, sizeof(buffer)); return UUID(buffer, sizeof(buffer)); }
SpellData::SpellData(TFormValuesList &form) { mId = UUID(form["id"][0]); mName = form["name"][0]; mCastTime = atof(form["cast_time"][0].c_str()) * 1000; mCooldown = atof(form["cooldown"][0].c_str()) * 1000; mType = (SpellType) atoi(form["spell_type"][0].c_str()); mCastType = (SpellCastType) atoi(form["cast_type"][0].c_str()); mRange = atof(form["range"][0].c_str()); mRadius = atof(form["radius"][0].c_str()); mShape = (SpellShape) atoi(form["shape"][0].c_str()); int numEffects = atoi(form["num_effects"][0].c_str()); for (int i = 0; i < numEffects; i++) { SpellEffectData effect; effect.id = UUID(form["effect.id"][i]); effect.spellId = mId; effect.duration = atof(form["effect.duration"][i].c_str()); effect.school = (SpellSchool) atoi(form["effect.school"][i].c_str()); effect.effectType = (SpellEffectType) atoi(form["effect.type"][i].c_str()); mEffects.push_back(effect); } int numTriggers = atoi(form["num_triggers"][0].c_str()); for (int i = 0; i < numTriggers; i++) { SpellTriggerData trigger; trigger.id = UUID(form["trigger.id"][i]); trigger.spellId = mId; trigger.triggerSpellId = UUID(form["trigger.trigger_spell_id"][i]); trigger.chance = atof(form["trigger.chance"][i].c_str()); trigger.triggerType = (TriggerType) atoi(form["trigger.type"][i].c_str()); mTriggers.push_back(trigger); } }
UUID UUID::RandomUUID() { char uuid[UUID_STR_SIZE]; memset(uuid, 0, sizeof(uuid)); int fd = fopen("/proc/sys/kernel/random/uuid", "r"); if(fd) { fread(uuid, sizeof(uuid), sizeof(uuid), fd); fclose(fd); } Aws::String uuidStr(uuid); return UUID(uuidStr); }
///gets called when a complete 24 byte header is actually received: uses the UUID within to match up appropriate sockets void buildStream(TcpSstHeaderArray *buffer, TCPSocket *socket, std::tr1::shared_ptr<TCPStreamListener::Data> data, const boost::system::error_code &error, std::size_t bytes_transferred) { if (error || std::memcmp(buffer->begin(),TCPStream::STRING_PREFIX(),TCPStream::STRING_PREFIX_LENGTH)!=0) { SILOG(tcpsst,warning,"Connection received with incomprehensible header"); } else { boost::asio::ip::tcp::no_delay option(data->mNoDelay); socket->set_option(option); UUID context=UUID(buffer->begin()+(TCPStream::TcpSstHeaderSize-16),16); IncompleteStreamMap::iterator where=sIncompleteStreams.find(context); unsigned int numConnections=(((*buffer)[TCPStream::STRING_PREFIX_LENGTH]-'0')%10)*10+(((*buffer)[TCPStream::STRING_PREFIX_LENGTH+1]-'0')%10); if (numConnections>data->mMaxSimultaneousSockets) numConnections=data->mMaxSimultaneousSockets; if (where==sIncompleteStreams.end()) { sIncompleteStreams[context].mNumSockets=numConnections; where=sIncompleteStreams.find(context); assert(where!=sIncompleteStreams.end()); } if ((int)numConnections!=where->second.mNumSockets) { SILOG(tcpsst,warning,"Single client disagrees on number of connections to establish: "<<numConnections<<" != "<<where->second.mNumSockets); sIncompleteStreams.erase(where); } else { where->second.mSockets.push_back(socket); if (numConnections==(unsigned int)where->second.mSockets.size()) { MultiplexedSocketPtr shared_socket( MultiplexedSocket::construct<MultiplexedSocket>(&data->ios,context,where->second.mSockets,data->cb,data->mSendBufferSize)); MultiplexedSocket::sendAllProtocolHeaders(shared_socket,UUID::random()); sIncompleteStreams.erase(where); Stream::StreamID newID=Stream::StreamID(1); TCPStream * strm=new TCPStream(shared_socket,newID); TCPSetCallbacks setCallbackFunctor(&*shared_socket,strm); data->cb(strm,setCallbackFunctor); if (setCallbackFunctor.mCallbacks==NULL) { SILOG(tcpsst,error,"Client code for stream "<<newID.read()<<" did not set listener on socket"); shared_socket->closeStream(shared_socket,newID); } } else { sStaleUUIDs.push_back(context); } } } delete buffer; }
UUID UUID::RandomUUID() { auto secureRandom = Crypto::CreateSecureRandomBytesImplementation(); assert(secureRandom); unsigned char randomBytes[UUID_BINARY_SIZE]; memset(randomBytes, 0, UUID_BINARY_SIZE); secureRandom->GetBytes(randomBytes, UUID_BINARY_SIZE); //Set version bits to 0100 //https://tools.ietf.org/html/rfc4122#section-4.1.3 randomBytes[VERSION_LOCATION] = (randomBytes[VERSION_LOCATION] & VERSION_MASK) | VERSION; //set variant bits to 10 //https://tools.ietf.org/html/rfc4122#section-4.1.1 randomBytes[VARIANT_LOCATION] = (randomBytes[VARIANT_LOCATION] & VARIANT_MASK) | VARIANT; return UUID(randomBytes); }
void BeaconsFinder::scan(){ BTDevice bt; if( detector.discoverDevice(bt) ){ if(bt.distance <= range){ auto b = inRangeBeacons.begin(); auto t = detectionTimes.begin(); for( ; b != inRangeBeacons.end(); ++b, ++t){ if(equal(b->uuid, b->uuid + 16, bt.uuid)){ *t = millis(); return; } } inRangeBeacons.push_back( UUID(bt.uuid) ); detectionTimes.push_back( millis() ); } } }
void IndoorLocalizationService::addTrackedDeviceListCharacteristic() { MasterBuffer& mb = MasterBuffer::getInstance(); buffer_ptr_t buffer = NULL; uint16_t maxLength = 0; mb.getBuffer(buffer, maxLength); _trackedDeviceListCharac = new Characteristic<buffer_ptr_t>(); addCharacteristic(_trackedDeviceListCharac); _trackedDeviceListCharac->setUUID(UUID(getUUID(), TRACKED_DEVICE_LIST_UUID)); _trackedDeviceListCharac->setName(BLE_CHAR_TRACK_LIST); _trackedDeviceListCharac->setWritable(false); _trackedDeviceListCharac->setNotifies(false); _trackedDeviceListCharac->setValue(buffer); _trackedDeviceListCharac->setMaxGattValueLength(maxLength); _trackedDeviceListCharac->setValueLength(0); }
///gets called when a complete 24 byte header is actually received: uses the UUID within to match up appropriate sockets void buildStream(Array<uint8,TCPStream::TcpSstHeaderSize> *buffer, TCPSocket *socket, IOService *ioService, Stream::SubstreamCallback callback, const boost::system::error_code &error, std::size_t bytes_transferred) { if (error || std::memcmp(buffer->begin(),TCPStream::STRING_PREFIX(),TCPStream::STRING_PREFIX_LENGTH)!=0) { SILOG(tcpsst,warning,"Connection received with incomprehensible header"); }else { UUID context=UUID(buffer->begin()+(TCPStream::TcpSstHeaderSize-16),16); IncompleteStreamMap::iterator where=sIncompleteStreams.find(context); unsigned int numConnections=(((*buffer)[TCPStream::STRING_PREFIX_LENGTH]-'0')%10)*10+(((*buffer)[TCPStream::STRING_PREFIX_LENGTH+1]-'0')%10); if (numConnections>99) numConnections=99;//FIXME: some option in options if (where==sIncompleteStreams.end()){ sIncompleteStreams[context].mNumSockets=numConnections; where=sIncompleteStreams.find(context); assert(where!=sIncompleteStreams.end()); } if ((int)numConnections!=where->second.mNumSockets) { SILOG(tcpsst,warning,"Single client disagrees on number of connections to establish: "<<numConnections<<" != "<<where->second.mNumSockets); sIncompleteStreams.erase(where); }else { where->second.mSockets.push_back(socket); if (numConnections==(unsigned int)where->second.mSockets.size()) { std::tr1::shared_ptr<MultiplexedSocket> shared_socket( MultiplexedSocket::construct<MultiplexedSocket>(ioService,context,where->second.mSockets,callback)); MultiplexedSocket::sendAllProtocolHeaders(shared_socket,UUID::random()); sIncompleteStreams.erase(where); Stream::StreamID newID=Stream::StreamID(1); TCPStream * strm=new TCPStream(shared_socket,newID); TCPSetCallbacks setCallbackFunctor(&*shared_socket,strm); callback(strm,setCallbackFunctor); if (setCallbackFunctor.mCallbacks==NULL) { SILOG(tcpsst,error,"Client code for stream "<<newID.read()<<" did not set listener on socket"); shared_socket->closeStream(shared_socket,newID); } }else{ sStaleUUIDs.push_back(context); } } } delete buffer; }
void dmz::QtPluginCanvasLink::update_link_attribute_object ( const Handle LinkHandle, const Handle AttributeHandle, const UUID &SuperIdentity, const Handle SuperHandle, const UUID &SubIdentity, const Handle SubHandle, const UUID &AttributeIdentity, const Handle AttributeObjectHandle, const UUID &PrevAttributeIdentity, const Handle PrevAttributeObjectHandle) { if (AttributeObjectHandle) { LinkStruct *ls = _linkTable.lookup (LinkHandle); if (ls) { _attrObjTable.store (AttributeObjectHandle, ls); } if (_flowAttrHandle) { ObjectModule *objMod (get_object_module ()); if (objMod) { Mask state; if (objMod->lookup_state (AttributeObjectHandle, _flowAttrHandle, state)) { update_object_state ( UUID (), AttributeObjectHandle, _flowAttrHandle, state, 0); } } } } if (PrevAttributeObjectHandle) { _attrObjTable.remove (PrevAttributeObjectHandle); } }
void nRF5xCharacteristicDescriptorDiscoverer::process(uint16_t connectionHandle, const ble_gattc_evt_desc_disc_rsp_t& descriptors) { Discovery* discovery = findRunningDiscovery(connectionHandle); // the discovery has been removed if(!discovery) { return; } for (uint16_t i = 0; i < descriptors.count; ++i) { const ble_gattc_desc_t& desc = descriptors.descs[i]; const ble_uuid_t& uuid = desc.uuid; if (uuid.type == BLE_UUID_TYPE_BLE) { discovery->process( desc.handle, UUID(uuid.uuid) ); } else { // discover attribute infos of the descriptor ble_error_t err = gattc_attr_info_discover(connectionHandle, desc.handle, desc.handle); if (err) { terminate(discovery, err); } return; } } // prepare the next discovery request (if needed) uint16_t startHandle = descriptors.descs[descriptors.count - 1].handle + 1; uint16_t endHandle = discovery->getCharacteristic().getLastHandle(); if(startHandle > endHandle) { terminate(discovery, BLE_ERROR_NONE); return; } ble_error_t err = gattc_descriptors_discover(connectionHandle, startHandle, endHandle); if(err) { terminate(discovery, err); return; } }
MediaExtractor::ExtractorDef GETEXTRACTORDEF() { return { MediaExtractor::EXTRACTORDEF_VERSION, UUID("c86639c9-2f31-40ac-a715-fa01b4493aaf"), 1, "AMR Extractor", []( DataSourceBase *source, float *confidence, void **, MediaExtractor::FreeMetaFunc *) -> MediaExtractor::CreatorFunc { if (SniffAMR(source, nullptr, confidence)) { return []( DataSourceBase *source, void *) -> MediaExtractor* { return new AMRExtractor(source);}; } return NULL; } }; }
UUID UUID::fromString(const NPT_String& s) { const char *cc = s.GetChars(); if (s.GetLength() == 36 && cc[8] == '-' && cc[13] == '-' && cc[18] == '-' && cc[23] == '-') { UUID uuid; if (!parseHex(*reinterpret_cast<NPT_UInt32*>(uuid.m_data + 0), cc, 8)) return UUID(); if (!parseHex(*reinterpret_cast<NPT_UInt16*>(uuid.m_data + 4), cc + 9, 4)) return UUID(); if (!parseHex(*reinterpret_cast<NPT_UInt16*>(uuid.m_data + 6), cc + 14, 4)) return UUID(); if (!parseHex(*reinterpret_cast<NPT_UInt8*>(uuid.m_data + 8), cc + 19, 2)) return UUID(); if (!parseHex(*reinterpret_cast<NPT_UInt8*>(uuid.m_data + 9), cc + 21, 2)) return UUID(); for (int i = 0; i < 6; i++) { if (!parseHex(*reinterpret_cast<NPT_UInt8*>(uuid.m_data + 10 + i), cc + 24 + i * 2, 2)) return UUID(); } return uuid; } return UUID(); }
JoinMessage(const int version = -1, const UUID& source = UUID::nil(), const ViewId& source_view_id = ViewId(), const seqno_t seq = -1, const seqno_t aru_seq = -1, const int64_t fifo_seq = -1, const MessageNodeList& node_list = MessageNodeList()) : Message(version, Message::T_JOIN, source, source_view_id, ViewId(), 0xff, O_UNRELIABLE, fifo_seq, seq, -1, aru_seq, 0, UUID(), Range(), node_list) { }
void notifyLocUpdate() { // We don't really need the protocol version of the loc // update, but it's a convenient way to construct the update // we need. Sirikata::Protocol::Loc::LocationUpdate update; update.set_object(UUID((uint32)mContext->id())); update.set_seqno(mSeqnoSource++); // Bogus index ID (as used in prox update) so manual queries can route // updates to the right place update.add_index_id(1); Sirikata::Protocol::ITimedMotionVector motion = update.mutable_location(); motion.set_t(mContext->simTime()); motion.set_position(mRegion.center()); motion.set_velocity(Vector3f(0,0,0)); Sirikata::Protocol::ITimedMotionQuaternion msg_orient = update.mutable_orientation(); msg_orient.set_t(Time::null()); msg_orient.set_position(Quaternion::identity()); msg_orient.set_velocity(Quaternion::identity()); Sirikata::Protocol::IAggregateBoundingInfo msg_bounds = update.mutable_aggregate_bounds(); msg_bounds.set_center_offset( Vector3f(0,0,0) ); msg_bounds.set_center_bounds_radius( mRegion.toBoundingSphere().radius() ); msg_bounds.set_max_object_size(mLargest); update.set_query_data(mQueryData); // notify wants to only pass through values and tries to copy the // LocProtocolLocUpdate by default -- we need to jump through hoops and // specify the exact template types explicitly to make this work NopTimeSynced nop_ts; LocProtocolLocUpdate tmp(update, nop_ts);//need to assign a temporary for llvm compilers notify<void(PintoServerQuerierListener::*)(const Sirikata::LocUpdate&), const LocProtocolLocUpdate&>(&PintoServerQuerierListener::onPintoServerLocUpdate, tmp); }
void IndoorLocalizationService::addTrackedDeviceCharacteristic() { MasterBuffer& mb = MasterBuffer::getInstance(); buffer_ptr_t buffer = NULL; uint16_t maxLength = 0; mb.getBuffer(buffer, maxLength); _trackedDeviceCharac = new Characteristic<buffer_ptr_t>(); addCharacteristic(_trackedDeviceCharac); _trackedDeviceCharac->setUUID(UUID(getUUID(), TRACKED_DEVICE_UUID)); _trackedDeviceCharac->setName(BLE_CHAR_TRACK); _trackedDeviceCharac->setWritable(true); _trackedDeviceCharac->setNotifies(false); _trackedDeviceCharac->setValue(buffer); _trackedDeviceCharac->setMaxGattValueLength(maxLength); _trackedDeviceCharac->setValueLength(0); _trackedDeviceCharac->onWrite([&](const uint8_t accessLevel, const buffer_ptr_t& value, uint16_t length) -> void { Tracker::getInstance().handleTrackedDeviceCommand(_trackedDeviceCharac->getValue(), _trackedDeviceCharac->getValueLength()); }); }
void ObjectFactory::generateStaticTraceObjects(const BoundingBox3f& region, const Duration& duration) { Time start(Time::null()); uint32 nobjects = GetOptionValue<uint32>(OBJECT_SL_NUM); if (nobjects == 0) return; String pack_filename = GetOptionValue<String>(OBJECT_SL_FILE); assert(!pack_filename.empty()); String pack_dir = GetOptionValue<String>(OBJECT_PACK_DIR); pack_filename = pack_dir + pack_filename; Vector3f sim_center = GetOptionValue<Vector3f>(OBJECT_SL_CENTER); // First, load in all the objects. FILE* pack_file = fopen(pack_filename.c_str(), "rb"); if (pack_file == NULL) { SILOG(objectfactory,error,"Couldn't open object pack file, not generating any objects."); assert(false); return; } TraceObjectMap trace_objects; // parse each line: uuid x y z t rad SLEntry ent; char uuid[256]; while( !feof(pack_file) && fscanf(pack_file, "%s %f %f %f %d %f", uuid, &ent.pos.x, &ent.pos.y, &ent.pos.z, &ent.t, &ent.rad) ) { ent.uuid = UUID(std::string(uuid), UUID::HumanReadable()); //SILOG(oh,error,"Preating "<<ent.uuid.toString()<<" radius "<<ent.rad); TraceObjectMap::iterator obj_it = trace_objects.find(ent.uuid); if (obj_it == trace_objects.end()) { trace_objects[ent.uuid] = ObjectUpdateList(); obj_it = trace_objects.find(ent.uuid); } obj_it->second[ent.t] = ent; } fclose(pack_file); // Now get a version sorted by distance from typedef std::set<ObjectUpdateList, SortObjectUpdateListByDist> ObjectsByDistanceList; ObjectsByDistanceList objs_by_dist = ObjectsByDistanceList( SortObjectUpdateListByDist(sim_center) ); for(TraceObjectMap::iterator obj_it = trace_objects.begin(); obj_it != trace_objects.end(); obj_it++) objs_by_dist.insert(obj_it->second); // Finally, for the number of objects requested, insert the data ObjectsByDistanceList::iterator obj_it = objs_by_dist.begin(); for(uint32 i = 0; i < nobjects; i++, obj_it++) { ObjectInputs* inputs = new ObjectInputs; SLEntry first = (obj_it->begin())->second; inputs->localID = mLocalIDSource++; inputs->motion = new StaticMotionPath(Time::microseconds(first.t*1000), first.pos); inputs->bounds = BoundingSphere3f( Vector3f(0, 0, 0), first.rad ); inputs->registerQuery = false; inputs->queryAngle = SolidAngle::Max; inputs->connectAt = Duration::seconds(0.f); inputs->startTimer = Network::IOTimer::create(mContext->ioService); mObjectIDs.insert(first.uuid); mInputs[first.uuid] = inputs; } }
void notifyResult() { // Construct dummy update consisting of single node addition of leaf // node with our own ID so recursion to our own data will proceed where // an update like this is necessary for that to happen. It's actually a // bit more complicated because we don't actually support single node // trees -- we need at least one internal node and then the leaf node. Sirikata::Protocol::Prox::ProximityUpdate prox_update; Sirikata::Protocol::Prox::IIndexProperties index_props = prox_update.mutable_index_properties(); index_props.set_id(1); index_props.set_index_id( boost::lexical_cast<String>(NullServerID) ); index_props.set_dynamic_classification(Sirikata::Protocol::Prox::IndexProperties::Static); // Single addition of fake root { Sirikata::Protocol::Prox::IObjectAddition addition = prox_update.add_addition(); // Shoe-horn server ID into UUID addition.set_object(mRootNodeID); addition.set_seqno (mSeqnoSource++); Sirikata::Protocol::ITimedMotionVector motion = addition.mutable_location(); motion.set_t(mContext->simTime()); motion.set_position(mRegion.center()); motion.set_velocity(Vector3f(0,0,0)); Sirikata::Protocol::ITimedMotionQuaternion msg_orient = addition.mutable_orientation(); msg_orient.set_t(Time::null()); msg_orient.set_position(Quaternion::identity()); msg_orient.set_velocity(Quaternion::identity()); Sirikata::Protocol::IAggregateBoundingInfo msg_bounds = addition.mutable_aggregate_bounds(); msg_bounds.set_center_offset( Vector3f(0,0,0) ); msg_bounds.set_center_bounds_radius( mRegion.toBoundingSphere().radius() ); msg_bounds.set_max_object_size(mLargest); addition.set_query_data(mQueryData); addition.set_type(Sirikata::Protocol::Prox::ObjectAddition::Aggregate); } // Single addition of our own node { Sirikata::Protocol::Prox::IObjectAddition addition = prox_update.add_addition(); // Shoe-horn server ID into UUID addition.set_object(UUID((uint32)mContext->id())); addition.set_seqno (mSeqnoSource++); Sirikata::Protocol::ITimedMotionVector motion = addition.mutable_location(); motion.set_t(mContext->simTime()); motion.set_position(mRegion.center()); motion.set_velocity(Vector3f(0,0,0)); Sirikata::Protocol::ITimedMotionQuaternion msg_orient = addition.mutable_orientation(); msg_orient.set_t(Time::null()); msg_orient.set_position(Quaternion::identity()); msg_orient.set_velocity(Quaternion::identity()); Sirikata::Protocol::IAggregateBoundingInfo msg_bounds = addition.mutable_aggregate_bounds(); msg_bounds.set_center_offset( Vector3f(0,0,0) ); msg_bounds.set_center_bounds_radius( mRegion.toBoundingSphere().radius() ); msg_bounds.set_max_object_size(mLargest); addition.set_query_data(mQueryData); addition.set_type(Sirikata::Protocol::Prox::ObjectAddition::Object); addition.set_parent(mRootNodeID); } notify(&PintoServerQuerierListener::onPintoServerResult, prox_update); }