当前位置: 首页>>代码示例>>C++>>正文


C++ OCRepresentation::setValue方法代码示例

本文整理汇总了C++中OCRepresentation::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ OCRepresentation::setValue方法的具体用法?C++ OCRepresentation::setValue怎么用?C++ OCRepresentation::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCRepresentation的用法示例。


在下文中一共展示了OCRepresentation::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get

    // gets the updated representation.
    // Updates the representation with latest internal state before
    // sending out.
    OCRepresentation get()
    {
        m_lightRep.setValue("state", m_state);
        m_lightRep.setValue("power", m_power);

        return m_lightRep;
    }
开发者ID:EmuxEvans,项目名称:iotivity,代码行数:10,代码来源:simpleserver.cpp

示例2: LightResource

    /// Constructor
    LightResource()
        :m_power(""), m_lightUri("/a/light") {
        // Initialize representation
        m_lightRep.setUri(m_lightUri);

        m_lightRep.setValue("power", m_power);
    }
开发者ID:EmuxEvans,项目名称:iotivity,代码行数:8,代码来源:lightserver.cpp

示例3: getLightRepresentation

    OCRepresentation getLightRepresentation()
    {
        m_lightRep.setValue("state", m_lightState);
        m_lightRep.setValue("color", m_lightColor);

        return m_lightRep;
    }
开发者ID:iotk,项目名称:iochibity-cxx,代码行数:7,代码来源:roomserver.cpp

示例4: LOGD

/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    setValueRepresentation
* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation
(JNIEnv *env, jobject thiz, jstring jKey, jobject jValue)
{
    LOGD("OcRepresentation_setValueRepresentation");
    if (!jKey)
    {
        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
        return;
    }
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep)
    {
        return;
    }

    std::string key = env->GetStringUTFChars(jKey, nullptr);

    if (jValue)
    {
        OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);
        if (!value)
        {
            return;
        }
        rep->setValue(key, *value);
    }
    else
    {
        rep->setNULL(key);
    }
}
开发者ID:Subh1994,项目名称:iotivity,代码行数:36,代码来源:JniOcRepresentation.cpp

示例5: executeJumpingRule

void SensorResource::executeJumpingRule(int heartRate)
{
	std::cout << "Crazy Jumping enable flag: " << m_rr->m_crazyJumping << "current heartRate: " << heartRate << std::endl;
	if (m_rr->m_crazyJumping && m_led.s_active && m_led.s_resource) {
		OCRepresentation ledrep;
		PutCallback p (std::bind(&SensorResource::onPut, this, PH::_1, PH::_2, PH::_3));
		if (heartRate >= m_rr->m_heartRate){
			ledrep.setValue("ledColor", RED);
		} else {
			ledrep.setValue("ledColor", GREEN);

		}

		m_led.s_resource->put(ledrep, QueryParamsMap(), p);
	}
}
开发者ID:ttzeng,项目名称:makeground,代码行数:16,代码来源:sensor_resource.cpp

示例6: refreshAccessToken

OCStackResult OCAccountManager::refreshAccessToken(const std::string& userUuid,
                                                   const std::string& refreshToken,
                                                   PostCallback cloudConnectHandler)
{
    std::string uri = m_host + OC_RSRVD_ACCOUNT_TOKEN_REFRESH_URI;

    OCRepresentation rep;
    rep.setValue(OC_RSRVD_USER_UUID, userUuid);
    rep.setValue(OC_RSRVD_DEVICE_ID, m_deviceID);
    rep.setValue(OC_RSRVD_GRANT_TYPE, OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN);
    rep.setValue(OC_RSRVD_REFRESH_TOKEN, refreshToken);

    return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
                         OCDevAddr(), uri, rep, QueryParamsMap(), HeaderOptions(),
                         m_connType, cloudConnectHandler, m_defaultQos);
}
开发者ID:stjong,项目名称:iotivity,代码行数:16,代码来源:OCAccountManager.cpp

示例7: forceTermination

WANIpConnection::ConnectionState WANIpConnection::forceTermination()
{
    unique_lock<mutex> wanIpLock(m_mutex);
    m_connectionState = {"", "", 0};
    OCRepresentation rep;
    rep.setValue("uri", m_resource->uri());
    OCRepresentation attributes;
    attributes.setValue("statusUpdateRequest", string("ForceTermination"));
    rep.setValue("connectionState", attributes);
    m_forceTerminationCB = bind(&WANIpConnection::onForceTermination, this, _1, _2, _3);
    m_resource->post(rep, QueryParamsMap(), m_forceTerminationCB);
    if (m_cv.wait_for(wanIpLock, chrono::seconds(MAX_WAIT_TIME_FOR_BLOCKING_CALL)) == cv_status::timeout)
    {
        cerr << "Remote device failed to respond to the request." << endl;
    }
    return m_connectionState;
}
开发者ID:iotivity,项目名称:iotivity-upnp-bridge,代码行数:17,代码来源:WANIpConnection.cpp

示例8: FanResource

    /// Constructor
    FanResource() :
        m_speed(10), m_fanUri("/a/fan"), m_resourceHandle(0)
    {
        // Initialize representation
        m_fanRep.setUri(m_fanUri);

        m_fanRep.setValue("speed", m_speed);
    }
开发者ID:santais,项目名称:iotivity,代码行数:9,代码来源:fanserver.cpp

示例9: getRepresentation

    OCRepresentation getRepresentation()
    {
        OCRepresentation rep;

        rep.setValue("level", (int) m_pressure);

        return rep;
    }
开发者ID:kartben,项目名称:iotivity,代码行数:8,代码来源:bookmark.cpp

示例10: putClientRepresentation

void putClientRepresentation(std::shared_ptr<OCResource> resource, string &key, int value)
{
	if(resource)
	{
		OCRepresentation rep;
		std::cout << "Putting representation..."<<std::endl;
		rep.setValue(key, value);
		resource->put(rep, QueryParamsMap(), &onPut);
	}
}
开发者ID:iamsanjeev,项目名称:practice,代码行数:10,代码来源:geniviocfs2.cpp

示例11: executeGasRule

void SensorResource::executeGasRule(int density)
{
	if (m_fan.s_active && m_fan.s_resource) {
		OCRepresentation fanrep;
		PutCallback p (std::bind(&SensorResource::onPut, this, PH::_1, PH::_2, PH::_3));
		if ((density > m_rr->m_density) && (m_fanState == false)) {
			std::cout << "Turning on the fan..."<<std::endl;

			fanrep.setValue("fanstate", std::string("on"));
			m_fan.s_resource->put(fanrep, QueryParamsMap(), p);
		}
		else if ((density <= m_rr->m_density) && (m_fanState == true)) {
			std::cout << "Turning off the fan..."<<std::endl;

			fanrep.setValue("fanstate", std::string("off"));
			m_fan.s_resource->put(fanrep, QueryParamsMap(), p);
		}
	}
}
开发者ID:ttzeng,项目名称:makeground,代码行数:19,代码来源:sensor_resource.cpp

示例12: unprovisionEnrollee

        void RemoteEnrolleeResource::unprovisionEnrollee()
        {
            if (m_ocResource == nullptr)
            {
                throw ESBadRequestException("Resource is not initialized");
            }

            OCRepresentation provisioningRepresentation;

            provisioningRepresentation.setValue(OC_RSRVD_ES_TNN, "");
            provisioningRepresentation.setValue(OC_RSRVD_ES_CD, "");

            m_ocResource->post(provisioningRepresentation, QueryParamsMap(),
                    std::function<
                            void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
                                    const int eCode) >(
                    std::bind(&RemoteEnrolleeResource::checkProvInformationCb, this,
                    std::placeholders::_1, std::placeholders::_2,
                    std::placeholders::_3)));
        }
开发者ID:mobileink,项目名称:iotivity,代码行数:20,代码来源:RemoteEnrolleeResource.cpp

示例13: signInOut

OCStackResult OCAccountManager::signInOut(const std::string& userUuid,
                                          const std::string& accessToken,
                                          bool isSignIn,
                                          PostCallback cloudConnectHandler)
{
    std::string uri = m_host + OC_RSRVD_ACCOUNT_SESSION_URI;

    OCRepresentation rep;
    if (isSignIn)
    {
        rep.setValue(OC_RSRVD_USER_UUID, userUuid);
        rep.setValue(OC_RSRVD_DEVICE_ID, m_deviceID);
        rep.setValue(OC_RSRVD_ACCESS_TOKEN, accessToken);
    }
    rep.setValue(OC_RSRVD_LOGIN, isSignIn);

    return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
                         OCDevAddr(), uri, rep, QueryParamsMap(), HeaderOptions(),
                         m_connType, cloudConnectHandler, m_defaultQos);
}
开发者ID:stjong,项目名称:iotivity,代码行数:20,代码来源:OCAccountManager.cpp

示例14: allBulbOff

void allBulbOff()
{
    OCRepresentation rep;

    rep.setValue("DoAction", std::string("AllBulbOff"));

    if (g_resource)
    {
        g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
                &onPost);
    }
}
开发者ID:rzr,项目名称:iotivity-1,代码行数:12,代码来源:groupserver.cpp

示例15: onObserve

void SensorResource::onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
	const int& eCode, const int& sequenceNumber)
{
	int density = 0;
	int ledColor = 0;
	bool motion = false;
	try
	{
		if(eCode == OC_STACK_OK) {
			if (rep.hasAttribute("density")) {
				m_gas.s_active = true;
				rep.getValue("density", density);
				std::cout << "\tdensity: " << density << std::endl;

				if (m_rr->m_kitchenMonitor) {
					std::cout << "Kitchen Monitor is enabled" << std::endl;
					executeGasRule(density);
				}
			}

			if (rep.hasAttribute("fanstate")) {
				m_fan.s_active = true;
				std::string state = rep.getValue<std::string>("fanstate");
				m_fanState = (state == "on" ? true:false);
				std::cout << "\tfanstate: " << m_fanState << std::endl;
			}

			if (rep.hasAttribute("ledColor")) {
				m_led.s_active = true;
				rep.getValue("ledColor", ledColor);
				std::cout << "\tledColor: " << ledColor << std::endl;
			}
			if (rep.hasAttribute("motion")) {
				m_pri.s_active = true;
				rep.getValue("motion", motion);
				std::cout << "\tmotion: " << motion << std::endl;
				PutCallback p (std::bind(&SensorResource::onPut, this, PH::_1, PH::_2, PH::_3));
				if ((motion == true) && (m_led.s_active == true)) {
					OCRepresentation ledrep;
					ledrep.setValue("ledColor", BLUE);
					m_led.s_resource->put(ledrep, QueryParamsMap(), p);
				}
			}
		}
		else {
			std::cout << "onObserve Response error: " << eCode << std::endl;
		}
	}
	catch(std::exception& e) {
		std::cout << "Exception: " << e.what() << " in onObserve" << std::endl;
	}
}
开发者ID:ttzeng,项目名称:makeground,代码行数:52,代码来源:sensor_resource.cpp


注:本文中的OCRepresentation::setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。