Accessories
Arduino for motors and lights library.
AccessoryMotor Class Referenceabstract

#include "AccessoryMotor.hpp"

Inheritance diagram for AccessoryMotor:
Accessory AccessoryMotorOneWay AccessoryMotorTwoWays

Public Member Functions

 AccessoryMotor ()
 
bool ActionEnded ()
 
bool IsLeft () const
 
bool IsRight () const
 
bool IsStopped () const
 
void begin (Port *inpPort, unsigned long inId, int inSpeed, unsigned long inDurationMilli = 0)
 
void Event (unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0)
 
int EEPROMLoad (int inPos)
 
void Move (unsigned long inId)
 
virtual void MoveLeft (unsigned long inDuration = 0, int inSpeed = 0)
 
virtual void MoveRight (unsigned long inDuration = 0, int inSpeed = 0)
 
virtual ACC_STATE MoveToggle (unsigned long inDuration = 0, int inSpeed = 0) = 0
 
virtual void MoveStop ()
 
void ExternalMove (ACC_STATE inNewState)
 
- Public Member Functions inherited from Accessory
 Accessory ()
 
void begin (ACC_STATE inStartingState = STATE_NONE)
 
PortGetPort () const
 
ACC_STATE GetState () const
 
ACC_STATE GetPreviousState () const
 
bool IsNone () const
 
bool IsFirst () const
 
bool IsSecond () const
 
unsigned int GetDebounceDelay () const
 
unsigned long GetLastMoveTime () const
 
unsigned long GetDuration () const
 
bool loop ()
 
virtual int EEPROMSave (int inPos, bool inSimulate = false)
 
uint8_t AddMovingPosition (unsigned long inId, int inPosition)
 
uint8_t AddMovingPositions (const MovingPosition *inMovingPositions_P)
 
void AdjustMovingPositionsSize (uint8_t inNewSize)
 
bool IsEmpty () const
 
uint8_t IndexOfMovingPositionById (unsigned long inId) const
 
int GetMovingPositionValueById (unsigned long inId) const
 
int GetMovingPositionValueByIndex (uint8_t inIndex) const
 
unsigned long GetMovingPositionIdByIndex (uint8_t inIndex) const
 
const uint8_t GetLastMovingPosition () const
 
const uint8_t GetMovingPositionSize () const
 
void SetLastMovingPosition (uint8_t inLastPositionIndex)
 
void SetDebounceDelay (unsigned int inDebounceDelay)
 
void SetLastMoveTime ()
 
void SetDuration (unsigned long inDuration)
 
void SetNextAccessory (Accessory *inAccessory)
 
Accessory * GetNextAccessory () const
 
unsigned long GetActionStartingMillis () const
 
virtual void StartAction ()
 
virtual void StartAction (ACC_STATE inState)
 
virtual void ResetAction ()
 
bool IsActionDelayPending () const
 
virtual bool IsGroupActionPending () const
 
virtual bool CanBePositional () const
 
virtual void MovePosition (int inPosition)
 
void SetStateRaw (ACC_STATE inNewState)
 
void SetStartingMillis ()
 
void ResetStartingMillis ()
 

Protected Member Functions

void SetState (ACC_STATE instate)
 
ACC_STATE Toggle ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Accessory
static void ExecuteEvent (unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0)
 
static uint8_t GetCount ()
 
static bool IsActionPending ()
 
static Accessory * GetFirstAccessory ()
 
- Protected Attributes inherited from Accessory
PortpPort
 
ACC_STATE prevState
 

Detailed Description

This class describes a classic rotative or linear motor. This is an abstract class, which cannot be instantiated.

Definition at line 33 of file AccessoryMotor.hpp.

Constructor & Destructor Documentation

AccessoryMotor::AccessoryMotor ( )

Default constructor.

Definition at line 11 of file AccessoryMotor.cpp.

Member Function Documentation

bool AccessoryMotor::ActionEnded ( )
virtual

Ends the current action of this accessory.

Returns
true if the action is not finished.
Remarks
Only for internal usage.

Reimplemented from Accessory.

Definition at line 170 of file AccessoryMotor.cpp.

void AccessoryMotor::begin ( Port inpPort,
unsigned long  inId,
int  inSpeed,
unsigned long  inDurationMilli = 0 
)

Initialize the instance.

Parameters
inpPortPort driven this motor.
inIdId of this accessory.
inSpeedSets the initial speed for movements.
inDurationMilliDuration in milliseconds of the movement. If 0, the movement will not stop until a MoveStop(). Default is 0.

Definition at line 15 of file AccessoryMotor.cpp.

int AccessoryMotor::EEPROMLoad ( int  inPos)
virtual

Reload all data from the EEPROM.

Remarks
Only for internal usage.

Reimplemented from Accessory.

void AccessoryMotor::Event ( unsigned long  inId,
ACCESSORIES_EVENT_TYPE  inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID,
int  inData = 0 
)
virtual

Execute a new event.

Parameters
inIdId of an accessory or an accessory item.
inEventType of the new event. Default is ACCESSORIES_EVENT_MOVEPOSITIONID.
inDataAssociated data to the event type. Default is 0.

Reimplemented from Accessory.

Definition at line 68 of file AccessoryMotor.cpp.

void AccessoryMotor::ExternalMove ( ACC_STATE  inNewState)
inline

Change the state of the motor, to reflect a manual or external movement.

Parameters
[in]inNewStatenew state.

Definition at line 112 of file AccessoryMotor.hpp.

bool AccessoryMotor::IsLeft ( ) const
inline

Checks if current state is LEFT, or STATE_FIRST in basic accessory word.

Returns
true if the current state is LEFT.

Definition at line 48 of file AccessoryMotor.hpp.

bool AccessoryMotor::IsRight ( ) const
inline

Checks if current state is RIGHT, or STATE_SECOND in basic accessory word.

Returns
true if the current state is RIGHT.

Definition at line 53 of file AccessoryMotor.hpp.

bool AccessoryMotor::IsStopped ( ) const
inline

Checks if current state is STOP, or STATE_NONE in basic accessory word.

Returns
true if the current state is STOP.

Definition at line 58 of file AccessoryMotor.hpp.

void AccessoryMotor::Move ( unsigned long  inId)
virtual

Basic moving function.

Parameters
[in]inIdnew position id from MovingPosition to reach.

Implements Accessory.

Definition at line 150 of file AccessoryMotor.cpp.

virtual void AccessoryMotor::MoveLeft ( unsigned long  inDuration = 0,
int  inSpeed = 0 
)
inlinevirtual

Move to left position.

Parameters
[in]inDurationDuration of the movement. If 0, the movement will not stop until a MoveStop(). Default is 0.
[in]inSpeedspeed for this movement. This speed becomes the default speed for next movements. If 0, the speed is not updated. Default is 0.

Definition at line 91 of file AccessoryMotor.hpp.

virtual void AccessoryMotor::MoveRight ( unsigned long  inDuration = 0,
int  inSpeed = 0 
)
inlinevirtual

Move to right position.

Parameters
[in]inDurationDuration of the movement. If 0, the movement will not stop until a MoveStop(). Default is 0.
[in]inSpeedspeed for this movement. This speed becomes the default speed for next movements. If 0, the speed is not updated. Default is 0.

Reimplemented in AccessoryMotorOneWay.

Definition at line 97 of file AccessoryMotor.hpp.

void AccessoryMotor::MoveStop ( )
virtual

Stop the movement.

Definition at line 164 of file AccessoryMotor.cpp.

ACC_STATE AccessoryMotor::MoveToggle ( unsigned long  inDuration = 0,
int  inSpeed = 0 
)
pure virtual

Change from left to right or right to left.

Parameters
[in]inDurationDuration of the movement. If 0, the movement will not stop until a MoveStop(). Default is 0.
[in]inSpeedspeed for this movement. This speed becomes the default speed for next movements. If 0, the speed is not updated. Default is 0.
Returns
returns the new state.

Implemented AccessoryMotorTwoWays, and AccessoryMotorOneWay.

Definition at line 25 of file AccessoryMotor.cpp.

void AccessoryMotor::SetState ( ACC_STATE  inNewState)
protectedvirtual

Change the state of the accessory. The accessory will physically move to reach the new state.

Parameters
inNewStatenew state to reach.

Reimplemented from Accessory.

Definition at line 128 of file AccessoryMotor.cpp.

ACC_STATE AccessoryMotor::Toggle ( )
inlineprotectedvirtual

Basic function to toggle the accessory. A turnout will change its position, a light will change its state to on or off depending of its current state...

Returns
new state of the accessory.

Implements Accessory.

Definition at line 116 of file AccessoryMotor.hpp.


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