PikeAero::CTaskAggregator Class Reference

#include <ctaskaggregator.h>

Inheritance diagram for PikeAero::CTaskAggregator:

Inheritance graph
[legend]
Collaboration diagram for PikeAero::CTaskAggregator:

Collaboration graph
[legend]

Public Member Functions

CMachine::ubit16 analog (int n)
 CTaskAggregator (CMachine::ubit32 frequency=BASE_TIMER_FREQUENCY)
CMachine::ubit32 days ()
CMachine::ubit32 deliverEventsPerSecond ()
CMachine::ubit32 dequeueEventsPerSecond ()
CMachine::ubit32 enqueueEventsPerSecond ()
virtual void event (CEvent *e)
 receive a software queued event.
virtual CMachine::bit32 fault ()
CMachine::ubit32 hours ()
virtual CMachine::bit32 init ()
virtual bool iowait ()
CMachine::ubit32 maxEventsInQueuePerSecond ()
CMachine::ubit32 minutes ()
virtual const char * name ()
CMachine::ubit32 rpm ()
virtual CMachine::bit32 run ()
 Called periodically by CTaskScheduler to do a piece of work.
CMachine::ubit32 seconds ()
virtual CMachine::bit32 start ()
virtual CMachine::bit32 stop ()
CMachine::ubit32 taskSlicesPerSecond ()
CMachine::ubit64 ticks ()
CMachine::ubit32 vectorIRQCountPerSecond ()
virtual ~CTaskAggregator ()

Private Member Functions

CMachine::ubit16 mADValues[16] __attribute__ ((aligned))
CMachine::real calculateRPM ()
 calculate the current rpm.
void outputLEDs (CMachine::ubit32 status)
void perSecond ()

Private Attributes

CMachine::ubit32 mDays
CMachine::ubit32 mDeliverEventsPerSecond
CMachine::ubit32 mDequeueEventsPerSecond
CMachine::ubit32 mEnqueueEventsPerSecond
CMachine::ubit32 mFrequency
CMachine::ubit32 mHours
CInputTimingmInputTiming [2]
CMachine::ubit64 mLastTicks
CBinaryOutputGPIOmLEDs [4]
CMachine::ubit32 mMaxEventsInQueuePerSecond
CMachine::ubit32 mMinutes
CMachine::ubit32 mRPM
CMachine::ubit32 mSeconds
CMachine::ubit32 mStatus
CMachine::ubit32 mTaskSlicesPerSecond
CMachine::ubit64 mTicks
CMachine::ubit32 mVectorIRQCountPerSecond

Detailed Description

Implements a data and statistics aggregator class. Compiles raw data into useful data.
Author:
Michael Sharkey <mike@pikeaero.com>

Definition at line 33 of file ctaskaggregator.h.


Constructor & Destructor Documentation

PikeAero::CTaskAggregator::CTaskAggregator ( CMachine::ubit32  frequency = BASE_TIMER_FREQUENCY  ) 

Definition at line 30 of file ctaskaggregator.cpp.

00031  : ITask()
00032  , mStatus(0)
00033  , mLastTicks(0)
00034  , mTicks(0)
00035  , mSeconds(0)
00036  , mMinutes(0)
00037  , mHours(0)
00038  , mDays(0)
00039  , mRPM(0)
00040  , mTaskSlicesPerSecond(0)
00041  , mMaxEventsInQueuePerSecond(0)
00042  , mEnqueueEventsPerSecond(0)
00043  , mDequeueEventsPerSecond(0)
00044  , mDeliverEventsPerSecond(0)
00045  , mVectorIRQCountPerSecond(0)
00046  , mFrequency(frequency)
00047 {
00048 }

PikeAero::CTaskAggregator::~CTaskAggregator (  )  [virtual]

Definition at line 50 of file ctaskaggregator.cpp.

References stop().

00051 {
00052     stop();
00053 }

Here is the call graph for this function:


Member Function Documentation

CMachine::ubit16 mADValues [16] PikeAero::CTaskAggregator::__attribute__ ( (aligned)   )  [private]

Current detected engione RPM

CMachine::ubit16 PikeAero::CTaskAggregator::analog ( int  n  )  [inline]

Retrieve analog data.

Definition at line 94 of file ctaskaggregator.h.

Referenced by PikeAero::CCommandHandler::commandA(), and PikeAero::CTaskConsole::monitor().

00094 {return mADValues[n];}

Here is the caller graph for this function:

CMachine::real PikeAero::CTaskAggregator::calculateRPM (  )  [private]

calculate the current rpm.

got a channel with a pulse width measurement, so determine rpm from it...

Definition at line 117 of file ctaskaggregator.cpp.

References PikeAero::CInputTiming::countPerRevA(), PikeAero::CInputTiming::countPerRevB(), PikeAero::CBinaryInputOutputTimer::frequency(), mInputTiming, PikeAero::CBinaryInputCapture::pulseWidthA(), PikeAero::CBinaryInputCapture::pulseWidthB(), rpm(), and PikeAero::CTaskScheduler::yield().

Referenced by run().

00118 {
00119     CMachine::real rpm=0.0;
00120     CMachine::ubit32 index;
00121     CMachine::real pulseWidth;
00122     CMachine::real frequency;
00123     CMachine::real countPerRev;
00124     for ( CMachine::ubit32 channel=0; channel < 4; channel++ )
00125     {
00126         CTaskScheduler::yield();
00127         index = (channel&0x2)>>1;
00128         pulseWidth = channel&0x1 ? mInputTiming[index]->pulseWidthB() : mInputTiming[index]->pulseWidthA();
00129         if ( pulseWidth )
00130         {
00131             /** got a channel with a pulse width measurement, so determine rpm from it... */
00132             frequency = mInputTiming[index]->frequency();
00133             countPerRev = channel&0x1 ? mInputTiming[index]->countPerRevB() : mInputTiming[index]->countPerRevA();
00134             rpm = ( ( frequency / pulseWidth ) / countPerRev ) * 60.0;
00135             return rpm;
00136         }
00137     }
00138     return rpm;
00139 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CTaskAggregator::days (  )  [inline]

Definition at line 84 of file ctaskaggregator.h.

References mDays.

Referenced by PikeAero::CTaskConsole::monitor().

00084 {return mDays;}

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CTaskAggregator::deliverEventsPerSecond (  )  [inline]

Definition at line 101 of file ctaskaggregator.h.

References mDeliverEventsPerSecond.

Referenced by PikeAero::CTaskConsole::monitor().

00101 {return mDeliverEventsPerSecond;}

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CTaskAggregator::dequeueEventsPerSecond (  )  [inline]

Definition at line 100 of file ctaskaggregator.h.

References mDequeueEventsPerSecond.

Referenced by PikeAero::CTaskConsole::monitor().

00100 {return mDequeueEventsPerSecond;}

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CTaskAggregator::enqueueEventsPerSecond (  )  [inline]

Definition at line 99 of file ctaskaggregator.h.

References mEnqueueEventsPerSecond.

Referenced by PikeAero::CTaskConsole::monitor().

00099 {return mEnqueueEventsPerSecond;}

Here is the caller graph for this function:

void PikeAero::CTaskAggregator::event ( CEvent e  )  [virtual]

receive a software queued event.

receive a software event [ inherits pointer ownership ]

wake up

Reimplemented from PikeAero::CObject.

Definition at line 246 of file ctaskaggregator.cpp.

References PikeAero::CEvent::AnalogToDigital, mTicks, PikeAero::ITask::setSleeping(), PikeAero::CEvent::Tick, and PikeAero::CEvent::type().

00247 {
00248     switch( e->type() )
00249     {
00250         case CEvent::Tick:
00251             mTicks = ((CEventTick*)e)->ticks();
00252             break;
00253         case CEvent::AnalogToDigital:
00254         {
00255             CEventAnalogConversion* event = (CEventAnalogConversion*)e;
00256             for( CMachine::ubit32 i=0; i < 16; i++ )
00257             {
00258                 mADValues[i] = event->value( i );
00259             }
00260         }
00261         break;
00262     }
00263     setSleeping(false); /** wake up */
00264 }

Here is the call graph for this function:

CMachine::bit32 PikeAero::CTaskAggregator::fault (  )  [virtual]

The CTaskScheduler will call the fault() method when a fault code was returned by any of the task's other methods.

Reimplemented from PikeAero::ITask.

Definition at line 228 of file ctaskaggregator.cpp.

00229 {
00230     return 0;
00231 }

CMachine::ubit32 PikeAero::CTaskAggregator::hours (  )  [inline]

Definition at line 83 of file ctaskaggregator.h.

References mHours.

Referenced by PikeAero::CTaskConsole::monitor().

00083 {return mHours;}

Here is the caller graph for this function:

CMachine::bit32 PikeAero::CTaskAggregator::init (  )  [virtual]

called exactly once. perform task initialization such as initializing private variable. other tasks are not guaranteed so do not interract with other tasks at this stage.

Returns:
0 on success.
called exactly once. perform task initialization such as initializing private variable. other tasks are not guaranteed so do not interract with other tasks at this stage.
Returns:
0 on success.

Reimplemented from PikeAero::ITask.

Definition at line 60 of file ctaskaggregator.cpp.

00061 {
00062     return 0;
00063 }

bool PikeAero::CTaskAggregator::iowait (  )  [virtual]

The CTaskScheduler::iowait() method will call the task's iowait method periodically to test if the task is still in an I/O wait state.

Returns:
true if still waiting on I/O, false otherwise.
The CTaskScheduler::iowait() method will call the task's iowait method periodically to test if the task is still in an I/O wait state.
Returns:
true if still waiting on I/O, false otherwise.

Reimplemented from PikeAero::ITask.

Definition at line 238 of file ctaskaggregator.cpp.

00239 {
00240     return false;
00241 }

CMachine::ubit32 PikeAero::CTaskAggregator::maxEventsInQueuePerSecond (  )  [inline]

Definition at line 98 of file ctaskaggregator.h.

References mMaxEventsInQueuePerSecond.

Referenced by PikeAero::CTaskConsole::monitor().

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CTaskAggregator::minutes (  )  [inline]

Definition at line 82 of file ctaskaggregator.h.

References mMinutes.

Referenced by PikeAero::CTaskConsole::monitor().

00082 {return mMinutes;}

Here is the caller graph for this function:

virtual const char* PikeAero::CTaskAggregator::name (  )  [inline, virtual]

Returns:
a CString containing an human readable name for the task

Reimplemented from PikeAero::ITask.

Definition at line 39 of file ctaskaggregator.h.

00039 {return "CTaskAggregator";}

void PikeAero::CTaskAggregator::outputLEDs ( CMachine::ubit32  status  )  [private]

calculate the current engine RPM

Output the LEDs....

Definition at line 144 of file ctaskaggregator.cpp.

References mLEDs, and PikeAero::CBinaryInputOutputGPIO::reset().

Referenced by perSecond().

00145 {
00146     (status & 0x01) ? mLEDs[0]->set() : mLEDs[0]->reset();
00147     (status & 0x02) ? mLEDs[1]->set() : mLEDs[1]->reset();
00148     (status & 0x04) ? mLEDs[2]->set() : mLEDs[2]->reset();
00149     (status & 0x08) ? mLEDs[3]->set() : mLEDs[3]->reset();
00150 }

Here is the call graph for this function:

Here is the caller graph for this function:

void PikeAero::CTaskAggregator::perSecond (  )  [private]

output the status LEDs

Stuff to do per second...

calculate performance statistics...

output the status word

ripple the wall clock...

Reimplemented from PikeAero::ITask.

Definition at line 155 of file ctaskaggregator.cpp.

References PikeAero::CTaskScheduler::at(), PikeAero::CTaskScheduler::count(), PikeAero::CEventQueue::deliveryCount(), PikeAero::CEventQueue::dequeueCount(), PikeAero::CObject::dispatch(), PikeAero::CEventQueue::enqueueCount(), PikeAero::CEventQueue::maxInQueue(), mDays, mDeliverEventsPerSecond, mDequeueEventsPerSecond, mEnqueueEventsPerSecond, mHours, mMaxEventsInQueuePerSecond, mMinutes, mSeconds, mStatus, mTaskSlicesPerSecond, mVectorIRQCountPerSecond, outputLEDs(), PikeAero::ITask::perSecond(), PikeAero::CEventQueue::resetDeliveryCount(), PikeAero::CEventQueue::resetDequeueCount(), PikeAero::CEventQueue::resetEnqueueCount(), PikeAero::CEventQueue::resetMaxInQueue(), PikeAero::CTaskScheduler::resetTaskSlices(), PikeAero::CMachine::resetVectorIRQCount(), PikeAero::CTaskScheduler::taskSlices(), and PikeAero::CMachine::vectorIRQCount().

Referenced by run().

00156 {
00157     /** calculate performance statistics... */
00158 
00159     mVectorIRQCountPerSecond = CMachine::vectorIRQCount();
00160     CMachine::resetVectorIRQCount();
00161 
00162     mTaskSlicesPerSecond = CTaskScheduler::taskSlices();
00163     CTaskScheduler::resetTaskSlices();
00164 
00165     for( CMachine::ubit32 i=0; i < CTaskScheduler::count(); i++ )
00166     {
00167         CTaskScheduler::at(i)->perSecond();
00168     }
00169 
00170     mMaxEventsInQueuePerSecond = CEventQueue::maxInQueue();
00171     CEventQueue::resetMaxInQueue();
00172 
00173     mEnqueueEventsPerSecond = CEventQueue::enqueueCount();
00174     CEventQueue::resetEnqueueCount();
00175 
00176     mDequeueEventsPerSecond = CEventQueue::dequeueCount();
00177     CEventQueue::resetDequeueCount();
00178 
00179     mDeliverEventsPerSecond = CEventQueue::deliveryCount();
00180     CEventQueue::resetDeliveryCount();
00181 
00182     /** output the status word */
00183     outputLEDs(++mStatus);
00184 
00185     /** ripple the wall clock... */
00186     if ( ++mSeconds == 60 )
00187     {
00188         mSeconds = 0;
00189         if ( ++mMinutes == 60 )
00190         {
00191             mMinutes = 0;
00192             if ( ++mHours == 24 )
00193             {
00194                 mHours = 0;
00195                 ++mDays;
00196             }
00197         }
00198     }
00199 
00200     dispatch( new CEventClock(this,mSeconds,mMinutes,mHours,mDays) );
00201 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CTaskAggregator::rpm (  )  [inline]

Retrieve engine rpm.

Definition at line 89 of file ctaskaggregator.h.

References mRPM.

Referenced by calculateRPM(), PikeAero::CCommandHandler::commandOPEN(), PikeAero::CTaskConsole::drawStatusBar(), and PikeAero::CTaskFuelInjection::run().

00089 {return mRPM;}

Here is the caller graph for this function:

CMachine::bit32 PikeAero::CTaskAggregator::run (  )  [virtual]

Called periodically by CTaskScheduler to do a piece of work.

called periodically by CTaskScheduler to do a piece of work.

Returns:
0 on success.

0 on success.

back to sleep

calculate the RPM

every second...

Reimplemented from PikeAero::ITask.

Definition at line 207 of file ctaskaggregator.cpp.

References calculateRPM(), mLastTicks, mRPM, mTicks, perSecond(), and PikeAero::ITask::setSleeping().

00208 {
00209     /** back to sleep */
00210     setSleeping(true);
00211 
00212     /** calculate the RPM */
00213     mRPM = (int)calculateRPM();
00214 
00215     /** every second... */
00216     if ( mLastTicks + 10 <= mTicks )
00217     {
00218         mLastTicks = mTicks;
00219         perSecond();
00220     }
00221     return 0;
00222 }

Here is the call graph for this function:

CMachine::ubit32 PikeAero::CTaskAggregator::seconds (  )  [inline]

Definition at line 81 of file ctaskaggregator.h.

References mSeconds.

Referenced by PikeAero::CTaskConsole::monitor().

00081 {return mSeconds;}

Here is the caller graph for this function:

CMachine::bit32 PikeAero::CTaskAggregator::start (  )  [virtual]

called exactly once. all tasks are initialized at this point. called just prior to first call to run()

Returns:
0 on success.
called exactly once. all tasks are initialized at this point. called just prior to first call to run()
Returns:
0 on success.

FIXME: get number of pulse per cy, and invert from config

Enable the LEDs display...

Reimplemented from PikeAero::ITask.

Definition at line 69 of file ctaskaggregator.cpp.

References PikeAero::CEvent::AnalogToDigital, GPIO6, GPIO_PIN_10, GPIO_PIN_11, GPIO_PIN_12, GPIO_PIN_13, PikeAero::CEventQueue::installListener(), mFrequency, mInputTiming, mLEDs, PikeAero::ITask::setSleeping(), PikeAero::CEvent::Tick, TIM8, TIM9, PikeAero::CMachine::Vector_TIM8, and PikeAero::CMachine::Vector_TIM9.

00070 {
00071     setSleeping(true);
00072 
00073     /** FIXME: get number of pulse per cy, and invert from config */
00074     mInputTiming[0] = new CInputTimingToothCounter( CMachine::Vector_TIM8, TIM8, false, false, 60, 60, mFrequency );
00075     mInputTiming[1] = new CInputTiming( CMachine::Vector_TIM9, TIM9, false, false, 1, 4 /* FIXME: 8 cyl / 2 (cam speed) */, mFrequency );
00076 
00077    /** Enable the LEDs display... */
00078     mLEDs[0] = new CBinaryOutputGPIO( GPIO6, GPIO_PIN_10, true, true );
00079     mLEDs[1] = new CBinaryOutputGPIO( GPIO6, GPIO_PIN_11, true, true );
00080     mLEDs[2] = new CBinaryOutputGPIO( GPIO6, GPIO_PIN_12, true, true );
00081     mLEDs[3] = new CBinaryOutputGPIO( GPIO6, GPIO_PIN_13, true, true );
00082 
00083     // CEventQueue::installListener(this,CEvent::Clock);
00084     CEventQueue::installListener(this,CEvent::AnalogToDigital);
00085     CEventQueue::installListener(this,CEvent::Tick);
00086 
00087     return 0;
00088 }

Here is the call graph for this function:

CMachine::bit32 PikeAero::CTaskAggregator::stop (  )  [virtual]

The CTaskScheduler will call the stop () method after the task was scheduled for cancelation.

Returns:
0 on success.
CTaskScheduler will call the stop () method after the task was scheduled for cancelation.
Returns:
0 on success.

Reimplemented from PikeAero::ITask.

Definition at line 94 of file ctaskaggregator.cpp.

References PikeAero::CEvent::AnalogToDigital, mInputTiming, mLEDs, PikeAero::CEventQueue::removeListener(), and PikeAero::CEvent::Tick.

Referenced by ~CTaskAggregator().

00095 {
00096     CEventQueue::removeListener(this,CEvent::Tick);
00097     CEventQueue::removeListener(this,CEvent::AnalogToDigital);
00098     for( CMachine::ubit32 n=0; n < 2; n++ )
00099     {
00100         if ( mInputTiming[n] != NULL )
00101         {
00102             delete mInputTiming[n];
00103             mInputTiming[n] = NULL;
00104         }
00105     }
00106     delete mLEDs[0];
00107     delete mLEDs[1];
00108     delete mLEDs[2];
00109     delete mLEDs[3];
00110 
00111     return 0;
00112 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CTaskAggregator::taskSlicesPerSecond (  )  [inline]

performance statistics

Definition at line 97 of file ctaskaggregator.h.

References mTaskSlicesPerSecond.

Referenced by PikeAero::CTaskConsole::monitor().

00097 {return mTaskSlicesPerSecond;}

Here is the caller graph for this function:

CMachine::ubit64 PikeAero::CTaskAggregator::ticks (  )  [inline]

Retrieve times.

Definition at line 80 of file ctaskaggregator.h.

References mTicks.

00080 {return mTicks;}

CMachine::ubit32 PikeAero::CTaskAggregator::vectorIRQCountPerSecond (  )  [inline]

Definition at line 102 of file ctaskaggregator.h.

References mVectorIRQCountPerSecond.

Referenced by PikeAero::CTaskConsole::monitor().

00102 {return mVectorIRQCountPerSecond;}

Here is the caller graph for this function:


Field Documentation

Definition at line 116 of file ctaskaggregator.h.

Referenced by days(), and perSecond().

Total dequeued events per second

Definition at line 123 of file ctaskaggregator.h.

Referenced by deliverEventsPerSecond(), and perSecond().

Total enqueued events per second

Definition at line 122 of file ctaskaggregator.h.

Referenced by dequeueEventsPerSecond(), and perSecond().

Maximum number of events waiting in queue per second

Definition at line 121 of file ctaskaggregator.h.

Referenced by enqueueEventsPerSecond(), and perSecond().

Total IRQ interrupts delivered per second

Definition at line 125 of file ctaskaggregator.h.

Referenced by start().

Definition at line 115 of file ctaskaggregator.h.

Referenced by hours(), and perSecond().

do one-second tasks

Definition at line 108 of file ctaskaggregator.h.

Referenced by calculateRPM(), start(), and stop().

The status output LEDs

Definition at line 111 of file ctaskaggregator.h.

Referenced by run().

The current status word

Definition at line 110 of file ctaskaggregator.h.

Referenced by outputLEDs(), start(), and stop().

Total number of task slices per second

Definition at line 120 of file ctaskaggregator.h.

Referenced by maxEventsInQueuePerSecond(), and perSecond().

Definition at line 114 of file ctaskaggregator.h.

Referenced by minutes(), and perSecond().

Definition at line 117 of file ctaskaggregator.h.

Referenced by rpm(), and run().

Definition at line 113 of file ctaskaggregator.h.

Referenced by perSecond(), and seconds().

Input timing objects

Reimplemented from PikeAero::ITask.

Definition at line 109 of file ctaskaggregator.h.

Referenced by perSecond().

Internal Analog to Digital values

Definition at line 119 of file ctaskaggregator.h.

Referenced by perSecond(), and taskSlicesPerSecond().

Definition at line 112 of file ctaskaggregator.h.

Referenced by event(), run(), and ticks().

Total delivered events per second

Definition at line 124 of file ctaskaggregator.h.

Referenced by perSecond(), and vectorIRQCountPerSecond().


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

Generated on Sun Oct 25 14:00:21 2009 for stingray3 by  doxygen 1.5.8