Serial Studio 1.1.6
A dashboard software for your embedded projects
JSON::Generator Class Reference

The Generator class. More...

#include <Generator.h>

Inheritance diagram for JSON::Generator:
Inheritance graph
Collaboration diagram for JSON::Generator:
Collaboration graph

Public Types

enum  OperationMode { kManual = 0x00 , kAutomatic = 0x01 }
 

Public Slots

void loadJsonMap ()
 
void loadJsonMap (const QString &path)
 
void setOperationMode (const JSON::Generator::OperationMode &mode)
 
void readSettings ()
 
void writeSettings (const QString &path)
 

Signals

void jsonFileMapChanged ()
 
void operationModeChanged ()
 
void jsonChanged (const QJsonObject &json)
 

Public Member Functions

QString jsonMapData () const
 
QString jsonMapFilename () const
 
QString jsonMapFilepath () const
 
OperationMode operationMode () const
 

Static Public Member Functions

static Generatorinstance ()
 

Properties

QString jsonMapFilename
 
QString jsonMapFilepath
 
OperationMode operationMode
 

Private Slots

void reset ()
 
void readData (const QByteArray &data)
 

Private Member Functions

 Generator ()
 
 Generator (Generator &&)=delete
 
 Generator (const Generator &)=delete
 
Generatoroperator= (Generator &&)=delete
 
Generatoroperator= (const Generator &)=delete
 

Private Attributes

QFile m_jsonMap
 
QJsonObject m_json
 
QJSEngine m_jsEngine
 
QSettings m_settings
 
QString m_jsonMapData
 
OperationMode m_opMode
 
QJsonParseError m_error
 
QStringList m_latestValidValues
 

Detailed Description

The Generator class.

The JSON generator class receives raw frame data from the I/O manager class and generates a JSON file that represents the project title, the groups that compose the project and the datasets that compose each group.

As described in the documentation of the Frame class, the process of receiving data and generating the Serial Studio user interface is: 1) Physical device sends data 2) I/O driver receives data 3) I/O manager processes the data and separates the frames 4) JSON generator creates a JSON file with the data contained in each frame. 5) UI dashboard class receives the JSON file. 6) TimerEvents class notifies the UI dashboard that the user interface should be re-generated. 7) UI dashboard feeds JSON data to a Frame object. 8) The Frame object creates a model of the JSON data with the values of the latest received frame. 9) UI dashboard updates the widgets with the C++ model provided by this class.

Member Enumeration Documentation

◆ OperationMode

Enumerator
kManual 
kAutomatic 

Constructor & Destructor Documentation

◆ Generator() [1/3]

JSON::Generator::Generator ( )
explicitprivate

Initializes the JSON Parser class and connects appropiate SIGNALS/SLOTS

◆ Generator() [2/3]

JSON::Generator::Generator ( Generator &&  )
privatedelete

◆ Generator() [3/3]

JSON::Generator::Generator ( const Generator )
privatedelete

Member Function Documentation

◆ instance()

JSON::Generator & JSON::Generator::instance ( )
static

Returns the only instance of the class

◆ jsonChanged

void JSON::Generator::jsonChanged ( const QJsonObject &  json)
signal

◆ jsonFileMapChanged

void JSON::Generator::jsonFileMapChanged ( )
signal

◆ jsonMapData()

QString JSON::Generator::jsonMapData ( ) const

Returns the JSON map data from the loaded file as a string

◆ jsonMapFilename()

QString JSON::Generator::jsonMapFilename ( ) const

Returns the file name (e.g. "JsonMap.json") of the loaded JSON map file

◆ jsonMapFilepath()

QString JSON::Generator::jsonMapFilepath ( ) const

Returns the file path of the loaded JSON map file

◆ loadJsonMap [1/2]

void JSON::Generator::loadJsonMap ( )
slot

Creates a file dialog & lets the user select the JSON file map

◆ loadJsonMap [2/2]

void JSON::Generator::loadJsonMap ( const QString &  path)
slot

Opens, validates & loads into memory the JSON file in the given path.

◆ operationMode()

JSON::Generator::OperationMode JSON::Generator::operationMode ( ) const

Returns the operation mode

◆ operationModeChanged

void JSON::Generator::operationModeChanged ( )
signal

◆ operator=() [1/2]

Generator & JSON::Generator::operator= ( const Generator )
privatedelete

◆ operator=() [2/2]

Generator & JSON::Generator::operator= ( Generator &&  )
privatedelete

◆ readData

void JSON::Generator::readData ( const QByteArray &  data)
privateslot

Tries to parse the given data as a JSON document according to the selected operation mode.

Possible operation modes:

  • Auto: serial data contains the JSON data frame
  • Manual: serial data only contains the comma-separated values, and we need to use a JSON map file (given by the user) to know what each value means

If JSON parsing is successfull, then the class shall notify the rest of the application in order to process packet data.

◆ readSettings

void JSON::Generator::readSettings ( )
slot

Loads the last saved JSON map file (if any)

◆ reset

void JSON::Generator::reset ( )
privateslot

Resets all the statistics related to the current device and the JSON map file

◆ setOperationMode

void JSON::Generator::setOperationMode ( const JSON::Generator::OperationMode mode)
slot

Changes the operation mode of the JSON parser. There are two possible op. modes:

kManual serial data only contains the comma-separated values, and we need to use a JSON map file (given by the user) to know what each value means. This method is recommended when we need to transfer & display a large amount of information from the microcontroller unit to the computer.

kAutomatic serial data contains the JSON data frame, good for simple applications or for prototyping.

◆ writeSettings

void JSON::Generator::writeSettings ( const QString &  path)
slot

Saves the location of the last valid JSON map file that was opened (if any)

Member Data Documentation

◆ m_error

QJsonParseError JSON::Generator::m_error
private

◆ m_jsEngine

QJSEngine JSON::Generator::m_jsEngine
private

◆ m_json

QJsonObject JSON::Generator::m_json
private

◆ m_jsonMap

QFile JSON::Generator::m_jsonMap
private

◆ m_jsonMapData

QString JSON::Generator::m_jsonMapData
private

◆ m_latestValidValues

QStringList JSON::Generator::m_latestValidValues
private

◆ m_opMode

OperationMode JSON::Generator::m_opMode
private

◆ m_settings

QSettings JSON::Generator::m_settings
private

Property Documentation

◆ jsonMapFilename

QString JSON::Generator::jsonMapFilename
read

◆ jsonMapFilepath

QString JSON::Generator::jsonMapFilepath
read

◆ operationMode

OperationMode JSON::Generator::operationMode
readwrite

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