Ejemplo n.º 1
0
void CSensorImpl::setProperties(const rho::Hashtable<rho::String, rho::String>& propertyMap, rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request to set properties : " + m_sensorId;

    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot set properties");
    } else
    {
        for (rho::Hashtable<rho::String, rho::String>::const_iterator propMapItr = propertyMap.begin(); propMapItr != propertyMap.end(); propMapItr++)
        {
            if (_stricmp(propMapItr->first.c_str(), "minimumGap") == 0)
            {
                int minimumGap = atoi(propMapItr->second.c_str());
                if (minimumGap < 200)
                {
                    minimumGap = 200;
                }
                this->m_rawSensor->setMinimumGap(minimumGap);
            } else
            {
                oResult.setError(propMapItr->first + " is readonly or is invalid.");
            }
        }
    }
}
Ejemplo n.º 2
0
void CSensorImpl::getProperties(const rho::Vector<rho::String>& arrayofNames, rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request for get properties : " + m_sensorId;

    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot get properties");
    } else
    {
        rho::Hashtable<rho::String, rho::String> propsHash;
        for (rho::Vector<rho::String>::const_iterator namesIterator = arrayofNames.begin(); namesIterator != arrayofNames.end(); namesIterator++)
        {
            if (_stricmp((*namesIterator).c_str(), "minimumGap") == 0)
            {
                propsHash.put(*namesIterator, rho::common::convertToStringA<int>(this->m_rawSensor->getMinimumGap()));
            } else if (_stricmp((*namesIterator).c_str(), "type") == 0)
            {
                propsHash.put(*namesIterator, this->m_rawSensor->getType());
            } else if (_stricmp((*namesIterator).c_str(), "status") == 0)
            {
                propsHash.put(*namesIterator, this->m_rawSensor->getStatus());
            } else
            {
                propsHash.put(*namesIterator, "Invalid attribute");
            }
        }
        oResult.set(propsHash);
    }


}
Ejemplo n.º 3
0
void CSensorImpl::getType(rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Request received for type : " + m_sensorId;
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot get type.");
    } else
    {
        oResult.set(this->m_rawSensor->getType());
    }
}
Ejemplo n.º 4
0
        //methods
        virtual void start( int interval, rho::apiGenerator::CMethodResult& oResult) 
		{
			if (interval <= 0)
			{
				oResult.setError("invalid interval");
				return;
			}

			m_oResult = oResult;
			common::CRhoTimer& timerManager = RHODESAPP().getTimer();
			timerManager.addNativeTimer(interval, this);
        } 
Ejemplo n.º 5
0
void CSensorImpl::setProperty(const rho::String& propertyName,  const rho::String& propertyValue, rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request to set property : " + m_sensorId + " : " + propertyName + " = " + propertyValue;
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot set property " + propertyName);
    } else
    {
        if (_stricmp(propertyName.c_str(), "minimumGap") == 0)
        {
            int minimumGap = atoi(propertyValue.c_str());
            if (minimumGap < 200)
            {
                minimumGap = 200;
            }
            this->m_rawSensor->setMinimumGap(minimumGap);            
        } else
        {
            oResult.setError(propertyName + " is readonly or is invalid.");
        }
    }
}
Ejemplo n.º 6
0
void CSensorImpl::getProperty(const rho::String& propertyName, rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request for get property : " + m_sensorId + " : " + propertyName;
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot set " + propertyName);
    } else
    {
        if (_stricmp(propertyName.c_str(), "minimumGap") == 0)
        {
            oResult.set(this->m_rawSensor->getMinimumGap());
        } else if (_stricmp(propertyName.c_str(), "type") == 0)
        {
            oResult.set(this->m_rawSensor->getType());
        } else if (_stricmp(propertyName.c_str(), "status") == 0)
        {
            oResult.set(this->m_rawSensor->getStatus());
        } else
        {
            oResult.setError("Invalid attribute");
        }
    }
}
Ejemplo n.º 7
0
void CSensorImpl::setMinimumGap(int minimumGap, rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Request received to set minimum gap : " + m_sensorId + " : to " + rho::common::convertToStringA<int>(minimumGap);
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot set minimumegap.");
    }
    else
    {
        if (minimumGap < 200)
            minimumGap = 200;         
        this->m_rawSensor->setMinimumGap(minimumGap);
        oResult.set(true);
    }
}
Ejemplo n.º 8
0
void CSensorImpl::getAllProperties(rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request for get all properties : " + m_sensorId;

    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot get properties");
    } else
    {
        rho::Hashtable<rho::String, rho::String> propsHash;

        propsHash.put("minimumGap", rho::common::convertToStringA<int>(this->m_rawSensor->getMinimumGap()));
        propsHash.put("type", this->m_rawSensor->getType());
        propsHash.put("status", this->m_rawSensor->getStatus());
        oResult.set(propsHash);

    }

}
Ejemplo n.º 9
0
void CSensorImpl::stop(rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request to stop sensor: " + m_sensorId;
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot get stop.");
    }
    else
    {
        
        this->m_rawSensor->Stop();
        if ((NULL != m_callbackMethodResult) && (m_callbackMethodResult->hasCallback()))
        {
            m_callbackMethodResult = NULL;

        }
        rho::common::CMutexLock lock(m_cs);
        m_cache.clear();
    }
}
Ejemplo n.º 10
0
void CSensorImpl::readData(rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request to readData: " + m_sensorId;
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot get stop.");
    }
    else
    {
        rho::common::CMutexLock lock(m_cs);
        if (m_cache.empty())
        {
            rho::Hashtable<rho::String, rho::String> props;
            props.put("message", "No Samples received from sensor. Check status");// The sampling is stopped (check status) or retry based on the minium gap property or reduce the gap interval");
	        props.put("status", "error");
            oResult.set(props);
        }
        else
            oResult.set(m_cache);
    }
}
Ejemplo n.º 11
0
void CSensorImpl::start(rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request to start sensor: " + m_sensorId;
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot get start.");
    }
    else
    {
        //const char * status = m_rawSensor->getStatus();
        this->m_rawSensor->Start();
        rho::common::CMutexLock lock(m_cs);
        if (oResult.hasCallback())
        {
            m_callbackMethodResult = &oResult;
        }
        else
        {
            m_callbackMethodResult = NULL;
        }
    }

}
Ejemplo n.º 12
0
void CSystemImpl::setWindowSize(int, int, rho::apiGenerator::CMethodResult& result)
{
    result.setError("not implemented at Android platform");
}
Ejemplo n.º 13
0
void CSystemImpl::getScreenSleeping(rho::apiGenerator::CMethodResult& result)
{
    result.setError("not implemented at Android platform");
}
Ejemplo n.º 14
0
void CSystemImpl::setShowKeyboard(bool, rho::apiGenerator::CMethodResult& result)
{
    result.setError("not implemented at Android platform");
}
Ejemplo n.º 15
0
void CSystemImpl::setHttpProxyURI(const rho::String&, rho::apiGenerator::CMethodResult& result)
{
    result.setError("not implemented at Android platform");
}