Symbian3/SDK/Source/GUID-0CA7F22E-59D7-4D65-9D6C-735E4E0F0454.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-0CA7F22E-59D7-4D65-9D6C-735E4E0F0454" xml:lang="en"><title>Setting
Channel Properties</title><shortdesc>The channel properties can be configured using the <codeph>CSensrvChannel::SetProperty()</codeph> function.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<prereq id="GUID-578E2FA5-5265-4AF7-88EC-9BA5C143DDF7">       <p>Before setting
channel properties, you must <xref href="GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B.dita#GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B/GUID-FBBD3A8B-F240-4DC0-B516-3A51FDD86A88">open
the sensor channel</xref>.</p>     </prereq>
<steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-10-1-9-1-1-6-1-4-1-4-1-7-1-3-2">
<step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-10-1-9-1-1-6-1-4-1-4-1-7-1-3-2-1"><cmd>Create a <parmname>TSensrvProperty</parmname> property
object for setting the <parmname>KSensrvPropIdDataRate</parmname> property
using the <parmname>TSensrvProperty(const TSensrvPropertyId,const TInt,const
TInt)</parmname> constructor.</cmd>
<stepxmp><codeblock xml:space="preserve">...
TInt val=2;
TSensrvProperty sensrvProperty(KSensrvPropIdDataRate,KSensrvItemIndexNone,val);
...</codeblock></stepxmp>
</step>
<step id="GUID-3AC7711D-8CBB-427A-BEA1-800539AC1377"><cmd>Set the <parmname>KSensrvPropIdDataRate</parmname> property
value by passing the property object that you created to <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-B69100DD-522F-3B5A-AC65-DE1950A673F0"><apiname>CSensrvChannel::SetProperty()</apiname></xref>.</cmd>
<stepxmp><codeblock xml:space="preserve">...
CSensrvChannel* channel;
...
TInt ret;
ret=channel-&gt;SetProperty(sensrvProperty);
...</codeblock></stepxmp>
</step>
</steps>
<example><p>The following example explains how to set the x-axis of accelerometer
channel status from activated to deactivated. </p><p>The axis active property <parmname>KSensrvPropIdAxisActive</parmname> is
first retrieved using the <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-1E9D960B-23C4-30DF-A184-7E978AC9AC1B"><apiname>CSensrvChannel::GetPropertyL()</apiname></xref> function.
If the axis is active, the new <b>deactivated</b> value is set in the retrieved
property object. Then the channel is updated with this updated property object
by using the <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-B69100DD-522F-3B5A-AC65-DE1950A673F0"><apiname>CSensrvChannel::SetProperty()</apiname></xref> function.</p><codeblock xml:space="preserve">TSensrvProperty property;
    TInt err( KErrNone );
    TInt axisActive( 0 );
    iSensorChannel-&gt;GetPropertyL( KSensrvPropIdAxisActive,
                                  TSensrvAccelerometerAxisData::Index::iAxisX,
                                  property );
    property.GetValue( axisActive );
    if( 1 == axisActive )
        {
        property.SetValue( 0 ); // A value other than 1 means that sensor axis is deactivated.
        err = iSensorChannel-&gt;SetProperty( property );
        if( KErrNone == err )
            {
            //Accelerometer x-axis was successfully deactivated
            }
       }
    else
        {
        //Accelerometer x-axis is already inactive
        }</codeblock></example>
<postreq id="GUID-5155648B-6A69-4BF4-A5C2-83A8611F2B22"><p>End the session
with the sensor channel using the <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-0B8F50A6-2CA1-316A-82AB-AA026005E810"><apiname>CSensrvChannel::CloseChannel()</apiname></xref> function.</p></postreq>
</taskbody></task>