130 lines
3.6 KiB
C++
130 lines
3.6 KiB
C++
#ifndef ROBOGLUE_SHARED_H
|
|
#define ROBOGLUE_SHARED_H
|
|
|
|
/*
|
|
* Created on: Jan 22, 2019
|
|
* Author: emanuele
|
|
*
|
|
* Modulo di memoria condivisa tra i thread per lo scambio di strutture dati che non è permesso
|
|
* nell'invio di segnali.
|
|
* Conterrà anche le funzioni che si occupano di salvare e ripristinare le configurazioni del software.
|
|
*
|
|
* 20190122 - Prima Scittura
|
|
* 20190123 - Implementate le funzioni che leggono il file di configurazione e ripristinano
|
|
* le impostazioni ad ogni avvio.
|
|
* Le impostazioni persistenti sono raggruppate in strutture accessibili ai vari moduli.
|
|
* le funzioni in questa classe si occupano solo di ripristinare i valori salvati
|
|
* ogni modulo è responsabile di aggiornare i valori nella sua struttra e nel file
|
|
* di configurazione che viene salvato alla chiusura del programma.
|
|
* Questo perchè gli eventi che modificano le configurazioni sono molteplici e sparsi in
|
|
* tutti i moduli
|
|
* QUESTA COSA VA GIÀ CAMBIATA PERCHÈ È TROPPO CONFUSIONARIA!!
|
|
* 20190124 - Implementati tutti i metodi che salvano e ripristinano le configurazioni.
|
|
* 20190311 - Aggiunta la struttura che tiene gli stati che devono rimanere comuni ai moduli.
|
|
*
|
|
*/
|
|
|
|
#include <QMutex>
|
|
#include <QSettings>
|
|
#include <QPoint>
|
|
#include <QSize>
|
|
#include <stdexcept>
|
|
#include <libJson/json.hpp>
|
|
#include <libURcom/URCLinterface.h>
|
|
|
|
using namespace nlohmann;
|
|
|
|
class RoboGlue_SHARED : public QObject{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
RoboGlue_SHARED(QSettings *set);
|
|
QMutex mutex;
|
|
|
|
//////////// COMMON MODULES STATUS ///////////////
|
|
struct {
|
|
bool isRecording = false;
|
|
bool isPlaying = false;
|
|
bool isRealtime = false;
|
|
bool isFileOpen = false;
|
|
} commonStatus;
|
|
|
|
/////////// PERMANENT SETTINGS VARIABLES /////////
|
|
struct{
|
|
json baseMessage;
|
|
} commonSettings;
|
|
|
|
struct {
|
|
QPoint pos;
|
|
QSize size;
|
|
std::string version;
|
|
bool autoMain;
|
|
bool autoGui;
|
|
bool autoTrack;
|
|
bool autoCom;
|
|
} initSettings;
|
|
|
|
struct {
|
|
struct {
|
|
std::string robotIp = std::string("192.168.0.31");
|
|
uint robotPort = 30002;
|
|
unsigned char retry = 5;
|
|
bool autoConnect = false;
|
|
char prefix = '{';
|
|
char suffix = '}';
|
|
} connection;
|
|
struct{
|
|
kineDH_t DHtable;
|
|
float maxReach = 1.2;
|
|
} kine;
|
|
std::vector<std::string> subList {
|
|
{"roboglue_com/ros2com/commands"},
|
|
{"roboglue_com/ros2com/coordinates"},
|
|
{"roboglue_com/ros2com/state"}
|
|
};
|
|
std::vector<std::string> pubList {
|
|
{"roboglue_com/com2ros/commands"},
|
|
{"roboglue_com/com2ros/coordinates"},
|
|
{"roboglue_com/com2ros/state"}
|
|
};
|
|
enum {
|
|
COMM, COORD, STAT
|
|
} tList;
|
|
} comSettings;
|
|
|
|
struct {
|
|
std::string namePath = "../RoboGlue/names.json";
|
|
} guiSettings;
|
|
|
|
struct {
|
|
|
|
} mainSettings;
|
|
|
|
struct {
|
|
|
|
} trackSettings;
|
|
|
|
QSettings *settings;
|
|
clientData_t robotData;
|
|
std::map<std::string,int> robotVariables;
|
|
|
|
void restoreCommonSettings();
|
|
void restoreInitSettings();
|
|
void restoreComSettings();
|
|
void restoreGuiSettings();
|
|
void restoreMainSettings();
|
|
void restoreTrackSettings();
|
|
|
|
void saveCommonSettings();
|
|
void saveInitSettings();
|
|
void saveComSettings();
|
|
void saveGuiSettings();
|
|
void saveMainSettings();
|
|
void saveTrackSettings();
|
|
|
|
signals:
|
|
void commonStatusChange(void);
|
|
};
|
|
|
|
#endif // ROBOGLUE_SHARED_H
|