-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** Implements a packet source for magazines | ||
*/ | ||
|
||
#include "packetmag.h" | ||
|
||
using namespace vbit; | ||
|
||
// @todo Initialise the magazine data | ||
PacketMag::PacketMag(uint8_t mag, std::list<TTXPageStream>* pageSet, ttx::Configure *configure, uint8_t priority) : | ||
_pageSet(pageSet), | ||
_configure(configure), | ||
_page(NULL), | ||
_magNumber(mag), | ||
_priority(priority), | ||
_priorityCount(priority) | ||
{ | ||
//ctor | ||
if (_pageSet->size()>0) | ||
{ | ||
//std::cerr << "[Mag::Mag] enters. page size=" << _pageSet->size() << std::endl; | ||
_it=_pageSet->begin(); | ||
//_it->DebugDump(); | ||
_page=&*_it; | ||
} | ||
_carousel=new vbit::Carousel(); | ||
} | ||
|
||
PacketMag::~PacketMag() | ||
{ | ||
//dtor | ||
delete _carousel; | ||
} | ||
|
||
// @todo Invent a packet sequencer similar to mag.cpp which this will replace | ||
Packet* PacketMag::GetPacket() | ||
{ | ||
static vbit::Packet* filler=new Packet(8,25," "); // filler | ||
|
||
|
||
// If there is no page, we should send a filler | ||
if (_pageSet->size()<1) | ||
{ | ||
return filler; | ||
} | ||
|
||
// If we send a header we go into a wait state | ||
ClearEvent(EVENT_FIELD); // @todo Only when we send the header | ||
return filler; // Dummy return for now | ||
} | ||
|
||
/** Is there a packet ready to go? | ||
* If the ready flag is set | ||
* and the priority count allows a packet to go out | ||
*/ | ||
bool PacketMag::IsReady() | ||
{ | ||
// This happens unless we have just sent out a header | ||
if (GetEvent(EVENT_FIELD)) | ||
{ | ||
// If we send a header we want to wait for this to get set GetEvent(EVENT_FIELD) | ||
_priorityCount--; | ||
if (_priorityCount==0) | ||
{ | ||
_priorityCount=_priority; | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef PACKETMAG_H | ||
#define PACKETMAG_H | ||
#include <list> | ||
#include <PacketSource.h> | ||
#include "ttxpagestream.h" | ||
#include "carousel.h" | ||
#include "configure.h" | ||
|
||
namespace vbit | ||
{ | ||
|
||
|
||
class PacketMag : public PacketSource | ||
{ | ||
public: | ||
/** Default constructor */ | ||
PacketMag(uint8_t mag, std::list<TTXPageStream>* pageSet, ttx::Configure *configure, uint8_t priority); | ||
/** Default destructor */ | ||
virtual ~PacketMag(); | ||
|
||
/** Get the next packet | ||
* @return The next packet OR if IsReady() would return false then a filler packet | ||
*/ | ||
Packet* GetPacket() override; | ||
|
||
bool IsReady(); | ||
|
||
|
||
protected: | ||
|
||
private: | ||
std::list<TTXPageStream>* _pageSet; //!< Member variable "_pageSet" | ||
ttx::Configure* _configure; | ||
TTXPageStream* _page; //!< The current page being output | ||
int _magNumber; //!< The number of this magazine. (where 0 is mag 8) | ||
uint8_t _priority; //!< Priority of transmission where 1 is highest | ||
|
||
std::list<TTXPageStream>::iterator _it; | ||
Carousel* _carousel; | ||
uint8_t _priorityCount; // Controls transmission priority | ||
}; | ||
|
||
} | ||
|
||
#endif // PACKETMAG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters