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


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

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


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

示例1: Reset

 void Reset() {
   m_talonCounter->Reset();
   m_victorCounter->Reset();
   m_jaguarCounter->Reset();
   m_talon->Set(0.0f);
   m_victor->Set(0.0f);
   m_jaguar->Set(0.0f);
 }
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:8,代码来源:CounterTest.cpp

示例2: 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

示例3: UpdateNormalSequence

// Update normal light sequence by checking the main counter
int UpdateNormalSequence(int goLightTime) {     
    int i = 1;
    while (mainCounter.GetCounter() > i * goLightTime)
        i++;
    
    // On Select Sequence Button, cycle through the sequences immediately
    if (btnSelectSequence.IsPressed()) {
        // reset the main counter to start of new sequence
        mainCounter.Reset(i * goLightTime);
        i++;
    }
        
    // if maximum sequences has reached reset the main counter
    if (i == MAX_SEQUENCES + 1) {
        mainCounter.Reset();
        i = 1;
    }
    
    return i;
}
开发者ID:Swoorup,项目名称:ardu-trafficlight,代码行数:21,代码来源:trafficlightsystem.cpp

示例4: setup

void setup()
{
    Serial.begin(SERIAL_BAUD);
    
    trafficLight0.SetPins(
        PIN_GREEN_LIGHT_0, 
        PIN_ORANGE_LIGHT_0, 
        PIN_RED_LIGHT_0,
        PIN_FILTERTURN_LIGHT_0,
        PIN_PED_LIGHT_0,
        PIN_PEDCROSS_BUZZER_0
    );
    
    trafficLight90.SetPins(
        PIN_GREEN_LIGHT_90, 
        PIN_ORANGE_LIGHT_90, 
        PIN_RED_LIGHT_90,
        PIN_FILTERTURN_LIGHT_90,
        PIN_PED_LIGHT_90,
        PIN_PEDCROSS_BUZZER_90
    );
    
    trafficLight270.SetPins(
        PIN_GREEN_LIGHT_270, 
        PIN_ORANGE_LIGHT_270, 
        PIN_RED_LIGHT_270,
        PIN_FILTERTURN_LIGHT_270,
        PIN_PED_LIGHT_270,
        PIN_PEDCROSS_BUZZER_270
    );
    
    mainCounter.Reset();
    
    pot.SetPin(PIN_POT);
    pot.ApplySmoothing();
    
    ther.SetPin(PIN_THER);
    ther.SetFixedResistorR2(10000);
    ther.SetVIn(5);
    ther.ApplySmoothing();
    
    ldr.SetPin(PIN_LDR);
    ldr.SetFixedResistorR2(10000);
    ldr.SetVIn(5);
    ldr.ApplySmoothing();
    
    btnEmergency.SetPin(PIN_BTN_EMERGENCY);
    btnRoadWork.SetPin(PIN_BTN_ROADWORK);
    
    btnSelectSequence.SetPin(PIN_BTN_SELECTSEQUENCE);
    btnPedCross0.SetPin(PIN_BTN_PEDCROSS_0);
    btnPedCross270.SetPin(PIN_BTN_PEDCROSS_270);
    btnPedCross90.SetPin(PIN_BTN_PEDCROSS_90);
}
开发者ID:Swoorup,项目名称:ardu-trafficlight,代码行数:54,代码来源:trafficlightsystem.cpp

示例5: FlashForRoadWork

// on road work mode flash orange light only at all junction
void FlashForRoadWork() {
    static Counter roadWorkCounter;
    // flash the orange light by checking the counter time
    if(roadWorkCounter.GetCounter() <= 500) {
        trafficLight0.RoadWorkLightOnly();
        trafficLight90.RoadWorkLightOnly();
        trafficLight270.RoadWorkLightOnly();
    }
    else if(roadWorkCounter.GetCounter() <= 1000) {
        trafficLight0.ledOrange.SwitchOff();
        trafficLight90.ledOrange.SwitchOff();
        trafficLight270.ledOrange.SwitchOff();
    }
    else
        roadWorkCounter.Reset();
}
开发者ID:Swoorup,项目名称:ardu-trafficlight,代码行数:17,代码来源:trafficlightsystem.cpp

示例6: FlashForPedCrossFinish

// on ped crossing mode when time is finished flash ped light at all junction
void FlashForPedCrossFinish() {
    static Counter pedCrossCounter;
    // flash the ped light by checking the counter time
    if(pedCrossCounter.GetCounter() <= 500) {
        trafficLight270.ledPed.SwitchOn();
        trafficLight0.ledPed.SwitchOn();
        trafficLight90.ledPed.SwitchOn();
    }
    else if(pedCrossCounter.GetCounter() <= 1000) {
        trafficLight0.ledPed.SwitchOff();
        trafficLight90.ledPed.SwitchOff();
        trafficLight270.ledPed.SwitchOff();
    }
    else
        pedCrossCounter.Reset();
}
开发者ID:Swoorup,项目名称:ardu-trafficlight,代码行数:17,代码来源:trafficlightsystem.cpp

示例7: UpdateWithLightTransition

 // this function simulates normal light condition when called at every loop
 // it automatically transitions from green to red signal by using the OrangeTransitionCounter
 void UpdateWithLightTransition(bool goSignal, bool turnLight, bool pedLight, int orangeLightTime) {
 
     // if green or go signal turn off transitioning process 
     // and only light up the green light
     if (goSignal) {
         transitionState = 0;
         GreenLight();
     }
     
     // if red signal and green light was previously on
     // start transitioning to red by firt turning on the 
     // orange light
     else if(!goSignal && ledGreen.IsOn() && transitionState == 0) {
         OrangeLight();
         transitionState = 1;
         OrangeTransitionCounter.Reset();
     } 
     // if red signal and greenlight was not on, directly
     // switch on the red light
     else if(!goSignal && !ledGreen.IsOn() && transitionState == 0)
         RedLight();
     
     // check if we are still transitioning to red light
     // if orangeTransitionCounter has passed orangeLightTime interval 
     // turn on the Red light only
     if (transitionState == 1) {
         if (OrangeTransitionCounter.GetCounter() < orangeLightTime)
             OrangeLight();
         else
             transitionState = 2;
     }
     
     if (transitionState == 2)
         RedLight();
         
     if (turnLight)
         ledFilterTurn.SwitchOn();
     else
         ledFilterTurn.SwitchOff();
     
     // ped lights turn on only when the normal lights are in red signal
     if (pedLight && ledRed.IsOn())
         ledPed.SwitchOn();
     else
         ledPed.SwitchOff();
 }
开发者ID:Swoorup,项目名称:ardu-trafficlight,代码行数:48,代码来源:trafficlightsystem.cpp

示例8: main

int main()
{
    Counter MomCounter;
    char choice;

    cout<<setw(4)<<setfill('0') << endl <<MomCounter.GetCount() << endl << endl;

    cin>>choice;

    choice=toupper(choice);


    while(choice!='X')
    {
        switch(choice)
        {

            case 'F':
                if(MomCounter.GetCount()+1<=MomCounter.GetMax())
                {
                MomCounter.Incr1();
                }
                else
                {
                    cout << "\n|OVERFLOW|\n";
                }

                break;

            case 'D':
                if(MomCounter.GetCount()+10<=MomCounter.GetMax())
                {
                    MomCounter.Incr10();
                }
                else
                {
                    cout << "\n|OVERFLOW|\n";
                }
                break;

            case 'S':
                if(MomCounter.GetCount()+100<=MomCounter.GetMax())
                {
                    MomCounter.Incr100();
                }
                else
                {
                    cout << "\n|OVERFLOW|\n";
                }
                break;

            case 'A':
                if(MomCounter.GetCount()+1000<=MomCounter.GetMax())
                {
                    MomCounter.Incr1000();
                }
                else
                {
                    cout << "\n|OVERFLOW|\n";
                }
                break;


            case 'R':
                MomCounter.Reset();
                break;


        }
        cout<<setw(4)<<setfill('0') << endl <<MomCounter.GetCount() << endl;
        cout<<"\n:" ;
        cin>>choice;


        choice = toupper(choice);
    }

    
    return 0;
}
开发者ID:jonathanpchan,项目名称:SchoolWork,代码行数:80,代码来源:main.cpp

示例9: ResetCounter

/**
 * Reset the Counter to zero.
 * Set the counter value to zero. This doesn't effect the running state of the counter, just sets
 * the current value to zero.
 * @param slot The slot the digital module is plugged into
 * @param channel The channel of the digital input used with this counter
 */
void ResetCounter(UINT8 moduleNumber, UINT32 channel)
{
    Counter *counter = AllocateCounter(moduleNumber, channel);
    if (counter != NULL)
        counter->Reset();
}
开发者ID:anidev,项目名称:frc-simulator,代码行数:13,代码来源:CCounter.cpp

示例10: AddPedCrossStageOnRequest

// function to allow for ped crossing on the press of a button
// ped crossing works by pausing the main counter at the end of a sequence 
// and resuming after the ped has crossed.
// returns whether alarm is currently on progression or not
bool AddPedCrossStageOnRequest(int state, int pedCrossTime, int orangeLightTime){
#define NO_PED_CROSS 0
#define PED_CROSS_BTN_PRESSED 1
#define PED_CROSS_IN_PROGRESS 2
    static int alarmState = 0;
    
    // check for button presses at all the junctions
    if(btnPedCross0.IsPressed() || btnPedCross90.IsPressed() || btnPedCross270.IsPressed())
        if (alarmState == NO_PED_CROSS) alarmState = PED_CROSS_BTN_PRESSED;
    
    // update the buzzer asyncronously
    trafficLight0.crossingBuzzer.UpdateAsync();
    trafficLight90.crossingBuzzer.UpdateAsync();
    trafficLight270.crossingBuzzer.UpdateAsync();
    
    static int prevState = 0;
    static Counter pedCrossCounter;
    
    // check if the current sequence has ended
    if (prevState != state && alarmState == PED_CROSS_BTN_PRESSED) {
        // pause the timer
        mainCounter.Pause();
        // reset the crossing counter to 0
        pedCrossCounter.Reset();
        // activate the flag to transition all the green signal to red first
        alarmState = PED_CROSS_IN_PROGRESS; 
        return true;
    }

    if (alarmState == PED_CROSS_IN_PROGRESS) {
        if (pedCrossCounter.GetCounter() <= pedCrossTime) {
                // if there were no green lights from the previous sequence, directly turn on the red light
                if (trafficLight0.ledRed.IsOn() && trafficLight90.ledRed.IsOn() && trafficLight270.ledRed.IsOn())
                {
                    trafficLight270.UpdateWithLightTransition(0, 0, 1, orangeLightTime);
                    trafficLight0.UpdateWithLightTransition(0, 0, 1, orangeLightTime);
                    trafficLight90.UpdateWithLightTransition(0, 0, 1, orangeLightTime);
                    trafficLight0.crossingBuzzer.TriggerAlarm();
                    trafficLight90.crossingBuzzer.TriggerAlarm();
                    trafficLight270.crossingBuzzer.TriggerAlarm();
                }
                // if there were green lights on the previous sequence, transition to red first
                else {
                    trafficLight270.UpdateWithLightTransition(0, 0, 0, orangeLightTime);
                    trafficLight0.UpdateWithLightTransition(0, 0, 0, orangeLightTime);
                    trafficLight90.UpdateWithLightTransition(0, 0, 0, orangeLightTime);
                    trafficLight0.crossingBuzzer.TurnOffAlarm();
                    trafficLight90.crossingBuzzer.TurnOffAlarm();
                    trafficLight270.crossingBuzzer.TurnOffAlarm();
                }
                return true;
        } 
        // if ped cross time has finish blink the ped light as in australian ped crossing
        else if (pedCrossCounter.GetCounter() <= pedCrossTime + orangeLightTime) {
            FlashForPedCrossFinish();
            trafficLight0.crossingBuzzer.TurnOffAlarm();
            trafficLight90.crossingBuzzer.TurnOffAlarm();
            trafficLight270.crossingBuzzer.TurnOffAlarm();
            return true;
        } 
        else {
            alarmState = NO_PED_CROSS;
        }
    }
    prevState = state;
    return false;
}
开发者ID:Swoorup,项目名称:ardu-trafficlight,代码行数:71,代码来源:trafficlightsystem.cpp

示例11: TRAFFICLIGHT

 TRAFFICLIGHT() {
     OrangeTransitionCounter.Reset();
     transitionState = 0;
 }
开发者ID:Swoorup,项目名称:ardu-trafficlight,代码行数:4,代码来源:trafficlightsystem.cpp


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