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."); } } } }
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); } }
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()); } }
//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); }
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."); } } }
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"); } } }
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); } }
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); } }
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(); } }
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); } }
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; } } }
void CSystemImpl::setWindowSize(int, int, rho::apiGenerator::CMethodResult& result) { result.setError("not implemented at Android platform"); }
void CSystemImpl::getScreenSleeping(rho::apiGenerator::CMethodResult& result) { result.setError("not implemented at Android platform"); }
void CSystemImpl::setShowKeyboard(bool, rho::apiGenerator::CMethodResult& result) { result.setError("not implemented at Android platform"); }
void CSystemImpl::setHttpProxyURI(const rho::String&, rho::apiGenerator::CMethodResult& result) { result.setError("not implemented at Android platform"); }