Exemplo n.º 1
0
void SensorRule::updateRuleView(const OC::OCRepresentation &rep)
{
    bool value;

    setEnabled(true);

    if (rep.hasAttribute(IoTivity::IOTIVITY_KITCH_RULE))
    {
        rep.getValue(IoTivity::IOTIVITY_KITCH_RULE, value);
        updateKitchMonitorState(value);
    }

    if (rep.hasAttribute(IoTivity::IOTIVITY_CRAZY_JUMPING_RULE))
    {
        rep.getValue(IoTivity::IOTIVITY_CRAZY_JUMPING_RULE, value);
        updateCrazyJumpingState(value);
    }

    if (rep.hasAttribute("density"))
    {
        int densityValue;
        rep.getValue("density", densityValue);
        updateDefineDensity(densityValue);
    }

    if (rep.hasAttribute("heartRate"))
    {
        int heartRateValue;
        rep.getValue("heartRate", heartRateValue);
        updateDefineHeartRate(heartRateValue);
    }
}
Exemplo n.º 2
0
JNIEXPORT jboolean JNICALL hasAttribute(JNIEnv *env, jobject jobj, jstring jstr)
{
    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
	string str = env->GetStringUTFChars(jstr,0);

    return rep->hasAttribute(str);
}
void on_iotivity_utility_get(const OC::HeaderOptions &headerOptions,
                             const OC::OCRepresentation &rep, const int eCode)
{
    (void) headerOptions;
    if (eCode == OC_STACK_OK)
    {
        if (rep.hasAttribute("name"))
        {
            std::string name = "";
            rep.getValue("name", name);
            std::cout << "\tname " << name << std::endl;
        }
    }
    g_iotivity_utility_condition_variable.notify_one();
}
void processAttributes(const OC::OCRepresentation &rep,
                       const std::map <std::string, AttrDesc> *attrMap,
                       std::string prefix)
{
    for (auto &attr : *attrMap)
    {
        if (rep.hasAttribute(attr.first))
        {
            std::cout << prefix << attr.first << "";
        }
        else
        {
            continue;
        }

        switch (attr.second.type)
        {
            case ATTR_TYPE_BOOL:
                {
                    bool value;
                    rep.getValue(attr.first, value);
                    std::cout << " (bool):\t " << ((value) ? "TRUE" : "FALSE") << std::endl;
                    break;
                }
            case ATTR_TYPE_INT:
                {
                    int value;
                    rep.getValue(attr.first, value);
                    std::cout << " (int):\t " << value << std::endl;
                    break;
                }
            case ATTR_TYPE_INT64:
                {
                    double value;
                    rep.getValue(attr.first, value);
                    std::cout << " (int64): \t " << value << std::endl;
                    break;
                }
            case ATTR_TYPE_STRING:
                {
                    std::string value;
                    rep.getValue(attr.first, value);
                    std::cout << " (string): \t " << value << std::endl;
                    break;
                }
            case ATTR_TYPE_VECTOR:
                {
                    OC::OCRepresentation internal;
                    rep.getValue(attr.first, internal);
                    std::cout << std::endl;
                    processAttributes(internal, attr.second.composite, prefix + "\t");
                    break;
                }
            default:
                {
                    std::cout << "not handled yet" << std::endl;
                    break;
                }
        }
    }

}