Serial Studio 1.1.6
A dashboard software for your embedded projects
CSV::Player Class Reference

The Player class. More...

#include <Player.h>

Inheritance diagram for CSV::Player:
Inheritance graph
Collaboration diagram for CSV::Player:
Collaboration graph

Public Slots

void play ()
 
void pause ()
 
void toggle ()
 
void openFile ()
 
void closeFile ()
 
void nextFrame ()
 
void previousFrame ()
 
void openFile (const QString &filePath)
 
void setProgress (const qreal &progress)
 

Signals

void openChanged ()
 
void timestampChanged ()
 
void playerStateChanged ()
 

Public Member Functions

bool isOpen () const
 
qreal progress () const
 
bool isPlaying () const
 
int frameCount () const
 
QString filename () const
 
int framePosition () const
 
QString timestamp () const
 
QString csvFilesPath () const
 

Static Public Member Functions

static Playerinstance ()
 

Properties

bool isOpen
 
qreal progress
 
bool isPlaying
 
QString timestamp
 

Private Slots

void updateData ()
 

Private Member Functions

 Player ()
 
 Player (Player &&)=delete
 
 Player (const Player &)=delete
 
Playeroperator= (Player &&)=delete
 
Playeroperator= (const Player &)=delete
 
QByteArray getFrame (const int row)
 
QString getCellValue (const int row, const int column, bool &error)
 

Private Attributes

int m_framePos
 
bool m_playing
 
QFile m_csvFile
 
QString m_timestamp
 
QVector< QVector< QString > > m_csvData
 

Detailed Description

The Player class.

The CSV player class allows users to select a CSV file and "re-play" it with Serial Studio.

Constructor & Destructor Documentation

◆ Player() [1/3]

CSV::Player::Player ( )
explicitprivate

Constructor function

◆ Player() [2/3]

CSV::Player::Player ( Player &&  )
privatedelete

◆ Player() [3/3]

CSV::Player::Player ( const Player )
privatedelete

Member Function Documentation

◆ closeFile

void CSV::Player::closeFile ( )
slot

Closes the file & cleans up internal variables. This helps us to reduice memory usage & prepare the module to load another CSV file.

◆ csvFilesPath()

QString CSV::Player::csvFilesPath ( ) const

Returns the default path for CSV files

◆ filename()

QString CSV::Player::filename ( ) const

Returns the short filename of the current CSV file

◆ frameCount()

int CSV::Player::frameCount ( ) const

Returns the total number of frames in the CSV file. This can be calculated by getting the number of rows of the CSV and substracting 1 (because the title cells do not count as a valid frame).

◆ framePosition()

int CSV::Player::framePosition ( ) const

Returns the current row that we are using to create the JSON data that is feed to the JsonParser class.

◆ getCellValue()

QString CSV::Player::getCellValue ( const int  row,
const int  column,
bool &  error 
)
private

Safely returns the value in the cell at the given row & column. If an error occurs or the cell does not exist, the value of error shall be set to true.

◆ getFrame()

QByteArray CSV::Player::getFrame ( const int  row)
private

Generates a frame from the data at the given row. The first item of each row is ignored because it contains the RX date/time, which is used to regulate the interval at which the frames are parsed.

◆ instance()

CSV::Player & CSV::Player::instance ( )
static

Returns the only instance of the class

◆ isOpen()

bool CSV::Player::isOpen ( ) const

Returns true if an CSV file is open for reading

◆ isPlaying()

bool CSV::Player::isPlaying ( ) const

Returns true if the user is currently re-playing the CSV file at real-time speed.

◆ nextFrame

void CSV::Player::nextFrame ( )
slot

Reads & processes the next CSV row (until we get to the last row)

◆ openChanged

void CSV::Player::openChanged ( )
signal

◆ openFile [1/2]

void CSV::Player::openFile ( )
slot

Lets the user select a CSV file

◆ openFile [2/2]

void CSV::Player::openFile ( const QString &  filePath)
slot

Opens a CSV file and valitates it by comparing every data row with the title row. If one of the data rows does not correspond to the title row, the CSV is considered to be invalid.

◆ operator=() [1/2]

Player & CSV::Player::operator= ( const Player )
privatedelete

◆ operator=() [2/2]

Player & CSV::Player::operator= ( Player &&  )
privatedelete

◆ pause

void CSV::Player::pause ( )
slot

Pauses the CSV playback so that the user can see WTF happened at certain point of the mission.

◆ play

void CSV::Player::play ( )
slot

Enables CSV playback at 'live' speed (as it happened when CSV file was saved to the computer).

◆ playerStateChanged

void CSV::Player::playerStateChanged ( )
signal

◆ previousFrame

void CSV::Player::previousFrame ( )
slot

Reads & processes the previous CSV row (until we get to the first row)

◆ progress()

qreal CSV::Player::progress ( ) const

Returns the CSV playback progress in a range from 0.0 to 1.0

◆ setProgress

void CSV::Player::setProgress ( const qreal &  progress)
slot

Reads a specific row from the progress range (which can have a value ranging from 0.0 to 1.0).

◆ timestamp()

QString CSV::Player::timestamp ( ) const

Returns the timestamp of the current data frame / row.

◆ timestampChanged

void CSV::Player::timestampChanged ( )
signal

◆ toggle

void CSV::Player::toggle ( )
slot

Toggles play/pause state

◆ updateData

void CSV::Player::updateData ( )
privateslot

Generates a JSON data frame by combining the values of the current CSV row & the structure of the JSON map file loaded in the JsonParser class.

If playback is enabled, this function calculates the difference in milliseconds between the current row and the next row & schedules a re-call of this function using a timer.

Member Data Documentation

◆ m_csvData

QVector<QVector<QString> > CSV::Player::m_csvData
private

◆ m_csvFile

QFile CSV::Player::m_csvFile
private

◆ m_framePos

int CSV::Player::m_framePos
private

◆ m_playing

bool CSV::Player::m_playing
private

◆ m_timestamp

QString CSV::Player::m_timestamp
private

Property Documentation

◆ isOpen

bool CSV::Player::isOpen
read

◆ isPlaying

bool CSV::Player::isPlaying
read

◆ progress

qreal CSV::Player::progress
read

◆ timestamp

QString CSV::Player::timestamp
read

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