Esempio n. 1
0
returnValue PIDcontroller::determineControlAction(	const Vector& error,
													Vector& output
													)
{
	uint i;
	double tmp;
	
	output.init( getNumOutputs() );
	output.setZero( );

	// update integral value
	for( i=0; i<getNumInputs(); ++i )
		iValue(i) += error(i) * getSamplingTime( );

	// determine outputs
	for( i=0; i<getNumInputs(); ++i )
	{
		tmp  = pWeights(i) * error(i);
		tmp += iWeights(i) * iValue(i);
		tmp += dWeights(i) * (error(i) - lastError(i)) / getSamplingTime( );

		if ( getNumOutputs( ) > 1 )
			output(i) = tmp;
		else
			output(0) += tmp;
	}

	// update last error
	lastError = error;

	return SUCCESSFUL_RETURN;
}
void CLog_idle::CheckedRunL()
{
    CALLSTACKITEM_N(_CL("CLog_idle"), _CL("CheckedRunL"));

    if (iStatus!=KErrNone) {
        if (User::InactivityTime().Int()>iTimeOut) {
            iCurrentState=EActive;
        } else {
            iCurrentState=EIdle;
        }
    }

    if (iCurrentState==EIdle) {
        iValue()=_L("active");
        iCurrentState=EActive;
        iTimer.Inactivity(iStatus, iTimeOut);
    } else {
        iValue()=_L("idle");
        iCurrentState=EIdle;
        iTimer.Inactivity(iStatus, 0);
    }
    iEvent.iData()=&iValue;
    iEvent.iStamp()=GetTime();
    post_new_value(iEvent);
    SetActive();
}
void CLog_idle::GetState()
{
    CALLSTACKITEM_N(_CL("CLog_idle"), _CL("GetState"));

    if (User::InactivityTime().Int()>iTimeOut) {
        iCurrentState=EIdle;
        iValue()=_L("idle");
    } else {
        iCurrentState=EActive;
        iValue()=_L("active");
    }
}
Esempio n. 4
0
USING_MX_NAMESPACE

TEST(CoordinateArraySequence_resize)
{
	VarSequenceInt array(1,12);
	EXPECT_TRUE(array.size() == 12);

	array.resize(25,123);
	EXPECT_TRUE(array.size() == 25);

	for(int i=12;i<25;i++)
	{
		EXPECT_TRUE(array.getValue(i,1) == 123);
	}

	VarSequenceDouble iValue(2,3);
	iValue.setValue(0,1,0);
	iValue.setValue(0,2,1);
	iValue.setValue(1,1,2);
	iValue.setValue(1,2,3);
	iValue.setValue(2,1,4);
	iValue.setValue(2,2,5);

	for(int i=0;i<3;i++)
	{
		EXPECT_TRUE(iValue.getValue(i,1) == i * 2);
		EXPECT_TRUE(iValue.getValue(i,2) == (i * 2 + 1));
	}
}
void CBluetoothPhysicalLinkMetricSubscriber::SubscribePhysicalLinkMetric(TBTLMIoctls aIoctl)
	{
	if (!IsActive())
		{
		iPhysicalLinkMetric = aIoctl;
		iValue() = KMaxTInt;
		// KMaxTInt is not a valid value that will be returned by the controller, so this is used
		// as a value to get the initial value from the stack.
		iBaseband.ReadNewPhysicalLinkMetricValue(iStatus, iValue, iPhysicalLinkMetric);
		SetActive();
		}
	}
void CBluetoothPhysicalLinkMetricSubscriber::RunL()
	{
	User::LeaveIfError(iStatus.Int());
	iBaseband.ReadNewPhysicalLinkMetricValue(iStatus, iValue, iPhysicalLinkMetric);
	SetActive();
	switch (iPhysicalLinkMetric)
		{
		case KLMReadRssiIoctl:
			iParent.RssiChanged(iValue());
			break;
		case KLMReadCurrentTransmitPowerLevelIoctl:
			iParent.TransmitPowerLevelChanged(iValue());
			break;
		case KLMReadLinkQualityIoctl:
			iParent.LinkQualityChanged(iValue());
			break;
		case KLMReadFailedContactCounterIoctl:
			iParent.FailedContactCounterChanged(iValue());
			break;
		default:
			__ASSERT_ALWAYS(EFalse,User::Panic(KPhysLinkMetricFaultCat, EInvalidMetric));
		}
	}
Esempio n. 7
0
	float InputAssignment::fValue() const
	{
		return float(iValue());
	}