Коммит b95b0cef создал по автору Коул Милена Ричардовна's avatar Коул Милена Ричардовна
Просмотр файлов

fix play program work

владелец 462b7654
......@@ -36,9 +36,11 @@ BluetoothMode::BluetoothMode(Vench *vench, QWidget *parent) :
connect(ui->CommTextEdit, &QLineEdit::returnPressed, this, &BluetoothMode::RuchnCommClicked);
connect(ui->BRuchnComm, &QPushButton::clicked, this, &BluetoothMode::RuchnCommClicked);
connect(ui->checkLog, &QCheckBox::clicked, m_vench, &Vench::on_checkLog_n_B_clicked);
connect(ui->checkCicl, &QCheckBox::clicked, m_vench, &Vench::on_checkCicl_n_B_clicked);
connect(ui->BRec, &QPushButton::clicked, this, &BluetoothMode::RecClicked);
connect(ui->BPlay, &QPushButton::clicked, this, &BluetoothMode::PlayClicked);
connect(m_vench, &Vench::playDone, this, &BluetoothMode::PlayClicked);
}
void BluetoothMode::RuchnCommClicked()
......
......@@ -67,7 +67,8 @@ void Vench::init()
mSleep(100);
fl_rec = 0;
fl_play = 0;
fl_play = false;
fl_playLoop = false;
mass_comm_n.clear();
qDebug("ustroistvo vvoda-vivoda: %s\n", addr.toLocal8Bit().constData()); // smotrim kakoe ustroistvo otkrilos
......@@ -122,29 +123,43 @@ int Vench::COMClose()
void Vench::BPressPlay()
{
if(fl_play == 0)
if(!fl_play)
{
ReadProg1();
fl_rec = 0;
fl_play = 1;
fl_play = true;
SendProgramCommand();
}
else
{
fl_play = false;
on_BStop_B_clicked();
}
}
for(int uu = 0; uu < mass_comm_n.count(); ++uu)
{
xml_command xml_c = mass_comm_n.at(uu);
void Vench::SendProgramCommand()
{
if (mass_comm_n.count() > 0)
{
int com = mass_comm_n.first();
mass_comm_n.removeFirst();
if (fl_playLoop)
mass_comm_n.push_back(com);
#ifdef PRINT_DEBUG
qDebug("m1 =%d\n", xml_c.imp1);
qDebug("m2 =%d\n", xml_c.imp2);
qDebug("m3 =%d\n", xml_c.napr);
qDebug("m3 =%d\n", com);
#endif
DoCommand(CommandsCode.key(xml_c.napr, None));
mSleep(1000);
if(fl_play)
{
DoCommand(Stop);
mSleep(500);
DoCommand(CommandsCode.key(com, None));
QTimer::singleShot(500, this, SLOT(SendProgramCommand()));
}
else
return;
}
else
{
fl_play = 0;
on_BStop_B_clicked();
}
emit playDone();
}
void Vench::SetKatalog(QString kat)
......@@ -167,10 +182,7 @@ void Vench::WriteProg1( int k )
for(int i = 0; i < k; ++i)
{
QDomElement node1 = md.createElement("pole");
xml_command xml_c = mass_comm_n.at(i);
node1.setAttribute("imp1", QString().setNum(xml_c.imp1, 10));
node1.setAttribute("imp2", QString().setNum(xml_c.imp2, 10));
node1.setAttribute("napr", QString().setNum(xml_c.napr, 16));
node1.setAttribute("napr", QString().setNum(mass_comm_n.at(i), 16));
node.appendChild(node1);
}
root.appendChild(node);
......@@ -219,12 +231,7 @@ void Vench::ReadProg1()
while(!node1.isNull())
{
if (node1.toElement().tagName() == "pole")
{
xml_command xml_c(node1.toElement().attribute("imp1").toInt(),
node1.toElement().attribute("imp2").toInt(),
node1.toElement().attribute("napr").toInt(nullptr, 16));
mass_comm_n.append(xml_c);
}
mass_comm_n.append(node1.toElement().attribute("napr").toInt(nullptr, 16));
node1 = node1.nextSibling();
}
}
......@@ -440,7 +447,6 @@ int Vench::COMInit(const char* port)
int Vench::Write(int port, QList<int> bt_com)
{
qWarning() << bt_com;
int len = bt_com.count();
unsigned char buf[10];
for (int i = 0; i < len; ++i)
......@@ -560,9 +566,8 @@ void Vench::BRec_pressed_n()
void Vench::DoCommand(Command com)
{
qWarning() << com;
if (fl_rec && CommandsCode.contains(com))
mass_comm_n.append(xml_command(CommandsCode.value(com)));
mass_comm_n.append(CommandsCode.value(com));
if (BluetoothCommands.contains(com))
Write(com_port, BluetoothCommands.value(com));
......@@ -609,6 +614,11 @@ void Vench::on_checkLog_n_B_clicked(bool checked)
fl_print_log = checked;
}
void Vench::on_checkCicl_n_B_clicked(bool checked)
{
fl_playLoop = checked;
}
void Vench::RuchnComm(QString text)
{
text = text.toUpper().replace(" ", " ");
......
......@@ -18,27 +18,6 @@
class QSerialPort;
#endif
struct xml_command
{
public:
int imp1;
int imp2;
int napr;
xml_command(int _napr)
{
imp1 = 10;
imp2 = 10;
napr = _napr;
}
xml_command(int _imp1, int _imp2, int _napr)
{
imp1 = _imp1;
imp2 = _imp2;
napr = _napr;
}
};
enum Command
{
Up,
......@@ -86,8 +65,9 @@ public:
void RuchnComm(QString text);
protected:
QList <xml_command> mass_comm_n;
int fl_play;
QList <int> mass_comm_n;
bool fl_play;
bool fl_playLoop;
int fl_rec;
int fl_kat;
int fl_port_s;
......@@ -125,8 +105,12 @@ protected:
void DoCommand(Command com);
protected slots:
void SendProgramCommand();
public slots:
void on_checkLog_n_B_clicked(bool checked);
void on_checkCicl_n_B_clicked(bool checked);
void on_BUp_B_pressed();
void on_BDown_B_pressed();
void on_BLeft_B_pressed();
......@@ -134,6 +118,9 @@ public slots:
void on_BBip_B_clicked();
void on_BLight_B_clicked();
void on_BStop_B_clicked();
signals:
void playDone();
};
#endif
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать