-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Software][Cyclope controller] Allowed to power the robot off from th…
…e user interface.
- Loading branch information
1 parent
c746c75
commit e809f48
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Software/Raspberry_Pi/cyclope/package/cyclope-controller/src/Includes/WebPagePowerOff.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** @file WebPagePowerOff.hpp | ||
* Cleanly power the robot off. | ||
* @author Adrien RICCIARDI | ||
*/ | ||
#ifndef HPP_WEB_PAGE_POWER_OFF_HPP | ||
#define HPP_WEB_PAGE_POWER_OFF_HPP | ||
|
||
#include <WebPageBase.hpp> | ||
|
||
class WebPagePowerOff : public WebPageBase | ||
{ | ||
public: | ||
// See base class documentation for description | ||
WebPagePowerOff(); | ||
|
||
// See base class documentation for description | ||
virtual int generateContent(std::string &referenceStringContent) override; | ||
}; | ||
|
||
/** Give global access to the page statically allocated instance. */ | ||
extern WebPagePowerOff webPagePowerOff; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Software/Raspberry_Pi/cyclope/package/cyclope-controller/src/Sources/WebPagePowerOff.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** @file WebPagePowerOff.cpp | ||
* See WebPagePowerOff.hpp for description. | ||
* @author Adrien RICCIARDI | ||
*/ | ||
#include <cstdlib> | ||
#include <Log.hpp> | ||
#include <WebPagePowerOff.hpp> | ||
|
||
WebPagePowerOff::WebPagePowerOff() : WebPageBase("/power-off") {}; | ||
|
||
int WebPagePowerOff::generateContent(std::string &referenceStringContent) | ||
{ | ||
referenceStringContent = | ||
"<div class=\"text-center\">\n" | ||
" <h1>The robot has been powered off.</h1>\n" | ||
"</div>\n"; | ||
|
||
LOG(LOG_INFO, "Received the power off command, shutting the system down."); | ||
system("poweroff"); | ||
|
||
return 0; | ||
} | ||
|
||
// The statically allocated instance of the page | ||
WebPagePowerOff webPagePowerOff{}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters