//! //! Handles the client describe sensor request. //! //! @param[in] pStub a pointer to the node controller (NC) stub structure //! @param[in] pMeta a pointer to the node controller (NC) metadata structure //! @param[in] historySize teh size of the data history to retrieve //! @param[in] collectionIntervalTimeMs the data collection interval in milliseconds //! @param[in] instIds the list of instance identifiers string //! @param[in] instIdsLen the number of instance identifiers in the instIds list //! @param[in] sensorIds a list of sensor identifiers string //! @param[in] sensorIdsLen the number of sensor identifiers string in the sensorIds list //! @param[out] outResources a list of sensor resources created by this request //! @param[out] outResourcesLen the number of sensor resources contained in the outResources list //! //! @return the result of doDescribeSensors() //! //! @see doDescribeSensors() //! int ncDescribeSensorsStub(ncStub * pStub, ncMetadata * pMeta, int historySize, long long collectionIntervalTimeMs, char **instIds, int instIdsLen, char **sensorIds, int sensorIdsLen, sensorResource *** outResources, int *outResourcesLen) { return doDescribeSensors(pMeta, historySize, collectionIntervalTimeMs, instIds, instIdsLen, sensorIds, sensorIdsLen, outResources, outResourcesLen); }
adb_DescribeSensorsResponse_t *DescribeSensorsMarshal(adb_DescribeSensors_t *describeSensors, const axutil_env_t *env) { int result = ERROR; adb_describeSensorsType_t * input = adb_DescribeSensors_get_DescribeSensors(describeSensors, env); adb_describeSensorsResponseType_t * output = adb_describeSensorsResponseType_create(env); // get standard fields from input /////axis2_char_t * correlationId = adb_describeSensorsType_get_correlationId(input, env); /////axis2_char_t * userId = adb_describeSensorsType_get_userId(input, env); // get operation-specific fields from input int historySize = adb_describeSensorsType_get_historySize(input, env); long long collectionIntervalTimeMs = adb_describeSensorsType_get_collectionIntervalTimeMs(input, env); int instIdsLen = adb_describeSensorsType_sizeof_instanceIds(input, env); char ** instIds = malloc (sizeof(char *) * instIdsLen); if (instIds == NULL) { logprintfl (EUCAERROR, "out of memory for 'instIds' in 'DescribeSensorsMarshal'\n"); goto reply; } for (int i=0; i<instIdsLen; i++) { instIds[i] = adb_describeSensorsType_get_instanceIds_at(input, env, i); } int sensorIdsLen = adb_describeSensorsType_sizeof_sensorIds(input, env); char ** sensorIds = malloc (sizeof(char *) * sensorIdsLen); if (sensorIds == NULL) { logprintfl (EUCAERROR, "out of memory for 'sensorIds' in 'DescribeSensorsMarshal'\n"); goto reply; } for (int i=0; i<sensorIdsLen; i++) { sensorIds[i] = adb_describeSensorsType_get_sensorIds_at(input, env, i); } { // do it ncMetadata meta; EUCA_MESSAGE_UNMARSHAL(describeSensorsType, input, (&meta)); sensorResource **outResources; int outResourcesLen; int error = doDescribeSensors (&meta, historySize, collectionIntervalTimeMs, instIds, instIdsLen, sensorIds, sensorIdsLen, &outResources, &outResourcesLen); if (error) { logprintfl (EUCAERROR, "ERROR: doDescribeSensors() failed error=%d\n", error); } else { // set standard fields in output adb_describeSensorsResponseType_set_correlationId(output, env, meta.correlationId); adb_describeSensorsResponseType_set_userId(output, env, meta.userId); // set operation-specific fields in output for (int i=0; i<outResourcesLen; i++) { adb_sensorsResourceType_t * resource = copy_sensor_resource_to_adb (env, outResources[i]); if (outResources[i]) free(outResources[i]); adb_describeSensorsResponseType_add_sensorsResources(output, env, resource); } if (outResourcesLen>0 && outResources!=NULL) free (outResources); result = OK; // success } } reply: if (result == ERROR) { adb_describeSensorsResponseType_set_return(output, env, AXIS2_FALSE); } else { adb_describeSensorsResponseType_set_return(output, env, AXIS2_TRUE); } // set response to output adb_DescribeSensorsResponse_t * response = adb_DescribeSensorsResponse_create(env); adb_DescribeSensorsResponse_set_DescribeSensorsResponse(response, env, output); return response; }