当前位置: 首页>>代码示例>>C++>>正文


C++ Counter::Get方法代码示例

本文整理汇总了C++中Counter::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::Get方法的具体用法?C++ Counter::Get怎么用?C++ Counter::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Counter的用法示例。


在下文中一共展示了Counter::Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

TEST_F(TestMemFnPointerSample, All) {
    Counter counter;
    CountLater countLater;

    int expected = 0;
    EXPECT_EQ(expected, counter.Get());

    counter.Increment();
    ++expected;
    EXPECT_EQ(expected, counter.Get());
    counter.Decrement();
    counter.Decrement();
    expected -= 2;
    EXPECT_EQ(expected, counter.Get());

    countLater.Execute();
    EXPECT_EQ(expected, counter.Get());

    countLater.ExecuteLater(&counter, &Counter::Decrement);
    EXPECT_EQ(expected, counter.Get());
    --expected;
    for(int i=0; i<2; ++i) {
        countLater.Execute();
        EXPECT_EQ(expected, counter.Get());
    }

    countLater.ExecuteLater(&counter, &Counter::Increment);
    EXPECT_EQ(expected, counter.Get());
    countLater.ExecuteLater(&counter, &Counter::Increment);
    ++expected;
    EXPECT_EQ(expected, counter.Get());
}
开发者ID:zettsu-t,项目名称:cppMockgen,代码行数:32,代码来源:mockgenSampleTestBody.cpp

示例2: GetCounter

/**
 * Read the current counter value.
 * Read the value at this instant. It may still be running, so it reflects the current value. Next
 * time it is read, it might have a different value.

 * @param channel The channel of the digital input used with this counter
 */
INT32 GetCounter(UINT32 channel)
{
    Counter *counter = AllocateCounter(channel);
    if (counter != NULL)
        return counter->Get();
    else
        return 0;
}
开发者ID:anidev,项目名称:frc-simulator,代码行数:15,代码来源:CCounter.cpp

示例3: UpdateGearCount

	void UpdateGearCount ()
	//this function turns the relative gear tooth counter into an absolute counter
	{
		if (curForkSetSpeed < 0)
			forkDirection = inwards;
		else //curForkSetSpeed > 0; this function should not be called when curForkSpeed = 0, should on be called when the forks are moving;
			forkDirection = outwards;

		curGearToothCount = gearToothCounter->Get();
		absGearToothCount += forkDirection*(curGearToothCount-lastGearToothCount);
		lastGearToothCount = curGearToothCount;
	}
开发者ID:prajwal1121,项目名称:2015,代码行数:12,代码来源:Robot.cpp

示例4: TeleopPeriodic

	void TeleopPeriodic()
	{
		char myString [STAT_STR_LEN];

		if (initialZeroing)  // moving to the inner limit
		{
			sprintf(myString, "initZero ip\n"); //in progress
			SmartDashboard::PutString("DB/String 0", myString);
			if (GetForkLimitSwitchMin())
			{
				SetForkMotor(MOTOR_SPEED_STOP);
				gearToothCounter->Reset();
				initialZeroing = false;
				sprintf(myString, "initZero comp\n"); //complete
				SmartDashboard::PutString("DB/String 0", myString);
			}
		}
		else  //manual control
		{
			//motor control
			if (joystick->GetRawButton(BUT_JS_OUT) && !GetForkLimitSwitchMax())  // move outwards
				SetForkMotor(MOTOR_SPEED_GO);
			else if(joystick->GetRawButton(BUT_JS_IN) && !GetForkLimitSwitchMin())  // move inwards
				SetForkMotor(-MOTOR_SPEED_GO);
			else
				SetForkMotor(MOTOR_SPEED_STOP); //stop

			//counter control
			if (joystick->GetRawButton(BUT_JS_RES_GTC))  // reset the gear tooth counter
				gearToothCounter->Reset();
		}

		//status
		sprintf(myString, "jsOut %d\n", joystick->GetRawButton(BUT_JS_OUT));
		SmartDashboard::PutString("DB/String 1", myString);
		sprintf(myString, "jsIn %d\n", joystick->GetRawButton(BUT_JS_IN));
		SmartDashboard::PutString("DB/String 2", myString);
		sprintf(myString, "jsResGtc %d\n", joystick->GetRawButton(BUT_JS_RES_GTC));
		SmartDashboard::PutString("DB/String 3", myString);
		sprintf(myString, "curr: %f\n", forkMotor->GetOutputCurrent());
		SmartDashboard::PutString("DB/String 4", myString);
		sprintf(myString, "gtc #: %d\n", gearToothCounter->Get()); //gtc count
		SmartDashboard::PutString("DB/String 5", myString);
	}
开发者ID:prajwal1121,项目名称:2015,代码行数:44,代码来源:Robot.cpp

示例5: TeleopPeriodic

	void TeleopPeriodic()
	{
		char myString[64];
		float   y;


// get the joystick position and filter the deadband
		y = -joystick->GetY();

		if (y > -0.1 && y < 0.1)
			y = 0;

		sprintf(myString, "joystick setting: %f\n", y);
		SmartDashboard::PutString("DB/String 1", myString);
		motor->Set(y, 0); // set the speed of the motor
		sprintf(myString, "gear count: %d\n", gearToothCounter->Get());
		SmartDashboard::PutString("DB/String 2", myString);
		sprintf(myString, "gear stopped: %d\n", gearToothCounter->GetStopped());
		SmartDashboard::PutString("DB/String 3", myString);

//		sprintf(myString, "In val: %d\n", toothInput->GetValue());
//		SmartDashboard::PutString("DB/String 2", myString);
	}
开发者ID:prajwal1121,项目名称:2015,代码行数:23,代码来源:Robot.cpp


注:本文中的Counter::Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。