-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmanager.h
104 lines (78 loc) · 3 KB
/
tmanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef TMANAGER_H
#define TMANAGER_H
#include <QObject>
#include <QFile>
#include <QDir>
#include "lib/ParamPart_PCSide/parampart_pcs.h"
#include <QtMultimedia/QMediaPlayer>
#include "tstatustable.h"
#include "clock.h"
#include <unistd.h>
class SerialX;
class SlotMaster;
class Mixer;
class TStatusTable;
class TManager:public QObject
{
Q_OBJECT
friend class SlotMaster;
private:
//Managed object pointers
ParamPart *m_ParamPart_ptr;
SlotMaster *m_SM_ptr;
SerialX *m_Serial_ptr;
Mixer *m_Mixer_ptr;
Clock *m_clocky_ptr;
TStatusTable *m_Table_ptr;
QMediaPlayer *player = new QMediaPlayer(NULL,QMediaPlayer::LowLatency);
public:
//Constructor
TManager()=delete;
explicit TManager(ParamPart *PP, SlotMaster *SM, Mixer *M, SerialX *QSP, TStatusTable *ST, Clock *CL, QObject *parent = nullptr)
: QObject(parent),m_ParamPart_ptr(PP),m_SM_ptr(SM),m_Serial_ptr(QSP),m_Mixer_ptr(M),m_Table_ptr(ST),m_clocky_ptr(CL)
{
};
//Functions
bool newJob(const QString& requestLine);
void Reaction(ParamPart &P);
void DeviceReady() {
player->setMedia(QUrl::fromLocalFile("/home/piotr/Pobrane/ding2.wav"));
player->setVolume(30); player->play();
// usleep(2000000);
// sendToDevice("<boot;>",4);
unlockApp();
};
void Log(const QString& Line,const int& Interface=0);
public slots:
// Communication with device - main function
void sendToDevice(const QString& cmd, const int& Interface); // Send normal message to device
void slots_Save(); // Send slots to device
void slots_Load() {sendToDevice("<lq_i;>",4); }; // Load slots from device // Send slots to device // Load slots from device
void drink_Save(); // Save drink schemes to device
void drink_Load() {sendToDevice("<sch_i;>",4);}; // Load drink schemes from device
void drink_Delete(const QString& name) {sendToDevice("<sch_del;"+name+";>",4);};
void glass_Save(bool Force=false); // Save glass settings to device
void glass_Load() {sendToDevice("<n_i;>",4);}; // Load glass settings from device
void fuel_Force(int Idx) {sendToDevice("<rl_fuel;"+QString::number(Idx)+";>",4);};
void sett_ForceSave();// Save settings on device
void executeDisp();
void makeQue();// Start action (move and dispense)
void escape();
void home();
void sink();
//////////////////////////////////
void saveLogToFile(const QString m_text)
{
QDir directory(".");
QString Header="<body bgcolor='black'>";
QFile file(directory.absolutePath()+"/logs/log"+m_clocky_ptr->getDateReformated()+".html");
if(file.open(QIODevice::WriteOnly)) {
QTextStream stream(&file);
stream << Header << m_text;
}
}
signals:
QString addLog(const QString& Line, const QString& Interface="SYSTEM", const QString& Color="red");
void unlockApp();
};
#endif // TMANAGER_H