Description:
This is an abstract base class for subclasses which bin a stream of packets into different files depending on some criterion.
This class maintains a list of files and PacketWriters for writing to those files. It also provides functionality for appending a time value to an arbitrary integer ID, in order to make that ID unique for the life of the mission. Note this is non-trivial, since an ID may remain valid past "midnight" when the time value increments.
Sub-classes need only override the getFile() method to specify the bin file to which a packet should be directed. The getFile() and getFileNearTime() methods will probably be useful for this.
Packets which cannot be binned come out the other side of the pipe. Therefore it is probably a good idea to connect something downstream to catch these packets.
It really only makes sense to push packets into a PacketBinner. If you try to pull a packet out, it will simply pull a packet from the upstream connection like an empty pipe, bypassing all binning. This is probably not what you want.
Data Fields | ||
private | map<string, PacketWriter*> | writers |
private | deque<string> | filenames |
private | int | max_files |
protected | string | _dir |
protected | string | _base |
protected | string | _ext |
protected | string | _separator |
Constructors / Destructor | |
public | PacketBinner()Constructor. |
public | ~PacketBinner()Destructor. |
Methods | |||
public | virtual | void | dir(const string& dir) |
public | virtual | void | base(const string& base) |
public | virtual | void | ext(const string& ext) |
public | virtual | void | separator(const string& sep) |
public | virtual | void | pushIn(CCSDSPacket* packet) |
public | virtual | File* | getFile(int apid, int time, unsigned int id)Construct a File object for a given apid, time, and id. The time is included in the file name, to insure that we have a unique identifier even if the id can repeat itself. This way we can distinguish e.g. id=6 on 2001-08-29 from id=6 on 2001-09-01. Note that the units of time are arbitrary. Subclasses should choose a time unit which is longer than the time spanned by the packets in a given file, but shorter than the period over which the id can repeat itself. See the getFileNearTime() method for more information. |
public | virtual | File* | getFileNearTime(int apid, int time, unsigned int id)Returns a File object for a file with a time indicator within one of the given time, preferably one which already exists. This takes care of the problem that a time indicator may increment by one in the middle of a bin file (i.e. the bin spans "midnight"). |
public | virtual | PacketWriter* | getWriter(File* f)Return the PacketWriter for a particular File object, creating one if it does not already exist. Note this method deletes the File object when it is done with it. |
public | pure virtual | File* | getFile(CCSDSPacket* p) |
private | virtual | void | closeFile()Close the oldest file. |
private | virtual | int | getFileCount()Returns the number of open files. |
Operators |