mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 18:33:34 +08:00
Changed AppMgr to AppState
The previous name implied some kind of daemon. AppState is aggregated state of an application's running state and interfaces to request app termination, and check app state. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -43,14 +43,14 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
px4::AppMgr HelloExample::mgr;
|
||||
px4::AppState HelloExample::appState;
|
||||
|
||||
int HelloExample::main()
|
||||
{
|
||||
mgr.setRunning(true);
|
||||
appState.setRunning(true);
|
||||
|
||||
int i=0;
|
||||
while (!mgr.exitRequested() && i<5) {
|
||||
while (!appState.exitRequested() && i<5) {
|
||||
sleep(2);
|
||||
|
||||
printf(" Doing work...\n");
|
||||
|
||||
@@ -49,5 +49,5 @@ public:
|
||||
|
||||
int main();
|
||||
|
||||
static px4::AppMgr mgr; /* Manage requests to terminate app */
|
||||
static px4::AppState appState; /* track requests to terminate app */
|
||||
};
|
||||
|
||||
@@ -63,7 +63,7 @@ int hello_main(int argc, char *argv[])
|
||||
|
||||
if (!strcmp(argv[1], "start")) {
|
||||
|
||||
if (HelloExample::mgr.isRunning()) {
|
||||
if (HelloExample::appState.isRunning()) {
|
||||
printf("already running\n");
|
||||
/* this is not an error */
|
||||
return 0;
|
||||
@@ -80,12 +80,12 @@ int hello_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "stop")) {
|
||||
HelloExample::mgr.requestExit();
|
||||
HelloExample::appState.requestExit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "status")) {
|
||||
if (HelloExample::mgr.isRunning()) {
|
||||
if (HelloExample::appState.isRunning()) {
|
||||
printf("is running\n");
|
||||
|
||||
} else {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
px4::AppMgr VCDevExample::mgr;
|
||||
px4::AppState VCDevExample::appState;
|
||||
|
||||
using namespace device;
|
||||
|
||||
@@ -117,7 +117,7 @@ int test_pub_block(int fd, unsigned long blocked)
|
||||
|
||||
int VCDevExample::main()
|
||||
{
|
||||
mgr.setRunning(true);
|
||||
appState.setRunning(true);
|
||||
|
||||
_node = new VCDevNode();
|
||||
|
||||
@@ -164,7 +164,7 @@ int VCDevExample::main()
|
||||
writer_main,
|
||||
(char* const*)NULL);
|
||||
|
||||
while (!mgr.exitRequested() && i<5) {
|
||||
while (!appState.exitRequested() && i<3) {
|
||||
sleep(2);
|
||||
|
||||
printf(" polling...\n");
|
||||
@@ -179,12 +179,15 @@ int VCDevExample::main()
|
||||
printf("poll failed %d %d\n", ret, px4_errno);
|
||||
px4_close(fd);
|
||||
}
|
||||
else if (ret == 0)
|
||||
printf(" Nothing to read\n");
|
||||
else {
|
||||
printf(" %d to read\n", ret);
|
||||
else if (i > 0 && ret == 0)
|
||||
printf(" Nothing to read - PASS\n");
|
||||
else if (i == 0) {
|
||||
if (ret == 1)
|
||||
printf(" %d to read - %s\n", ret, fds[0].revents & POLLIN ? "PASS" : "FAIL");
|
||||
else
|
||||
printf(" %d to read - FAIL\n", ret);
|
||||
|
||||
}
|
||||
printf(" Doing work...\n");
|
||||
++i;
|
||||
}
|
||||
px4_close(fd);
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
int main();
|
||||
|
||||
static px4::AppMgr mgr; /* Manage requests to terminate app */
|
||||
static px4::AppState appState; /* track requests to terminate app */
|
||||
|
||||
private:
|
||||
VCDevNode *_node;
|
||||
|
||||
@@ -58,7 +58,7 @@ int vcdevtest_main(int argc, char *argv[])
|
||||
|
||||
if (!strcmp(argv[1], "start")) {
|
||||
|
||||
if (VCDevExample::mgr.isRunning()) {
|
||||
if (VCDevExample::appState.isRunning()) {
|
||||
printf("already running\n");
|
||||
/* this is not an error */
|
||||
return 0;
|
||||
@@ -75,12 +75,12 @@ int vcdevtest_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "stop")) {
|
||||
VCDevExample::mgr.requestExit();
|
||||
VCDevExample::appState.requestExit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "status")) {
|
||||
if (VCDevExample::mgr.isRunning()) {
|
||||
if (VCDevExample::appState.isRunning()) {
|
||||
printf("is running\n");
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user