use spaces instead of tab
This commit is contained in:
+174
-174
@@ -36,220 +36,220 @@ namespace ebusd {
|
||||
* The main loop handling requests from connected clients.
|
||||
*/
|
||||
class MainLoop : public Thread, DeviceListener {
|
||||
public:
|
||||
/**
|
||||
* Construct the main loop and create network and bus handling components.
|
||||
* @param opt the program options.
|
||||
* @param device the @a Device instance.
|
||||
* @param messages the @a MessageMap instance.
|
||||
*/
|
||||
MainLoop(const struct options opt, Device *device, MessageMap* messages);
|
||||
public:
|
||||
/**
|
||||
* Construct the main loop and create network and bus handling components.
|
||||
* @param opt the program options.
|
||||
* @param device the @a Device instance.
|
||||
* @param messages the @a MessageMap instance.
|
||||
*/
|
||||
MainLoop(const struct options opt, Device *device, MessageMap* messages);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~MainLoop();
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~MainLoop();
|
||||
|
||||
/**
|
||||
* Get the @a BusHandler instance.
|
||||
* @return the created @a BusHandler instance.
|
||||
*/
|
||||
BusHandler* getBusHandler() { return m_busHandler; }
|
||||
/**
|
||||
* Get the @a BusHandler instance.
|
||||
* @return the created @a BusHandler instance.
|
||||
*/
|
||||
BusHandler* getBusHandler() { return m_busHandler; }
|
||||
|
||||
/**
|
||||
* Add a client @a NetMessage to the queue.
|
||||
* @param message the client @a NetMessage to handle.
|
||||
*/
|
||||
void addMessage(NetMessage* message) { m_netQueue.push(message); }
|
||||
/**
|
||||
* Add a client @a NetMessage to the queue.
|
||||
* @param message the client @a NetMessage to handle.
|
||||
*/
|
||||
void addMessage(NetMessage* message) { m_netQueue.push(message); }
|
||||
|
||||
// @copydoc
|
||||
virtual void notifyDeviceData(const unsigned char byte, bool received);
|
||||
// @copydoc
|
||||
virtual void notifyDeviceData(const unsigned char byte, bool received);
|
||||
|
||||
|
||||
protected:
|
||||
// @copydoc
|
||||
virtual void run();
|
||||
protected:
|
||||
// @copydoc
|
||||
virtual void run();
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Decode and execute client message.
|
||||
* @param data the data string to decode (may be empty).
|
||||
* @param connected set to false when the client connection shall be closed.
|
||||
* @param isHttp true for HTTP message.
|
||||
* @param listening set to true when the client is in listening mode.
|
||||
* @param reload set to true when the configuration files were reloaded.
|
||||
* @return result string to send back to the client.
|
||||
*/
|
||||
string decodeMessage(const string& data, const bool isHttp, bool& connected, bool& listening, bool& reload);
|
||||
private:
|
||||
/**
|
||||
* Decode and execute client message.
|
||||
* @param data the data string to decode (may be empty).
|
||||
* @param connected set to false when the client connection shall be closed.
|
||||
* @param isHttp true for HTTP message.
|
||||
* @param listening set to true when the client is in listening mode.
|
||||
* @param reload set to true when the configuration files were reloaded.
|
||||
* @return result string to send back to the client.
|
||||
*/
|
||||
string decodeMessage(const string& data, const bool isHttp, bool& connected, bool& listening, bool& reload);
|
||||
|
||||
/**
|
||||
* Parse the hex master message from the remaining arguments.
|
||||
* @param args the arguments passed to the command.
|
||||
* @param argPos the index of the first argument to parse.
|
||||
* @param master the master @a SymbolString to write the data to.
|
||||
* @return the result from parsing the arguments.
|
||||
*/
|
||||
result_t parseHexMaster(vector<string> &args, size_t argPos, SymbolString& master);
|
||||
/**
|
||||
* Parse the hex master message from the remaining arguments.
|
||||
* @param args the arguments passed to the command.
|
||||
* @param argPos the index of the first argument to parse.
|
||||
* @param master the master @a SymbolString to write the data to.
|
||||
* @return the result from parsing the arguments.
|
||||
*/
|
||||
result_t parseHexMaster(vector<string> &args, size_t argPos, SymbolString& master);
|
||||
|
||||
/**
|
||||
* Execute the read command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeRead(vector<string> &args);
|
||||
/**
|
||||
* Execute the read command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeRead(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the write command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeWrite(vector<string> &args);
|
||||
/**
|
||||
* Execute the write command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeWrite(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the hex command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeHex(vector<string> &args);
|
||||
/**
|
||||
* Execute the hex command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeHex(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the find command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeFind(vector<string> &args);
|
||||
/**
|
||||
* Execute the find command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeFind(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the listen command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @param listening set to true when the client is in listening mode.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeListen(vector<string> &args, bool& listening);
|
||||
/**
|
||||
* Execute the listen command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @param listening set to true when the client is in listening mode.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeListen(vector<string> &args, bool& listening);
|
||||
|
||||
/**
|
||||
* Execute the state command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeState(vector<string> &args);
|
||||
/**
|
||||
* Execute the state command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeState(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the grab command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeGrab(vector<string> &args);
|
||||
/**
|
||||
* Execute the grab command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeGrab(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the scan command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeScan(vector<string> &args);
|
||||
/**
|
||||
* Execute the scan command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeScan(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the log command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeLog(vector<string> &args);
|
||||
/**
|
||||
* Execute the log command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeLog(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the raw command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeRaw(vector<string> &args);
|
||||
/**
|
||||
* Execute the raw command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeRaw(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the dump command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeDump(vector<string> &args);
|
||||
/**
|
||||
* Execute the dump command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeDump(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the reload command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeReload(vector<string> &args);
|
||||
/**
|
||||
* Execute the reload command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeReload(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the info command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeInfo(vector<string> &args);
|
||||
/**
|
||||
* Execute the info command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeInfo(vector<string> &args);
|
||||
|
||||
/**
|
||||
* Execute the quit command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @param connected set to false when the client connection shall be closed.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeQuit(vector<string> &args, bool& connected);
|
||||
/**
|
||||
* Execute the quit command.
|
||||
* @param args the arguments passed to the command (starting with the command itself), or empty for help.
|
||||
* @param connected set to false when the client connection shall be closed.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeQuit(vector<string> &args, bool& connected);
|
||||
|
||||
/**
|
||||
* Execute the help command.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeHelp();
|
||||
/**
|
||||
* Execute the help command.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeHelp();
|
||||
|
||||
/**
|
||||
* Execute the HTTP GET command.
|
||||
* @param args the arguments passed to the command (starting with the command itself).
|
||||
* @param connected set to false when the client connection shall be closed.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeGet(vector<string> &args, bool& connected);
|
||||
/**
|
||||
* Execute the HTTP GET command.
|
||||
* @param args the arguments passed to the command (starting with the command itself).
|
||||
* @param connected set to false when the client connection shall be closed.
|
||||
* @return the result string.
|
||||
*/
|
||||
string executeGet(vector<string> &args, bool& connected);
|
||||
|
||||
/** the @a Device instance. */
|
||||
Device* m_device;
|
||||
/** the @a Device instance. */
|
||||
Device* m_device;
|
||||
|
||||
/** the number of reconnects requested from the @a Device. */
|
||||
unsigned int m_reconnectCount;
|
||||
/** the number of reconnects requested from the @a Device. */
|
||||
unsigned int m_reconnectCount;
|
||||
|
||||
/** the @a RotateFile for writing sent/received bytes in log format, or NULL. */
|
||||
RotateFile* m_logRawFile;
|
||||
/** the @a RotateFile for writing sent/received bytes in log format, or NULL. */
|
||||
RotateFile* m_logRawFile;
|
||||
|
||||
/** whether raw logging to @p logNotice is enabled (only relevant if m_logRawFile is NULL). */
|
||||
bool m_logRawEnabled;
|
||||
/** whether raw logging to @p logNotice is enabled (only relevant if m_logRawFile is NULL). */
|
||||
bool m_logRawEnabled;
|
||||
|
||||
/** the @a RotateFile for dumping received data, or NULL. */
|
||||
RotateFile* m_dumpFile;
|
||||
/** the @a RotateFile for dumping received data, or NULL. */
|
||||
RotateFile* m_dumpFile;
|
||||
|
||||
/** the @a MessageMap instance. */
|
||||
MessageMap* m_messages;
|
||||
/** the @a MessageMap instance. */
|
||||
MessageMap* m_messages;
|
||||
|
||||
/** the own master address for sending on the bus. */
|
||||
const unsigned char m_address;
|
||||
/** the own master address for sending on the bus. */
|
||||
const unsigned char m_address;
|
||||
|
||||
/** whether to pick configuration files matching initial scan. */
|
||||
const bool m_scanConfig;
|
||||
/** whether to pick configuration files matching initial scan. */
|
||||
const bool m_scanConfig;
|
||||
|
||||
/** the initial address to scan for @a m_scanConfig (@a ESC=none, 0xfe=broadcast ident, @a SYN=full scan, else: single slave address). */
|
||||
const unsigned char m_initialScan;
|
||||
/** the initial address to scan for @a m_scanConfig (@a ESC=none, 0xfe=broadcast ident, @a SYN=full scan, else: single slave address). */
|
||||
const unsigned char m_initialScan;
|
||||
|
||||
/** whether to enable the hex command. */
|
||||
const bool m_enableHex;
|
||||
/** whether to enable the hex command. */
|
||||
const bool m_enableHex;
|
||||
|
||||
/** the created @a BusHandler instance. */
|
||||
BusHandler* m_busHandler;
|
||||
/** the created @a BusHandler instance. */
|
||||
BusHandler* m_busHandler;
|
||||
|
||||
/** the created @a Network instance. */
|
||||
Network* m_network;
|
||||
/** the created @a Network instance. */
|
||||
Network* m_network;
|
||||
|
||||
/** the @a NetMessage @a Queue. */
|
||||
Queue<NetMessage*> m_netQueue;
|
||||
/** the @a NetMessage @a Queue. */
|
||||
Queue<NetMessage*> m_netQueue;
|
||||
|
||||
/** the path for HTML files served by the HTTP port. */
|
||||
string m_htmlPath;
|
||||
/** the path for HTML files served by the HTTP port. */
|
||||
string m_htmlPath;
|
||||
|
||||
/** the registered @a DataHandler instances. */
|
||||
list<DataHandler*> m_dataHandlers;
|
||||
/** the registered @a DataHandler instances. */
|
||||
list<DataHandler*> m_dataHandlers;
|
||||
};
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
Reference in New Issue
Block a user