Bits and Droids connector
Connect your microcontroller to handle MFS2020 commands.
Loading...
Searching...
No Matches
Signals | Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
MFSWorker Class Reference

MFSWorker is a class that handles the connection to Microsoft Flight Simulator This class handles the connection to Microsoft Flight Simulator and the data that is sent to and from the simulator. This class inherits from QThread and is run in a separate thread from the main thread. More...

#include <MFSWorker.h>

Inheritance diagram for MFSWorker:

Signals

void boardConnectionMade (int con)
 
void logMessage (std::string message, LogLevel level)
 

Public Member Functions

void setInputs (std::map< int, Input >inputsToSet)
 
 MFSWorker ()
 
 ~MFSWorker ()
 
void eventLoop ()
 MFSWorker::eventLoop is the main loop of the application. It directs the connection to the sim and the microcontrollers This loop is started from the Dashboard using the StartButton. /sa Dashboard. More...
 
void sendToArduino (float received, const string &prefix, int index, int mode)
 MFSWorker::sendToArduino is responsible for sending data to the Arduino The modes are defined in the ModeEnum class. More...
 

Public Attributes

bool abortDual
 
QMutex mutex
 
QWaitCondition condition
 

Private Member Functions

void run () override
 
void setConnected (bool connectedToSim)
 
void loadRunningPortsAndSets ()
 MFSWorker::loadRunningPortsAndSets initiates the ports and sets that are saved in the settings file It loads in the coms and bundles them into a single ComBundle object. After this the app loads in all the inputs from the dist/Inputs.json file. More...
 

Static Private Member Functions

static void MyDispatchProcInput (SIMCONNECT_RECV *pData, DWORD cbData, void *pContext)
 MFSWorker::MyDispatchProcInput handles the data received from the simulator. More...
 

Private Attributes

bool connected = false
 
SettingsHandler settingsHandler
 
SIMCONNECT_OBJECT_ID objectID = SIMCONNECT_OBJECT_ID_USER
 
OutputHandler OutputHandler
 
QList< ComBundle * > * comBundles = new QList<ComBundle *>()
 
InputSwitchHandlerdualInputHandler
 
InputMapper dualInputMapper = InputMapper()
 
outputMapperdualOutputMapper = new outputMapper()
 
double dataF = 1.2
 
SIMCONNECT_CLIENT_DATA_ID ClientDataID = 1
 
InputEnum radioDefs = InputEnum()
 
InputMapper radioMap = InputMapper()
 
QList< Output * > outputsToMap
 
QStringList * keys = new QStringList()
 
OutputConverters converter = OutputConverters()
 
std::map< int, Inputinputs = std::map<int, Input>()
 

Detailed Description

MFSWorker is a class that handles the connection to Microsoft Flight Simulator This class handles the connection to Microsoft Flight Simulator and the data that is sent to and from the simulator. This class inherits from QThread and is run in a separate thread from the main thread.

Constructor & Destructor Documentation

◆ MFSWorker()

MFSWorker::MFSWorker ( )

◆ ~MFSWorker()

MFSWorker::~MFSWorker ( )

Member Function Documentation

◆ boardConnectionMade

void MFSWorker::boardConnectionMade ( int  con)
signal

◆ eventLoop()

void MFSWorker::eventLoop ( )

MFSWorker::eventLoop is the main loop of the application. It directs the connection to the sim and the microcontrollers This loop is started from the Dashboard using the StartButton. /sa Dashboard.

◆ loadRunningPortsAndSets()

void MFSWorker::loadRunningPortsAndSets ( )
private

MFSWorker::loadRunningPortsAndSets initiates the ports and sets that are saved in the settings file It loads in the coms and bundles them into a single ComBundle object. After this the app loads in all the inputs from the dist/Inputs.json file.

See also
ComBundle

◆ logMessage

void MFSWorker::logMessage ( std::string  message,
LogLevel  level 
)
signal

◆ MyDispatchProcInput()

void MFSWorker::MyDispatchProcInput ( SIMCONNECT_RECV pData,
DWORD  cbData,
void *  pContext 
)
staticprivate

MFSWorker::MyDispatchProcInput handles the data received from the simulator.

This function monitors the SimConnect data. The function handles SimConnect events provided by the simulator. If new data is available, the function will send the data to the Microcontroller using the sendToArduino function. It also handles the data received from the WASM module.

Parameters
*pData
cbData
*pContextPointer to the calling MFSWorker object. This can be used to reference the MFSWorker object.
See also
MFSWorker::sendToArduino

◆ run()

void MFSWorker::run ( )
inlineoverrideprivate

◆ sendToArduino()

void MFSWorker::sendToArduino ( float  received,
const string &  prefix,
int  index,
int  mode 
)

MFSWorker::sendToArduino is responsible for sending data to the Arduino The modes are defined in the ModeEnum class.

Parameters
receivedis the data received from the simulator
prefixprefix to tag the data
indexindex of the comport
modedefines the data type
See also
ModeEnum

◆ setConnected()

void MFSWorker::setConnected ( bool  connectedToSim)
private

◆ setInputs()

void MFSWorker::setInputs ( std::map< int, Input inputsToSet)

Member Data Documentation

◆ abortDual

bool MFSWorker::abortDual

◆ ClientDataID

SIMCONNECT_CLIENT_DATA_ID MFSWorker::ClientDataID = 1
private

◆ comBundles

QList<ComBundle *>* MFSWorker::comBundles = new QList<ComBundle *>()
private

◆ condition

QWaitCondition MFSWorker::condition

◆ connected

bool MFSWorker::connected = false
private

◆ converter

OutputConverters MFSWorker::converter = OutputConverters()
private

◆ dataF

double MFSWorker::dataF = 1.2
private

◆ dualInputHandler

InputSwitchHandler* MFSWorker::dualInputHandler
private

◆ dualInputMapper

InputMapper MFSWorker::dualInputMapper = InputMapper()
private

◆ dualOutputMapper

outputMapper* MFSWorker::dualOutputMapper = new outputMapper()
private

◆ inputs

std::map<int, Input> MFSWorker::inputs = std::map<int, Input>()
private

◆ keys

QStringList* MFSWorker::keys = new QStringList()
private

◆ mutex

QMutex MFSWorker::mutex

◆ objectID

SIMCONNECT_OBJECT_ID MFSWorker::objectID = SIMCONNECT_OBJECT_ID_USER
private

◆ OutputHandler

OutputHandler MFSWorker::OutputHandler
private

◆ outputsToMap

QList<Output *> MFSWorker::outputsToMap
private

◆ radioDefs

InputEnum MFSWorker::radioDefs = InputEnum()
private

◆ radioMap

InputMapper MFSWorker::radioMap = InputMapper()
private

◆ settingsHandler

SettingsHandler MFSWorker::settingsHandler
private

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