inital commit
This commit is contained in:
commit
fede535b95
32 changed files with 2357 additions and 0 deletions
78
src/microcontroller.h
Normal file
78
src/microcontroller.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#ifndef MICROCONTROLLER_H
|
||||
#define MICROCONTROLLER_H
|
||||
|
||||
#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"
|
||||
|
||||
class Microcontroller : public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
static constexpr char AMP_RELAY = 0;
|
||||
static constexpr char SENSOR_TEMPERATURE = 1;
|
||||
static constexpr char SENSOR_DOOR = 0 ;
|
||||
|
||||
private:
|
||||
|
||||
bool listMode = false;
|
||||
|
||||
//uint8_t _auxState = 0;
|
||||
|
||||
QIODevice* _port = nullptr;
|
||||
|
||||
std::vector< std::shared_ptr<Item> > itemList;
|
||||
|
||||
QScopedPointer<QEventLoop> loop;
|
||||
QString _buffer;
|
||||
|
||||
void processMicroReturn();
|
||||
void processList(const QString& buffer);
|
||||
void processItemState(const QString& buffer);
|
||||
std::shared_ptr<Item> processTrainLine(const QString& buffer);
|
||||
|
||||
void write(char *buffer, const size_t length);
|
||||
void write(const QByteArray& buffer);
|
||||
|
||||
public:
|
||||
Microcontroller(QIODevice* port);
|
||||
Microcontroller();
|
||||
~Microcontroller();
|
||||
bool connected();
|
||||
void setIODevice(QIODevice* port);
|
||||
|
||||
public slots:
|
||||
void requestState();
|
||||
|
||||
void itemSetSpeed(uint8_t id, uint8_t speed);
|
||||
void itemReverse(uint8_t id);
|
||||
void itemSetFunction(uint8_t id, uint8_t function, bool on);
|
||||
void estop();
|
||||
void setPower(bool on);
|
||||
|
||||
private slots:
|
||||
void isReadyRead();
|
||||
|
||||
signals:
|
||||
void textRecived(const QString string);
|
||||
void itemChanged(ItemData relay);
|
||||
void auxStateChanged(int value);
|
||||
void gotItemList(std::vector< std::shared_ptr<Item> >&);
|
||||
};
|
||||
|
||||
#endif // MICROCONTROLLER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue