-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.cpp
More file actions
108 lines (89 loc) · 2.7 KB
/
tests.cpp
File metadata and controls
108 lines (89 loc) · 2.7 KB
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
105
106
107
#include "tests.h"
#include "controller.h"
#include "ip_connection.h"
#include <QFileInfo>
#include <QThread>
Tests::Tests(Controller *c, IP_Connection *testPCB, QObject *parent):
QObject(parent)
{
PCB = testPCB;
control = c;
// connect(PCB->socket, SIGNAL(readyRead()), this, SLOT(PrintBoardResponse()));
}
void Tests::Test(int setID, int motorID)
{
QString data_to_send = QString("test_motor")
+ QString::number(motorID+1)
+ "_setID="
+ QString::number(setID);
// qDebug() << data_to_send;
PCB->PCB_SendData(data_to_send);
}
void Tests::TestPulsesForOscilloscope()
{
QString data_to_send = QString("test_pulses");
qDebug() << data_to_send;
PCB->PCB_SendData(data_to_send);
}
void Tests::TestForce(int width, int begin, int end, int setID, int motorID)
{
stopForseTest = 0;
for (int period = begin; period <= end; period++) {
if (stopForseTest) break;
qDebug() << period;
control->SetPulses(setID, motorID, QString::number(width), QString::number(period));
QTest::qWait(250);
Test(setID, motorID);
QTest::qWait(5000);
}
}
void Tests::StopForseTest()
{
stopForseTest = 1;
}
void Tests::PrintBoardResponse()
{
QString resp = PCB->socket->readAll();
qDebug() << resp;
}
void Tests::CollectData(int setID, int motorID, QString period)
{
QFileInfo *info = new QFileInfo("D:\\Leetech\\Slave\\DebugLogs\\MatlabSignalFile.log");
QDateTime lastMod = info->lastModified();
QDateTime modified;
for(int pulseWidth = 110; pulseWidth >= 50; pulseWidth -= 10) {
control->SetPulses(setID, motorID, QString::number(pulseWidth), period);
QThread::msleep(200);
for(double destination = 3.; destination <= 12.; destination += 1.) {
control->Reset(setID, motorID);
QThread::msleep(200);
control->SetMotorCoordinate(setID, motorID, QString::number(destination));
QThread::msleep(200);
while(1) {
info->refresh();
QThread::msleep(500);
modified = info->lastModified();
if (modified > lastMod) {
lastMod = modified;
break;
}
}
}
}
}
void Tests::WaitForMotorData()
{
QFileInfo *info = new QFileInfo("D:\\Leetech\\Slave\\DebugLogs\\MatlabSignalFile.log");
QDateTime lastMod = info->lastModified();
QDateTime modified;
bool received = false;
while(received == false) {
info->refresh();
QThread::msleep(100);
modified = info->lastModified();
if (modified > lastMod) {
received = true;
}
}
delete info;
}