Plaquette
 
Loading...
Searching...
No Matches
pq::Engine Class Reference

The main Plaquette static class containing all the units. More...

#include <PqCore.h>

Public Member Functions

void preBegin (unsigned long baudrate=PLAQUETTE_SERIAL_BAUD_RATE)
 Initializes all components (calls begin() on all of them).
 
void postBegin ()
 Performs additional tasks after the class to begin().
 
void preStep ()
 Updates all components (calls step() on all of them).
 
bool timeStep ()
 Performs additional tasks after the class to step().
 
void begin (unsigned long baudrate=PLAQUETTE_SERIAL_BAUD_RATE)
 Function to be used within the PlaquetteLib context (needs to be called at top of setup() method).
 
bool step ()
 Function to be used within the PlaquetteLib context (needs to be called at top of loop() method).
 
void end ()
 Optional function to be used within the PlaquetteLib context.
 
size_t nUnits ()
 Returns the current number of units.
 
float seconds (bool referenceTime=true) const
 Returns time in seconds.
 
uint32_t milliSeconds (bool referenceTime=true) const
 Returns time in milliseconds.
 
uint64_t microSeconds (bool referenceTime=true) const
 Returns time in microseconds.
 
unsigned long nSteps () const
 Returns number of steps.
 
bool hasAutoSampleRate () const
 Returns true iff the auto sample rate mode is enabled (default).
 
void autoSampleRate ()
 Enables auto sample rate mode (default).
 
void sampleRate (float sampleRate)
 Sets sample rate to a fixed value, thus disabling auto sampling rate.
 
void samplePeriod (float samplePeriod)
 Sets sample period to a fixed value, thus disabling auto sampling rate.
 
float sampleRate () const
 Returns sample rate.
 
float samplePeriod () const
 Returns sample period.
 
uint32_t deltaTimeMicroSeconds () const
 Returns time between steps (in microseconds).
 
float deltaTimeSecondsTimesFixed32Max () const
 Returns time between steps, expressed in fixed point propotion.
 
bool isPrimary () const
 Returns true if this Engine is the main.
 
bool randomTrigger (float timeWindow)
 Randomly triggers an event about once per time window, on average.
 

Static Public Member Functions

static Engineprimary ()
 Returns the main instance of Plaquette.
 

Friends

class Unit
 

Detailed Description

The main Plaquette static class containing all the units.

Member Function Documentation

◆ end()

void pq::Engine::end ( )
inline

Optional function to be used within the PlaquetteLib context.

No need to call it if the program is looping indefinitely. Call if the program stops at some point.

◆ microSeconds()

uint64_t pq::Engine::microSeconds ( bool  referenceTime = true) const

Returns time in microseconds.

Optional parameter allows to ask for reference time (default) which will yield the same value through one iteration of step(), or "real" time which will return the current total running time.

Parameters
referenceTimedetermines whether the function returns the reference time or the real time
Returns
the time in microseconds

◆ milliSeconds()

uint32_t pq::Engine::milliSeconds ( bool  referenceTime = true) const

Returns time in milliseconds.

Optional parameter allows to ask for reference time (default) which will yield the same value through one iteration of step(), or "real" time which will return the current total running time.

Parameters
referenceTimedetermines whether the function returns the reference time or the real time
Returns
the time in milliseconds

◆ randomTrigger()

bool pq::Engine::randomTrigger ( float  timeWindow)

Randomly triggers an event about once per time window, on average.

Call this function once in each step(). It will occasionally return true, with the frequency adjusted so that you get roughly one event for each timeWindow period, no matter how fast your loop is running.

Parameters
timeWindowduration of the window (in seconds)
Returns
true when an event occurs during this sample

◆ seconds()

float pq::Engine::seconds ( bool  referenceTime = true) const

Returns time in seconds.

Optional parameter allows to ask for reference time (default) which will yield the same value through one iteration of step(), or "real" time which will return the current total running time.

Parameters
referenceTimedetermines whether the function returns the reference time or the real time
Returns
the time in seconds

◆ timeStep()

bool pq::Engine::timeStep ( )
inline

Performs additional tasks after the class to step().

Returns
true if the program should

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