Pi-XPlane-FMC-CDU
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
FMCManager Class Reference

Manages "current" screen by channelling data and keypresses to a FMC Handler. More...

#include <FMCManager.h>

Public Member Functions

void keyPressEvent (int row, int col)
 
void keyReleaseEvent (int row, int col)
 
void tick ()
 called once every second by Screen's mainloop More...
 
void gotoSplashFMC ()
 
void gotoMainFMC ()
 
void XPlaneBeaconListener (XPlaneBeaconListener::XPlaneServer server, bool exists)
 
void connectToServer (std::string host, int port)
 connect to the server More...
 
void receiveDataFromServer (std::string type, std::string dataref, std::string value)
 callback from network client More...
 
void onExtPlaneConnect ()
 called when server connected. More...
 
void onExtPlaneDisconnect ()
 called when server disconnected.
 
void subscribeDataRef (std::string dataref, float accuracy=0)
 subscribe to a dataref from the current server More...
 
void unsubscribeDataRef (std::string dataref)
 unsubscribe from a dataref from the current server More...
 
void setDataRef (std::string dataref, std::string value)
 set dataref on the server More...
 
void setCurrentFMC (std::string fmc)
 sets current FMC based on string More...
 
std::vector< std::string > getActualFMCList ()
 gets names of actual FMCs
 
void sendCommand (std::string cmd)
 send CMD to current server
 

Static Public Member Functions

static FMCManagergetInstance ()
 

Protected Member Functions

void drawCenteredText (int line, std::string text)
 
void splash ()
 
void setCurrentFMC (AbstractFMC *fmc)
 

Protected Attributes

time_t timeStarted
 time when the FMCManager was created
 
std::string currentConnection
 tracker for current server we're connected to. More...
 
XPlaneExtPlaneClient::ExtPlaneClient * xplaneConnection
 our "connection" to the server More...
 
time_t clearKeyPressTime = 0
 track time when CLR was pressed. More...
 

Static Protected Attributes

static FMCManagerinstance = NULL
 

Detailed Description

Manages "current" screen by channelling data and keypresses to a FMC Handler.

Member Function Documentation

§ connectToServer()

void FMCManager::connectToServer ( std::string  host,
int  port 
)

connect to the server

Well not really a "connection" since we use the UDP interface, but this at least creates the XPlaneUDPClient instance. It's actually possible to connect to a server that isn't there, so ...

We track the "current" connection server by name, so if it if the connection is for a different server, the the old connection is shutdown first.

§ onExtPlaneConnect()

void FMCManager::onExtPlaneConnect ( )

called when server connected.

We should subscribe to datarefs we need here.

§ receiveDataFromServer()

void FMCManager::receiveDataFromServer ( std::string  type,
std::string  dataref,
std::string  value 
)

callback from network client

This is called whenever a dataref update is received from the client.

§ setCurrentFMC()

void FMCManager::setCurrentFMC ( std::string  fmc)

sets current FMC based on string

Used to set an active FMC, by pressing EXEC in selectFMC. Looks up the instance by name in actualFMCs, then calls setCurrentFMC (AbstractFMC * fmc).

Parameters
fmc

§ setDataRef()

void FMCManager::setDataRef ( std::string  dataref,
std::string  value 
)

set dataref on the server

§ subscribeDataRef()

void FMCManager::subscribeDataRef ( std::string  dataref,
float  accuracy = 0 
)

subscribe to a dataref from the current server

Parameters
dataref

§ tick()

void FMCManager::tick ( )

called once every second by Screen's mainloop

§ unsubscribeDataRef()

void FMCManager::unsubscribeDataRef ( std::string  dataref)

unsubscribe from a dataref from the current server

Parameters
dataref

Member Data Documentation

§ clearKeyPressTime

time_t FMCManager::clearKeyPressTime = 0
protected

track time when CLR was pressed.

Used to trigger going to Select screen if held for more than 2 seconds.

§ currentConnection

std::string FMCManager::currentConnection
protected

tracker for current server we're connected to.

a contraction of host + ":" + port. We just use this to see if a connection request is to a different server, in which case we shutdown the old connection first.

§ xplaneConnection

XPlaneExtPlaneClient::ExtPlaneClient* FMCManager::xplaneConnection
protected

our "connection" to the server


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