Telescope Control Library
Diff: EqMountServer.h
- Revision:
- 4:b8ad57bbf9e1
- Parent:
- 0:6cb2eaf8b133
- Child:
- 10:e356188d208e
diff -r d3ea3816dad7 -r b8ad57bbf9e1 EqMountServer.h --- a/EqMountServer.h Tue Aug 21 00:00:48 2018 +0000 +++ b/EqMountServer.h Mon Aug 27 23:24:00 2018 +0000 @@ -1,7 +1,7 @@ /* * EqMountServer.h * - * Created on: 2018Äê3ÔÂ1ÈÕ + * Created on: 2018��3��1�� * Author: caoyuan9642 */ @@ -13,6 +13,8 @@ #include "MountServer.h" #include "EquatorialMount.h" +/** Command structure for the mount server +*/ struct ServerCommand { const char *cmd; /// Name of the command @@ -30,37 +32,48 @@ #define ERR_WRONG_NUM_PARAM 1 #define ERR_PARAM_OUT_OF_RANGE 2 +/** EqMount server class. Receives commands from a stream and execute on the binded EqMount. +*/ class EqMountServer: public MountServer { protected: - EquatorialMount *eq_mount; - FileHandle &stream; + EquatorialMount *eq_mount; /// EqMount to be binded + FileHandle &stream; /// Input stream Thread thread;bool echo; /// Echo - void task_thread(); - - void command_execute(ServerCommand &, int argn, char *argv[], char *buffer); + void task_thread(); /// Main task entrance + void command_execute(ServerCommand &, int argn, char *argv[], char *buffer); /// To execute a server command public: + /** Creates a server with input stream and optionally echoing to the stream. + */ EqMountServer(FileHandle &stream, bool echo = false); virtual ~EqMountServer(); + /** Bind to a EqMount. Commands will be ignored if no mount is binded. + */ void bind(EquatorialMount &eq) { eq_mount = &eq; } + /** @return binded EqMount + */ EquatorialMount* getEqMount() const { return eq_mount; } + /** @return associated stream + */ FileHandle& getStream() const { return stream; } + /** Add a command to the available commands. Must have unique names. + */ static void addCommand(const ServerCommand &cmd); };