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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
void K8055QT::ConnectButton_clicked()
{
if (self.card != None) and (self.k == None):
try:
#print "Connect to card #",self.card
self.k = k8055(self.card)
self.EnableAll()
self.ClearAllDigitalButton_clicked()
self.ClearAllAnalogButton_clicked()
self.comboCounter1.setCurrentItem(0)
self.comboCounter2.setCurrentItem(0)
self.ConnectButton.setText(self.__tr("Disconnect"))
except:
print "No such Card"
elif (self.k != None):
try:
#print "Disconnect from card #",self.card
self.k.CloseDevice()
self.k = None
self.DisableAll()
self.OutputBox1.setChecked(0)
self.OutputBox2.setChecked(0)
self.OutputBox3.setChecked(0)
self.OutputBox4.setChecked(0)
self.OutputBox5.setChecked(0)
self.OutputBox6.setChecked(0)
self.OutputBox7.setChecked(0)
self.OutputBox8.setChecked(0)
self.BarDA1.setValue(0)
self.BarDA2.setValue(0)
self.BarAD1.setValue(0)
self.BarAD2.setValue(0)
self.DA1Value.setProperty("intValue",QVariant(0))
self.DA2Value.setProperty("intValue",QVariant(0))
self.AD1Value.setProperty("intValue",QVariant(0))
self.AD2Value.setProperty("intValue",QVariant(0))
self.comboCounter1.setCurrentItem(0)
self.comboCounter2.setCurrentItem(0)
self.Counter1Value.setProperty("intValue",QVariant(0))
self.Counter2Value.setProperty("intValue",QVariant(0))
self.ConnectButton.setText(self.__tr("Connect"))
except:
pass
}
void K8055QT::CardButton1_clicked()
{
self.card = 0
}
void K8055QT::CardButton2_clicked()
{
self.card = 1
}
void K8055QT::CardButton3_clicked()
{
self.card = 2
}
void K8055QT::CardButton4_clicked()
{
self.card = 3
}
void K8055QT::init()
{
self.k = None
self.DisableAll()
}
void K8055QT::ClearCounter1_clicked()
{
if self.k:
self.k.ResetCounter(1)
}
void K8055QT::ClearCounter2_clicked()
{
if self.k:
self.k.ResetCounter(2)
}
void K8055QT::OutputBox1_clicked()
{
if self.k:
if self.OutputBox1.isChecked():
self.k.SetDigitalChannel(1)
else:
self.k.ClearDigitalChannel(1)
}
void K8055QT::OutputBox2_clicked()
{
if self.k:
if self.OutputBox2.isChecked():
self.k.SetDigitalChannel(2)
else:
self.k.ClearDigitalChannel(2)
void K8055QT::OutputBox3_clicked()
{
if self.k:
if self.OutputBox3.isChecked():
self.k.SetDigitalChannel(3)
else:
self.k.ClearDigitalChannel(3)
}
void K8055QT::OutputBox4_clicked()
{
if self.k:
if self.OutputBox4.isChecked():
self.k.SetDigitalChannel(4)
else:
self.k.ClearDigitalChannel(4)
}
void K8055QT::OutputBox5_clicked()
{
if self.k:
if self.OutputBox5.isChecked():
self.k.SetDigitalChannel(5)
else:
self.k.ClearDigitalChannel(5)
}
void K8055QT::OutputBox6_clicked()
{
if self.k:
if self.OutputBox6.isChecked():
self.k.SetDigitalChannel(6)
else:
self.k.ClearDigitalChannel(6)
}
void K8055QT::OutputBox7_clicked()
{
if self.k:
if self.OutputBox7.isChecked():
self.k.SetDigitalChannel(7)
else:
self.k.ClearDigitalChannel(7)
}
void K8055QT::OutputBox8_clicked()
{
if self.k:
if self.OutputBox8.isChecked():
self.k.SetDigitalChannel(8)
else:
self.k.ClearDigitalChannel(8)
}
void K8055QT::SetAllAnalogButton_clicked()
{
if self.k:
self.k.SetAllAnalog()
self.BarAD1.setValue(0)
self.BarAD2.setValue(0)
self.AD1Value.setProperty("intValue",QVariant(255))
self.AD2Value.setProperty("intValue",QVariant(255))
}
void K8055QT::ClearAllAnalogButton_clicked()
{
if self.k:
self.k.ClearAllAnalog()
self.BarAD1.setValue(255)
self.BarAD2.setValue(255)
self.AD1Value.setProperty("intValue",QVariant(0))
self.AD2Value.setProperty("intValue",QVariant(0))
}
void K8055QT::SetAllDigitalButton_clicked()
{
if self.k:
self.k.SetAllDigital()
self.OutputBox1.setChecked(1)
self.OutputBox2.setChecked(1)
self.OutputBox3.setChecked(1)
self.OutputBox4.setChecked(1)
self.OutputBox5.setChecked(1)
self.OutputBox6.setChecked(1)
self.OutputBox7.setChecked(1)
self.OutputBox8.setChecked(1)
}
void K8055QT::ClearAllDigitalButton_clicked()
{
if self.k:
self.k.ClearAllDigital()
self.OutputBox1.setChecked(0)
self.OutputBox2.setChecked(0)
self.OutputBox3.setChecked(0)
self.OutputBox4.setChecked(0)
self.OutputBox5.setChecked(0)
self.OutputBox6.setChecked(0)
self.OutputBox7.setChecked(0)
self.OutputBox8.setChecked(0)
}
void K8055QT::BarAD1_valueChanged( int )
{
if self.k:
self.k.OutputAnalogChannel(1,255-a0)
self.AD1Value.setProperty("intValue",QVariant(255-a0))
}
void K8055QT::BarAD2_valueChanged( int )
{
if self.k:
self.k.OutputAnalogChannel(2,255-a0)
self.AD2Value.setProperty("intValue",QVariant(255-a0))
}
void K8055QT::comboCounter2_activated( int )
{
if self.k:
v = str(self.comboCounter2.currentText()).split()
self.k.SetCounterDebounceTime(2,int(v[0]))
}
void K8055QT::comboCounter1_activated( int )
{
if self.k:
v = str(self.comboCounter1.currentText()).split()
self.k.SetCounterDebounceTime(1,int(v[0]))
}
void K8055QT::TestDigitalButton_clicked()
{
self.DigitalTest()
}
void K8055QT::TestAnalogButton_clicked()
{
self.AnalogTest()
}
|