Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::control::HoldRepeatCommandMapping Class Reference

#include <hold_repeat_command_mapping.hpp>

Inheritance diagram for tap::control::HoldRepeatCommandMapping:
Collaboration diagram for tap::control::HoldRepeatCommandMapping:

Public Member Functions

 HoldRepeatCommandMapping (Drivers *drivers, const std::vector< Command * > cmds, const RemoteMapState &rms, bool endCommandsWhenNotHeld, int maxTimesToSchedule=-1)
 
 ~HoldRepeatCommandMapping () override=default
 
void executeCommandMapping (const RemoteMapState &currState) override
 
mockable void setMaxTimesToSchedule (int maxTimes)
 Set the maximum times each of commands should be re-scheduled.
 
- Public Member Functions inherited from tap::control::CommandMapping
 CommandMapping (Drivers *drivers, const std::vector< Command * > cmds, const RemoteMapState &rms)
 
virtual ~CommandMapping ()=default
 
virtual bool mappingSubset (const RemoteMapState &mapState)
 
const RemoteMapStategetAssociatedRemoteMapState () const
 
const std::vector< Command * > & getAssociatedCommands () const
 

Protected Member Functions

void incrementRescheduleCount (int cmdIndex)
 
bool okToScheduleCommand (int cmdIndex) const
 
- Protected Member Functions inherited from tap::control::CommandMapping
void addCommands ()
 
void removeCommands ()
 
bool noCommandsScheduled () const
 

Protected Attributes

bool held
 
bool endCommandsWhenNotHeld
 
int maxTimesToSchedule
 
std::vector< int > rescheduleCounts
 
- Protected Attributes inherited from tap::control::CommandMapping
const RemoteMapState mapState
 
std::vector< Command * > mappedCommands
 
Driversdrivers
 

Additional Inherited Members

- Static Public Member Functions inherited from tap::control::CommandMapping
static bool negKeysSubset (const RemoteMapState &state1, const RemoteMapState &state2)
 

Detailed Description

A CommandMapping that adds Commands when the contained mapping is a subset of the remote mapping. If a Command finishes and the contained mapping is still a subset of the remote mapping, it is added again. It then removes the Commands when the mapping is no longer a subset if endCommandsWhenNotHeld is true, or doesn't end commands if endCommandsWhenNotHeld is false. Furthermore, will stop scheduling commands if maxTimesToSchedule is not -1 after the command has been added to the scheduler maxTimesToSchedule.

Additionally, When neg keys are being used and the mapping's neg keys are a subset of the remote map state, the Commands are removed.

Constructor & Destructor Documentation

◆ HoldRepeatCommandMapping()

tap::control::HoldRepeatCommandMapping::HoldRepeatCommandMapping ( Drivers drivers,
const std::vector< Command * >  cmds,
const RemoteMapState rms,
bool  endCommandsWhenNotHeld,
int  maxTimesToSchedule = -1 
)
inline

Constructor must take the set of Commands and the RemoteMapState.

Parameters
[in]driversGlobal drivers instance.
[in]cmdsvector of commands that will be scheduled by this command mapping.
[in]rmsRemoteMapState that controls when commands will be scheduled.
[in]endCommandsWhenNotHeldIf true, the commands will be forcibly ended by the command mapping when no longer being held. Otherwise, the commands will naturally finish.
[in]maxTimesToScheduleNumber of times to reschedule each of the commands. If -1 is passed in, the command mapping will continue to reschedule the commands forever. If there are multiple commands that have the potential to end, each command will be scheduled maxTimesToSchedule.

◆ ~HoldRepeatCommandMapping()

tap::control::HoldRepeatCommandMapping::~HoldRepeatCommandMapping ( )
overridedefault

Default destructor.

Member Function Documentation

◆ executeCommandMapping()

void tap::control::HoldRepeatCommandMapping::executeCommandMapping ( const RemoteMapState currState)
overridevirtual

Using currState, determines whether or not to add or remove Commands from the main scheduler. Up the the implementer to determine what the criteria for adding and removing Commands should be.

Parameters
[in]currStateThe current state of the remote.

Implements tap::control::CommandMapping.

◆ incrementRescheduleCount()

void tap::control::HoldRepeatCommandMapping::incrementRescheduleCount ( int  cmdIndex)
inlineprotected

◆ okToScheduleCommand()

bool tap::control::HoldRepeatCommandMapping::okToScheduleCommand ( int  cmdIndex) const
inlineprotected

◆ setMaxTimesToSchedule()

mockable void tap::control::HoldRepeatCommandMapping::setMaxTimesToSchedule ( int  maxTimes)
inline

Set the maximum times each of commands should be re-scheduled.

Member Data Documentation

◆ endCommandsWhenNotHeld

bool tap::control::HoldRepeatCommandMapping::endCommandsWhenNotHeld
protected

◆ held

bool tap::control::HoldRepeatCommandMapping::held
protected

◆ maxTimesToSchedule

int tap::control::HoldRepeatCommandMapping::maxTimesToSchedule
protected

◆ rescheduleCounts

std::vector<int> tap::control::HoldRepeatCommandMapping::rescheduleCounts
protected

The documentation for this class was generated from the following files: