Scripting Class Reference

Scripting engine - manages all of the ScriptStream streams and various scripting servers. More...

#include <Scripting.h>

List of all members.

Public Member Functions

 Scripting (wxWindow *pParent, MapControl *pctlMap)
 Scripting constructor - initialize all variables.
 ~Scripting ()
 Destructor - free all memory.
void Pump ()
 Pump everything.
bool RunFromFile (wxString strFilename)
 Run a script from a file.
bool AddTCPServer (int iPort, bool bLocalConnectionsOnly)
 Listen on a TCP port for connection for scripting commands.
void DeleteAllTCPServers ()
 Delete all TCP servers.

Static Public Member Functions

static bool WriteWaypointToFile (wxString strFilename, bool bAppend, const MapMarker &cMarker)
 Writes a MapMarker to the specified file (add_waypoint command).

Private Member Functions

void PumpScripts ()
 Processes queued up events - best if run from the main thread of the application, in OnIdle or a timer.
void PumpServers ()
 Accept connections on any servers running.
void AddScript (wxInputStream *pInputStream, wxOutputStream *pOutputStream, wxSocketBase *pSocket)
 Internal function to add script to list.
void AddServer (wxSocketServer *pServer)
 Internal function to add server to list.
std::list< wxString > ExecuteCommand (wxString strCmdAndArgs)
 Low level function to perform the command in a string.
std::list< wxString > ExecuteCommand (std::list< wxString > vCmdAndArgs)
std::list< wxString > CommandAddWaypoint (wxString strCmd, std::list< wxString > vArgs)
 add_waypoint command
std::list< wxString > CommandGetWaypoint (wxString strCmd, std::list< wxString > vArgs)
 get_waypoint command
std::list< wxString > CommandDeleteWaypoint (wxString strCmd, std::list< wxString > vArgs)
 delete_waypoint command
std::list< wxString > CommandExit (wxString strCmd, std::list< wxString > vArgs)
 exit command

Static Private Member Functions

static wxString CompileCommand (std::list< wxString > vCmdAndArgs)

Private Attributes

MapControl * m_pctlMap
 associated map control
std::vector< ScriptStream * > m_vScripts
 Streams associated with this scripting engine.
wxMutex m_mtxScripts
 Mutex protecting m_vScripts.
std::vector< wxSocketServer * > m_vServers
 Socket servers associated with this engine.
wxMutex m_mtxServers
 Mutex protecting m_vServers.
wxWindow * m_pParent
 Parent window.


Detailed Description

Scripting engine - manages all of the ScriptStream streams and various scripting servers.

Scripting Commands

The scripting engines supports the commands described in the following sections. In each case, arguments are separated from each other by tabs, and the end of a command is signaled by a carriage return.

ADD_WAYPOINT

The ADD_WAYPOINT creates a new waypoint, or updates an existing one. It accepts one of the following sets of arguments:

ADD_WAYPOINT <name> <visible> <call_out> <small_label> <icon_filename> <long> <lat> [scale_icon]

ADD_WAYPOINT <name> <visible> <call_out> <small_label> <icon_filename> <street_#> <street_name> <street_type> <city> <state> [scale_icon]

where:

<name> is the name of the waypoint being created or updated.

<visible> is either 1 or 0, indicating if the waypoint should be visible or not.

<call_out> is either 1 or 0, indicating if a callout box should be shown or not.

<small_label> is either 1 or 0, indicating if a small label just showing the waypoint name should be visible or not.

<icon_filename> is the name of the icon that should be shown for the marker. It may be blank to have no icon shown.

[scale_icon] is optional and is either 1 or 0, indicating if the waypoint's icon should be scaled based on the zoom level of the map.

<long> is the longitude of the marker. If must be in ddd.ddddddd format at this time.

<lat> is the latitude of the marker. If must be in ddd.ddddddd format at this time.

<street_#> is the street number of the marker's address.

<street_name> is the street name of the marker's address.

<street_type> is the street type of the marker's address (drive, lane, road, etc.).

<city> is the city of the marker's address.

<state> is the state of the marker's address.

GET_WAYPOINT

GET_WAYPOINT takes a single argument - the name of a marker. It returns the address of the requested marker.

DELETE_WAYPOINT

DELETE_WAYPOINT takes a single argument - the name of a marker. It immediately deletes the specified marker.

EXIT

EXIT does not take any arguments. It immediately closes Roadnav.

Accessing the Scripting Engine

The scripting engine can be accessed either through a TCP connection, or through script files. If the TCP server is enabled in preferences, then Roadnav will listen for TCP connections on the specified port (default 12937). By default connections must come from the computer that is running Roadnav, however, this can be changed from preferences. Clients connected to that TCP port may issue scripting commands and receive back results.

The scripting engine can also read commands from ordinary text files. In the typical use case, on the car computer, in preferences, the startup script enabled option would be checked, and Roadnav would read the script from a USB stick or other removable media. The script would be generated on a different computer, generally a desktop machine. This way, waypoints and other settings can be configured from the convenience of a desktop machine, and then fed into a (typically keyboard-less) car computer for actual use.

Definition at line 154 of file Scripting.h.


Constructor & Destructor Documentation

Scripting::Scripting ( wxWindow *  pParent,
MapControl *  pctlMap 
)

Scripting constructor - initialize all variables.

Definition at line 132 of file Scripting.cpp.

Scripting::~Scripting (  ) 

Destructor - free all memory.

Definition at line 143 of file Scripting.cpp.


Member Function Documentation

void Scripting::Pump (  ) 

Pump everything.

Definition at line 358 of file Scripting.cpp.

bool Scripting::RunFromFile ( wxString  strFilename  ) 

Run a script from a file.

Definition at line 370 of file Scripting.cpp.

bool Scripting::AddTCPServer ( int  iPort,
bool  bLocalConnectionsOnly 
)

Listen on a TCP port for connection for scripting commands.

Definition at line 386 of file Scripting.cpp.

void Scripting::DeleteAllTCPServers (  ) 

Delete all TCP servers.

Definition at line 416 of file Scripting.cpp.

bool Scripting::WriteWaypointToFile ( wxString  strFilename,
bool  bAppend,
const MapMarker &  cMarker 
) [static]

Writes a MapMarker to the specified file (add_waypoint command).

Definition at line 694 of file Scripting.cpp.

void Scripting::PumpScripts (  )  [private]

Processes queued up events - best if run from the main thread of the application, in OnIdle or a timer.

Definition at line 191 of file Scripting.cpp.

void Scripting::PumpServers (  )  [private]

Accept connections on any servers running.

Definition at line 328 of file Scripting.cpp.

void Scripting::AddScript ( wxInputStream *  pInputStream,
wxOutputStream *  pOutputStream,
wxSocketBase *  pSocket 
) [private]

Internal function to add script to list.

Definition at line 165 of file Scripting.cpp.

void Scripting::AddServer ( wxSocketServer *  pServer  )  [private]

Internal function to add server to list.

Definition at line 177 of file Scripting.cpp.

std::list< wxString > Scripting::ExecuteCommand ( wxString  strCmdAndArgs  )  [private]

Low level function to perform the command in a string.

Definition at line 434 of file Scripting.cpp.

std::list<wxString> Scripting::ExecuteCommand ( std::list< wxString >  vCmdAndArgs  )  [private]

list< wxString > Scripting::CommandAddWaypoint ( wxString  strCmd,
std::list< wxString >  vArgs 
) [private]

add_waypoint command

add_waypoint <name> <visible> <call_out> <small_label> <icon_filename> <long> <lat> [scale_icon]

add_waypoint <name> <visible> <call_out> <small_label> <icon_filename> <street_#> <street name>=""> <street type>=""> <city> <state> [scale_icon]

Definition at line 491 of file Scripting.cpp.

list< wxString > Scripting::CommandGetWaypoint ( wxString  strCmd,
std::list< wxString >  vArgs 
) [private]

get_waypoint command

get_waypoint <name>

Will return the address and coordinates of waypoint

Definition at line 619 of file Scripting.cpp.

list< wxString > Scripting::CommandDeleteWaypoint ( wxString  strCmd,
std::list< wxString >  vArgs 
) [private]

delete_waypoint command

delete_waypoint <name>

Definition at line 591 of file Scripting.cpp.

list< wxString > Scripting::CommandExit ( wxString  strCmd,
std::list< wxString >  vArgs 
) [private]

exit command

exit

Causes Roadnav to exit

Definition at line 649 of file Scripting.cpp.

static wxString Scripting::CompileCommand ( std::list< wxString >  vCmdAndArgs  )  [static, private]


Member Data Documentation

MapControl* Scripting::m_pctlMap [private]

associated map control

Definition at line 187 of file Scripting.h.

std::vector<ScriptStream *> Scripting::m_vScripts [private]

Streams associated with this scripting engine.

Definition at line 190 of file Scripting.h.

wxMutex Scripting::m_mtxScripts [private]

Mutex protecting m_vScripts.

Definition at line 193 of file Scripting.h.

std::vector<wxSocketServer *> Scripting::m_vServers [private]

Socket servers associated with this engine.

Definition at line 197 of file Scripting.h.

wxMutex Scripting::m_mtxServers [private]

Mutex protecting m_vServers.

Definition at line 200 of file Scripting.h.

wxWindow* Scripting::m_pParent [private]

Parent window.

Definition at line 203 of file Scripting.h.


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

Generated on Sun Jul 27 17:26:16 2008 for Roadnav by  doxygen 1.5.5