#include "AccessoryMotor.hpp"
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) |
![]() | |
Accessory () | |
void | begin (ACC_STATE inStartingState = STATE_NONE) |
Port * | GetPort () const |
ACC_STATE | GetState () const |
ACC_STATE | GetPreviousState () const |
bool | IsNone () const |
bool | IsFirst () const |
bool | IsSecond () const |
uint8_t | AddMovingPosition (unsigned long inId, int inPosition) |
unsigned int | GetDebounceDelay () const |
unsigned long | GetLastMoveTime () const |
unsigned long | GetDuration () const |
bool | loop () |
virtual int | EEPROMSave (int inPos, bool inSimulate = false) |
void | AdjustMovingPositionsSize (uint8_t inNewSize) |
bool | IsEmpty () const |
uint8_t | IndexOfMovingPosition (unsigned long inId) const |
int | GetMovingPosition (unsigned long inId) const |
int | GetMovingPositionByIndex (int inIndex) const |
unsigned long | GetMovingPositionIdByIndex (int 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 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 () |
![]() | |
Port * | pPort |
ACC_STATE | prevState |
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.
AccessoryMotor::AccessoryMotor | ( | ) |
Default constructor.
Definition at line 11 of file AccessoryMotor.cpp.
|
virtual |
Ends the current action of this accessory.
Reimplemented from Accessory.
Definition at line 166 of file AccessoryMotor.cpp.
void AccessoryMotor::begin | ( | Port * | inpPort, |
unsigned long | inId, | ||
int | inSpeed, | ||
unsigned long | inDurationMilli = 0 |
||
) |
Initialize the instance.
inpPort | Port driven this motor. |
inId | Id of this accessory. |
inSpeed | Sets the initial speed for movements. |
inDurationMilli | Duration 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.
|
virtual |
|
virtual |
Execute a new event.
inId | Id of an accessory or an accessory item. |
inEvent | Type of the new event. Default is ACCESSORIES_EVENT_MOVEPOSITIONID. |
inData | Associated data to the event type. Default is 0. |
Reimplemented from Accessory.
Definition at line 68 of file AccessoryMotor.cpp.
|
inline |
Change the state of the motor, to reflect a manual or external movement.
[in] | inNewState | new state. |
Definition at line 112 of file AccessoryMotor.hpp.
|
inline |
Checks if current state is LEFT, or STATE_FIRST in basic accessory word.
Definition at line 48 of file AccessoryMotor.hpp.
|
inline |
Checks if current state is RIGHT, or STATE_SECOND in basic accessory word.
Definition at line 53 of file AccessoryMotor.hpp.
|
inline |
Checks if current state is STOP, or STATE_NONE in basic accessory word.
Definition at line 58 of file AccessoryMotor.hpp.
|
virtual |
Basic moving function.
[in] | inId | new position id from MovingPosition to reach. |
Implements Accessory.
Definition at line 146 of file AccessoryMotor.cpp.
|
inlinevirtual |
Move to left position.
[in] | inDuration | Duration of the movement. If 0, the movement will not stop until a MoveStop(). Default is 0. |
[in] | inSpeed | speed 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.
|
inlinevirtual |
Move to right position.
[in] | inDuration | Duration of the movement. If 0, the movement will not stop until a MoveStop(). Default is 0. |
[in] | inSpeed | speed 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.
|
virtual |
Stop the movement.
Definition at line 160 of file AccessoryMotor.cpp.
|
pure virtual |
Change from left to right or right to left.
[in] | inDuration | Duration of the movement. If 0, the movement will not stop until a MoveStop(). Default is 0. |
[in] | inSpeed | speed for this movement. This speed becomes the default speed for next movements. If 0, the speed is not updated. Default is 0. |
Implemented AccessoryMotorTwoWays, and AccessoryMotorOneWay.
Definition at line 25 of file AccessoryMotor.cpp.
|
protectedvirtual |
Change the state of the accessory. The accessory will physically move to reach the new state.
inNewState | new state to reach. |
Reimplemented from Accessory.
Definition at line 124 of file AccessoryMotor.cpp.
|
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...
Implements Accessory.
Definition at line 116 of file AccessoryMotor.hpp.