javaextensions/sensor/src.s60/csensorlimitcondition.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Limit condition implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "csensorlimitcondition.h"
       
    19 #include "sensornativeconstants.h"
       
    20 #include "logger.h"
       
    21 
       
    22 CSensorLimitCondition::CSensorLimitCondition(
       
    23     TInt aChannelId, TReal64& aLimit, TInt aOp)
       
    24         : CSensorConditionBase(aChannelId), iLimit(aLimit), iOp(aOp)
       
    25 {
       
    26     JELOG2(ESensor);
       
    27 }
       
    28 
       
    29 CSensorLimitCondition::~CSensorLimitCondition()
       
    30 {
       
    31     JELOG2(ESensor);
       
    32 }
       
    33 
       
    34 TBool CSensorLimitCondition::Evaluate(TReal aValue, TInt aChannelId)
       
    35 {
       
    36     JELOG2(ESensor);
       
    37     if (aChannelId != iChannelId)
       
    38     {
       
    39         return EFalse;
       
    40     }
       
    41     switch (iOp)
       
    42     {
       
    43     case INT_EQUALS:
       
    44     {
       
    45         return aValue == iLimit;
       
    46     }
       
    47     case INT_GREATER_THAN:
       
    48     {
       
    49         return aValue > iLimit;
       
    50     }
       
    51     case INT_GREATER_THAN_OR_EQUALS:
       
    52     {
       
    53         return aValue >= iLimit;
       
    54     }
       
    55     case INT_LESS_THAN:
       
    56     {
       
    57         return aValue < iLimit;
       
    58     }
       
    59     case INT_LESS_THAN_OR_EQUALS:
       
    60     {
       
    61         return aValue <= iLimit;
       
    62     }
       
    63     }
       
    64     return EFalse;
       
    65 }