Commit Iniziale
This commit is contained in:
196
init/roboglue_init.cpp
Normal file
196
init/roboglue_init.cpp
Normal file
@@ -0,0 +1,196 @@
|
||||
#include "roboglue_init.h"
|
||||
#include "ui_roboglue_init.h"
|
||||
|
||||
RoboGlue_INIT::RoboGlue_INIT(QWidget *parent, const char*) : QMainWindow(parent) {
|
||||
|
||||
//////// SETUP LOGGER //////////
|
||||
inilog = spdlog::stdout_logger_mt("RoboGlue_inilog");
|
||||
inilog->info("INIT Started");
|
||||
|
||||
//////// SETUP USER INTERFACE ///////
|
||||
ui = new Ui::RoboGlue_INIT;
|
||||
ui->setupUi(this);
|
||||
|
||||
//////// INITIALIZE MEMORY MODULE ////////////
|
||||
QCoreApplication::setOrganizationName("ETsoft");
|
||||
QCoreApplication::setApplicationName("RoboGlue");
|
||||
settings = new QSettings("../RoboGlue/roboglue.conf", QSettings::IniFormat);
|
||||
sharedmem = new RoboGlue_SHARED(settings);
|
||||
|
||||
//////// RESTORE SETTINGS FOR ALL MODULES ////////////
|
||||
sharedmem->restoreInitSettings();
|
||||
sharedmem->restoreComSettings();
|
||||
sharedmem->restoreGuiSettings();
|
||||
sharedmem->restoreMainSettings();
|
||||
sharedmem->restoreTrackSettings();
|
||||
|
||||
//////// RESTORE UI STATE ////////////
|
||||
ui->chk_comAuto->setChecked(sharedmem->initSettings.autoCom);
|
||||
ui->chk_guiAuto->setChecked(sharedmem->initSettings.autoGui);
|
||||
ui->chk_mainAuto->setChecked(sharedmem->initSettings.autoMain);
|
||||
ui->chk_trackAuto->setChecked(sharedmem->initSettings.autoTrack);
|
||||
|
||||
//////// AUTO START MODULES //////////
|
||||
if (sharedmem->initSettings.autoGui) this->on_btn_guiStart_clicked();
|
||||
if (sharedmem->initSettings.autoMain) this->on_btn_mainStart_clicked();
|
||||
if (sharedmem->initSettings.autoCom) this->on_btn_comStart_clicked();
|
||||
if (sharedmem->initSettings.autoTrack) this->on_btn_trackStart_clicked();
|
||||
|
||||
//////// CONNECT SIGNALS & SLOTS ///////
|
||||
connect(this, SIGNAL(destroyed()), this, SLOT(deleteLater()), Qt::ConnectionType::QueuedConnection);
|
||||
}
|
||||
|
||||
RoboGlue_INIT::~RoboGlue_INIT() {
|
||||
// close order must be opposite of opening one
|
||||
on_btn_trackStop_clicked();
|
||||
on_btn_comStop_clicked();
|
||||
on_btn_mainStop_clicked();
|
||||
on_btn_guistop_clicked();
|
||||
|
||||
sharedmem->saveInitSettings();
|
||||
sharedmem->saveMainSettings();
|
||||
sharedmem->saveTrackSettings();
|
||||
sharedmem->saveComSettings();
|
||||
sharedmem->saveGuiSettings();
|
||||
|
||||
delete robot;
|
||||
delete gui;
|
||||
delete main;
|
||||
delete track;
|
||||
delete settings;
|
||||
delete sharedmem;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/////////////// HEARTBEAT SLOTS ///////////////////
|
||||
///////////////////////////////////////////////////
|
||||
void RoboGlue_INIT::on_robotHeartBeat(){
|
||||
|
||||
}
|
||||
void RoboGlue_INIT::on_guiHeartBeat(){
|
||||
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_mainHeartBeat(){
|
||||
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_trackHeartBeat(){
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////
|
||||
/////////////// BUTTON SLOTS //////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
void RoboGlue_INIT::on_btn_comStart_clicked(){
|
||||
if (robot == nullptr) {
|
||||
robot = new RoboGlue_COM(sharedmem);
|
||||
robot->start();
|
||||
// connect signals
|
||||
if (gui != nullptr){
|
||||
// robot to gui
|
||||
connect(robot, SIGNAL(com_newData(void)),
|
||||
gui, SLOT(on_newRobotData(void)), Qt::ConnectionType::QueuedConnection);
|
||||
//gui to robot
|
||||
connect(gui, SIGNAL(sendROScommand(QString, QVariantMap)),
|
||||
robot, SLOT(on_sendROScommand(QString,QVariantMap)),
|
||||
Qt::ConnectionType::QueuedConnection);
|
||||
connect(gui, SIGNAL(sendROScoordinates(QList<double>)),
|
||||
robot, SLOT(on_sendROScoordinates(QList<double>)),
|
||||
Qt::ConnectionType::QueuedConnection);
|
||||
connect(gui, SIGNAL(sendROSstate(QMap<std::string, bool>, QMap<std::string, uint16_t>)),
|
||||
robot, SLOT(on_sendROSstate(QMap<std::string, bool>, QMap<std::string, uint16_t>)),
|
||||
Qt::ConnectionType::QueuedConnection);
|
||||
connect(gui, SIGNAL(robotSendURscript(QString)),
|
||||
robot, SLOT(on_sendURscript(QString)),
|
||||
Qt::ConnectionType::QueuedConnection);
|
||||
connect(gui, SIGNAL(robotConnect(QString, uint, uchar)),
|
||||
robot, SLOT(on_connect(QString, uint, uchar)),
|
||||
Qt::ConnectionType::QueuedConnection);
|
||||
connect(gui, SIGNAL(robotDisconnect()),
|
||||
robot, SLOT(on_disconnect()),
|
||||
Qt::ConnectionType::QueuedConnection);
|
||||
}
|
||||
// robot to init
|
||||
connect(robot, SIGNAL(com_heartBeat(void)),
|
||||
this, SLOT(on_robotHeartBeat(void)), Qt::ConnectionType::QueuedConnection);
|
||||
// shared memory to robot
|
||||
connect(sharedmem, SIGNAL(commonStatusChange(void)),
|
||||
robot, SLOT(on_commonStatusChange(void)));
|
||||
}
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_btn_comStop_clicked() {
|
||||
if (robot == nullptr) return;
|
||||
robot->on_quit();
|
||||
while (!robot->isFinished()){
|
||||
QThread::msleep(100);
|
||||
}
|
||||
robot->deleteLater();
|
||||
robot=nullptr;
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_btn_guiStart_clicked() {
|
||||
if (gui == nullptr) {
|
||||
gui = new RoboGlue_GUI(sharedmem);
|
||||
gui->show();
|
||||
// shared memory to robot
|
||||
connect(sharedmem, SIGNAL(commonStatusChange(void)),
|
||||
gui, SLOT(on_commonStatusChange(void)));
|
||||
if (robot != nullptr){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_btn_guistop_clicked() {
|
||||
if (gui == nullptr) return;
|
||||
gui->deleteLater();
|
||||
gui = nullptr;
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_btn_mainStart_clicked() {
|
||||
if (main == nullptr){
|
||||
main = new RoboGlue_MAIN(sharedmem);
|
||||
main->start();
|
||||
// connect signals
|
||||
// connect()
|
||||
}
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_btn_mainStop_clicked(){
|
||||
if (main == nullptr) return;
|
||||
main->deleteLater();
|
||||
main = nullptr;
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_btn_trackStart_clicked() {
|
||||
if (track == nullptr){
|
||||
track = new RoboGlue_TRACK(sharedmem);
|
||||
track->start();
|
||||
// connect signals
|
||||
// connect()
|
||||
}
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_btn_trackStop_clicked() {
|
||||
if (track == nullptr) return;
|
||||
track->deleteLater();
|
||||
track = nullptr;
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_chk_comAuto_clicked(bool checked) {
|
||||
sharedmem->initSettings.autoCom=checked;
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_chk_guiAuto_clicked(bool checked) {
|
||||
sharedmem->initSettings.autoGui=checked;
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_chk_trackAuto_clicked(bool checked) {
|
||||
sharedmem->initSettings.autoTrack=checked;
|
||||
}
|
||||
|
||||
void RoboGlue_INIT::on_chk_mainAuto_clicked(bool checked){
|
||||
sharedmem->initSettings.autoMain=checked;
|
||||
}
|
||||
61
init/roboglue_init.h
Normal file
61
init/roboglue_init.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef ROBOGLUE_INIT_H
|
||||
#define ROBOGLUE_INIT_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QThread>
|
||||
#include <QSettings>
|
||||
#include <spdlog/logger.h>
|
||||
#include <spdlog/sinks/stdout_sinks.h>
|
||||
#include <shared/roboglue_shared.h>
|
||||
#include <gui/roboglue_gui.h>
|
||||
#include <com/roboglue_com.h>
|
||||
#include <track/roboglue_track.h>
|
||||
#include <main/roboglue_main.h>
|
||||
|
||||
namespace Ui {
|
||||
class RoboGlue_INIT;
|
||||
}
|
||||
|
||||
class RoboGlue_INIT : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RoboGlue_INIT(QWidget *parent = nullptr, const char* settingsFile = nullptr);
|
||||
virtual ~RoboGlue_INIT();
|
||||
|
||||
private:
|
||||
shared_ptr<spdlog::logger> inilog;
|
||||
|
||||
Ui::RoboGlue_INIT *ui;
|
||||
|
||||
QSettings *settings;
|
||||
RoboGlue_SHARED *sharedmem;
|
||||
RoboGlue_COM *robot = nullptr;
|
||||
RoboGlue_GUI *gui = nullptr;
|
||||
RoboGlue_MAIN *main = nullptr;
|
||||
RoboGlue_TRACK *track = nullptr;
|
||||
|
||||
private slots:
|
||||
// modules heartbeat slots
|
||||
void on_robotHeartBeat();
|
||||
void on_guiHeartBeat();
|
||||
void on_mainHeartBeat();
|
||||
void on_trackHeartBeat();
|
||||
// button slots
|
||||
void on_btn_comStart_clicked();
|
||||
void on_btn_guiStart_clicked();
|
||||
void on_btn_comStop_clicked();
|
||||
void on_btn_guistop_clicked();
|
||||
void on_btn_mainStart_clicked();
|
||||
void on_btn_trackStart_clicked();
|
||||
void on_btn_mainStop_clicked();
|
||||
void on_btn_trackStop_clicked();
|
||||
// checkbox slots
|
||||
void on_chk_comAuto_clicked(bool checked);
|
||||
void on_chk_guiAuto_clicked(bool checked);
|
||||
void on_chk_trackAuto_clicked(bool checked);
|
||||
void on_chk_mainAuto_clicked(bool checked);
|
||||
};
|
||||
|
||||
#endif // ROBOGLUE_INIT_H
|
||||
279
init/roboglue_init.ui
Normal file
279
init/roboglue_init.ui
Normal file
@@ -0,0 +1,279 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RoboGlue_INIT</class>
|
||||
<widget class="QMainWindow" name="RoboGlue_INIT">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>499</width>
|
||||
<height>248</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>RoboGlue_INIT</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_title">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-size:20pt;">RoboGlue_INIT</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="5" column="3">
|
||||
<widget class="QLabel" name="lbl_guiStatus">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="btn_comStop">
|
||||
<property name="text">
|
||||
<string>STOP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Module</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QCheckBox" name="chk_mainAuto">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="btn_guiStart">
|
||||
<property name="text">
|
||||
<string>START</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>RoboGlue_MAIN</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="QCheckBox" name="chk_guiAuto">
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>RoboGlue_GUI</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="lbl_mainStatus">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="btn_mainStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>START</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="btn_guistop">
|
||||
<property name="text">
|
||||
<string>STOP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>RoboGlue_COM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="btn_comStart">
|
||||
<property name="text">
|
||||
<string>START</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="btn_mainStop">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>STOP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>AutoStart</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QCheckBox" name="chk_comAuto">
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="lbl_comStatus">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>RoboGlue_TRACK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="btn_trackStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>START</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="btn_trackStop">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>STOP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QCheckBox" name="chk_trackAuto">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="lbl_trackStatus">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user