-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotor.cpp
More file actions
executable file
·62 lines (52 loc) · 1.11 KB
/
motor.cpp
File metadata and controls
executable file
·62 lines (52 loc) · 1.11 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
#include "gpib/ib.h"
#include "gpib/gpib_user.h"
#include "unistd.h"
#include <cstring>
#include "motor.h"
#include <iostream>
using namespace std;
int Motor::InitGPIB()
{
int boardIndex=0;
int primaryAddress = 4;
int secondaryAddress=0;
int gpibTimeout = T3s;
int EOImode = 1;
int EOSmode = 0;
userDescriptor = ibdev(boardIndex,
primaryAddress,
secondaryAddress,
gpibTimeout,
EOImode,
EOSmode);
if (userDescriptor<0) return -1;
return 0;
}
int Motor::SendStringGPIB(char *x)
{
ibwrt(userDescriptor,x,strlen(x));
if (ibsta & ERR)
{
printf("Send string error. String is %s. ibsta=0x%x\n",x,ibsta);
return -1;
}
return 0;
}
Motor::Motor(QObject *parent) : QObject(parent)
{
}
void Motor::perform_motion()
{
int status;
status = InitGPIB();
if (status < 0)
{
printf("GPIB detection error\n");
sleep(2);
emit GPIB_err_connection();
std::cout << "No connection" << std::endl; //sta roba non va
} else{
emit GPIBconnected();
std::cout << "Connection!" << std::endl;
}
}