6.10.3 GetChannelProperty

GetChannelProperty is used to get the channel property of the specified sensor channel.

The following is an example for using GetChannelProperty:

sensor_handle.call('GetChannelProperty', 
                   {'ChannelInfoMap':{'ChannelId': result['ChannelId'], 
                                      'ContextType': result['ContextType'], 
                                      'Quantity': result['Quantity'], 
                                      'ChannelType': result['ChannelType'], 
                                      'Location': result['Location'], 
                                      'VendorId': result['VendorId'], 
                                      'DataItemSize': result['DataItemSize'], 
                                      'ChannelDataTypeId': result['ChannelDataTypeId']}, 
                   'propertyId': u'DataRate'})

The following table summarizes the specification of GetChannelProperty:

Interface ISensor
Description Gets the specified property of a sensor channel.
Response Model Synchronous
Pre-condition ISensor interface is loaded.
Post-condition Client application receives the requested property details.

Input Parameters

Input parameters define the ChannelInfoMap and PropertyId.

Table 6.201: Input parameters for GetChannelProperty
Name Type Range Description
ChannelInfoMap map as mentioned in FindSensorChannel. Refer ChannelInfoMap 6.194 NA The map is obtained by invoking FindSensorChannel.
PropertyId unicode string Range for PropertyId:
DataRate
Availability
MeasureRange
ChannelDataFormat
ChannelAccuracy
ChannelScale
ScaledRange
ChannelUnit
SensorModel
ConnectionType
Description
The property ID string for which the property is being queried.


Output Parameters

Output contains ReturnValue. It also contains ErrorCode and an ErrorMessage if the operation fails. ReturnValue contains the requested channel property.

Table 6.202: Output parameters for GetChannelProperty
Name Type Range Description
ErrorCode int NA Contains the SAPI specific error code when the operation fails.
ErrorMessage string NA Error Description in Engineering English.
ReturnValue Channel property map:
Type: Name
string: PropertyId
32 bit int: PropertyDataType
32 bit Integer: ItemIndex
bool: ReadOnly
32 bit int/ double/ string: PropertyValue
The channel property can either be of type integer, double, or string.

Range for PropertyDataType:
0: For Integer datatype
1: For Double datatype
2: For String datatype

ReturnValue contains a map of key-value pair for channel property.


Errors

The following table lists the error codes and their values:

Table 6.203: Error codes
Error code value Description
0 Success
1002 Bad argument type
1003 Missing argument
1012 Item not found


Error Messages

The following table lists the error messages and their description:

Table 6.204: Error messages
Error messages Description
Sensors:GetChannelProperty: Property id missing Indicates that the property ID input parameter is missing.
Sensors:GetChannelProperty: Invalid property id Indicates that the input property ID is invalid and does not fall within the specified range of property ID strings.
Sensors:GetChannelProperty: ChannelInfoMap missing Indicates that the channel information map is not provided as input parameter.
Sensors:GetChannelProperty: Channel property not supported Indicates that the channel property is not supported hence no value is returned.
Sensors:GetChannelProperty: Incomplete input param list Indicates that the input param list is incomplete.


Example

The following sample code illustrates how to get the specified property of sensor channel:

try:
    result = sensor_handle.call('FindSensorChannel',
                                   {'SearchCriterion': u'Rotation'})

    ChannelId = result[0]['ChannelId']
    ContextType = result[0]['ContextType']
    Quantity = result[0]['Quantity']
    ChannelType = result[0]['ChannelType']
    Location = result[0]['Location']
    VendorId = result[0]['VendorId']
    DataItemSize = result[0]['DataItemSize']
    ChannelDataTypeId = result[0]['ChannelDataTypeId']

    result = sensor_handle.call('GetChannelProperty',
                    {'ChannelInfoMap':{'ChannelId': ChannelId,
                                       'ContextType': ContextType,
                                       'Quantity': Quantity,
                                       'ChannelType': ChannelType,
                                       'Location': Location,
                                       'VendorId': VendorId,
                                       'DataItemSize': DataItemSize,
                                       'ChannelDataTypeId': ChannelDataTypeId},
                                       'PropertyId': u'DataRate'})
    print "Property Id: ", result["PropertyId"]
    print "PropertyDataType: ", result["PropertyDataType"]
    print "ItemIndex: ",  result["ItemIndex"]
    print "ReadOnly: ", result["ReadOnly"]
    print "PropertyValue: ",result["PropertyValue"]

except scriptext.ScriptextError, err:
    print "Error performing the operation : ", err

See About this document... for information on suggesting changes.