?? scripting.h
字號(hào):
/* * Roadnav * Scripting.h * * Copyright (c) 2004 - 2007 Richard L. Lynch <rllynch@users.sourceforge.net> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *////////////////////////////////////////////////////////////////////////////////// \file////// Scripting functions/////////////////////////////////////////////////////////////////////////////////#ifndef SCRIPTING_H#define SCRIPTING_H#ifdef USE_SCRIPTING#include <wx/wx.h>#include <wx/thread.h>#include <wx/datetime.h>#include <wx/stream.h>#include <wx/socket.h>#include <list>#include "libroadnav/MapControl.h"#define DEFAULT_SCRIPTING_TCP_PORT_NUMBER 12937wxString GetScriptExportFilename();bool GetScriptAppendMode();//////////////////////////////////////////////////////////////////////////////////// \brief This class holds a single stream that feeds scripting commands/// to the Scripting class./////////////////////////////////////////////////////////////////////////////////class ScriptStream{ public: ScriptStream(wxInputStream * pInputStream, wxOutputStream * pOutputStream, wxSocketBase * pSocket); ~ScriptStream(); wxInputStream * m_pInputStream; wxString m_strInputBuffer; wxOutputStream * m_pOutputStream; wxSocketBase * m_pSocket; wxDateTime m_tLastRead;};//////////////////////////////////////////////////////////////////////////////////// \brief Scripting engine - manages all of the ScriptStream streams/// and various scripting servers.//////////////////////////////////////////////////////////////////////////////////**\section ScriptingCommands Scripting CommandsThe 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 acommand is signaled by a carriage return.\subsection ADD_WAYPOINT ADD_WAYPOINT The ADD_WAYPOINT creates a new waypoint, or updates an existing one. It acceptsone 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.\subsection GET_WAYPOINT GET_WAYPOINTGET_WAYPOINT takes a single argument - the name of a marker. It returns the address of the requested marker.\subsection DELETE_WAYPOINT DELETE_WAYPOINTDELETE_WAYPOINT takes a single argument - the name of a marker. It immediately deletes the specified marker.\subsection EXIT EXITEXIT does not take any arguments. It immediately closes Roadnav.\section ScriptingAccess Accessing the Scripting EngineThe scripting engine can be accessed either through a TCP connection, or through script files. If the TCP server is enabled in preferences, thenRoadnav will listen for TCP connections on the specified port (default12937). By default connections must come from the computer that is runningRoadnav, however, this can be changed from preferences. Clients connectedto 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, waypointsand other settings can be configured from the convenience of a desktopmachine, and then fed into a (typically keyboard-less) car computer foractual use.*/class Scripting{ public: Scripting(wxWindow * pParent, MapControl * pctlMap); ~Scripting(); void Pump(); bool RunFromFile(wxString strFilename); bool AddTCPServer(int iPort, bool bLocalConnectionsOnly); void DeleteAllTCPServers(); static bool WriteWaypointToFile(wxString strFilename, bool bAppend, const MapMarker & cMarker); private: void PumpScripts(); void PumpServers(); void AddScript(wxInputStream * pInputStream, wxOutputStream * pOutputStream, wxSocketBase * pSocket); void AddServer(wxSocketServer * pServer); std::list<wxString> ExecuteCommand(wxString strCmdAndArgs); std::list<wxString> ExecuteCommand(std::list<wxString> vCmdAndArgs); std::list<wxString> CommandAddWaypoint(wxString strCmd, std::list<wxString> vArgs); std::list<wxString> CommandGetWaypoint(wxString strCmd, std::list<wxString> vArgs); std::list<wxString> CommandDeleteWaypoint(wxString strCmd, std::list<wxString> vArgs); std::list<wxString> CommandExit(wxString strCmd, std::list<wxString> vArgs); static wxString CompileCommand(std::list<wxString> vCmdAndArgs); /// associated map control MapControl * m_pctlMap; /// Streams associated with this scripting engine std::vector<ScriptStream *> m_vScripts; /// Mutex protecting m_vScripts wxMutex m_mtxScripts; /// Socket servers associated with this engine std::vector<wxSocketServer *> m_vServers; /// Mutex protecting m_vServers wxMutex m_mtxServers; /// Parent window wxWindow * m_pParent;};#endif#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -