-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.cpp
106 lines (89 loc) · 2.5 KB
/
client.cpp
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
#include "client.h"
// Client* Client::p_instance = NULL;
void Client::writePV(QString name, QString value)
{
if(!_writePV(name, value.toStdString().c_str(), DBF_STRING))
{
QMessageBox::warning(NULL, "Error writing to PV", "Could not write the value to PV: " + name);
return;
}
}
void Client::writePV(QString name, int value)
{
if(!_writePV(name, &value, DBF_INT))
{
QMessageBox::warning(NULL, "Error writing to PV", "Could not write the value to PV: " + name);
return;
}
}
void Client::writePV(QString name, double value)
{
if(!_writePV(name, &value, DBF_DOUBLE))
{
QMessageBox::warning(NULL, "Error writing to PV", "Could not write the value to PV: " + name);
return;
}
}
void Client::writePV(QString name, unsigned value)
{
if(!_writePV(name, &value, DBF_LONG))
{
QMessageBox::warning(NULL, "Error writing to PV", "Could not write the value to PV: " + name);
return;
}
}
void Client::writeArray(QString name, void *data, unsigned long size)
{
int status;
chid pvID;
ca_search(name.toStdString().c_str(), &pvID);
status = ca_pend_io(1);
if(status != ECA_NORMAL)
{
QMessageBox::warning(NULL, "Error writing to PV", "Could not write the value to PV: " + name);
return;
}
ca_array_put(DBF_LONG, size, pvID, data);
return;
}
void Client::writeDoubleArray(QString name, void *data, unsigned long size)
{
int status;
chid pvID;
ca_search(name.toStdString().c_str(), &pvID);
status = ca_pend_io(1);
if(status != ECA_NORMAL)
{
QMessageBox::warning(NULL, "Error writing to PV", "Could not write the value to PV: " + name);
return;
}
ca_array_put(DBF_DOUBLE, size, pvID, data);
return;
}
void Client::writeStringToWaveform(QString name, QString value)
{
int status;
chid pvID;
ca_search(name.toStdString().c_str(), &pvID);
status = ca_pend_io(1);
if (status != ECA_NORMAL)
{
QMessageBox::warning(nullptr, "Error writing to PV", "Could not write the value to PV: " + name);
return;
}
ca_array_put(DBR_CHAR, value.length() + 1, pvID, const_cast<char*>(value.toStdString().c_str()));
return;
}
bool Client::_writePV(QString name, const void* value, int type)
{
int status;
chid pvID;
ca_search(name.toStdString().c_str(), &pvID);
status = ca_pend_io(1);
if(status != ECA_NORMAL)
{
return false;
}
ca_put(type, pvID, value);
return true;
}