static int get(struct RandomSeed* randomSeed, uint64_t output[8])
{
    if (getUUID(output) || getUUID(output+2) || getUUID(output+4) || getUUID(output+6)) {
        return -1;
    }
    return 0;
}
Пример #2
0
void CAccount::setLabel(const std::string& label, CWalletDB* Db)
{
    accountLabel = label;
    if (Db) {
        Db->EraseAccountLabel(getUUID());
        Db->WriteAccountLabel(getUUID(), label);
    }
}
Пример #3
0
void CAccount::setNonCompoundRewardScript(const CScript& rewardScript, CWalletDB* Db)
{
    nonCompoundRewardScript = rewardScript;
    if (Db)
    {
        Db->EraseAccountNonCompoundWitnessEarningsScript(getUUIDAsString(getUUID()));
        Db->WriteAccountNonCompoundWitnessEarningsScript(getUUIDAsString(getUUID()), nonCompoundRewardScript);
    }
}
Пример #4
0
void CAccount::setCompounding(CAmount compoundAmount_, CWalletDB* Db)
{
    //fixme: (2.1) Signal UI to update compound checkbox to reflect changes.
    compoundEarnings = compoundAmount_;
    if (Db)
    {
        Db->EraseAccountCompoundingSettings(getUUIDAsString(getUUID()));
        Db->WriteAccountCompoundingSettings(getUUIDAsString(getUUID()), compoundEarnings);
    }
}
/**
 * @brief Retrieve a map of all the characteristics of this service.
 * @return A map of all the characteristics of this service.
 */
std::map<std::string, BLERemoteCharacteristic *> * BLERemoteService::getCharacteristics() {
	ESP_LOGD(LOG_TAG, ">> getCharacteristics() for service: %s", getUUID().toString().c_str());
	// If is possible that we have not read the characteristics associated with the service so do that
	// now.  The request to retrieve the characteristics by calling "retrieveCharacteristics" is a blocking
	// call and does not return until all the characteristics are available.
	if (!m_haveCharacteristics) {
		retrieveCharacteristics();
	}
	ESP_LOGD(LOG_TAG, "<< getCharacteristics() for service: %s", getUUID().toString().c_str());
	return &m_characteristicMap;
} // getCharacteristics
/**
 * @brief Read the value of the remote characteristic.
 * @return The value of the remote characteristic.
 */
std::string BLERemoteCharacteristic::readValue() {
	ESP_LOGD(LOG_TAG, ">> readValue(): uuid: %s, handle: %d 0x%.2x", getUUID().toString().c_str(), getHandle(), getHandle());

	// Check to see that we are connected.
	if (!getRemoteService()->getClient()->isConnected()) {
		ESP_LOGE(LOG_TAG, "Disconnected");
		throw BLEDisconnectedException();
	}

	m_semaphoreReadCharEvt.take("readValue");

	// Ask the BLE subsystem to retrieve the value for the remote hosted characteristic.
	// This is an asynchronous request which means that we must block waiting for the response
	// to become available.
	esp_err_t errRc = ::esp_ble_gattc_read_char(
		m_pRemoteService->getClient()->getGattcIf(),
		m_pRemoteService->getClient()->getConnId(),    // The connection ID to the BLE server
		getHandle(),                                   // The handle of this characteristic
		ESP_GATT_AUTH_REQ_NONE);                       // Security

	if (errRc != ESP_OK) {
		ESP_LOGE(LOG_TAG, "esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
		return "";
	}

	// Block waiting for the event that indicates that the read has completed.  When it has, the std::string found
	// in m_value will contain our data.
	m_semaphoreReadCharEvt.wait("readValue");

	ESP_LOGD(LOG_TAG, "<< readValue(): length: %d", m_value.length());
	return m_value;
} // readValue
Пример #7
0
void LLHTTPAssetRequest::prepareCompressedUpload()
{
	mZStream.next_in = Z_NULL;
	mZStream.avail_in = 0;
	mZStream.zalloc = Z_NULL;
	mZStream.zfree = Z_NULL;
	mZStream.opaque = Z_NULL;

	int r = deflateInit2(&mZStream,
			1,			// compression level
			Z_DEFLATED,	// the only method defined
			15 + 16,	// the default windowBits + gzip header flag
			8,			// the default memLevel
			Z_DEFAULT_STRATEGY);

	if (r != Z_OK)
	{
		llerrs << "LLHTTPAssetRequest::prepareCompressedUpload defalateInit2() failed" << llendl;
	}

	mZInitialized = true;
	mZInputBuffer = new char[COMPRESSED_INPUT_BUFFER_SIZE];
	mZInputExhausted = false;

	mVFile = new LLVFile(gAssetStorage->mVFS,
					getUUID(), getType(), LLVFile::READ);
}
Пример #8
0
ByteBuffer Mesh::_toBuffer() {
    ByteBuffer uuid = ::toBuffer ( getUUID() );
    ByteBuffer name = ::toBuffer ( getName () );

    unsigned long long totalSize = 5 * sizeof ( unsigned int ) +
            get < unsigned int > ( "#Vertices" ) * sizeof ( Vector3d ) +
            get < unsigned int > ( "#TexVertices" ) * sizeof ( Vector2d ) +
            get < unsigned int > ( "#Normals" ) * sizeof ( Vector3d )
            + get < unsigned int > ( "#Faces" ) * sizeof ( Triangle ),
            index = 0;
    ByteBuffer result ( totalSize );
    index = ::toBuffer ( result, index, get < unsigned int > ( "#Vertices" ) );
    index = ::toBuffer ( result, index, get < Vector3d* > ( "Vertices" ), get < unsigned int > ( "#Vertices" ) );
    index = ::toBuffer ( result, index, get < unsigned int > ( "#TexVertices" ) );
    index = ::toBuffer ( result, index, get < Vector2d* > ( "TexVertices" ), get < unsigned int > ( "#TexVertices" ) );
    index = ::toBuffer ( result, index, get < unsigned int > ( "#Normals" ) );
    index = ::toBuffer ( result, index, get < Vector3d* > ( "Normals" ), get < unsigned int > ( "#Normals" ) );
    /**/
    index = ::toBuffer ( result, index, get < unsigned int > ( "#Faces" ) );
    index = ::toBuffer ( result, index, get < Triangle* > ( "Faces" ), get < unsigned int > ( "#Faces" ) );
    /**/
    index = ::toBuffer ( result, index, getSize < MaterialGroup* > ( "MaterialGroups" ) );
    for ( unsigned int i = 0 ; i < getSize < MaterialGroup* > ( "MaterialGroups" ) ; i ++ ) {
        MaterialGroup* grp = get < MaterialGroup* > ( "MaterialGroups", i );
        ByteBuffer grpBuf = grp->convertToBuffer ();
        result.append(grpBuf);
    }
    return result;
}
Пример #9
0
/**
 * @brief Execute the creation of the descriptor with the BLE runtime in ESP.
 * @param [in] pCharacteristic The characteristic to which to register this descriptor.
 */
void BLEDescriptor::executeCreate(BLECharacteristic* pCharacteristic) {
	ESP_LOGD(LOG_TAG, ">> executeCreate(): %s", toString().c_str());

	if (m_handle != NULL_HANDLE) {
		ESP_LOGE(LOG_TAG, "Descriptor already has a handle.");
		return;
	}

	m_pCharacteristic = pCharacteristic; // Save the characteristic associated with this service.

	esp_attr_control_t control;
	control.auto_rsp = ESP_GATT_RSP_BY_APP;
	m_semaphoreCreateEvt.take("executeCreate");
	esp_err_t errRc = ::esp_ble_gatts_add_char_descr(
			pCharacteristic->getService()->getHandle(),
			getUUID().getNative(),
			(esp_gatt_perm_t)(ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE),
			&m_value,
			&control);
	if (errRc != ESP_OK) {
		ESP_LOGE(LOG_TAG, "<< esp_ble_gatts_add_char_descr: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
		return;
	}

	m_semaphoreCreateEvt.wait("executeCreate");
	ESP_LOGD(LOG_TAG, "<< executeCreate");
} // executeCreate
Пример #10
0
// method does subscription to changes in avatar name cache for current session/participant conversation item.
void LLConversationItem::fetchAvatarName(bool isParticipant /*= true*/)
{
	LLUUID item_id = getUUID();

	// item should not be null for participants
	if (isParticipant)
	{
		llassert(item_id.notNull());
	}

	// disconnect any previous avatar name cache connection
	if (mAvatarNameCacheConnection.connected())
	{
		mAvatarNameCacheConnection.disconnect();
	}

	// exclude nearby chat item
	if (item_id.notNull())
	{
		// for P2P session item, override it as item of called agent
		if (CONV_SESSION_1_ON_1 == getType())
		{
			item_id = LLIMModel::getInstance()->getOtherParticipantID(item_id);
		}

		// subscribe on avatar name cache changes for participant and session items
		mAvatarNameCacheConnection = LLAvatarNameCache::get(item_id, boost::bind(&LLConversationItem::onAvatarNameCache, this, _2));
	}
}
Пример #11
0
DataDescriptor::DataDescriptor(const QJsonObject &jo) {
	_uuid = getUUID();
	_name = jo["name"].toString();
	_unit = jo["unit"].toString();
	_factor = jo["factor"].toDouble();
	_type = static_cast<Type>(jo["type"].toInt());
}
Пример #12
0
/**
 * @brief Set the handle associated with this service.
 * @param [in] handle The handle associated with the service.
 */
void BLEService::setHandle(uint16_t handle) {
	ESP_LOGD(LOG_TAG, ">> setHandle - Handle=0x%.2x, service UUID=%s)", handle, getUUID().toString().c_str());
	if (m_handle != NULL_HANDLE) {
		ESP_LOGE(LOG_TAG, "!!! Handle is already set %.2x", m_handle);
		return;
	}
	m_handle = handle;
	ESP_LOGD(LOG_TAG, "<< setHandle");
} // setHandle
Пример #13
0
void CAccount::possiblyUpdateEarliestTime(uint64_t creationTime, CWalletDB* Db)
{
    if (creationTime < earliestPossibleCreationTime)
        earliestPossibleCreationTime = creationTime;

    if (Db) {
        Db->WriteAccount(getUUID(), this);
    }
}
static int get(struct RandomSeed* randomSeed, uint64_t output[8])
{

#ifdef SYS_getrandom
    // Try using getrandom instead sysctl as with systems with getrandom
    // sysctl is probably alrady deprecated and possibly disabled.
    Bits_memset(output, 0, 64); // Just make sure that it is zero all along.

    long ret = syscall(SYS_getrandom, output, 64, 0);
    if (ret == 64 && !Bits_isZero(output, 64)) {
        return 0;
    }
#endif
    if (getUUID(output) || getUUID(output+2) || getUUID(output+4) || getUUID(output+6)) {
        return -1;
    }
    return 0;
}
Пример #15
0
void Mesh::Usage()
{
    std::cout << getUUID().toString().toStdString() <<
                 " && " << getName ().toStdString() <<
                 " #v: " << get < unsigned int > ( "#Vertices" ) <<
                 " #t: " << get < unsigned int > ( "#TexVertices" ) <<
                 " #n: " << get < unsigned int > ( "#Normals" ) <<
                 " #f: " << get < unsigned int > ( "#Faces" ) <<
                 " #g: " << getSize < MaterialGroup* > ( "MaterialGroups" ) << std::endl;
}
Пример #16
0
std::string
SnapshotToolCut::str() const
{
    std::stringstream ss;

    ss << "name: " << name() << std::endl
       << "backendSize: " << stored() << std::endl
       << "uuid: " << getUUID() << std::endl
       << "date: " << getDate();
    return ss.str();
}
Пример #17
0
bool CheckCloudConnection::checkServer()
{
	if (verbose)
		fprintf(stderr, "Checking cloud connection...\n");

	QTimer timer;
	timer.setSingleShot(true);
	QEventLoop loop;
	QNetworkRequest request;
	request.setRawHeader("Accept", "text/plain");
	request.setRawHeader("User-Agent", getUserAgent().toUtf8());
	request.setRawHeader("Client-Id", getUUID().toUtf8());
	request.setUrl(QString(prefs.cloud_base_url) + TEAPOT);
	QNetworkAccessManager *mgr = new QNetworkAccessManager();
	reply = mgr->get(request);
	connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
	connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
	connect(reply, &QNetworkReply::sslErrors, this, &CheckCloudConnection::sslErrors);
	for (int seconds = 1; seconds <= prefs.cloud_timeout; seconds++) {
		timer.start(1000); // wait the given number of seconds (default 5)
		loop.exec();
		if (timer.isActive()) {
			// didn't time out, did we get the right response?
			timer.stop();
			if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == HTTP_I_AM_A_TEAPOT &&
			    reply->readAll() == QByteArray(MILK)) {
				reply->deleteLater();
				mgr->deleteLater();
				if (verbose > 1)
					qWarning() << "Cloud storage: successfully checked connection to cloud server";
				git_storage_update_progress(false, "successfully checked cloud connection");
				return true;
			}
		} else if (seconds < prefs.cloud_timeout) {
			QString text = QString("waited %1 sec for cloud connetion").arg(seconds);
			git_storage_update_progress(false, qPrintable(text));
		} else {
			disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
			reply->abort();
		}
	}
	git_storage_update_progress(false, "cloud connection failed");
	prefs.git_local_only = true;
	if (verbose)
		qDebug() << "connection test to cloud server failed" <<
			    reply->error() << reply->errorString() <<
			    reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() <<
			    reply->readAll();
	reply->deleteLater();
	mgr->deleteLater();
	if (verbose)
		qWarning() << "Cloud storage: unable to connect to cloud server";
	return false;
}
Пример #18
0
void CAccount::possiblyUpdateEarliestTime(uint64_t creationTime, CWalletDB* Db)
{
    if (creationTime < earliestPossibleCreationTime)
        earliestPossibleCreationTime = creationTime;

    //fixme: (2.1) Can we just set dirty or something and then it gets saved later? This would be cleaner instead of taking the Db here and writing directly to it...
    if (Db)
    {
        Db->WriteAccount(getUUIDAsString(getUUID()), this);
    }
}
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);
	});
}
Пример #21
0
// virtual
LLSD LLAssetRequest::getTerseDetails() const
{
	LLSD sd;
	sd["asset_id"] = getUUID();
	sd["type_long"] = LLAssetType::lookupHumanReadable(getType());
	sd["type"] = LLAssetType::lookup(getType());
	sd["time"] = mTime;
	time_t timestamp = (time_t) mTime;
	std::ostringstream time_string;
	time_string << ctime(&timestamp);
	sd["time_string"] = time_string.str();
	return sd;
}
Пример #22
0
/**
 * @brief Retrieve all the characteristics for this service.
 * This function will not return until we have all the characteristics.
 * @return N/A
 */
void BLERemoteService::retrieveCharacteristics() {

	ESP_LOGD(LOG_TAG, ">> getCharacteristics() for service: %s", getUUID().toString().c_str());

	removeCharacteristics(); // Forget any previous characteristics.

	uint16_t offset = 0;
	esp_gattc_char_elem_t result;
	while(1) {
		uint16_t count = 1;
		esp_gatt_status_t status = ::esp_ble_gattc_get_all_char(
			getClient()->getGattcIf(),
			getClient()->getConnId(),
			m_startHandle,
			m_endHandle,
			&result,
			&count,
			offset
		);

		if (status == ESP_GATT_INVALID_OFFSET) {   // We have reached the end of the entries.
			break;
		}

		if (status != ESP_GATT_OK) {   // If we got an error, end.
			ESP_LOGE(LOG_TAG, "esp_ble_gattc_get_all_char: %s", BLEUtils::gattStatusToString(status).c_str());
			break;
		}

		if (count == 0) {   // If we failed to get any new records, end.
			break;
		}

		ESP_LOGD(LOG_TAG, "Found a characteristic: Handle: %d, UUID: %s", result.char_handle, BLEUUID(result.uuid).toString().c_str());

		// We now have a new characteristic ... let us add that to our set of known characteristics
		BLERemoteCharacteristic *pNewRemoteCharacteristic = new BLERemoteCharacteristic(
			result.char_handle,
			BLEUUID(result.uuid),
			result.properties,
			this
		);

		m_characteristicMap.insert(std::pair<std::string, BLERemoteCharacteristic*>(pNewRemoteCharacteristic->getUUID().toString(), pNewRemoteCharacteristic));

		offset++;   // Increment our count of number of descriptors found.
	} // Loop forever (until we break inside the loop).

	m_haveCharacteristics = true; // Remember that we have received the characteristics.
	ESP_LOGD(LOG_TAG, "<< getCharacteristics()");
} // getCharacteristics
Пример #23
0
 std::string UUID::toPrettyString(uint32_t indent) {
   std::string UUID = getUUID();
   if (UUID == "d4807ef2-ca39-4695-8e54-26cb9e46a79f") {
     return ((UUID_TrackFragmentReference *)this)->toPrettyString(indent);
   }
   if (UUID == "6d1d9b05-42d5-44e6-80e2-141daff757b2") {
     return ((UUID_TFXD *)this)->toPrettyString(indent);
   }
   std::stringstream r;
   r << std::string(indent, ' ') << "[uuid] Extension box (" << boxedSize() << ")" << std::endl;
   r << std::string(indent + 1, ' ') << "UUID: " << UUID << std::endl;
   r << std::string(indent + 1, ' ') << "Unknown UUID - ignoring contents." << std::endl;
   return r.str();
 }
Пример #24
0
QMimeData* LS3SelectionDisplayModel::mimeData(const QModelIndexList &indexes) const {
    QMimeData *mimeData = new QMimeData();
    QByteArray encodedData;

    QDataStream stream(&encodedData, QIODevice::WriteOnly);
    foreach (QModelIndex index, indexes) {
        if (index.isValid()) {
            QString text = getUUID(index);
            stream << text;
        }
    }
    mimeData->setData("litsoz3/list.uuid", encodedData);
    return mimeData;
}
Пример #25
0
        void LightManager::updateUUID(UUID const& uuid)
        {
            const std::string uuidStr = uuid.toString();
            auto find = m_Lights.find(uuidStr);

            if(find != m_Lights.end())
            {
                auto object = find->second;

                m_Lights.erase(find);

                m_Lights.insert(std::make_pair(object->getUUID().toString(), object));
            }
        }
/**
 * @brief Populate the descriptors (if any) for this characteristic.
 */
void BLERemoteCharacteristic::retrieveDescriptors() {
	ESP_LOGD(LOG_TAG, ">> retrieveDescriptors() for characteristic: %s", getUUID().toString().c_str());

	removeDescriptors();   // Remove any existing descriptors.

	// Loop over each of the descriptors within the service associated with this characteristic.
	// For each descriptor we find, create a BLERemoteDescriptor instance.
	uint16_t offset = 0;
	esp_gattc_descr_elem_t result;
	while(1) {
		uint16_t count = 1;
		esp_gatt_status_t status = ::esp_ble_gattc_get_all_descr(
			getRemoteService()->getClient()->getGattcIf(),
			getRemoteService()->getClient()->getConnId(),
			getHandle(),
			&result,
			&count,
			offset
		);

		if (status == ESP_GATT_INVALID_OFFSET) {   // We have reached the end of the entries.
			break;
		}

		if (status != ESP_GATT_OK) {
			ESP_LOGE(LOG_TAG, "esp_ble_gattc_get_all_descr: %s", BLEUtils::gattStatusToString(status).c_str());
			break;
		}

		if (count == 0) {
			break;
		}
		ESP_LOGE(LOG_TAG, "");
		ESP_LOGD(LOG_TAG, "Found a descriptor: Handle: %d, UUID: %s", result.handle, BLEUUID(result.uuid).toString().c_str());

		// We now have a new characteristic ... let us add that to our set of known characteristics
		BLERemoteDescriptor *pNewRemoteDescriptor = new BLERemoteDescriptor(
			result.handle,
			BLEUUID(result.uuid),
			this
		);

		m_descriptorMap.insert(std::pair<std::string, BLERemoteDescriptor*>(pNewRemoteDescriptor->getUUID().toString(), pNewRemoteDescriptor));

		offset++;
	} // while true
	//m_haveCharacteristics = true; // Remember that we have received the characteristics.
	ESP_LOGD(LOG_TAG, "<< retrieveDescriptors(): Found %d descriptors.", offset);
} // getDescriptors
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);
}
Пример #28
0
CPubKey CAccountHD::GenerateNewKey(CWallet& wallet, CKeyMetadata& metadata, int keyChain)
{
    CExtPubKey childKey;
    do
    {
        GetPubKey(childKey, keyChain);
    }
    while( wallet.HaveKey(childKey.pubkey.GetID()) );//fixme: (Post-2.1) (BIP44) No longer need wallet here.

    //LogPrintf("CAccount::GenerateNewKey(): NewHDKey [%s]\n", CGuldenAddress(childKey.pubkey.GetID()).ToString());

    metadata.hdKeypath = std::string("m/44'/87'/") +  std::to_string(m_nIndex)  + "/" + std::to_string(keyChain) + "/" + std::to_string(childKey.nChild) + "'";
    metadata.hdAccountUUID = getUUIDAsString(getUUID());

    if (!wallet.AddHDKeyPubKey(childKey.nChild, childKey.pubkey, *this, keyChain))
        throw std::runtime_error("CAccount::GenerateNewKey(): AddKeyPubKey failed");

    return childKey.pubkey;
}
Пример #29
0
QoSManagerInterface* SthenoCore::getQoSManagerInterface(String& path, ULong runtime, ULong period,
        bool create) throw (RuntimeException&) {
    //return new QoSManagerInterface(this);
    UUIDPtr runtimeUUID;
    getUUID(runtimeUUID);
    String domainPath = "runtime_" + runtimeUUID->toString();
    if (Cgroup::FLAT_HIERARCHY) {
        if (path != "") {
            FlatHierarchicalPath::appendPaths(domainPath, path);
        }
    } else {
        HierarchicalPath::appendPaths(domainPath, path);
    }
    QoSManagerInterface* qosManager = new QoSManagerInterface(this, domainPath, runtime, period, create);
    //String domainPath = path;//"runtime_" + this->getUUID()->toString();
    //domainPath += "/p2p/mesh";
    //CPUGroupQoS qos("/HRT", domainPath, runtime, period, 1024);
    //qosManager->createGroupCPUReserve(domainPath, qos);
    return qosManager;
}
Пример #30
0
void P3LeafMesh::createRemoteService(const SAPInfo* hint, const UUIDPtr& uuid, const UUIDPtr& sid, ServiceParamsPtr& params, UUIDPtr& iid) throw (ServiceException&) {
    ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock);
    if (hint == 0) {
        throw ServiceException(ServiceException::SERVICE_WITHOUT_IMPL);
    }
    Endpoint endpoint;
    ACE_Connector<P3MeshClientHandler, ACE_SOCK_Connector> connector;
    hint->getFirstEndpoint(endpoint);
    QoSEndpoint qosE = *(endpoint.getQoS());
    UUIDPtr runtimeUUID;
    getUUID(runtimeUUID);
    UUIDPtr fid;
    getFID(fid);
    P3MeshClientHandler* clientHandler = new P3MeshClientHandler(
            runtimeUUID,
            fid,
            qosE,
            false, false, 0, 0, 0, 0);

    if (connector.connect(clientHandler, endpoint.getAddr()) == -1) {
        ACE_ERROR((LM_ERROR, ACE_TEXT("(%T)%@\n"),
                ACE_TEXT("(%T)ERROR: P3Mesh::createRemoteService - connect failed:")));
        clientHandler->close();
        clientHandler = 0;
        delete clientHandler;
    } else {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - Connect OK!\n")));
    }

    int ret = clientHandler->createService(params, iid);
    clientHandler->close();
    delete clientHandler;
    if (ret == -1) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - failed to create, not enough resources\n")));
        throw ServiceException(ServiceException::INSUFFICIENT_RESOURCES);
    }
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - service created!\n")));
}