@@ -78,6 +78,131 @@ class DashboardClient : public comm::TCPSocket
7878 */
7979 std::string sendAndReceive (const std::string& command);
8080
81+ /* !
82+ * \brief Sends command and compare it with the expected answer
83+ *
84+ * \param command Command that will be sent to the server. It is important, that the command sent is finished with a
85+ * '\n' (newline) so it will be processed by the server.
86+ * \param expected Expected replay
87+ *
88+ * \return True if the reply to the command is as expected
89+ */
90+ bool sendRequest (const std::string& command, const std::string& expected);
91+
92+ /* !
93+ * \brief brief Sends a command and wait until it returns the expected answer
94+ *
95+ * \param command Command that will be sent to the server
96+ * \param expected Expected replay
97+ * \param timeout Timeout time in seconds
98+ *
99+ * \return True if the reply was as expected within the timeout time
100+ */
101+ bool waitForReply (const std::string& command, const std::string& expected, double timeout = 30.0 );
102+
103+ /* !
104+ * \brief Keep Sending the requesting Command and wait until it returns the expected answer
105+ *
106+ * \param requestCommand Request command that will be sent to the server
107+ * \param requestExpectedResponse The expected reply to the request
108+ * \param waitRequest The status request
109+ * \param waitExpectedResponse The expected reply on the status
110+ * \param timeout Timeout time in seconds
111+ *
112+ * \return True when both the requested command was receive with the expected reply as well as the resulting status
113+ * also is as expected within the timeout time
114+ */
115+ bool retryCommand (const std::string& requestCommand, const std::string& requestExpectedResponse,
116+ const std::string& waitRequest, const std::string& waitExpectedResponse, unsigned int timeout);
117+
118+ /* !
119+ * \brief Send Power off command
120+ *
121+ * \return True succeeded
122+ */
123+ bool commandPowerOff ();
124+
125+ /* !
126+ * \brief Send Power on command
127+ *
128+ * \param timeout Timeout in seconds
129+ *
130+ * \return True succeeded
131+ */
132+ bool commandPowerOn (unsigned int timeout = 1200 );
133+
134+ /* !
135+ * \brief Send Brake release command
136+ *
137+ * \return True succeeded
138+ */
139+ bool commandBreakeRelease ();
140+
141+ /* !
142+ * \brief Send Load program command
143+ *
144+ * \param program_file_name The urp program file name with the urp extension
145+ *
146+ * \return True succeeded
147+ */
148+ bool commandLoadProgram (const std::string& program_file_name);
149+
150+ /* !
151+ * \brief Send Play program command
152+ *
153+ * \return True succeeded
154+ */
155+ bool commandPlay ();
156+
157+ /* !
158+ * \brief Send Pause program command
159+ *
160+ * \return True succeeded
161+ */
162+ bool commandPause ();
163+
164+ /* !
165+ * \brief Send Stop program command
166+ *
167+ * \return True succeeded
168+ */
169+ bool commandStop ();
170+
171+ /* !
172+ * \brief Send Close popup command
173+ *
174+ * \return True succeeded
175+ */
176+ bool commandClosePopup ();
177+
178+ /* !
179+ * \brief Send Close safety popup command
180+ *
181+ * \return True succeeded
182+ */
183+ bool commandCloseSafetyPopup ();
184+
185+ /* !
186+ * \brief Send Restart Safety command
187+ *
188+ * \return True succeeded
189+ */
190+ bool commandRestartSafety ();
191+
192+ /* !
193+ * \brief Send Unlock Protective stop popup command
194+ *
195+ * \return True succeeded
196+ */
197+ bool commandUnlockProtectiveStop ();
198+
199+ /* !
200+ * \brief Send Shutdown command
201+ *
202+ * \return True succeeded
203+ */
204+ bool commandShutdown ();
205+
81206protected:
82207 virtual bool open (int socket_fd, struct sockaddr * address, size_t address_len)
83208 {
@@ -87,11 +212,7 @@ class DashboardClient : public comm::TCPSocket
87212private:
88213 bool send (const std::string& text);
89214 std::string read ();
90-
91- void rtrim (std::string& str, const std::string& chars = " \t\n\v\f\r " )
92- {
93- str.erase (str.find_last_not_of (chars) + 1 );
94- }
215+ void rtrim (std::string& str, const std::string& chars = " \t\n\v\f\r " );
95216
96217 std::string host_;
97218 int port_;
0 commit comments