2018-12-19 09:15:42 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 dimercur
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TASKS_H__
|
|
|
|
#define __TASKS_H__
|
|
|
|
|
|
|
|
#ifdef __WITH_PTHREAD__
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2018-12-21 16:36:52 +01:00
|
|
|
//#include "monitor.h"
|
|
|
|
//#include "robot.h"
|
|
|
|
//#include "image.h"
|
|
|
|
//#include "message.h"
|
|
|
|
//#include "server.h"
|
2018-12-19 09:15:42 +01:00
|
|
|
|
2018-12-21 16:36:52 +01:00
|
|
|
#include "camera.h"
|
|
|
|
#include "img.h"
|
2018-12-19 09:15:42 +01:00
|
|
|
|
2018-12-21 16:36:52 +01:00
|
|
|
#include "messages.h"
|
|
|
|
#include "commonitor.h"
|
|
|
|
#include "comrobot.h"
|
2018-12-19 09:15:42 +01:00
|
|
|
|
2018-12-21 16:36:52 +01:00
|
|
|
#include <thread>
|
|
|
|
#include <mutex>
|
|
|
|
#include <condition_variable>
|
2018-12-19 09:15:42 +01:00
|
|
|
|
2018-12-21 16:36:52 +01:00
|
|
|
class Tasks {
|
|
|
|
public:
|
2018-12-19 09:15:42 +01:00
|
|
|
/**
|
2018-12-21 16:36:52 +01:00
|
|
|
* @brief Initialisation des structures de l'application (tâches, mutex,
|
|
|
|
* semaphore, etc.)
|
|
|
|
*/
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Démarrage des tâches
|
|
|
|
*/
|
|
|
|
void Run();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Arrêt des tâches
|
|
|
|
*/
|
|
|
|
void Stop();
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
void Join() {
|
|
|
|
threadServer->join();
|
|
|
|
threadTimer->join();
|
|
|
|
threadSendToMon->join();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
bool AcceptClient() {
|
|
|
|
return monitor.AcceptClient();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Thread handling server communication.
|
|
|
|
*/
|
|
|
|
void ServerTask(void *arg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Thread handling server communication.
|
|
|
|
*/
|
|
|
|
void TimerTask(void *arg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Thread handling communication to monitor.
|
|
|
|
*/
|
|
|
|
void SendToMonTask(void *arg);
|
|
|
|
private:
|
|
|
|
ComMonitor monitor;
|
|
|
|
ComRobot robot;
|
|
|
|
|
2019-01-04 16:55:48 +01:00
|
|
|
bool sendImage=false;
|
|
|
|
bool sendPosition=false;
|
|
|
|
|
2019-01-09 16:32:16 +01:00
|
|
|
int counter;
|
|
|
|
bool flag;
|
|
|
|
|
|
|
|
bool showArena=false;
|
|
|
|
|
2018-12-21 16:36:52 +01:00
|
|
|
thread *threadServer;
|
|
|
|
thread *threadSendToMon;
|
|
|
|
thread *threadTimer;
|
|
|
|
// thread *threadReceiveFromMon;
|
|
|
|
// thread *threadOpenComRobot;
|
|
|
|
// thread *threadStartRobot;
|
|
|
|
// thread *threadMove;
|
|
|
|
// thread *threadTimer;
|
|
|
|
|
|
|
|
mutex mutexTimer;
|
|
|
|
// mutex mutexRobotStarted;
|
|
|
|
// mutex mutexMove;
|
|
|
|
// mutex semBarrier;
|
|
|
|
// mutex semOpenComRobot;
|
|
|
|
// mutex semServerOk;
|
|
|
|
// mutex semStartRobot;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * @brief Thread handling communication from monitor.
|
|
|
|
// */
|
|
|
|
// void ReceiveFromMonTask(void *arg);
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * @brief Thread handling opening of robot communication.
|
|
|
|
// */
|
|
|
|
// void OpenComRobotTask(void * arg);
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * @brief Thread handling robot mouvements.
|
|
|
|
// */
|
|
|
|
// void MoveTask(void *arg);
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * @brief Thread handling robot activation.
|
|
|
|
// */
|
|
|
|
// void StartRobotTask(void *arg);
|
|
|
|
};
|
2018-12-19 09:15:42 +01:00
|
|
|
|
|
|
|
#endif // __WITH_PTHREAD__
|
|
|
|
#endif /* __TASKS_H__ */
|
|
|
|
|