I have a small GUI with two simple buttons to access a LabJAck IO module. This module is used to turn on or turn off an external device connected to it. I have written a class that inits the device and several methods to do some things with the device two of which are, turn on and turn off. The reason I am going about accessing the LAbJack this way is because I would like the code to be nice and neat and I will have several devices connected to my machine with each device having specific IO commands.
Here is my code for the LabJAck:
import u3
class LabJack:
def __init__(self):
try:
self.Switch = u3.U3()
except:
print "Labjack Error"
#Define State Registers for RB12 Relay Card
self.Chan0 = 6008
Chan1 = 6009
Chan2 = 6010
Chan3 = 6011
Chan4 = 6012
Chan5 = 6013
#Turn the channel on
def IO_On(self,Channel):
self.Switch.writeRegister(Channel,0)
#Turn the channel off
def IO_Off(self,Channel):
self.Switch.writeRegister(Channel,1)
#The State of the Channel
def StateSetting(self,Channel):
self.Switch.readRegister(Channel)
if Switch.readRegister(Channel) == 0:
print ('Channel is On')
else:
print('Channel is Off')
#Direction of Current Flow
def CurrentDirection(self,Channel):
self.Switch.readRegister(6108)
print self.Switch.readRegister(6108)
Here is my GUI Code:
import re
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
from LabJackIO import *
from Piezo902 import *
import ui_aldmainwindow
class ALDMainWindow(QMainWindow,ui_aldmainwindow.Ui_ALDMainWindow):
def __init__(self, parent=None):
super(ALDMainWindow,self).__init__(parent)
self.setupUi(self)
self.ValveControl = LabJack()
self.Valve_ON.clicked.connect(self.ValveControl.IO_On(6008))
self.Valve_OFF.clicked.connect(self.ValveControl.IO_Off(self.ValveControl.Chan0))
self.statusBar().showMessage('Valve Off')
app = QApplication(sys.argv)
app.setStyle('motif')
form = ALDMainWindow()
form.show()
app.exec_()
When running the code I get the following error:
Traceback (most recent call last):
File "ALDSoftwareMainWindow.py", line 26, in <module>
form = ALDMainWindow()
File "ALDSoftwareMainWindow.py", line 20, in __init__
self.Valve_ON.clicked.connect(self.ValveControl.IO_On(6008))
TypeError: connect() slot argument should be a callable or a signal, not 'int'
I cant figure out what I am doing wrong. Any help would be greatly appreciated.
Thanks.