move build system to cmake, add train overlord
This commit is contained in:
parent
ddd0b3a732
commit
a1f9fa172b
34
src/CMakeLists.txt
Normal file
34
src/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets Network SerialPort REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Network SerialPort REQUIRED)
|
||||
|
||||
set(COMMON_SOURCES
|
||||
../common/microcontroller.cpp
|
||||
../common/items/item.cpp
|
||||
../common/items/itemstore.cpp
|
||||
../common/items/signal.cpp
|
||||
../common/items/train.cpp
|
||||
../common/items/turnout.cpp
|
||||
)
|
||||
|
||||
include_directories(PRIVATE
|
||||
./common/items/
|
||||
./common
|
||||
|
||||
)
|
||||
|
||||
set(COMMON_LINK_LIBRARYS
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
Qt${QT_VERSION_MAJOR}::SerialPort
|
||||
)
|
||||
|
||||
add_subdirectory(trainControllerUI)
|
||||
add_subdirectory(trainOverlord)
|
@ -1,19 +0,0 @@
|
||||
#include "auxitem.h"
|
||||
|
||||
AuxItem::AuxItem(Microcontroller* micro, uint32_t itemIdIn, QString name, uint8_t value,
|
||||
QObject* parent): Item(itemIdIn, name, value, parent), micro_(micro)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AuxItem::setValue(uint8_t value)
|
||||
{
|
||||
Item::setValue(value);
|
||||
micro_->setAuxPwm(value);
|
||||
}
|
||||
|
||||
void AuxItem::store(QJsonObject &json)
|
||||
{
|
||||
json["Type"] = "Aux";
|
||||
Item::store(json);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "item.h"
|
||||
#include "../microcontroller.h"
|
||||
|
||||
class AuxItem: public Item
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
Microcontroller* micro_;
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void setValue(uint8_t value);
|
||||
|
||||
public:
|
||||
AuxItem(Microcontroller* micro, uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "",
|
||||
uint8_t value = 0, QObject* parent = nullptr);
|
||||
|
||||
virtual void store(QJsonObject& json);
|
||||
};
|
@ -2,7 +2,6 @@
|
||||
#include <QJsonArray>
|
||||
#include <QDebug>
|
||||
#include "train.h"
|
||||
#include "../trainjs.h"
|
||||
|
||||
ItemStore::ItemStore(QObject *parent): QObject(parent)
|
||||
{
|
||||
@ -21,62 +20,35 @@ void ItemStore::addItem(std::shared_ptr<Item> item)
|
||||
if(!mached)
|
||||
{
|
||||
items_.push_back(std::shared_ptr<Item>(item));
|
||||
|
||||
if(dynamic_cast<Train*>(item.get()))
|
||||
{
|
||||
std::vector<std::shared_ptr<TrainJs>> joysticks = TrainJs::getJsDevices();
|
||||
for(auto joystick: joysticks)
|
||||
{
|
||||
if(!joystick->itemIsSet())
|
||||
{
|
||||
joystick->setItem(item);
|
||||
connect(joystick.get(), &TrainJs::reqNewItem, this, &ItemStore::jsReqNewItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itemAdded(std::weak_ptr<Item>(items_.back()));
|
||||
}
|
||||
qDebug()<<"Got item: "<<item->id()<<" matched: "<<mached;
|
||||
}
|
||||
|
||||
void ItemStore::jsReqNewItem()
|
||||
{
|
||||
if(items_.empty())
|
||||
return;
|
||||
|
||||
std::vector<std::shared_ptr<TrainJs>> joysticks = TrainJs::getJsDevices();
|
||||
for(auto joystick: joysticks)
|
||||
{
|
||||
if(joystick->getWantsNewItem())
|
||||
{
|
||||
std::shared_ptr<Item> oldItem = joystick->getItem().lock();
|
||||
for(size_t i = 0; i < items_.size(); ++i)
|
||||
{
|
||||
if(!oldItem || *items_[i] == *oldItem)
|
||||
{
|
||||
for(size_t j = 1; j < items_.size(); ++j)
|
||||
{
|
||||
std::shared_ptr<Item> item = items_[(i+j) % items_.size()];
|
||||
if(dynamic_cast<Train*>(item.get()))
|
||||
{
|
||||
joystick->setItem(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ItemStore::addItems(const std::vector<std::shared_ptr<Item>>& itemIn)
|
||||
{
|
||||
for(unsigned j = 0; j < itemIn.size(); j++)
|
||||
{
|
||||
addItem(itemIn[j]);
|
||||
|
||||
Train* train = dynamic_cast<Train*>(itemIn[j].get());
|
||||
if(!train)
|
||||
continue;
|
||||
if(train->getTrainId() == 0)
|
||||
{
|
||||
const uint8_t uidBytes[] = {12, 154, 110, 34};
|
||||
train->tags.push_back(NfcUid(uidBytes, sizeof(uidBytes)));
|
||||
}
|
||||
else if(train->getTrainId() == 3)
|
||||
{
|
||||
const uint8_t uidBytes[] = {136, 83, 111, 26};
|
||||
train->tags.push_back(NfcUid(uidBytes, sizeof(uidBytes)));
|
||||
}
|
||||
else if(train->getTrainId() == 4)
|
||||
{
|
||||
const uint8_t uidBytes[] = {76, 55, 220, 31};
|
||||
train->tags.push_back(NfcUid(uidBytes, sizeof(uidBytes)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ItemStore::removeItem(const ItemData& item)
|
||||
@ -91,26 +63,21 @@ void ItemStore::removeItem(const ItemData& item)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ItemStore::clear()
|
||||
{
|
||||
for(size_t i = 0; i < items_.size(); ++i) itemDeleted(*items_[i]);
|
||||
items_.clear();
|
||||
}
|
||||
|
||||
|
||||
void ItemStore::itemStateChanged(const ItemData& item)
|
||||
{
|
||||
|
||||
for(unsigned i = 0; i < items_.size(); i++ )
|
||||
{
|
||||
if(items_[i]->operator==(item))
|
||||
{
|
||||
|
||||
if(items_[i]->getValue() != item.getValue())items_[i]->informValue(item.getValue());
|
||||
if(items_[i]->getValue() != item.getValue())
|
||||
items_[i]->informValue(item.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,12 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "item.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include "../nfcuid.h"
|
||||
|
||||
class ItemStore: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
protected:
|
||||
std::vector< std::shared_ptr<Item> > items_;
|
||||
|
||||
public:
|
||||
@ -23,10 +22,6 @@ public:
|
||||
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
|
||||
void jsReqNewItem();
|
||||
|
||||
signals:
|
||||
|
||||
void itemDeleted(ItemData item);
|
@ -1,16 +1,20 @@
|
||||
#ifndef TRAIN_H
|
||||
#define TRAIN_H
|
||||
|
||||
#include <vector>
|
||||
#include "item.h"
|
||||
#include "../microcontroller.h"
|
||||
#include "../nfcuid.h"
|
||||
|
||||
class Train : public Item
|
||||
{
|
||||
Q_OBJECT
|
||||
uint8_t functionMask_;
|
||||
uint8_t train_id_;
|
||||
int lastReader_ = -1;
|
||||
public:
|
||||
static Microcontroller *micro;
|
||||
std::vector<NfcUid> tags;
|
||||
|
||||
Train(uint8_t id = 0, uint8_t address = 0, uint8_t functionMask = 0, int8_t initalValue = 0);
|
||||
|
||||
@ -23,6 +27,13 @@ public slots:
|
||||
void reverse();
|
||||
virtual void setFunction(uint8_t function, bool on);
|
||||
virtual void setValue(int8_t value);
|
||||
bool passedReader(const NfcUid &uid)
|
||||
{
|
||||
if(lastReader_ == uid.reader)
|
||||
return false;
|
||||
lastReader_ = uid.reader;
|
||||
return true;
|
||||
}
|
||||
uint8_t getTrainId()
|
||||
{
|
||||
return train_id_;
|
@ -142,6 +142,22 @@ std::shared_ptr<Item> Microcontroller::processSignalLine(const QString& buffer)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Microcontroller::processNfcLine(const QString& buffer)
|
||||
{
|
||||
QStringList tokens = buffer.split(" ");
|
||||
if(tokens.size() < 4)
|
||||
return;
|
||||
|
||||
NfcUid uid;
|
||||
uid.reader = tokens[1].toUInt();
|
||||
tokens = tokens[3].split(':');
|
||||
uid.length = tokens.length();
|
||||
for(size_t i = 0; i < uid.length; ++i)
|
||||
uid.bytes[i] = tokens[i].toInt();
|
||||
qDebug()<<"Got Tag";
|
||||
gotTag(uid);
|
||||
}
|
||||
|
||||
void Microcontroller::processList(const QString& buffer)
|
||||
{
|
||||
QStringList bufferList = buffer.split(' ');
|
||||
@ -210,6 +226,10 @@ void Microcontroller::processMicroReturn()
|
||||
{
|
||||
processItemState(_buffer);
|
||||
}
|
||||
else if(_buffer.startsWith("NFC"))
|
||||
{
|
||||
processNfcLine(_buffer);
|
||||
}
|
||||
else if(_buffer.startsWith("TrainController"))
|
||||
{
|
||||
requestState();
|
@ -4,18 +4,17 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <QObject>
|
||||
#include <QColor>
|
||||
#include <QIODevice>
|
||||
#include <QString>
|
||||
#include <QRunnable>
|
||||
#include <QDebug>
|
||||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
#include <QAbstractButton>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include "items/item.h"
|
||||
#include "nfcuid.h"
|
||||
|
||||
class Microcontroller : public QObject
|
||||
{
|
||||
@ -44,6 +43,7 @@ private:
|
||||
std::shared_ptr<Item> processTrainLine(const QString& buffer);
|
||||
std::shared_ptr<Item> processTurnoutLine(const QString& buffer);
|
||||
std::shared_ptr<Item> processSignalLine(const QString& buffer);
|
||||
void processNfcLine(const QString& buffer);
|
||||
|
||||
void write(char *buffer, const size_t length);
|
||||
void write(const QByteArray& buffer);
|
||||
@ -74,6 +74,7 @@ signals:
|
||||
void itemChanged(ItemData relay);
|
||||
void auxStateChanged(int value);
|
||||
void gotItemList(std::vector<std::shared_ptr<Item>>&);
|
||||
void gotTag(NfcUid uid);
|
||||
};
|
||||
|
||||
#endif // MICROCONTROLLER_H
|
47
src/common/nfcuid.h
Normal file
47
src/common/nfcuid.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef NFCUID_H
|
||||
#define NFCUID_H
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class NfcUid
|
||||
{
|
||||
public:
|
||||
uint8_t reader;
|
||||
uint8_t bytes[10];
|
||||
uint8_t length;
|
||||
bool operator==(NfcUid& in) const
|
||||
{
|
||||
if(length != in.length)
|
||||
return false;
|
||||
for(uint8_t i = 0; i < length; ++i)
|
||||
{
|
||||
if(bytes[i] != in.bytes[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!=(NfcUid& in) const
|
||||
{
|
||||
return !operator==(in);
|
||||
}
|
||||
NfcUid(){}
|
||||
NfcUid(const uint8_t* const bytesIn, uint8_t lengthIn, uint8_t readerIn = 0):
|
||||
reader(readerIn), length(lengthIn)
|
||||
{
|
||||
for(uint8_t i = 0; i < length; ++i)
|
||||
bytes[i] = bytesIn[i];
|
||||
}
|
||||
std::string toString()
|
||||
{
|
||||
std::string str;
|
||||
for(uint8_t i = 0; i < length; ++i)
|
||||
{
|
||||
str.append(std::to_string((int)bytes[i]));
|
||||
if(i != length-1)
|
||||
str.push_back(':');
|
||||
}
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // NFCUID_H
|
28
src/trainControllerUI/CMakeLists.txt
Normal file
28
src/trainControllerUI/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
set(UI_SOURCES
|
||||
traincontrollerui.cpp
|
||||
mainobject.cpp
|
||||
QJoysticks.cpp
|
||||
trainjs.cpp
|
||||
ui/itemscrollbox.cpp
|
||||
ui/itemscrollbox.h
|
||||
ui/itemwidget.cpp
|
||||
ui/itemwidget.h
|
||||
ui/mainwindow.cpp
|
||||
ui/mainwindow.h
|
||||
ui/mainwindow.ui
|
||||
ui/relayscrollbox.ui
|
||||
ui/signalwidget.cpp
|
||||
ui/signalwidget.h
|
||||
ui/signalwidget.ui
|
||||
ui/trainwidget.cpp
|
||||
ui/trainwidget.h
|
||||
ui/trainwidget.ui
|
||||
jsbackend/SDL_Joysticks.cpp
|
||||
jsbackend/VirtualJoystick.cpp
|
||||
)
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
add_executable(traincontrollerui ${UI_SOURCES} ${COMMON_SOURCES})
|
||||
target_link_libraries(traincontrollerui PRIVATE ${COMMON_LINK_LIBRARYS} Qt${QT_VERSION_MAJOR}::Widgets ${SDL2_LIBRARIES})
|
||||
target_include_directories(traincontrollerui PRIVATE ./ ./ui ./jsbackend ${SDL2_INCLUDE_DIRS})
|
@ -7,9 +7,6 @@
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QTcpSocket>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonDocument>
|
||||
#include <QStandardPaths>
|
||||
#include <memory>
|
||||
|
||||
|
||||
@ -22,7 +19,6 @@
|
||||
#include "microcontroller.h"
|
||||
#include "ui/mainwindow.h"
|
||||
#include "items/itemstore.h"
|
||||
#include "items/auxitem.h"
|
||||
|
||||
class MainObject : public QObject
|
||||
{
|
@ -31,7 +31,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
//parse comand line
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("Smart Home Interface");
|
||||
parser.setApplicationDescription("Train control gui");
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
QCommandLineOption tcpOption(QStringList() << "t" << "tcp", QCoreApplication::translate("main", "Use Tcp connection"));
|
@ -43,6 +43,17 @@ void ItemScrollBox::addItem(std::weak_ptr<Item> item)
|
||||
widget->setShortcuts(QKeySequence(Qt::Key_R), QKeySequence(Qt::Key_F), QKeySequence(Qt::Key_V));
|
||||
else if(train->getTrainId() == 4)
|
||||
widget->setShortcuts(QKeySequence(Qt::Key_T), QKeySequence(Qt::Key_G), QKeySequence(Qt::Key_B));
|
||||
|
||||
std::vector<std::shared_ptr<TrainJs>> joysticks = TrainJs::getJsDevices();
|
||||
for(auto joystick: joysticks)
|
||||
{
|
||||
if(!joystick->itemIsSet())
|
||||
{
|
||||
joystick->setItem(item);
|
||||
connect(joystick.get(), &TrainJs::reqNewItem, this, &ItemScrollBox::jsReqNewItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(turnout)
|
||||
{
|
||||
@ -80,6 +91,39 @@ void ItemScrollBox::addItem(std::weak_ptr<Item> item)
|
||||
}
|
||||
}
|
||||
|
||||
void ItemScrollBox::jsReqNewItem()
|
||||
{
|
||||
if(widgets_.empty())
|
||||
return;
|
||||
|
||||
std::vector<std::shared_ptr<TrainJs>> joysticks = TrainJs::getJsDevices();
|
||||
for(auto joystick: joysticks)
|
||||
{
|
||||
if(joystick->getWantsNewItem())
|
||||
{
|
||||
std::shared_ptr<Item> oldItem = joystick->getItem().lock();
|
||||
for(size_t i = 0; i < widgets_.size(); ++i)
|
||||
{
|
||||
std::shared_ptr<Item> item = widgets_[i]->getItem().lock();
|
||||
if(item && (!oldItem || *item == *oldItem))
|
||||
{
|
||||
for(size_t j = 1; j < widgets_.size(); ++j)
|
||||
{
|
||||
ItemWidget* widget = widgets_[(i+j) % widgets_.size()];
|
||||
std::shared_ptr<Item> item = widgets_[i]->getItem().lock();
|
||||
if(item && dynamic_cast<Train*>(item.get()))
|
||||
{
|
||||
joystick->setItem(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ItemScrollBox::removeItem(const ItemData& item)
|
||||
{
|
||||
for(unsigned i = 0; i < widgets_.size(); i++)
|
@ -28,12 +28,11 @@ public:
|
||||
explicit ItemScrollBox(QWidget *parent = nullptr);
|
||||
~ItemScrollBox();
|
||||
|
||||
void setItemStore(ItemStore* itemStore);
|
||||
|
||||
public slots:
|
||||
|
||||
void addItem(std::weak_ptr<Item> item);
|
||||
void removeItem(const ItemData& item);
|
||||
void jsReqNewItem();
|
||||
|
||||
private:
|
||||
Ui::RelayScrollBox *ui;
|
@ -3,7 +3,6 @@
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
#include <QShortcut>
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "../items/item.h"
|
||||
|
||||
class ItemWidget : public QWidget
|
@ -1,8 +1,6 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "itemscrollbox.h"
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "itemcreationdialog.h"
|
||||
|
||||
MainWindow::MainWindow(Microcontroller * const micro, ItemStore* items, QWidget *parent) :
|
||||
QMainWindow(parent),
|
@ -3,7 +3,6 @@
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
#include <QShortcut>
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "../items/item.h"
|
||||
#include "itemwidget.h"
|
||||
|
8
src/trainOverlord/CMakeLists.txt
Normal file
8
src/trainOverlord/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
set(UI_SOURCES
|
||||
trainoverlord.cpp
|
||||
overlorditemstore.cpp
|
||||
)
|
||||
|
||||
add_executable(trainoverlord ${UI_SOURCES} ${COMMON_SOURCES})
|
||||
target_link_libraries(trainoverlord PRIVATE ${COMMON_LINK_LIBRARYS})
|
||||
target_include_directories(trainoverlord PRIVATE ./)
|
26
src/trainOverlord/overlorditemstore.cpp
Normal file
26
src/trainOverlord/overlorditemstore.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "overlorditemstore.h"
|
||||
#include <QDebug>
|
||||
#include "train.h"
|
||||
|
||||
OverlordItemStore::OverlordItemStore(QObject *parent): ItemStore(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void OverlordItemStore::gotNfcTag(NfcUid uid)
|
||||
{
|
||||
for(std::shared_ptr<Item> item : items_)
|
||||
{
|
||||
Train* train = dynamic_cast<Train*>(item.get());
|
||||
if(!train)
|
||||
continue;
|
||||
for(const NfcUid& trainUid : train->tags)
|
||||
{
|
||||
if(trainUid == uid)
|
||||
{
|
||||
if(train->passedReader(uid))
|
||||
train->setValue(0-train->getValue());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
src/trainOverlord/overlorditemstore.h
Normal file
16
src/trainOverlord/overlorditemstore.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "itemstore.h"
|
||||
#include <QTimer>
|
||||
|
||||
class OverlordItemStore: public ItemStore
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QTimer timer;
|
||||
public:
|
||||
OverlordItemStore(QObject *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
|
||||
void gotNfcTag(NfcUid);
|
||||
};
|
75
src/trainOverlord/trainoverlord.cpp
Normal file
75
src/trainOverlord/trainoverlord.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QIODevice>
|
||||
#include <QTcpSocket>
|
||||
#include <iostream>
|
||||
|
||||
#include "microcontroller.h"
|
||||
#include "nfcuid.h"
|
||||
#include "overlorditemstore.h"
|
||||
#include "train.h"
|
||||
#include "turnout.h"
|
||||
#include "signal.h"
|
||||
|
||||
void gotTag(NfcUid uid)
|
||||
{
|
||||
std::cout<<"Got tag from "<<uid.reader<<" uid ";
|
||||
for(size_t i = 0; i < uid.length; ++i)
|
||||
{
|
||||
std::cout<<(int)uid.bytes[i]<<(i == uid.length-1 ? "" : ":");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
//set info
|
||||
QCoreApplication::setOrganizationName("UVOS");
|
||||
QCoreApplication::setOrganizationDomain("uvos.xyz");
|
||||
QCoreApplication::setApplicationName("TrainOverlord");
|
||||
QCoreApplication::setApplicationVersion("0.1");
|
||||
|
||||
//parse comand line
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("Train control application");
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
QCommandLineOption hostOption(QStringList() << "H" << "host", QCoreApplication::translate("main",
|
||||
"Set server host ip addres"), "adress");
|
||||
parser.addOption(hostOption);
|
||||
QCommandLineOption portOption(QStringList() << "p" << "port", QCoreApplication::translate("main",
|
||||
"Set server Port in TCP mode or Serial port in serial mode"), "port");
|
||||
parser.addOption(portOption);
|
||||
parser.process(a);
|
||||
|
||||
QTcpSocket microSocket;
|
||||
|
||||
int port = 6856;
|
||||
if(parser.isSet(portOption))
|
||||
port = parser.value(portOption).toInt();
|
||||
|
||||
QString host("127.0.0.1");
|
||||
if(parser.isSet(hostOption)) host = parser.value(hostOption);
|
||||
std::cout<<"connecting to "<<host.toStdString()<<':'<<port<<'\n';
|
||||
microSocket.connectToHost(host, port, QIODevice::ReadWrite);
|
||||
if(!microSocket.waitForConnected(3000))
|
||||
{
|
||||
std::cout<<"Can not connect to to Server.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
OverlordItemStore items;
|
||||
|
||||
Microcontroller micro(µSocket);
|
||||
QObject::connect(µ, &Microcontroller::gotTag, gotTag);
|
||||
QObject::connect(µ, &Microcontroller::gotTag, &items, &OverlordItemStore::gotNfcTag);
|
||||
QObject::connect(µ, &Microcontroller::gotItemList, &items, &OverlordItemStore::addItems);
|
||||
QObject::connect(µ, &Microcontroller::itemChanged, &items, &OverlordItemStore::itemStateChanged);
|
||||
|
||||
Train::micro = µ
|
||||
Turnout::micro = µ
|
||||
Signal::micro = µ
|
||||
|
||||
return a.exec();
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AlarmSettingsDialog</class>
|
||||
<widget class="QDialog" name="AlarmSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>423</width>
|
||||
<height>281</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Sound File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Sunrise</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Enable</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>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AlarmSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AlarmSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,30 +0,0 @@
|
||||
#include "itemcreationdialog.h"
|
||||
#include "ui_itemcreationdialog.h"
|
||||
|
||||
ItemCreationDialog::ItemCreationDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ItemCreationDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->comboBox, &QComboBox::currentTextChanged, this, &ItemCreationDialog::itemTypeChanged);
|
||||
connect(ui->lineEdit, &QLineEdit::textChanged, this, &ItemCreationDialog::itemNameChanged);
|
||||
}
|
||||
|
||||
ItemCreationDialog::~ItemCreationDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ItemCreationDialog::itemTypeChanged(const QString& type)
|
||||
{
|
||||
ui->verticalLayout->removeWidget(widget);
|
||||
}
|
||||
|
||||
void ItemCreationDialog::itemNameChanged(const QString& name)
|
||||
{
|
||||
if(item)
|
||||
{
|
||||
item->setName(name);
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
#ifndef ITEMCREATIONDIALOG_H
|
||||
#define ITEMCREATIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <memory>
|
||||
#include "../items/item.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ItemCreationDialog;
|
||||
}
|
||||
|
||||
class ItemCreationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QWidget* widget;
|
||||
|
||||
public:
|
||||
explicit ItemCreationDialog(QWidget *parent = nullptr);
|
||||
~ItemCreationDialog();
|
||||
|
||||
std::shared_ptr<Item> item;
|
||||
|
||||
private slots:
|
||||
|
||||
void itemTypeChanged(const QString& type);
|
||||
void itemNameChanged(const QString& name);
|
||||
|
||||
private:
|
||||
Ui::ItemCreationDialog *ui;
|
||||
};
|
||||
|
||||
#endif // ITEMCREATIONDIALOG_H
|
@ -1,116 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ItemCreationDialog</class>
|
||||
<widget class="QDialog" name="ItemCreationDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>140</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create Item</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/UVOSicon.bmp</normaloff>:/images/UVOSicon.bmp</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>System</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="text">
|
||||
<string>Item</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ItemCreationDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ItemCreationDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,176 +0,0 @@
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "ui_itemsettingsdialog.h"
|
||||
#include<memory>
|
||||
|
||||
ItemSettingsDialog::ItemSettingsDialog(std::shared_ptr<Item> item, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
item_(item),
|
||||
ui(new Ui::ItemSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setModal(false);
|
||||
|
||||
ui->label_name->setText(item_->getName());
|
||||
ui->checkBox_Override->setChecked(item_->getOverride());
|
||||
|
||||
|
||||
if(std::shared_ptr<Relay> relay = std::dynamic_pointer_cast<Relay>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new RelayItemSettingsWidget(relay);
|
||||
}
|
||||
else if(std::shared_ptr<MessageItem> msgItem = std::dynamic_pointer_cast<MessageItem>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new MessageItemSettingsWidget(msgItem);
|
||||
}
|
||||
else if(std::shared_ptr<SystemItem> sysItem = std::dynamic_pointer_cast<SystemItem>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new SystemItemSettingsWidget(sysItem);
|
||||
}
|
||||
|
||||
if(itemSpecificWidget_)
|
||||
{
|
||||
ui->verticalLayout_2->addWidget(itemSpecificWidget_);
|
||||
}
|
||||
|
||||
connect(ui->pushButton_add, &QPushButton::clicked, this, &ItemSettingsDialog::addActor);
|
||||
connect(ui->pushButton_remove, &QPushButton::clicked, this, &ItemSettingsDialog::removeActor);
|
||||
connect(ui->pushButton_edit, &QPushButton::clicked, this, &ItemSettingsDialog::editActor);
|
||||
connect(ui->checkBox_Override, &QPushButton::clicked, this, &ItemSettingsDialog::changeOverride);
|
||||
|
||||
|
||||
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Actor"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Action"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem("Enabled"));
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(1, 60);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(2, 75);
|
||||
loadActorList();
|
||||
}
|
||||
|
||||
ItemSettingsDialog::~ItemSettingsDialog()
|
||||
{
|
||||
if(itemSpecificWidget_) delete itemSpecificWidget_;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::changeOverride()
|
||||
{
|
||||
item_->setOverride(ui->checkBox_Override->isChecked());
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::loadActorList()
|
||||
{
|
||||
//ui->listWidget->clear();
|
||||
ui->tableWidget->setRowCount(item_->getActors().size());
|
||||
|
||||
for(unsigned i = 0; i < item_->getActors().size(); i++)
|
||||
{
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(item_->getActors()[i]->getName()));
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(item_->getActors()[i]->actionName()));
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(item_->getActors()[i]->isActive() ? "Y" : "N"));
|
||||
}
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::addActor()
|
||||
{
|
||||
ActorSettingsDialog* dialog = nullptr;
|
||||
std::shared_ptr<Actor> actor = nullptr;
|
||||
|
||||
if(ui->comboBox->currentText() == "Alarm")
|
||||
{
|
||||
std::shared_ptr<AlarmTime> alarm = std::shared_ptr<AlarmTime>(new AlarmTime);
|
||||
actor = alarm;
|
||||
dialog = new ActorSettingsDialog(alarm, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Sensor")
|
||||
{
|
||||
std::shared_ptr<SensorActor> sensorActor = std::shared_ptr<SensorActor>(new SensorActor);
|
||||
actor = sensorActor;
|
||||
dialog = new ActorSettingsDialog(sensorActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Timer" )
|
||||
{
|
||||
std::shared_ptr<TimerActor> timerActor = std::shared_ptr<TimerActor>(new TimerActor);
|
||||
actor = timerActor;
|
||||
dialog = new ActorSettingsDialog(timerActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Regulator")
|
||||
{
|
||||
std::shared_ptr<Regulator> regulator = std::shared_ptr<Regulator>(new Regulator);
|
||||
actor = regulator;
|
||||
dialog = new ActorSettingsDialog(regulator, this);
|
||||
}
|
||||
|
||||
else if(ui->comboBox->currentText() == "Polynomal")
|
||||
{
|
||||
std::shared_ptr<PolynomalActor> polynomalActor = std::shared_ptr<PolynomalActor>(new PolynomalActor);
|
||||
actor = polynomalActor;
|
||||
dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
}
|
||||
|
||||
else if(ui->comboBox->currentText() == "Multi Factor")
|
||||
{
|
||||
std::shared_ptr<MultiFactorActor> polynomalActor = std::shared_ptr<MultiFactorActor>(new MultiFactorActor);
|
||||
actor = polynomalActor;
|
||||
dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
}
|
||||
|
||||
|
||||
if(dialog != nullptr)
|
||||
{
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
if(dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
item_->addActor(actor);
|
||||
loadActorList();
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::removeActor()
|
||||
{
|
||||
if(item_->getActors().size() > ui->tableWidget->currentRow())
|
||||
{
|
||||
item_->removeActor(item_->getActors().at(ui->tableWidget->currentRow()));
|
||||
loadActorList();
|
||||
}
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::editActor()
|
||||
{
|
||||
if(item_->getActors().size() > ui->tableWidget->currentRow())
|
||||
{
|
||||
std::shared_ptr<Actor> actor = item_->getActors()[ui->tableWidget->currentRow()];
|
||||
|
||||
std::shared_ptr<AlarmTime> alarmTime = std::dynamic_pointer_cast<AlarmTime>(actor);
|
||||
std::shared_ptr<Regulator> regulator = std::dynamic_pointer_cast<Regulator>(actor);
|
||||
std::shared_ptr<SensorActor> sensorActor = std::dynamic_pointer_cast<SensorActor>(actor);
|
||||
std::shared_ptr<TimerActor> timerActor = std::dynamic_pointer_cast<TimerActor>(actor);
|
||||
std::shared_ptr<PolynomalActor> polynomalActor = std::dynamic_pointer_cast<PolynomalActor>(actor);
|
||||
std::shared_ptr<MultiFactorActor> factorActor = std::dynamic_pointer_cast<MultiFactorActor>(actor);
|
||||
|
||||
ActorSettingsDialog* dialog;
|
||||
|
||||
if(alarmTime) dialog = new ActorSettingsDialog(alarmTime, this);
|
||||
else if(regulator) dialog = new ActorSettingsDialog(regulator, this);
|
||||
else if(sensorActor) dialog = new ActorSettingsDialog(sensorActor, this);
|
||||
else if(timerActor) dialog = new ActorSettingsDialog(timerActor, this);
|
||||
else if(polynomalActor) dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
else if(factorActor) dialog = new ActorSettingsDialog(factorActor, this);
|
||||
else dialog = new ActorSettingsDialog(actor, this);
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
dialog->exec();
|
||||
|
||||
for(int i = 0; i < ui->tableWidget->rowCount() && i < item_->getActors().size(); ++i)
|
||||
{
|
||||
ui->tableWidget->item(i, 0)->setText(item_->getActors()[i]->getName());
|
||||
ui->tableWidget->item(i, 1)->setText(item_->getActors()[i]->actionName());
|
||||
ui->tableWidget->item(i, 2)->setText(item_->getActors()[i]->isActive() ? "Y" : "N");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
#ifndef RELAYSETTINGSDIALOG_H
|
||||
#define RELAYSETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QSettings>
|
||||
#include <memory>
|
||||
#include "../items/item.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ItemSettingsDialog;
|
||||
}
|
||||
|
||||
class ItemSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
std::shared_ptr<Item> item_;
|
||||
QWidget* itemSpecificWidget_ = nullptr;
|
||||
|
||||
private:
|
||||
void loadActorList();
|
||||
|
||||
public:
|
||||
explicit ItemSettingsDialog(std::shared_ptr<Item> item, QWidget *parent = nullptr);
|
||||
~ItemSettingsDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
void removeActor();
|
||||
void addActor();
|
||||
void editActor();
|
||||
void changeOverride();
|
||||
|
||||
private:
|
||||
Ui::ItemSettingsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYSETTINGSDIALOG_H
|
@ -1,274 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ItemSettingsDialog</class>
|
||||
<widget class="QDialog" name="ItemSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>577</width>
|
||||
<height>390</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Item Settings</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/UVOSicon.bmp</normaloff>:/images/UVOSicon.bmp</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>5</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_Override">
|
||||
<property name="text">
|
||||
<string>Override</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="autoScroll">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="tabKeyNavigation">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="gridStyle">
|
||||
<enum>Qt::SolidLine</enum>
|
||||
</property>
|
||||
<property name="cornerButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="rowCount">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>32</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>32</number>
|
||||
</attribute>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_remove">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_edit">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Act on</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Sensor</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Polynomal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Regulator</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Alarm</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Timer</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Multi Factor</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_add">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ItemSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ItemSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,72 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2017-06-01T22:31:38
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui widgets network serialport
|
||||
|
||||
TARGET = traincontrollerui
|
||||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += /usr/include/libnl3/
|
||||
INCLUDEPATH += /usr/include/SDL2/
|
||||
|
||||
LIBS += -lnl-3 -lnl-genl-3 -lSDL2
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which as been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
DEFINES += SDL_SUPPORTED
|
||||
|
||||
QMAKE_CXXFLAGS += -std=c++17 -O2
|
||||
|
||||
SOURCES += \
|
||||
src/items/train.cpp \
|
||||
src/items/turnout.cpp \
|
||||
src/mainobject.cpp \
|
||||
src/trainjs.cpp \
|
||||
src/QJoysticks.cpp \
|
||||
src/jsbackend/SDL_Joysticks.cpp \
|
||||
src/jsbackend/VirtualJoystick.cpp \
|
||||
src/ui/itemwidget.cpp \
|
||||
src/ui/trainwidget.cpp \
|
||||
src/items/signal.cpp \
|
||||
src/ui/signalwidget.cpp \
|
||||
src/ui/itemscrollbox.cpp \
|
||||
src/ui/mainwindow.cpp \
|
||||
src/items/item.cpp \
|
||||
src/items/itemstore.cpp\
|
||||
src/main.cpp \
|
||||
src/microcontroller.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/items/train.h \
|
||||
src/items/turnout.h \
|
||||
src/mainobject.h \
|
||||
src/trainjs.h \
|
||||
src/QJoysticks.h \
|
||||
src/jsbackend/SDL_Joysticks.h \
|
||||
src/jsbackend/VirtualJoystick.h \
|
||||
src/jsbackend/JoysticksCommon.h \
|
||||
src/ui/itemwidget.h \
|
||||
src/ui/trainwidget.h \
|
||||
src/items/signal.h \
|
||||
src/ui/signalwidget.h \
|
||||
src/ui/itemscrollbox.h \
|
||||
src/ui/mainwindow.h \
|
||||
src/items/item.h \
|
||||
src/items/itemstore.h
|
||||
|
||||
HEADERS += \
|
||||
src/microcontroller.h \
|
||||
|
||||
INCLUDEPATH += src/ui/
|
||||
|
||||
FORMS += \
|
||||
src/ui/mainwindow.ui \
|
||||
src/ui/relayscrollbox.ui \
|
||||
src/ui/trainwidget.ui \
|
||||
src/ui/signalwidget.ui
|
Loading…
x
Reference in New Issue
Block a user