Add Gateway terminate status

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2020-10-12 17:35:16 +09:00
parent 1f9241b260
commit 21f2f84219
5 changed files with 15 additions and 3 deletions

View File

@@ -307,7 +307,7 @@ void MultiTaskProcess::waitStop(void)
} }
} }
void MultiTaskProcess::threadStoped(void) void MultiTaskProcess::threadStopped(void)
{ {
_mutex.lock(); _mutex.lock();
_stopCount++; _stopCount++;

View File

@@ -84,7 +84,7 @@ public:
int getParam(const char* parameter, char* value); int getParam(const char* parameter, char* value);
void run(void); void run(void);
void waitStop(void); void waitStop(void);
void threadStoped(void); void threadStopped(void);
void attach(Thread* thread); void attach(Thread* thread);
private: private:

View File

@@ -38,6 +38,7 @@ Gateway::Gateway(void)
_clientList = new ClientList(); _clientList = new ClientList();
_adapterManager = new AdapterManager(this); _adapterManager = new AdapterManager(this);
_topics = new Topics(); _topics = new Topics();
_stopFlg = false;
} }
Gateway::~Gateway() Gateway::~Gateway()
@@ -113,6 +114,7 @@ Gateway::~Gateway()
{ {
delete _topics; delete _topics;
} }
WRITELOG("Gateway is deleted normally.\r\n");
} }
int Gateway::getParam(const char* parameter, char* value) int Gateway::getParam(const char* parameter, char* value)
@@ -309,10 +311,13 @@ void Gateway::run(void)
WRITELOG(" CertKey: %s\n", _params.certKey); WRITELOG(" CertKey: %s\n", _params.certKey);
WRITELOG(" PrivateKey: %s\n\n\n", _params.privateKey); WRITELOG(" PrivateKey: %s\n\n\n", _params.privateKey);
_stopFlg = false;
/* Run Tasks until CTRL+C entred */ /* Run Tasks until CTRL+C entred */
MultiTaskProcess::run(); MultiTaskProcess::run();
_stopFlg = true;
/* stop Tasks */ /* stop Tasks */
Event* ev = new Event(); Event* ev = new Event();
ev->setStop(); ev->setStop();
@@ -331,6 +336,11 @@ void Gateway::run(void)
_lightIndicator.allLightOff(); _lightIndicator.allLightOff();
} }
bool Gateway::IsStopping(void)
{
return _stopFlg;
}
EventQue* Gateway::getPacketEventQue() EventQue* Gateway::getPacketEventQue()
{ {
return &_packetEventQue; return &_packetEventQue;

View File

@@ -199,6 +199,7 @@ public:
bool hasSecureConnection(void); bool hasSecureConnection(void);
Topics* getTopics(void); Topics* getTopics(void);
bool IsStopping(void);
private: private:
GatewayParams _params; GatewayParams _params;
@@ -210,6 +211,7 @@ private:
SensorNetwork _sensorNetwork; SensorNetwork _sensorNetwork;
AdapterManager* _adapterManager {nullptr}; AdapterManager* _adapterManager {nullptr};
Topics* _topics; Topics* _topics;
bool _stopFlg;
}; };
} }

View File

@@ -541,7 +541,7 @@ int Thread::start(void)
void Thread::stopProcess(void) void Thread::stopProcess(void)
{ {
theMultiTaskProcess->threadStoped(); theMultiTaskProcess->threadStopped();
} }
void Thread::stop(void) void Thread::stop(void)