Index: /trigger/CommServer.py
===================================================================
--- /trigger/CommServer.py	(revision 52)
+++ /trigger/CommServer.py	(revision 52)
@@ -0,0 +1,148 @@
+#!/usr/bin/python
+# First the server
+
+
+
+"""
+A basic, multiclient 'chat server' using Python's select module
+with interrupt handling.
+
+Entering any line of input at the terminal will exit the server.
+"""
+
+import select
+import socket
+import sys
+import signal
+from communication import send, receive
+import threading
+import GlobalVariables
+BUFSIZ = 1024
+
+
+class CommServer(threading.Thread):
+    """ Simple  server using select """
+    
+    def __init__(self, port=3490, backlog=5):
+        self.clients = 0
+        # Client map
+        self.clientmap = {}
+        # Output socket list
+        self.outputs = []
+        self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+        self.server.bind(('',port))
+        print 'Listening to port',port,'...'
+        self.server.listen(backlog)
+        # Trap keyboard interrupts
+        #signal.signal(signal.SIGINT, self.sighandler)
+        
+    def sighandler(self, signum, frame):
+        # Close the server
+        print 'Shutting down server...'
+        # Close existing client sockets
+        for o in self.outputs:
+            o.close()
+            
+        self.server.close()
+
+    def getname(self, client):
+
+        # Return the printable name of the
+        # client, given its socket...
+        info = self.clientmap[client]
+        host, name = info[0][0], info[1]
+        return '@'.join((name, host))
+        
+    def serve(self):
+        
+        inputs = [self.server,sys.stdin]
+        self.outputs = []
+
+        running = 1
+
+        while running:
+
+            try:
+                inputready,outputready,exceptready = select.select(inputs, self.outputs, [])
+            except select.error, e:
+                break
+            except socket.error, e:
+                break
+
+            for s in inputready:
+
+                if s == self.server:
+                    # handle the server socket
+                    client, address = self.server.accept()
+                    print 'server: got connection %d from %s' % (client.fileno(), address)
+                    # Read the login name
+                    cname = receive(client).split('NAME: ')[1]
+                    
+                    # Compute client name and send back
+                    self.clients += 1
+                    send(client, 'CLIENT: ' + str(address[0]))
+                    inputs.append(client)
+
+                    self.clientmap[client] = (address, cname)
+                    # Send joining information to other clients
+                    msg = '\n(Connected: New client (%d) from %s)' % (self.clients, self.getname(client))
+                    for o in self.outputs:
+                        # o.send(msg)
+                        send(o, msg)
+                    
+                    self.outputs.append(client)
+
+                #elif s == sys.stdin:
+                    # handle standard input
+                #    junk = sys.stdin.readline()
+                #    if (junk[:-1]=='exit'):
+                #        running = 0
+                elif s!=sys.stdin:
+                    # handle all other sockets
+                    try:
+                        # data = s.recv(BUFSIZ)
+                        data = receive(s)
+                        if data:
+                            # Send as new client's message...
+                            msg = 'SERVER: You sent: >> ' + data
+                            GlobalVariables.UserInput=data
+                            if(GlobalVariables.UserInput=='exit' or GlobalVariables.UserInput=='EXIT'):
+                                running=0
+                                print 'Shutting down server...'
+                                # Close existing client sockets
+                                for o in self.outputs:
+                                    o.close()
+                                    
+                            # Send data to all except ourselves
+                            for o in self.outputs:
+                                #if o != s:
+                                # o.send(msg)
+                                send(o, msg)
+                        else:
+                            print 'server: %d hung up' % s.fileno()
+                            self.clients -= 1
+                            s.close()
+                            inputs.remove(s)
+                            self.outputs.remove(s)
+
+                            # Send client leaving information to others
+                            msg = '\n(Hung up: Client from %s)' % self.getname(s)
+                            for o in self.outputs:
+                                # o.send(msg)
+                                send(o, msg)
+                                
+                    except socket.error, e:
+                        # Remove
+                        inputs.remove(s)
+                        self.outputs.remove(s)
+                        
+
+
+        self.server.close()
+        def run(self):
+            self.serve()
+            
+if __name__ == "__main__":
+    commServer=CommServer()
+    commServer().start()
Index: /trigger/CommSocket.py
===================================================================
--- /trigger/CommSocket.py	(revision 52)
+++ /trigger/CommSocket.py	(revision 52)
@@ -0,0 +1,163 @@
+#!/usr/bin/python
+# First the server
+
+
+
+"""
+A basic, multiclient 'chat server' using Python's select module
+with interrupt handling.
+
+Entering any line of input at the terminal will exit the server.
+"""
+
+import select
+import socket
+import sys
+import signal
+from communication import send, receive
+import threading
+import GlobalVariables
+import time
+BUFSIZ = 1024
+
+
+class CommServer(threading.Thread):
+    """ Simple  server using select """
+    
+    def __init__(self, port=3490, backlog=5):
+        self.clients = 0
+        # Client map
+        self.clientmap = {}
+        # Output socket list
+        self.outputs = []
+        self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+        self.server.bind(('',port))
+        print 'SERVER: Listening to port',port,'...'
+        self.server.listen(backlog)
+        # Trap keyboard interrupts
+        #signal.signal(signal.SIGINT, self.sighandler)
+        threading.Thread.__init__(self)
+    #def sighandler(self, signum, frame):
+    #    if(GlobalVariables.UserInput=='exit' or GlobalVariables.UserInput=='EXIT'):
+    #        running=0
+    #        for o in self.outputs:
+    #            o.close()
+    #        
+    #        self.server.close()
+     #   print "TEST"
+        # Close the server
+    #    print 'SERVER: Shutting down server...'
+        # Close existing client sockets
+     #   for o in self.outputs:
+      #      o.close()
+            
+     #   self.server.close()
+
+    def getname(self, client):
+
+        # Return the printable name of the
+        # client, given its socket...
+        info = self.clientmap[client]
+        host, name = info[0][0], info[1]
+        return '@'.join((name, host))
+        
+    def run(self):
+        
+        inputs = [self.server,sys.stdin]
+        self.outputs = []
+
+        running = 1
+
+        while running:
+            time.sleep(0.01)
+            if(GlobalVariables.UserInput=='exit' or GlobalVariables.UserInput=='EXIT'):
+                running=0
+            
+            try:
+                inputready,outputready,exceptready = select.select(inputs, self.outputs, [])
+            except select.error, e:
+                break
+            except socket.error, e:
+                break
+
+            for s in inputready:
+
+                if s == self.server:
+                    # handle the server socket
+                    client, address = self.server.accept()
+                    print 'SERVER: got connection %d from %s' % (client.fileno(), address)
+                    # Read the login name
+                    cname = receive(client).split('NAME: ')[1]
+                    
+                    # Compute client name and send back
+                    self.clients += 1
+                    send(client, 'FROM SERVER: CLIENT: ' + str(address[0]))
+                    inputs.append(client)
+
+                    self.clientmap[client] = (address, cname)
+                    # Send joining information to other clients
+                    msg = '\nFROM SERVER: (Connected: New client (%d) from %s)' % (self.clients, self.getname(client))
+                    for o in self.outputs:
+                        # o.send(msg)
+                        send(o, msg)
+                    
+                    self.outputs.append(client)
+
+                #elif s == sys.stdin:
+                    # handle standard input
+                 #   junk = sys.stdin.readline()
+                 #   if (junk[:-1]=='exit' or junk[:-1]=='EXIT' ):
+                 #       running = 0
+                        # Close the server
+                 #       print 'SERVER: Shutting down server...'
+                 #       # Close existing client sockets
+                 #       for o in self.outputs:
+                 #           o.close()
+                        
+                elif s!=sys.stdin:
+                    # handle all other sockets
+                    try:
+                        # data = s.recv(BUFSIZ)
+                        data = receive(s)
+                        if data:
+                            # Send as new client's message...
+                            msg = 'SERVER: You sent: >> ' + data
+                            GlobalVariables.UserInput=data
+                            print "SERVER: recv data: "+data
+                            for o in self.outputs:
+                                send(o, msg)
+                            if(GlobalVariables.UserInput=='exit' or GlobalVariables.UserInput=='EXIT'):
+                                running=0
+                                # Send data to all except ourselves
+                                                            
+                        else:
+                            print 'SERVER: %d hung up' % s.fileno()
+                            self.clients -= 1
+                            s.close()
+                            inputs.remove(s)
+                            self.outputs.remove(s)
+
+                            # Send client leaving information to others
+                            msg = 'SERVER: \n(Hung up: Client from %s)' % self.getname(s)
+                            for o in self.outputs:
+                                # o.send(msg)
+                                send(o, msg)
+                                
+                    except socket.error, e:
+                        # Remove
+                        inputs.remove(s)
+                        self.outputs.remove(s)
+                        
+
+        print 'SERVER: Shutting down server...'
+        # Close existing client sockets
+        for o in self.outputs:
+            o.close()
+        self.server.close()
+        #def run(self):
+        #    self.serve()
+            
+if __name__ == "__main__":
+    commServer=CommServer(3491,5)
+    commServer.start()
Index: /trigger/CommunicateWithVME.py
===================================================================
--- /trigger/CommunicateWithVME.py	(revision 52)
+++ /trigger/CommunicateWithVME.py	(revision 52)
@@ -0,0 +1,182 @@
+#!/usr/bin/python
+##############################################################
+#
+#  CommunicateWithVME.py
+#  Handles the communication with the VME crate
+#  can send commands to the VME crate
+#
+#  
+#  Michael Rissi 05/2009
+#
+#############################################################
+
+import GlobalVariables
+import threading
+import _VME
+import time
+def GetRate(module,channel):
+    _VME.V560_Clear_Scales( module)
+    beginCounter=_VME. V560_Read_Counter( module,  channel)
+    print "Evaluating rates (2 seconds)..."
+    time.sleep(2)
+    endCounter = _VME. V560_Read_Counter( module,  channel)
+    return (endCounter-beginCounter)/2000.
+
+def GetRates(module):
+    _VME.V560_Clear_Scales( module)
+    beginCounter =[0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0]
+    endCounter =  [0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0]
+    rates      =  [0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0]
+    
+    for i in range(0,16):
+        beginCounter[i]=_VME. V560_Read_Counter( module,  i)
+        print beginCounter[i]
+    print "Evaluating rates..."
+    time.sleep(2)
+    for i in range(0,16):
+        endCounter[i] = _VME. V560_Read_Counter( module,  i)
+        print endCounter[i]
+        rates[i] =(endCounter[i]-beginCounter[i])/2000.
+    return rates
+    
+class ParseUserInput(threading.Thread):
+    def Parse(self,Command):
+        print "PARSING: ",Command
+        sCommand=Command.split()
+        error_code=0
+        #python lacks switch...
+        try:
+            VMEModule=sCommand[0]
+            if(VMEModule == "help"): print "please use \'<V812|V560|Triggerboard> help\' "
+            
+            # now do the stuff for the V560:
+            if(VMEModule == "V560"):
+                V560Command=sCommand[1]
+                if(V560Command=="help"):
+                    print "available functions are: "
+                    print "V560 GetRate <module#> <channel#>"
+                    print "V560 GetRates <module#> "
+                    
+                if(V560Command=="GetRate"):
+                    print "trying to get rate"
+                    try:
+                        module = sCommand[2]
+                        channel= sCommand[3]
+                        print GetRate(int(module),int(channel))
+                    except:
+                        print "Syntax Error (GetRate)"
+                    #GlobalVariables.Rates[int(channel)] = GetRates(int(module),int(channel))
+
+                if(V560Command=="GetRates"):
+                    print "trying to get rates"
+                    try:
+                        module = sCommand[2]
+
+                        print GetRates(int(module))
+                    except:
+                        print "Syntax Error (GetRates)"
+                    #GlobalVariables.Rates[int(channel)] = GetRates(int(module),int(channel))
+        
+
+            # now do the stuff for the V812:
+            elif(VMEModule == "V812"):
+                V812Command=sCommand[1]
+                if(V812Command=="help"):
+                    print "available functions are: "
+                    print "V812 SetHexPat <module#[1-10]> <HexPattern[0x0000-0xFFFF>"
+                    print "V812 SetThresh <module#[1-10]> <channel#[0-15]> <thresh[0-255]>"
+                    print "V812 SetMajLevel <module#[1-10]> <MajLev[1-20]>"
+                    print "V812 SetMajThresh <module#[1-10]> <MajThr[0-255]>"
+                    print "V812 SetDeadTime <module#[1-10]> <Block [0-1]> <DeadTime[0-255]>"
+
+                #set the hexpattern:
+                elif(V812Command=="SetHexPat"):
+                    print "trying to set the hexpattern:"
+                    try:
+                        module = int(sCommand[2])
+                        hexpat = int(sCommand[3],16)
+                        #hexpat="ddd"
+                        print "setting module ",module," to hexpat: ",hex(hexpat)
+                        try:
+                            error_code=_VME.V812_Set_Pattern_Inhibit_Hex(module, hexpat)
+                            print "success! "
+                            
+                        except:
+                            VME_ErrorPrint(error_code)
+                    except:
+                        print "Syntax error (SetHexPat)"
+
+
+                elif(V812Command=="SetThresh"):
+                    print "trying to set the threshold:"
+                    try:
+                        module  = int(sCommand[2])
+                        channel = int(sCommand[3])
+                        thresh  = int(sCommand[4])
+                        print "setting threshold of channel: ",channel, " in module ",module," to: ",thresh
+                        print "success: ",_VME.V812_Set_Threshold(module, channel,  thresh)
+                    except:
+                        print "Syntax error (SetThresh) "
+                        
+                elif(V812Command=="SetMajLevel"):
+                    print "trying to set the majority level:"
+                    try:
+                        module  = int(sCommand[2])
+                        level   = int(sCommand[3])
+                        print "setting maj. level of module ",module," to: ",level
+                        print "success: ",_VME.V812_Set_Majority_Level(module,level)
+                    except:
+                        print "Syntax error (SetMajLevel)"
+
+                elif(V812Command=="SetMajThresh"):
+                    print "trying to set the majority threshold:"
+                    try:
+                        module  = int(sCommand[2])
+                        thresh  = int(sCommand[3])
+                        print "setting maj. level of module ",module," to: ",thresh
+                        print "success: ",_VME.V812_Set_Majority_Threshold(module,  thresh)
+                    except:
+                        print "Syntax error (SetMajThresh)"
+
+                elif(V812Command=="SetDeadTime"):
+                    print "trying to set the majority threshold:"
+                    try:
+                        module  = int(sCommand[2])
+                        block  = int(sCommand[3])
+                        deadtime= int(sCommand[4])
+                        print "setting deadtime of module ",module," block: ",block, " to: ",deadtime
+                        print "success: ",_VME.V812_Set_Dead_Time(module, block, deadtime);
+                    except:
+                        print "Syntax error (SetMajThresh)"
+
+                else:
+                    print "Syntax Error (V812)"
+                        
+        except:
+            print "syntax error"
+        #_VME.V812_Set_Threshold(1, 0,  255)
+    
+    def __init__(self):
+        threading.Thread.__init__(self)
+    def run(self):
+        oldcommand=GlobalVariables.UserInput
+        while(GlobalVariables.UserInput!="exit" and GlobalVariables.UserInput != "EXIT"):
+            CommandToParse=GlobalVariables.UserInput
+            if(oldcommand!=CommandToParse):
+                self.Parse(CommandToParse)
+                oldcommand=CommandToParse
+            time.sleep(0.05)
+
+
+            
+        print "EXITING PARSER...press <enter> to exit"
+            
Index: /trigger/GlobalVariables.py
===================================================================
--- /trigger/GlobalVariables.py	(revision 52)
+++ /trigger/GlobalVariables.py	(revision 52)
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+
+
+#contains only the user input:
+
+#global UserInput
+UserInput =''
+Rates = [16]
Index: /trigger/Main.py
===================================================================
--- /trigger/Main.py	(revision 52)
+++ /trigger/Main.py	(revision 52)
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+
+
+#################################################################
+#
+# Handles the communication between the driver _VMEmodule.so,
+# the user interface (PythonShell.py) and TCP/IP (CommSocket.py)
+#
+# Michael Rissi 06/2009
+#
+#################################################################
+
+import _VME
+import threading
+#import CommSocket
+import PythonShell
+import CommSocket
+#mport CommServer
+import GlobalVariables
+import CommunicateWithVME
+import time
+#connecting to the crates:
+print "connecting to the crates..."
+_VME.VME_Open()
+_VME.V560_Open()
+#_VME.V560_Print_Info()
+_VME.V812_Open()
+
+# clear the v560 scales:
+_VME.V560_Clear_Scales(1)
+
+
+
+GlobalVariables.UserInput = ''
+print "start the shell... "
+inputShell= PythonShell.InputShell()
+#inputShell.daemon=True
+inputShell.start()
+
+# start the server:
+print "start the server... "
+commServer = CommSocket.CommServer(3492,5)
+commServer.start()
+
+print "start the parser..."
+parseUserInput= CommunicateWithVME.ParseUserInput()
+parseUserInput.start()
+
+while(GlobalVariables.UserInput!="exit" and GlobalVariables.UserInput != "EXIT"):
+    time.sleep(0.1)
+    #do something
+#    dummy=1
+
+_VME.V812_Close()
+_VME.V560_Close()
+_VME.VME_Close()
Index: /trigger/PythonShell.py
===================================================================
--- /trigger/PythonShell.py	(revision 52)
+++ /trigger/PythonShell.py	(revision 52)
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+import readline
+import threading
+import time
+import GlobalVariables
+
+class InputShell(threading.Thread):
+    
+    def __init__(self):
+        threading.Thread.__init__(self)
+   
+
+    def run (self):
+        #outputShell= OutputShell()
+        #OutputShell.start(outputShell)
+        
+        while(GlobalVariables.UserInput!="exit" and GlobalVariables.UserInput != "EXIT"):
+            dummy=raw_input("SHELL>>> ")
+            if(GlobalVariables.UserInput!="exit" and GlobalVariables.UserInput != "EXIT"):
+                GlobalVariables.UserInput = dummy
+            else:
+                break
+            time.sleep(0.7)
+           
+               
+        print "EXITING INPUTSHELL... press <enter> to exit"
+   
+
+class OutputShell(threading.Thread):
+    lastvar=''
+    def run (self):
+        while(GlobalVariables.UserInput!="exit" and GlobalVariables.UserInput != "EXIT"):
+            if(GlobalVariables.UserInput!=self.lastvar):
+                print "\n(SHELL) You entered:",GlobalVariables.UserInput
+                #sys.stdout.write( "SHELL2 >>>")
+                self.lastvar=GlobalVariables.UserInput
+        print "EXITING OUTPUTSHELL...press <enter> to exit "
+        #sys.exit(0)
Index: /trigger/TestClient.py
===================================================================
--- /trigger/TestClient.py	(revision 52)
+++ /trigger/TestClient.py	(revision 52)
@@ -0,0 +1,14 @@
+#!/usr/bin/python
+import socket
+host = "localhost"
+port = 9992
+buf = 1024
+addr = (host,port)
+
+#create an INET, STREAMing socket
+s = socket.socket(
+    socket.AF_INET, socket.SOCK_STREAM)
+    #now connect to the web server on port 80 
+    # - the normal http port
+s.connect(('localhost', 9992))
+s.sendto(data,addr)
Index: /trigger/TestClient2.py
===================================================================
--- /trigger/TestClient2.py	(revision 52)
+++ /trigger/TestClient2.py	(revision 52)
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+# Client program
+
+from socket import *
+
+# Set the socket parameters
+host = "localhost"
+port = 9992
+buf = 1024
+addr = (host,port)
+
+# Create socket
+ClientSock = socket(AF_INET,SOCK_STREAM)
+ClientSock.connect(('localhost', 9994))
+def_msg = "===Enter message to send to server===";
+print "\n",def_msg
+backdata=''
+data=''
+# Send messages
+while (backdata!="EXIT" and backdata!="exit"):
+	data = raw_input('>> ')
+	if not data:
+		break
+	else:
+		if(ClientSock.sendto(data,addr)):
+			print "Sending message '",data,"'....."
+	backdata=ClientSock.recv(1024)
+	if(backdata):
+		print "SERVER>>> ",backdata
+
+# Close socket
+ClientSock.close()
Index: /trigger/TestClient3.py
===================================================================
--- /trigger/TestClient3.py	(revision 52)
+++ /trigger/TestClient3.py	(revision 52)
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+#############################################################################
+# The chat client
+#############################################################################
+
+"""
+Simple chat client for the chat server. Defines
+a simple protocol to be used with chatserver.
+
+"""
+
+import socket
+import sys
+import select
+import readline
+from communication import send, receive
+
+BUFSIZ = 1024
+
+class ChatClient(object):
+    """ A simple command line chat client using select """
+
+    def __init__(self, name, host='127.0.0.1', port=3490):
+        self.name = name
+        # Quit flag
+        self.flag = False
+        self.port = int(port)
+        self.host = host
+        # Initial prompt
+        self.prompt='[' + '@'.join((name, socket.gethostname().split('.')[0])) + ']> '
+        # Connect to server at port
+        try:
+            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            self.sock.connect((host, self.port))
+            print 'Connected to chat server@%d' % self.port
+            # Send my name...
+            send(self.sock,'NAME: ' + self.name) 
+            data = receive(self.sock)
+            # Contains client address, set it
+            addr = data.split('CLIENT: ')[1]
+            self.prompt = '[' + '@'.join((self.name, addr)) + ']> '
+        except socket.error, e:
+            print 'Could not connect to chat server @%d' % self.port
+            sys.exit(1)
+
+    def cmdloop(self):
+
+        while not self.flag:
+            try:
+                sys.stdout.write(self.prompt)
+                sys.stdout.flush()
+
+                # Wait for input from stdin & socket
+                inputready, outputready,exceptrdy = select.select([0, self.sock], [],[])
+                
+                for i in inputready:
+                    if i == 0:
+                        data = sys.stdin.readline().strip()
+                        if data: send(self.sock, data)
+                    elif i == self.sock:
+                        data = receive(self.sock)
+                        if not data:
+                            print 'Shutting down.'
+                            self.flag = True
+                            break
+                        else:
+                            sys.stdout.write(data + '\n')
+                            sys.stdout.flush()
+                            
+            except KeyboardInterrupt:
+                print 'Interrupted.'
+                self.sock.close()
+                break
+            
+            
+if __name__ == "__main__":
+    import sys
+
+    if len(sys.argv)<3:
+        sys.exit('Usage: %s chatid host portno' % sys.argv[0])
+        
+    client = ChatClient(sys.argv[1],sys.argv[2], int(sys.argv[3]))
+    client.cmdloop()
+
Index: /trigger/TestClient_prov.py
===================================================================
--- /trigger/TestClient_prov.py	(revision 52)
+++ /trigger/TestClient_prov.py	(revision 52)
@@ -0,0 +1,105 @@
+#!/usr/bin/python
+#############################################################################
+# The chat client
+#############################################################################
+
+"""
+Simple chat client for the chat server. Defines
+a simple protocol to be used with chatserver.
+
+"""
+
+import socket
+import sys
+import select
+import readline
+import threading
+import time
+from communication import send, receive
+
+BUFSIZ = 1024
+
+
+class MyUserInput(threading.Thread):
+    UserInput=''
+    ReceivedData=''
+    def run(self):
+        while (self.UserInput!="exit" and self.UserInput!="EXIT" and self.ReceivedData!="exit" and self.ReceivedData!="EXIT"):
+            dummy=raw_input("CLIENT >>>")
+            if(self.UserInput!="exit" and self.UserInput!="EXIT" and self.ReceivedData!="exit" and self.ReceivedData!="EXIT"):
+                self.UserInput=dummy
+            else:
+                break
+        time.sleep(0.5)
+            
+class ChatClient(object):
+    """ A simple command line chat client using select """
+
+    def __init__(self, name, host='127.0.0.1', port=3490):
+        self.myUserInput=MyUserInput()
+        self.myUserInput.daemon=True
+        self.myUserInput.start()
+        self.name = name
+        # Quit flag
+        self.flag = False
+        self.port = int(port)
+        self.host = host
+        # Initial prompt
+        self.prompt='[' + '@'.join((name, socket.gethostname().split('.')[0])) + ']> '
+        # Connect to server at port
+        try:
+            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            self.sock.connect((host, self.port))
+            print 'Connected to chat server@%d' % self.port
+            # Send my name...
+            send(self.sock,'NAME: ' + self.name) 
+            data = receive(self.sock)
+            # Contains client address, set it
+            addr = data.split('CLIENT: ')[1]
+            self.prompt = '[' + '@'.join((self.name, addr)) + ']> '
+        except socket.error, e:
+            print 'Could not connect to chat server @%d' % self.port
+            sys.exit(1)
+
+    def cmdloop(self):
+        oldUserInput=''
+        while not self.flag:
+            try:
+                #sys.stdout.write(self.prompt)
+                #sys.stdout.flush()
+
+                # Wait for input from stdin & socket
+                inputready, outputready,exceptrdy = select.select([self.sock], [],[])
+                
+                for i in inputready:
+                    #if i == 0:
+                    #    data = sys.stdin.readline().strip()
+                    #    if data: send(self.sock, data)
+                    if i == self.sock:
+                        data = receive(self.sock)
+                        if not data:
+                            print 'Shutting down.'
+                            self.flag = True
+                            break
+                        else:
+                            sys.stdout.write(data + '\n')
+                            sys.stdout.flush()
+                if(oldUserInput!=self.myUserInput.UserInput):
+                    oldUserInput=self.myUserInput.UserInput
+                    send(self.sock,self.myUserInput.UserInput)
+                            
+            except KeyboardInterrupt:
+                print 'Interrupted.'
+                self.sock.close()
+                break
+            
+            
+if __name__ == "__main__":
+    import sys
+
+    if len(sys.argv)<3:
+        sys.exit('Usage: %s chatid host portno' % sys.argv[0])
+        
+    client = ChatClient(sys.argv[1],sys.argv[2], int(sys.argv[3]))
+    client.cmdloop()
+
Index: /trigger/VME.i
===================================================================
--- /trigger/VME.i	(revision 52)
+++ /trigger/VME.i	(revision 52)
@@ -0,0 +1,37 @@
+// gcd.i
+%module VME
+%{
+//include extra headers necessary in your C source.
+//#include <headers.h>
+#include "v560.h"
+%}
+
+//VME stuff:
+VME_ErrorCode_t  VME_Open();
+VME_ErrorCode_t  VME_Close();
+int VME_ErrorPrint(VME_ErrorCode_t error_code);
+//V560 stuff:
+VME_ErrorCode_t  V560_Open();
+int V560_Send_Scale_Increment(short module);
+int V560_Set_Veto(short module);
+int V560_Reset_Veto(short module);
+int V560_Clear_Scales(short module);
+short V560_Read_Request_Register(short module);
+int V560_Write_Request_Register(short module,short request);
+int V560_Clear_VME_Interrupt(short module);
+int V560_Read_Counter(short module, short channel);
+int V560_Print_Info(void);
+VME_ErrorCode_t V560_Close(void);
+
+//V812 stuff:
+VME_ErrorCode_t V812_Open(void);
+int V812_Set_Threshold(short module, short channel, short threshold);
+int V812_Set_Pattern_Inhibit(short module, char channel[16]); 
+int V812_Set_Pattern_Inhibit_Hex(short module, short pattern);
+int V812_Set_Output_Width(short module, char channel_block, short width);
+int V812_Set_Dead_Time(short module, short channel_block, short dead_time);
+int V812_Set_Majority_Level(short module, short majority_level);
+int V812_Set_Majority_Threshold(short module, short majority_threshold);	
+int V812_Test_Pulse(short module);
+int V812_Print_Info(void);
+VME_ErrorCode_t V812_Close(void);
Index: /trigger/VME.py
===================================================================
--- /trigger/VME.py	(revision 52)
+++ /trigger/VME.py	(revision 52)
@@ -0,0 +1,83 @@
+# This file was created automatically by SWIG.
+# Don't modify this file, modify the SWIG interface instead.
+# This file is compatible with both classic and new-style classes.
+
+import _VME
+
+def _swig_setattr(self,class_type,name,value):
+    if (name == "this"):
+        if isinstance(value, class_type):
+            self.__dict__[name] = value.this
+            if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown
+            del value.thisown
+            return
+    method = class_type.__swig_setmethods__.get(name,None)
+    if method: return method(self,value)
+    self.__dict__[name] = value
+
+def _swig_getattr(self,class_type,name):
+    method = class_type.__swig_getmethods__.get(name,None)
+    if method: return method(self)
+    raise AttributeError,name
+
+import types
+try:
+    _object = types.ObjectType
+    _newclass = 1
+except AttributeError:
+    class _object : pass
+    _newclass = 0
+del types
+
+
+
+VME_Open = _VME.VME_Open
+
+VME_Close = _VME.VME_Close
+
+VME_ErrorPrint = _VME.VME_ErrorPrint
+
+V560_Open = _VME.V560_Open
+
+V560_Send_Scale_Increment = _VME.V560_Send_Scale_Increment
+
+V560_Set_Veto = _VME.V560_Set_Veto
+
+V560_Reset_Veto = _VME.V560_Reset_Veto
+
+V560_Clear_Scales = _VME.V560_Clear_Scales
+
+V560_Read_Request_Register = _VME.V560_Read_Request_Register
+
+V560_Write_Request_Register = _VME.V560_Write_Request_Register
+
+V560_Clear_VME_Interrupt = _VME.V560_Clear_VME_Interrupt
+
+V560_Read_Counter = _VME.V560_Read_Counter
+
+V560_Print_Info = _VME.V560_Print_Info
+
+V560_Close = _VME.V560_Close
+
+V812_Open = _VME.V812_Open
+
+V812_Set_Threshold = _VME.V812_Set_Threshold
+
+V812_Set_Pattern_Inhibit = _VME.V812_Set_Pattern_Inhibit
+
+V812_Set_Pattern_Inhibit_Hex = _VME.V812_Set_Pattern_Inhibit_Hex
+
+V812_Set_Output_Width = _VME.V812_Set_Output_Width
+
+V812_Set_Dead_Time = _VME.V812_Set_Dead_Time
+
+V812_Set_Majority_Level = _VME.V812_Set_Majority_Level
+
+V812_Set_Majority_Threshold = _VME.V812_Set_Majority_Threshold
+
+V812_Test_Pulse = _VME.V812_Test_Pulse
+
+V812_Print_Info = _VME.V812_Print_Info
+
+V812_Close = _VME.V812_Close
+
Index: /trigger/VME_wrap.c
===================================================================
--- /trigger/VME_wrap.c	(revision 52)
+++ /trigger/VME_wrap.c	(revision 52)
@@ -0,0 +1,1192 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.21
+ * 
+ * This file is not intended to be easily readable and contains a number of 
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG 
+ * interface file instead. 
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGPYTHON
+
+#include "Python.h"
+
+/*************************************************************** -*- c -*-
+ * python/precommon.swg
+ *
+ * Rename all exported symbols from common.swg, to avoid symbol
+ * clashes if multiple interpreters are included
+ *
+ ************************************************************************/
+
+#define SWIG_TypeRegister    SWIG_Python_TypeRegister
+#define SWIG_TypeCheck       SWIG_Python_TypeCheck
+#define SWIG_TypeCast        SWIG_Python_TypeCast
+#define SWIG_TypeDynamicCast SWIG_Python_TypeDynamicCast
+#define SWIG_TypeName        SWIG_Python_TypeName
+#define SWIG_TypeQuery       SWIG_Python_TypeQuery
+#define SWIG_TypeClientData  SWIG_Python_TypeClientData
+#define SWIG_PackData        SWIG_Python_PackData 
+#define SWIG_UnpackData      SWIG_Python_UnpackData 
+
+
+/***********************************************************************
+ * common.swg
+ *
+ *     This file contains generic SWIG runtime support for pointer
+ *     type checking as well as a few commonly used macros to control
+ *     external linkage.
+ *
+ * Author : David Beazley (beazley@cs.uchicago.edu)
+ *
+ * Copyright (c) 1999-2000, The University of Chicago
+ * 
+ * This file may be freely redistributed without license or fee provided
+ * this copyright message remains intact.
+ ************************************************************************/
+
+#include <string.h>
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#  if defined(_MSC_VER) || defined(__GNUC__)
+#    if defined(STATIC_LINKED)
+#      define SWIGEXPORT(a) a
+#      define SWIGIMPORT(a) extern a
+#    else
+#      define SWIGEXPORT(a) __declspec(dllexport) a
+#      define SWIGIMPORT(a) extern a
+#    endif
+#  else
+#    if defined(__BORLANDC__)
+#      define SWIGEXPORT(a) a _export
+#      define SWIGIMPORT(a) a _export
+#    else
+#      define SWIGEXPORT(a) a
+#      define SWIGIMPORT(a) a
+#    endif
+#  endif
+#else
+#  define SWIGEXPORT(a) a
+#  define SWIGIMPORT(a) a
+#endif
+
+#ifdef SWIG_GLOBAL
+#  define SWIGRUNTIME(a) SWIGEXPORT(a)
+#else
+#  define SWIGRUNTIME(a) static a
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+typedef struct swig_type_info {
+  const char             *name;
+  swig_converter_func     converter;
+  const char             *str;
+  void                   *clientdata;
+  swig_dycast_func        dcast;
+  struct swig_type_info  *next;
+  struct swig_type_info  *prev;
+} swig_type_info;
+
+#ifdef SWIG_NOINCLUDE
+
+SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
+SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
+SWIGIMPORT(void *)           SWIG_TypeCast(swig_type_info *, void *);
+SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **);
+SWIGIMPORT(const char *)     SWIG_TypeName(const swig_type_info *);
+SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *);
+SWIGIMPORT(void)             SWIG_TypeClientData(swig_type_info *, void *);
+SWIGIMPORT(char *)           SWIG_PackData(char *, void *, int);
+SWIGIMPORT(char *)           SWIG_UnpackData(char *, void *, int);
+
+#else
+
+static swig_type_info *swig_type_list = 0;
+
+/* Register a type mapping with the type-checking */
+SWIGRUNTIME(swig_type_info *)
+SWIG_TypeRegister(swig_type_info *ti) {
+  swig_type_info *tc, *head, *ret, *next;
+  /* Check to see if this type has already been registered */
+  tc = swig_type_list;
+  while (tc) {
+    if (strcmp(tc->name, ti->name) == 0) {
+      /* Already exists in the table.  Just add additional types to the list */
+      if (tc->clientdata) ti->clientdata = tc->clientdata;
+      head = tc;
+      next = tc->next;
+      goto l1;
+    }
+    tc = tc->prev;
+  }
+  head = ti;
+  next = 0;
+
+  /* Place in list */
+  ti->prev = swig_type_list;
+  swig_type_list = ti;
+
+  /* Build linked lists */
+  l1:
+  ret = head;
+  tc = ti + 1;
+  /* Patch up the rest of the links */
+  while (tc->name) {
+    head->next = tc;
+    tc->prev = head;
+    head = tc;
+    tc++;
+  }
+  if (next) next->prev = head;
+  head->next = next;
+  return ret;
+}
+
+/* Check the typename */
+SWIGRUNTIME(swig_type_info *) 
+SWIG_TypeCheck(char *c, swig_type_info *ty) {
+  swig_type_info *s;
+  if (!ty) return 0;        /* Void pointer */
+  s = ty->next;             /* First element always just a name */
+  do {
+    if (strcmp(s->name,c) == 0) {
+      if (s == ty->next) return s;
+      /* Move s to the top of the linked list */
+      s->prev->next = s->next;
+      if (s->next) {
+        s->next->prev = s->prev;
+      }
+      /* Insert s as second element in the list */
+      s->next = ty->next;
+      if (ty->next) ty->next->prev = s;
+      ty->next = s;
+      s->prev = ty;
+      return s;
+    }
+    s = s->next;
+  } while (s && (s != ty->next));
+  return 0;
+}
+
+/* Cast a pointer up an inheritance hierarchy */
+SWIGRUNTIME(void *) 
+SWIG_TypeCast(swig_type_info *ty, void *ptr) {
+  if ((!ty) || (!ty->converter)) return ptr;
+  return (*ty->converter)(ptr);
+}
+
+/* Dynamic pointer casting. Down an inheritance hierarchy */
+SWIGRUNTIME(swig_type_info *) 
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+  swig_type_info *lastty = ty;
+  if (!ty || !ty->dcast) return ty;
+  while (ty && (ty->dcast)) {
+    ty = (*ty->dcast)(ptr);
+    if (ty) lastty = ty;
+  }
+  return lastty;
+}
+
+/* Return the name associated with this type */
+SWIGRUNTIME(const char *)
+SWIG_TypeName(const swig_type_info *ty) {
+  return ty->name;
+}
+
+/* Search for a swig_type_info structure */
+SWIGRUNTIME(swig_type_info *)
+SWIG_TypeQuery(const char *name) {
+  swig_type_info *ty = swig_type_list;
+  while (ty) {
+    if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
+    if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
+    ty = ty->prev;
+  }
+  return 0;
+}
+
+/* Set the clientdata field for a type */
+SWIGRUNTIME(void)
+SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
+  swig_type_info *tc, *equiv;
+  if (ti->clientdata == clientdata) return;
+  ti->clientdata = clientdata;
+  equiv = ti->next;
+  while (equiv) {
+    if (!equiv->converter) {
+      tc = swig_type_list;
+      while (tc) {
+        if ((strcmp(tc->name, equiv->name) == 0))
+          SWIG_TypeClientData(tc,clientdata);
+        tc = tc->prev;
+      }
+    }
+    equiv = equiv->next;
+  }
+}
+
+/* Pack binary data into a string */
+SWIGRUNTIME(char *)
+SWIG_PackData(char *c, void *ptr, int sz) {
+  static char hex[17] = "0123456789abcdef";
+  int i;
+  unsigned char *u = (unsigned char *) ptr;
+  register unsigned char uu;
+  for (i = 0; i < sz; i++,u++) {
+    uu = *u;
+    *(c++) = hex[(uu & 0xf0) >> 4];
+    *(c++) = hex[uu & 0xf];
+  }
+  return c;
+}
+
+/* Unpack binary data from a string */
+SWIGRUNTIME(char *)
+SWIG_UnpackData(char *c, void *ptr, int sz) {
+  register unsigned char uu = 0;
+  register int d;
+  unsigned char *u = (unsigned char *) ptr;
+  int i;
+  for (i = 0; i < sz; i++, u++) {
+    d = *(c++);
+    if ((d >= '0') && (d <= '9'))
+      uu = ((d - '0') << 4);
+    else if ((d >= 'a') && (d <= 'f'))
+      uu = ((d - ('a'-10)) << 4);
+    d = *(c++);
+    if ((d >= '0') && (d <= '9'))
+      uu |= (d - '0');
+    else if ((d >= 'a') && (d <= 'f'))
+      uu |= (d - ('a'-10));
+    *u = uu;
+  }
+  return c;
+}
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/***********************************************************************
+ * python.swg
+ *
+ *     This file contains the runtime support for Python modules
+ *     and includes code for managing global variables and pointer
+ *     type checking.
+ *
+ * Author : David Beazley (beazley@cs.uchicago.edu)
+ ************************************************************************/
+
+#include "Python.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SWIG_PY_INT     1
+#define SWIG_PY_FLOAT   2
+#define SWIG_PY_STRING  3
+#define SWIG_PY_POINTER 4
+#define SWIG_PY_BINARY  5
+
+/* Flags for pointer conversion */
+
+#define SWIG_POINTER_EXCEPTION     0x1
+#define SWIG_POINTER_DISOWN        0x2
+
+/* Exception handling in wrappers */
+#define SWIG_fail   goto fail
+
+/* Constant information structure */
+typedef struct swig_const_info {
+    int type;
+    char *name;
+    long lvalue;
+    double dvalue;
+    void   *pvalue;
+    swig_type_info **ptype;
+} swig_const_info;
+
+/* Common SWIG API */
+#define SWIG_ConvertPtr(obj, pp, type, flags) \
+  SWIG_Python_ConvertPtr(obj, pp, type, flags)
+#define SWIG_NewPointerObj(p, type, flags) \
+  SWIG_Python_NewPointerObj(p, type, flags)
+#define SWIG_MustGetPtr(p, type, argnum, flags) \
+  SWIG_Python_MustGetPtr(p, type, argnum, flags)
+
+/* Python-specific SWIG API */
+#define SWIG_newvarlink() \
+  SWIG_Python_newvarlink()
+#define SWIG_addvarlink(p, name, get_attr, set_attr) \
+  SWIG_Python_addvarlink(p, name, get_attr, set_attr)
+#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
+  SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
+#define SWIG_NewPackedObj(ptr, sz, type) \
+  SWIG_Python_NewPackedObj(ptr, sz, type)
+#define SWIG_InstallConstants(d, constants) \
+  SWIG_Python_InstallConstants(d, constants)
+
+#ifdef SWIG_NOINCLUDE
+
+SWIGIMPORT(int)               SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int);
+SWIGIMPORT(PyObject *)        SWIG_Python_NewPointerObj(void *, swig_type_info *,int own);
+SWIGIMPORT(void *)            SWIG_Python_MustGetPtr(PyObject *, swig_type_info *, int, int);
+SWIGIMPORT(PyObject *)        SWIG_Python_newvarlink(void);
+SWIGIMPORT(void)              SWIG_Python_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
+SWIGIMPORT(int)               SWIG_Python_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int);
+SWIGIMPORT(PyObject *)        SWIG_Python_NewPackedObj(void *, int sz, swig_type_info *);
+SWIGIMPORT(void)              SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]);
+
+#else
+
+/* -----------------------------------------------------------------------------
+ * global variable support code.
+ * ----------------------------------------------------------------------------- */
+
+typedef struct swig_globalvar {   
+  char       *name;                  /* Name of global variable */
+  PyObject *(*get_attr)(void);       /* Return the current value */
+  int       (*set_attr)(PyObject *); /* Set the value */
+  struct swig_globalvar *next;
+} swig_globalvar;
+
+typedef struct swig_varlinkobject {
+  PyObject_HEAD
+  swig_globalvar *vars;
+} swig_varlinkobject;
+
+static PyObject *
+swig_varlink_repr(swig_varlinkobject *v) {
+  v = v;
+  return PyString_FromString("<Global variables>");
+}
+
+static int
+swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
+  swig_globalvar  *var;
+  flags = flags;
+  fprintf(fp,"Global variables { ");
+  for (var = v->vars; var; var=var->next) {
+    fprintf(fp,"%s", var->name);
+    if (var->next) fprintf(fp,", ");
+  }
+  fprintf(fp," }\n");
+  return 0;
+}
+
+static PyObject *
+swig_varlink_getattr(swig_varlinkobject *v, char *n) {
+  swig_globalvar *var = v->vars;
+  while (var) {
+    if (strcmp(var->name,n) == 0) {
+      return (*var->get_attr)();
+    }
+    var = var->next;
+  }
+  PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+  return NULL;
+}
+
+static int
+swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
+  swig_globalvar *var = v->vars;
+  while (var) {
+    if (strcmp(var->name,n) == 0) {
+      return (*var->set_attr)(p);
+    }
+    var = var->next;
+  }
+  PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+  return 1;
+}
+
+statichere PyTypeObject varlinktype = {
+  PyObject_HEAD_INIT(0)              
+  0,
+  (char *)"swigvarlink",              /* Type name    */
+  sizeof(swig_varlinkobject),         /* Basic size   */
+  0,                                  /* Itemsize     */
+  0,                                  /* Deallocator  */ 
+  (printfunc) swig_varlink_print,     /* Print        */
+  (getattrfunc) swig_varlink_getattr, /* get attr     */
+  (setattrfunc) swig_varlink_setattr, /* Set attr     */
+  0,                                  /* tp_compare   */
+  (reprfunc) swig_varlink_repr,       /* tp_repr      */    
+  0,                                  /* tp_as_number */
+  0,                                  /* tp_as_mapping*/
+  0,                                  /* tp_hash      */
+};
+
+/* Create a variable linking object for use later */
+SWIGRUNTIME(PyObject *)
+SWIG_Python_newvarlink(void) {
+  swig_varlinkobject *result = 0;
+  result = PyMem_NEW(swig_varlinkobject,1);
+  varlinktype.ob_type = &PyType_Type;    /* Patch varlinktype into a PyType */
+  result->ob_type = &varlinktype;
+  result->vars = 0;
+  result->ob_refcnt = 0;
+  Py_XINCREF((PyObject *) result);
+  return ((PyObject*) result);
+}
+
+SWIGRUNTIME(void)
+SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
+  swig_varlinkobject *v;
+  swig_globalvar *gv;
+  v= (swig_varlinkobject *) p;
+  gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
+  gv->name = (char *) malloc(strlen(name)+1);
+  strcpy(gv->name,name);
+  gv->get_attr = get_attr;
+  gv->set_attr = set_attr;
+  gv->next = v->vars;
+  v->vars = gv;
+}
+
+/* Convert a pointer value */
+SWIGRUNTIME(int)
+SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
+  swig_type_info *tc;
+  char  *c = 0;
+  static PyObject *SWIG_this = 0;
+  int    newref = 0;
+  PyObject  *pyobj = 0;
+
+  if (!obj) return 0;
+  if (obj == Py_None) {
+    *ptr = 0;
+    return 0;
+  }
+#ifdef SWIG_COBJECT_TYPES
+  if (!(PyCObject_Check(obj))) {
+    if (!SWIG_this)
+      SWIG_this = PyString_FromString("this");
+    pyobj = obj;
+    obj = PyObject_GetAttr(obj,SWIG_this);
+    newref = 1;
+    if (!obj) goto type_error;
+    if (!PyCObject_Check(obj)) {
+      Py_DECREF(obj);
+      goto type_error;
+    }
+  }  
+  *ptr = PyCObject_AsVoidPtr(obj);
+  c = (char *) PyCObject_GetDesc(obj);
+  if (newref) Py_DECREF(obj);
+  goto cobject;
+#else
+  if (!(PyString_Check(obj))) {
+    if (!SWIG_this)
+      SWIG_this = PyString_FromString("this");
+    pyobj = obj;
+    obj = PyObject_GetAttr(obj,SWIG_this);
+    newref = 1;
+    if (!obj) goto type_error;
+    if (!PyString_Check(obj)) {
+      Py_DECREF(obj);
+      goto type_error;
+    }
+  } 
+  c = PyString_AsString(obj);
+  /* Pointer values must start with leading underscore */
+  if (*c != '_') {
+    *ptr = (void *) 0;
+    if (strcmp(c,"NULL") == 0) {
+      if (newref) { Py_DECREF(obj); }
+      return 0;
+    } else {
+      if (newref) { Py_DECREF(obj); }
+      goto type_error;
+    }
+  }
+  c++;
+  c = SWIG_UnpackData(c,ptr,sizeof(void *));
+  if (newref) { Py_DECREF(obj); }
+#endif
+
+#ifdef SWIG_COBJECT_TYPES
+cobject:
+#endif
+
+  if (ty) {
+    tc = SWIG_TypeCheck(c,ty);
+    if (!tc) goto type_error;
+    *ptr = SWIG_TypeCast(tc,(void*) *ptr);
+  }
+
+  if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) {
+    PyObject *zero = PyInt_FromLong(0);
+    PyObject_SetAttrString(pyobj,(char*)"thisown",zero);
+    Py_DECREF(zero);
+  }
+  return 0;
+
+type_error:
+  if (flags & SWIG_POINTER_EXCEPTION) {
+    if (ty && c) {
+      char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c));
+      sprintf(temp,"Type error. Got %s, expected %s", c, ty->name);
+      PyErr_SetString(PyExc_TypeError, temp);
+      free((char *) temp);
+    } else {
+      PyErr_SetString(PyExc_TypeError,"Expected a pointer");
+    }
+  }
+  return -1;
+}
+
+/* Convert a pointer value, signal an exception on a type mismatch */
+SWIGRUNTIME(void *)
+SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
+  void *result;
+  SWIG_Python_ConvertPtr(obj, &result, ty, flags | SWIG_POINTER_EXCEPTION);
+  return result;
+}
+
+/* Convert a packed value value */
+SWIGRUNTIME(int)
+SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
+  swig_type_info *tc;
+  char  *c = 0;
+
+  if ((!obj) || (!PyString_Check(obj))) goto type_error;
+  c = PyString_AsString(obj);
+  /* Pointer values must start with leading underscore */
+  if (*c != '_') goto type_error;
+  c++;
+  c = SWIG_UnpackData(c,ptr,sz);
+  if (ty) {
+    tc = SWIG_TypeCheck(c,ty);
+    if (!tc) goto type_error;
+  }
+  return 0;
+
+type_error:
+
+  if (flags) {
+    if (ty && c) {
+      char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c));
+      sprintf(temp,"Type error. Got %s, expected %s", c, ty->name);
+      PyErr_SetString(PyExc_TypeError, temp);
+      free((char *) temp);
+    } else {
+      PyErr_SetString(PyExc_TypeError,"Expected a pointer");
+    }
+  }
+  return -1;
+}
+
+/* Create a new pointer object */
+SWIGRUNTIME(PyObject *)
+SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
+  PyObject *robj;
+  if (!ptr) {
+    Py_INCREF(Py_None);
+    return Py_None;
+  }
+#ifdef SWIG_COBJECT_TYPES
+  robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL);
+#else
+  {
+    char result[1024];
+    char *r = result;
+    *(r++) = '_';
+    r = SWIG_PackData(r,&ptr,sizeof(void *));
+    strcpy(r,type->name);
+    robj = PyString_FromString(result);
+  }
+#endif
+  if (!robj || (robj == Py_None)) return robj;
+  if (type->clientdata) {
+    PyObject *inst;
+    PyObject *args = Py_BuildValue((char*)"(O)", robj);
+    Py_DECREF(robj);
+    inst = PyObject_CallObject((PyObject *) type->clientdata, args);
+    Py_DECREF(args);
+    if (inst) {
+      if (own) {
+        PyObject *n = PyInt_FromLong(1);
+        PyObject_SetAttrString(inst,(char*)"thisown",n);
+        Py_DECREF(n);
+      }
+      robj = inst;
+    }
+  }
+  return robj;
+}
+
+SWIGRUNTIME(PyObject *)
+SWIG_Python_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
+  char result[1024];
+  char *r = result;
+  if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
+  *(r++) = '_';
+  r = SWIG_PackData(r,ptr,sz);
+  strcpy(r,type->name);
+  return PyString_FromString(result);
+}
+
+/* Install Constants */
+SWIGRUNTIME(void)
+SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
+  int i;
+  PyObject *obj;
+  for (i = 0; constants[i].type; i++) {
+    switch(constants[i].type) {
+    case SWIG_PY_INT:
+      obj = PyInt_FromLong(constants[i].lvalue);
+      break;
+    case SWIG_PY_FLOAT:
+      obj = PyFloat_FromDouble(constants[i].dvalue);
+      break;
+    case SWIG_PY_STRING:
+      obj = PyString_FromString((char *) constants[i].pvalue);
+      break;
+    case SWIG_PY_POINTER:
+      obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+      break;
+    case SWIG_PY_BINARY:
+      obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+      break;
+    default:
+      obj = 0;
+      break;
+    }
+    if (obj) {
+      PyDict_SetItemString(d,constants[i].name,obj);
+      Py_DECREF(obj);
+    }
+  }
+}
+
+#endif
+
+/* Contract support */
+
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* -------- TYPES TABLE (BEGIN) -------- */
+
+#define  SWIGTYPE_p_VME_ErrorCode_t swig_types[0] 
+#define  SWIGTYPE_p_char swig_types[1] 
+static swig_type_info *swig_types[3];
+
+/* -------- TYPES TABLE (END) -------- */
+
+
+/*-----------------------------------------------
+              @(target):= _VME.so
+  ------------------------------------------------*/
+#define SWIG_init    init_VME
+
+#define SWIG_name    "_VME"
+
+//include extra headers necessary in your C source.
+//#include <headers.h>
+#include "v560.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+static PyObject *_wrap_VME_Open(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    VME_ErrorCode_t result;
+    
+    if(!PyArg_ParseTuple(args,(char *)":VME_Open")) goto fail;
+    result = VME_Open();
+    
+    {
+        VME_ErrorCode_t * resultptr;
+        resultptr = (VME_ErrorCode_t *) malloc(sizeof(VME_ErrorCode_t));
+        memmove(resultptr, &result, sizeof(VME_ErrorCode_t));
+        resultobj = SWIG_NewPointerObj((void *) resultptr, SWIGTYPE_p_VME_ErrorCode_t, 1);
+    }
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_VME_Close(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    VME_ErrorCode_t result;
+    
+    if(!PyArg_ParseTuple(args,(char *)":VME_Close")) goto fail;
+    result = VME_Close();
+    
+    {
+        VME_ErrorCode_t * resultptr;
+        resultptr = (VME_ErrorCode_t *) malloc(sizeof(VME_ErrorCode_t));
+        memmove(resultptr, &result, sizeof(VME_ErrorCode_t));
+        resultobj = SWIG_NewPointerObj((void *) resultptr, SWIGTYPE_p_VME_ErrorCode_t, 1);
+    }
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_VME_ErrorPrint(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    VME_ErrorCode_t arg1 ;
+    int result;
+    VME_ErrorCode_t *argp1 ;
+    PyObject * obj0 = 0 ;
+    
+    if(!PyArg_ParseTuple(args,(char *)"O:VME_ErrorPrint",&obj0)) goto fail;
+    if ((SWIG_ConvertPtr(obj0,(void **) &argp1, SWIGTYPE_p_VME_ErrorCode_t,SWIG_POINTER_EXCEPTION) == -1)) SWIG_fail;
+    arg1 = *argp1; 
+    result = (int)VME_ErrorPrint(arg1);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Open(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    VME_ErrorCode_t result;
+    
+    if(!PyArg_ParseTuple(args,(char *)":V560_Open")) goto fail;
+    result = V560_Open();
+    
+    {
+        VME_ErrorCode_t * resultptr;
+        resultptr = (VME_ErrorCode_t *) malloc(sizeof(VME_ErrorCode_t));
+        memmove(resultptr, &result, sizeof(VME_ErrorCode_t));
+        resultobj = SWIG_NewPointerObj((void *) resultptr, SWIGTYPE_p_VME_ErrorCode_t, 1);
+    }
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Send_Scale_Increment(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"h:V560_Send_Scale_Increment",&arg1)) goto fail;
+    result = (int)V560_Send_Scale_Increment(arg1);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Set_Veto(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"h:V560_Set_Veto",&arg1)) goto fail;
+    result = (int)V560_Set_Veto(arg1);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Reset_Veto(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"h:V560_Reset_Veto",&arg1)) goto fail;
+    result = (int)V560_Reset_Veto(arg1);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Clear_Scales(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"h:V560_Clear_Scales",&arg1)) goto fail;
+    result = (int)V560_Clear_Scales(arg1);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Read_Request_Register(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    short result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"h:V560_Read_Request_Register",&arg1)) goto fail;
+    result = (short)V560_Read_Request_Register(arg1);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Write_Request_Register(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    short arg2 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hh:V560_Write_Request_Register",&arg1,&arg2)) goto fail;
+    result = (int)V560_Write_Request_Register(arg1,arg2);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Clear_VME_Interrupt(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"h:V560_Clear_VME_Interrupt",&arg1)) goto fail;
+    result = (int)V560_Clear_VME_Interrupt(arg1);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Read_Counter(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    short arg2 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hh:V560_Read_Counter",&arg1,&arg2)) goto fail;
+    result = (int)V560_Read_Counter(arg1,arg2);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Print_Info(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)":V560_Print_Info")) goto fail;
+    result = (int)V560_Print_Info();
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V560_Close(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    VME_ErrorCode_t result;
+    
+    if(!PyArg_ParseTuple(args,(char *)":V560_Close")) goto fail;
+    result = V560_Close();
+    
+    {
+        VME_ErrorCode_t * resultptr;
+        resultptr = (VME_ErrorCode_t *) malloc(sizeof(VME_ErrorCode_t));
+        memmove(resultptr, &result, sizeof(VME_ErrorCode_t));
+        resultobj = SWIG_NewPointerObj((void *) resultptr, SWIGTYPE_p_VME_ErrorCode_t, 1);
+    }
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Open(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    VME_ErrorCode_t result;
+    
+    if(!PyArg_ParseTuple(args,(char *)":V812_Open")) goto fail;
+    result = V812_Open();
+    
+    {
+        VME_ErrorCode_t * resultptr;
+        resultptr = (VME_ErrorCode_t *) malloc(sizeof(VME_ErrorCode_t));
+        memmove(resultptr, &result, sizeof(VME_ErrorCode_t));
+        resultobj = SWIG_NewPointerObj((void *) resultptr, SWIGTYPE_p_VME_ErrorCode_t, 1);
+    }
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Set_Threshold(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    short arg2 ;
+    short arg3 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hhh:V812_Set_Threshold",&arg1,&arg2,&arg3)) goto fail;
+    result = (int)V812_Set_Threshold(arg1,arg2,arg3);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Set_Pattern_Inhibit(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    char *arg2 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hs:V812_Set_Pattern_Inhibit",&arg1,&arg2)) goto fail;
+    result = (int)V812_Set_Pattern_Inhibit(arg1,arg2);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Set_Pattern_Inhibit_Hex(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    short arg2 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hh:V812_Set_Pattern_Inhibit_Hex",&arg1,&arg2)) goto fail;
+    result = (int)V812_Set_Pattern_Inhibit_Hex(arg1,arg2);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Set_Output_Width(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    char arg2 ;
+    short arg3 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hch:V812_Set_Output_Width",&arg1,&arg2,&arg3)) goto fail;
+    result = (int)V812_Set_Output_Width(arg1,arg2,arg3);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Set_Dead_Time(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    short arg2 ;
+    short arg3 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hhh:V812_Set_Dead_Time",&arg1,&arg2,&arg3)) goto fail;
+    result = (int)V812_Set_Dead_Time(arg1,arg2,arg3);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Set_Majority_Level(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    short arg2 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hh:V812_Set_Majority_Level",&arg1,&arg2)) goto fail;
+    result = (int)V812_Set_Majority_Level(arg1,arg2);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Set_Majority_Threshold(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    short arg2 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hh:V812_Set_Majority_Threshold",&arg1,&arg2)) goto fail;
+    result = (int)V812_Set_Majority_Threshold(arg1,arg2);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Test_Pulse(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    short arg1 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"h:V812_Test_Pulse",&arg1)) goto fail;
+    result = (int)V812_Test_Pulse(arg1);
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Print_Info(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)":V812_Print_Info")) goto fail;
+    result = (int)V812_Print_Info();
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_V812_Close(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    VME_ErrorCode_t result;
+    
+    if(!PyArg_ParseTuple(args,(char *)":V812_Close")) goto fail;
+    result = V812_Close();
+    
+    {
+        VME_ErrorCode_t * resultptr;
+        resultptr = (VME_ErrorCode_t *) malloc(sizeof(VME_ErrorCode_t));
+        memmove(resultptr, &result, sizeof(VME_ErrorCode_t));
+        resultobj = SWIG_NewPointerObj((void *) resultptr, SWIGTYPE_p_VME_ErrorCode_t, 1);
+    }
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyMethodDef SwigMethods[] = {
+	 { (char *)"VME_Open", _wrap_VME_Open, METH_VARARGS },
+	 { (char *)"VME_Close", _wrap_VME_Close, METH_VARARGS },
+	 { (char *)"VME_ErrorPrint", _wrap_VME_ErrorPrint, METH_VARARGS },
+	 { (char *)"V560_Open", _wrap_V560_Open, METH_VARARGS },
+	 { (char *)"V560_Send_Scale_Increment", _wrap_V560_Send_Scale_Increment, METH_VARARGS },
+	 { (char *)"V560_Set_Veto", _wrap_V560_Set_Veto, METH_VARARGS },
+	 { (char *)"V560_Reset_Veto", _wrap_V560_Reset_Veto, METH_VARARGS },
+	 { (char *)"V560_Clear_Scales", _wrap_V560_Clear_Scales, METH_VARARGS },
+	 { (char *)"V560_Read_Request_Register", _wrap_V560_Read_Request_Register, METH_VARARGS },
+	 { (char *)"V560_Write_Request_Register", _wrap_V560_Write_Request_Register, METH_VARARGS },
+	 { (char *)"V560_Clear_VME_Interrupt", _wrap_V560_Clear_VME_Interrupt, METH_VARARGS },
+	 { (char *)"V560_Read_Counter", _wrap_V560_Read_Counter, METH_VARARGS },
+	 { (char *)"V560_Print_Info", _wrap_V560_Print_Info, METH_VARARGS },
+	 { (char *)"V560_Close", _wrap_V560_Close, METH_VARARGS },
+	 { (char *)"V812_Open", _wrap_V812_Open, METH_VARARGS },
+	 { (char *)"V812_Set_Threshold", _wrap_V812_Set_Threshold, METH_VARARGS },
+	 { (char *)"V812_Set_Pattern_Inhibit", _wrap_V812_Set_Pattern_Inhibit, METH_VARARGS },
+	 { (char *)"V812_Set_Pattern_Inhibit_Hex", _wrap_V812_Set_Pattern_Inhibit_Hex, METH_VARARGS },
+	 { (char *)"V812_Set_Output_Width", _wrap_V812_Set_Output_Width, METH_VARARGS },
+	 { (char *)"V812_Set_Dead_Time", _wrap_V812_Set_Dead_Time, METH_VARARGS },
+	 { (char *)"V812_Set_Majority_Level", _wrap_V812_Set_Majority_Level, METH_VARARGS },
+	 { (char *)"V812_Set_Majority_Threshold", _wrap_V812_Set_Majority_Threshold, METH_VARARGS },
+	 { (char *)"V812_Test_Pulse", _wrap_V812_Test_Pulse, METH_VARARGS },
+	 { (char *)"V812_Print_Info", _wrap_V812_Print_Info, METH_VARARGS },
+	 { (char *)"V812_Close", _wrap_V812_Close, METH_VARARGS },
+	 { NULL, NULL }
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
+
+static swig_type_info _swigt__p_VME_ErrorCode_t[] = {{"_p_VME_ErrorCode_t", 0, "VME_ErrorCode_t *", 0},{"_p_VME_ErrorCode_t"},{0}};
+static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *", 0},{"_p_char"},{0}};
+
+static swig_type_info *swig_types_initial[] = {
+_swigt__p_VME_ErrorCode_t, 
+_swigt__p_char, 
+0
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
+
+static swig_const_info swig_const_table[] = {
+{0}};
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT(void) SWIG_init(void) {
+    static PyObject *SWIG_globals = 0; 
+    static int       typeinit = 0;
+    PyObject *m, *d;
+    int       i;
+    if (!SWIG_globals) SWIG_globals = SWIG_newvarlink();
+    m = Py_InitModule((char *) SWIG_name, SwigMethods);
+    d = PyModule_GetDict(m);
+    
+    if (!typeinit) {
+        for (i = 0; swig_types_initial[i]; i++) {
+            swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
+        }
+        typeinit = 1;
+    }
+    SWIG_InstallConstants(d,swig_const_table);
+    
+}
+
Index: /trigger/WrapVME.c
===================================================================
--- /trigger/WrapVME.c	(revision 52)
+++ /trigger/WrapVME.c	(revision 52)
@@ -0,0 +1,42 @@
+/*################################################
+#
+#  WrapVME.c
+#  Wraps the function calls to the VME crate
+#
+###############################################*/
+
+
+//#include "vme_rcc_common.h"
+#include "v560.h"
+#include "Python.h"
+#include<stdio.h>
+
+
+PyObject *wrap_V560_Open(PyObject *self, PyObject *args)
+{
+
+
+	VME_ErrorCode_t error_code; 
+	if (!PyArg_ParseTuple(args,"V560_Open"))
+	  return NULL;
+	error_code = V560_Open();
+	return Py_BuildValue("i",error_code);
+}
+
+/*static PyMethodDef exampleMethods[] = {
+         { "fact", wrap_fact, METH_VARARGS, "fact(int)" },
+         { "gcd", wrap_gcd, METH_VARARGS, "gcd(int, int)" },
+         { NULL, NULL, NULL, NULL }*/
+
+
+
+static PyMethodDef VMEMethods[] = {
+         { "V560_Open", wrap_V560_Open, METH_VARARGS, "V560()" },
+         { NULL, NULL }
+};
+// Module initialization
+void initVME() {
+         PyObject *m;
+         m = Py_InitModule("VME", VMEMethods);
+}
+
Index: /trigger/communication.py
===================================================================
--- /trigger/communication.py	(revision 52)
+++ /trigger/communication.py	(revision 52)
@@ -0,0 +1,32 @@
+###############################################################################
+# The communication module (communication.py)
+###############################################################################
+import cPickle
+import socket
+import struct
+
+marshall = cPickle.dumps
+unmarshall = cPickle.loads
+
+def send(channel, *args):
+    buf = marshall(args)
+    value = socket.htonl(len(buf))
+    size = struct.pack("L",value)
+    channel.send(size)
+    channel.send(buf)
+
+def receive(channel):
+
+    size = struct.calcsize("L")
+    size = channel.recv(size)
+    try:
+        size = socket.ntohl(struct.unpack("L", size)[0])
+    except struct.error, e:
+        return ''
+    
+    buf = ""
+
+    while len(buf) < size:
+        buf = channel.recv(size - len(buf))
+
+    return unmarshall(buf)[0]
Index: /trigger/makefile
===================================================================
--- /trigger/makefile	(revision 52)
+++ /trigger/makefile	(revision 52)
@@ -0,0 +1,37 @@
+Wrapper:		 _VMEmodule.so
+
+v560_test:		v560_test.o v560.o
+			cc v560_test.o v560.o -L/usr/atlas/lib -lvme_rcc -o v560_test
+dummy:			v560_test.o v560_dummy.o
+			cc v560_test.o v560_dummy.o -L/usr/atlas/lib -lvme_rcc -o v560_test_dummy
+v560.o:			v560.c
+			cc -c v560.c -I/usr/atlas/include 
+v560_dummy.o:		v560_dummy.c
+			cc -c v560_dummy.c -I/usr/atlas/include 
+v560_test.o:		v560_test.c v560.h
+			cc -c v560_test.c -I/usr/atlas/include 
+clean:			
+			rm *.o
+			rm *.so
+
+WrapVME.o:		WrapVME.c v560.h
+			cc -c WrapVME.c  -I/usr/atlas/include -I/usr/include/python2.3/ -I/usr/atlas/v560
+
+VMEmodule.so:		WrapVME.o v560.o
+			cc -shared WrapVME.o v560.o  -L/usr/atlas/lib  -lfl -lvme_rcc -lrcc_time_stamp   -o VMEmodule.so
+
+
+
+_VMEmodule.so:		VME_wrap.o 
+			cc -shared -L/usr/atlas/lib -lvme_rcc v812.o v560.o VME_wrap.o -o _VMEmodule.so
+
+VME_wrap.o:		v560.c VME_wrap.c v812.c
+			cc -fpic -c -I/usr/include/python2.3/  -I/usr/lib/python2.3/config/ -I/usr/atlas/include v560.c  v812.c VME_wrap.c
+
+VME_wrap.c:		VME.i
+			swig -python VME.i
+
+
+
+
+
Index: /trigger/test.py
===================================================================
--- /trigger/test.py	(revision 52)
+++ /trigger/test.py	(revision 52)
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+import sys, os, select, time
+
+i = 0
+
+def getInput():
+	input = ''
+	while len(select.select([sys.stdin.fileno()], [], [], 0.0)[0])>0:
+		input += os.read(sys.stdin.fileno(), 4096)
+	return input
+
+def doWork():
+	global i
+	time.sleep(0.5)
+	i += 1
+
+if __name__=='__main__':
+	input = ''
+	while not input:
+		doWork()
+		input = getInput()
+	print "got user input: %r" % input
+	print "did %d units of work" % i
Index: /trigger/v560.c
===================================================================
--- /trigger/v560.c	(revision 52)
+++ /trigger/v560.c	(revision 52)
@@ -0,0 +1,267 @@
+#include <stdio.h>
+//#include "rcc_error/rcc_error.h"
+//#include "vme_rcc/vme_rcc.h"
+#include "v560.h"
+//******************************************************************************
+//Constants
+//******************************************************************************
+
+#define NMAX_V560_MODULES 10 //maximum 65535, probably more than enough...
+#define V560_CHANNELS 16
+
+//******************************************************************************
+//Type definitions
+//******************************************************************************
+
+//This struct maps the memory of a v560 module.
+
+//This struct contains the information necessary to handle one module
+
+
+//******************************************************************************
+//Global Variables
+//******************************************************************************
+
+v560_module_t v560_modules[NMAX_V560_MODULES];
+
+//******************************************************************************
+//Function Definitions
+//******************************************************************************
+
+VME_ErrorCode_t V560_Open()
+{	
+  VME_ErrorCode_t error_code;
+  //first open connection to VME:
+  /*if(error_code = VME_Open()) {
+    VME_ErrorPrint(error_code);
+    printf("VME open not successful.\n");
+    return error_code;
+    }*/
+    u_int tmp_virtual_address, tmp_base_address;
+	u_short i=0;
+
+	VME_MasterMap_t master_map;
+	
+	master_map.vmebus_address	= 0x00010000;
+	master_map.window_size		= 0x1000;
+	master_map.address_modifier	= VME_A24;
+	master_map.options			= 0;
+	
+	for(i=0; i<NMAX_V560_MODULES; i++) {
+		v560_modules[i].present = 0;
+	}
+	
+	//opening the file containing the base addresses
+	FILE *datfile = fopen("v560_base.dat","r");
+	char line[256];
+	
+	i=0;
+	if (datfile!=NULL) {
+		while(fgets(line,255,datfile)) {
+			
+			//excluding comment lines
+			if(line[0] == '%') {
+				continue;
+			}
+			
+			//reading the hex address
+			if(!sscanf(&line[2],"%8x",&tmp_base_address)) {
+				printf("Reading input file v560_base.dat: non-comment line without address found. Please delete or comment this line.\n");
+			}
+			
+			//check address, assign to the master map
+			if(tmp_base_address & 0x0000FFFF) {
+				printf("Reading input file v560_base.dat: 0x%08x is no valid base address (0xXXXX0000)\n",tmp_base_address);
+				continue;
+			}
+			if(i>=NMAX_V560_MODULES) {
+				printf("Reading input file v560_base.dat: More addresses found than memory space provided.\nIncrease NMAX_V560_MODULES in v560.h and v560.c.\n");
+				break;
+			}
+			master_map.vmebus_address = tmp_base_address;
+			
+			if(error_code = VME_MasterMap(&master_map,&v560_modules[i].master_mapping)) {
+				VME_ErrorPrint(error_code);
+				return error_code;
+			}
+
+			if(error_code = VME_MasterMapVirtualAddress(v560_modules[i].master_mapping,&tmp_virtual_address)) {
+				VME_ErrorPrint(error_code);
+				return error_code;
+			}
+			printf("%i\n",sizeof(v560_registers_t));
+			v560_modules[i].registers = (v560_registers_t *) tmp_virtual_address;
+			printf("%i\n",sizeof(*(v560_modules[i].registers)));
+			u_short zahl= v560_modules[i].registers->manufacturer_type;
+			//u_short zahl= v560_modules[i].registers[0xFC];
+
+			//printf
+			printf("0x%01X%01X%01X%01X\n", zahl>>12 & 0xF,zahl>>8 & 0xF, zahl>>4 & 0xF,zahl & 0xF);
+			zahl= v560_modules[i].registers-> fixed_code;
+			
+			printf("0x%01X%01X%01X%01X\n", zahl>>12 & 0xF,zahl>>8 & 0xF, zahl>>4 & 0xF,zahl & 0xF);
+			zahl= v560_modules[i].registers-> version_series;
+			printf("0x%01X%01X%01X%01X\n", zahl>>12 & 0xF,zahl>>8 & 0xF, zahl>>4 & 0xF,zahl & 0xF);
+
+			//printf("%h",v560_modules[i].registers->manufacturer_type);
+			//if(v560_modules[i].registers->manufacturer_type==0x0818) {
+			if(v560_modules[i].registers->manufacturer_type==0x083A) {
+				printf("v560-module %i found at address 0x%08x:\n\tMaster mapping: %i\n\tVirtual address: 0x%08x\n\n",i+1,tmp_base_address,v560_modules[i].master_mapping,v560_modules[i].registers);
+				v560_modules[i].present = 1;
+			}
+			else {
+				printf("Module %i at address 0x%08x is not of type v560, or module not found. Please check the v560_base.dat-file.\n\n",i+1,tmp_base_address);
+				v560_modules[i].present = 0;
+				if(error_code = VME_MasterUnmap(v560_modules[i].master_mapping)) {
+					VME_ErrorPrint(error_code);
+					return error_code;
+				}
+				}
+			
+			i++;
+		}
+		fclose(datfile);
+	}
+	else { printf("File v560_base.dat containing the base addresses of the v560-modules not found.\n"); error_code = VME_FILE; return error_code; }
+	
+	return VME_SUCCESS;
+}
+
+//******************************************************************************
+
+int V560_Send_Scale_Increment(short module)
+{
+  if((module>NMAX_V560_MODULES) || (v560_modules[module-1].present != 1)) { return 1; }
+  //read or write access to base + %56 increases all counters by one:
+  v560_modules[module-1].registers->scale_increase =1;
+  return 0;
+}
+
+//******************************************************************************
+
+int V560_Set_Veto(short module)
+{
+  if((module>NMAX_V560_MODULES) || (v560_modules[module-1].present != 1)) { return 1; }
+  //read or write access to base + %56 increases all counters by one:
+  v560_modules[module-1].registers-> VME_veto_set =1;
+  return 0;
+}
+//******************************************************************************
+
+int V560_Reset_Veto(short module)
+{
+  if((module>NMAX_V560_MODULES) || (v560_modules[module-1].present != 1)) { return 1; }
+  //read or write access to base + %56 increases all counters by one:
+  v560_modules[module-1].registers-> VME_veto_reset =1;
+  return 0;
+}
+
+//******************************************************************************
+int V560_Clear_Scales(short module)
+{
+  if((module>NMAX_V560_MODULES) || (v560_modules[module-1].present != 1)) { return 1; }
+  //read or write access to base + %56 increases all counters by one:
+  v560_modules[module-1].registers-> scale_clear =1;
+  return 0;
+}
+//******************************************************************************
+
+u_short V560_Read_Request_Register(short module){
+  if((module>NMAX_V560_MODULES) || (v560_modules[module-1].present != 1)) { return 1; }
+  //read or write access to base + %56 increases all counters by one:
+  return v560_modules[module-1].registers-> request_register;
+}
+//******************************************************************************
+
+int V560_Write_Request_Register(short module,short request){
+  if((module>NMAX_V560_MODULES) || (v560_modules[module-1].present != 1)) { return 1; }
+  //read or write access to base + %56 increases all counters by one:
+  v560_modules[module-1].registers-> request_register = request;
+  return 0;
+}
+//******************************************************************************
+int V560_Clear_VME_Interrupt(short module)
+{
+  if((module>NMAX_V560_MODULES) || (v560_modules[module-1].present != 1)) { return 1; }
+  //read or write access to base + %56 increases all counters by one:
+  v560_modules[module-1].registers-> clear_VME_interrupt =1;
+  return 0;
+}
+//******************************************************************************
+int V560_Read_Counter(short module, short channel)
+{
+  if((module>NMAX_V560_MODULES) || (v560_modules[module-1].present != 1)) { return 1; }
+   if((channel >V560_CHANNELS ) || (channel<0)) {return 1;}
+    
+    int counts = v560_modules[module-1].registers->counter[channel];
+    return counts;
+
+
+}
+
+
+//******************************************************************************
+
+//******************************************************************************
+
+
+
+//******************************************************************************
+
+
+
+//******************************************************************************
+
+//******************************************************************************
+
+int V560_Print_Info(void)
+{
+  //return values
+  //0: print to stdio successful
+  
+  u_short manufacturer, type, version, sn, i;
+  
+  for(i=0; i<NMAX_V560_MODULES; i++) {
+    if(v560_modules[i].present != 1) {
+      //printf("Module %i is not present.\n",i+1);
+      continue;
+    }
+    
+    printf("v560-module %i (master mapping %i) found:\n",i+1,v560_modules[i].master_mapping);
+    manufacturer = v560_modules[i].registers->manufacturer_type;		manufacturer &= 0xFC00; // 0b1111 1100 0000 0000
+    type = v560_modules[i].registers->manufacturer_type;				type &= 0x03FF;			// 0b0000 0011 1111 1111
+    version = v560_modules[i].registers-> version_series;		version &= 0xF000;			// 0b1111 0000 0000 0000
+    sn = v560_modules[i].registers-> version_series;			sn &= 0x0FFF;				// 0b0000 1111 1111 1111
+    printf("Manufacturer: 0x%04x\nType: 0x%04x\nVersion: 0x%04x\nSerial Number:0x%04x\n\n", manufacturer, type, version, sn);
+  }
+  return 0;
+}
+
+//******************************************************************************
+
+VME_ErrorCode_t V560_Close(void)
+{
+	VME_ErrorCode_t error_code;
+	u_short i;
+	
+	for(i=0; i<NMAX_V560_MODULES; i++) {
+		if(v560_modules[i].present != 1) continue;
+		
+		printf("Closing v560-module %i with master mapping %i...",i+1,v560_modules[i].master_mapping);
+		if(error_code = VME_MasterUnmap(v560_modules[i].master_mapping)) {
+			VME_ErrorPrint(error_code);
+			return error_code;
+		}
+		printf("closed.\n");
+	}
+	//and close the VME:
+	/*if(error_code = VME_Close()) {
+	  VME_ErrorPrint(error_code);
+	  printf("VME close not succesful.\n");
+	  return error_code;
+	  }*/
+
+	return VME_SUCCESS;
+}
+
+//******************************************************************************
Index: /trigger/v560.h
===================================================================
--- /trigger/v560.h	(revision 52)
+++ /trigger/v560.h	(revision 52)
@@ -0,0 +1,83 @@
+/********************************************/
+/*Header file for the CAEN V560             */
+/*16 Channel scaler                         */
+/*        
+/*Author: Michael Rissi
+/*Date: 29 May 2009                         */
+/*Based on v792.h by Markus Joos            */
+/********************************************/
+
+#ifndef _V560_H
+#define _V560_H
+
+//******************************************************************************
+//Constants
+//******************************************************************************
+
+#define V560_CHANNELS 16
+#include "rcc_error/rcc_error.h"
+#include "vme_rcc/vme_rcc.h"
+//******************************************************************************
+//Type definitions
+//******************************************************************************
+
+//This struct maps the memory of a v560 module.
+typedef struct {
+  //	Variable name							//Adress offset		//Read-/Write-Mode
+  u_short dummy1[2];         	                                        //0x00-0x04			// none
+  u_short interrupt_vector_register;					//0x04-0x06			// r/w
+  u_short interrupt_level_register;				        //0x06-0x08			// r/w
+  u_short enable_VME_interrupt;              				//0x08-0x0A			// r/w
+  u_short disable_VME_interrupt;		         		//0x0A-0x0C			// r/w
+  u_short clear_VME_interrupt;           				//0x0C-0x0E			// r/w
+  u_short request_register;              				//0x0E-0x10			// r/w
+  u_int counter[V560_CHANNELS];                  			//0x10-0x50			// r
+  u_short scale_clear;                    				//0x50-0x52			// r/w
+  u_short VME_veto_set; 						//0x52-0x54			// r/w
+  u_short VME_veto_reset; 						//0x54-0x56			// r/w
+  u_short scale_increase; 						//0x56-0x58			// r/w
+  u_short scale_status_register;					//0x58-0x5A			// r/w
+   u_short dummy2[80];                                                   //0x5A-0xF8			// not used
+  u_short fixed_code;            					//0xFA-0xFC			// r
+  u_short manufacturer_type;           					//0xFC-0xFE			// r
+  u_short version_series;           					//0xFE   			// r 
+} v560_registers_t;
+
+//This struct contains the information necessary to handle one module
+typedef struct {
+	v560_registers_t* registers;		//contains the virtual address of the module
+	int master_mapping;					//contains the handle of the module
+	char present;						//0 if module not present, 1 if present
+} v560_module_t;
+
+//******************************************************************************
+//Global Variables
+//******************************************************************************
+
+v560_module_t v560_modules[]; //TODO: not sure if this is correct
+
+//******************************************************************************
+//Function Definitions
+//******************************************************************************
+
+VME_ErrorCode_t V560_Open();
+int V560_Send_Scale_Increment(short module);
+int V560_Set_Veto(short module);
+int V560_Reset_Veto(short module);
+int V560_Clear_Scales(short module);
+u_short V560_Read_Request_Register(short module);
+int V560_Write_Request_Register(short module,short request);
+int V560_Clear_VME_Interrupt(short module);
+int V560_Read_Counter(short module, short channel);
+//int V560_Set_Threshold(u_short module, u_char channel, u_short threshold);
+/*extern int V560_Set_Pattern_Inhibit(u_short module, u_char channel[16]);
+extern int V560_Set_Output_Width(u_short module, u_char channel_block, u_short width);
+extern int V560_Set_Dead_Time(u_short module, u_char channel_block, u_short dead_time);
+extern int V560_Set_Majority_Level(u_short module, u_short majority_level);
+extern int V560_Test_Pulse(u_short module);*/
+int V560_Print_Info(void);
+VME_ErrorCode_t V560_Close(void);
+
+//******************************************************************************
+
+#endif
Index: /trigger/v560_base.dat
===================================================================
--- /trigger/v560_base.dat	(revision 52)
+++ /trigger/v560_base.dat	(revision 52)
@@ -0,0 +1,15 @@
+%Lines starting with '%' are ignored.
+%This file contains the base addresses of the modules in the desired order:
+%First address: module nr. 1, second address: module nr. 2 ...
+%
+%Module #1
+0x000A0000
+%
+%Module #2
+%0x00020000
+%
+%Module #3
+%0x00030000
+%
+%Module #4
+%0x00040000
Index: /trigger/v560_dummy.c
===================================================================
--- /trigger/v560_dummy.c	(revision 52)
+++ /trigger/v560_dummy.c	(revision 52)
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include "rcc_error/rcc_error.h"
+#include "vme_rcc/vme_rcc.h"
+
+//******************************************************************************
+//Constants
+//******************************************************************************
+
+#define NMAX_V560_MODULES 10 //maximum 65535, probably more than enough...
+#define V560_CHANNELS 16
+
+//******************************************************************************
+//Type definitions
+//******************************************************************************
+
+//This struct maps the memory of a v560 module.
+typedef struct {
+//	Variable name							//Adress offset		//Read-/Write-Mode
+	u_short threshold_ch[V560_CHANNELS];	//0x00-0x1E			//w
+	u_short dummy1[16];						//0x20-0x3E			//none
+	u_short output_width[2];				//0x40-0x42			//w
+	u_short dead_time[2];					//0x44-0x46			//w
+	u_short majority_threshold;				//0x48				//w
+	u_short pattern_inhibit;				//0x4A				//w
+	u_short test_pulse;						//0x4C				//w
+	u_short dummy2[86];						//0x4E-0xF8			//none
+	u_short fixed_code;						//0xFA				//r
+	u_short manufacturer_type;				//0xFC				//r
+	u_short version_serialnumber;			//0xFE				//r
+} v560_registers_t;
+
+//This struct contains the information necessary to handle one module
+typedef struct {
+	v560_registers_t* registers;		//contains the virtual address of the module
+	int master_mapping;					//contains the handle of the module
+	char present;						//0 if module not present, 1 if present
+} v560_module_t;
+
+//******************************************************************************
+//Global Variables
+//******************************************************************************
+
+v560_module_t v560_modules[NMAX_V560_MODULES];
+
+//******************************************************************************
+//Function Definitions
+//******************************************************************************
+
+VME_ErrorCode_t V560_Open(void)
+{
+	printf("V560_Open() was called.\n");
+	return VME_SUCCESS;
+}
+
+//******************************************************************************
+
+int V560_Set_Threshold(u_short module, u_char channel, u_short threshold)
+{
+	printf("V560_Set_Threshold(module %i, channel %i, threshold %i) was called.\n", module, channel, threshold);
+	return 0;
+}
+
+//******************************************************************************
+
+int V560_Set_Pattern_Inhibit(u_short module, u_char channels[16])
+{
+	//create the pattern of inhibit
+	u_short pattern = 0;
+	int i;
+	for(i=0; i<16; i++) {
+		if(channels[i]!=0) {
+			switch(i) {
+				case 0: pattern |= 0x0001; break;
+				case 1: pattern |= 0x0002; break;
+				case 2: pattern |= 0x0004; break;
+				case 3: pattern |= 0x0008; break;
+				case 4: pattern |= 0x0010; break;
+				case 5: pattern |= 0x0020; break;
+				case 6: pattern |= 0x0040; break;
+				case 7: pattern |= 0x0080; break;
+				case 8: pattern |= 0x0100; break;
+				case 9: pattern |= 0x0200; break;
+				case 10: pattern |= 0x0400; break;
+				case 11: pattern |= 0x0800; break;
+				case 12: pattern |= 0x1000; break;
+				case 13: pattern |= 0x2000; break;
+				case 14: pattern |= 0x4000; break;
+				case 15: pattern |= 0x8000; break;
+			}
+		}
+	}
+	printf("v560_pattern_inhibit(module %i, pattern %04x) was called.\n", module, pattern);
+	return 0;
+}
+
+//******************************************************************************
+
+int V560_Set_Output_Width(u_short module, u_char channel_block, u_short width)
+{
+	printf("V560_Set_Output_Width(module %i, channel block %i, width %i) was called.\n", module, channel_block, width);
+	return 0;
+}
+
+//******************************************************************************
+
+int V560_Set_Dead_Time(u_short module, u_char channel_block, u_short dead_time)
+{
+	printf("V560_Set_Dead_Time(module %i, channel block %i, dead time %i) was called.\n", module, channel_block, dead_time);
+	return 0;
+}
+
+//******************************************************************************
+
+int V560_Set_Majority_Level(u_short module, u_short majority_level)
+{
+	printf("V560_Set_Majority_Level(module %i, majority_level %i) was called.\n", module, majority_level);
+	return 0;
+}
+
+//******************************************************************************
+
+int V560_Test_Pulse(u_short module)
+{
+	printf("V560_Test_Pulse(module %i) was called.\n", module);
+	return 0;
+}
+
+//******************************************************************************
+
+int V560_Print_Info(void)
+{
+	printf("V560_Print_Info() was called.\n");
+	return 0;
+}
+
+//******************************************************************************
+
+VME_ErrorCode_t V560_Close(void)
+{
+	printf("V560_Close() was called.\n");
+	return VME_SUCCESS;
+}
+
+//******************************************************************************
Index: /trigger/v560_test.c
===================================================================
--- /trigger/v560_test.c	(revision 52)
+++ /trigger/v560_test.c	(revision 52)
@@ -0,0 +1,54 @@
+//Simple Program to check the communication with the v560-modules listed in the file 'v560_base.dat'.
+#include <unistd.h>
+
+#include <stdio.h>
+//#include "rcc_error/rcc_error.h"
+//#include "vme_rcc/vme_rcc.h"
+#include "v560.h"
+
+int main(void)
+{
+	//return values
+	//0: programm run successful
+	//1: VME open not successful
+	//2: v560 open not successful
+	//3: v560 print info not successful
+	//4: v560 close not successful
+	//5: VME close not succesful
+
+	VME_ErrorCode_t error_code;
+	
+	printf("This program checks the communication with the v560-modules\nlisted in the file 'v560_base.dat'.\nThe programm should print the manufacturer's information\nstored in each module.\n\n");
+	
+	/*	if(error_code = VME_Open()) {
+		VME_ErrorPrint(error_code);
+		printf("VME open not successful.\n");
+		return 1;
+		}*/
+	
+	V560_Open();
+		
+	
+	V560_Print_Info();
+	//now send an increment and read the counter:
+	int cc;
+	V560_Clear_Scales(1);
+	while(1)
+	  {
+	    V560_Clear_Scales(1);
+	    sleep(1);
+	    printf("rate: %i kHz (C0), %i kHz (C1) \n",(int)(V560_Read_Counter(1,0)/1000.),(int)(V560_Read_Counter(1,1)/1000.));
+	    
+
+	  
+	  
+	  }
+	V560_Close();
+
+
+	
+	
+	//
+	return 0;
+
+}
Index: /trigger/v560_test.py
===================================================================
--- /trigger/v560_test.py	(revision 52)
+++ /trigger/v560_test.py	(revision 52)
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+
+import _VME
+
+import time
+
+_VME.VME_Open()
+_VME.V560_Open()
+_VME.V560_Print_Info()
+
+
+#while 1:
+#    _VME.V560_Clear_Scales(1)
+#    time.sleep(1)
+#    print "rate: " , _VME.V560_Read_Counter(1,1)/1000., " kHz"
+
+
+
+#now the V812:
+print "v812:\n"
+_VME.V812_Open()
+_VME.V812_Print_Info()
+#trying to set the hexpat:
+myhexpat = 0x0001
+_VME.V812_Set_Pattern_Inhibit_Hex(1,myhexpat);
+
+
+_VME.V812_Close()
+_VME.V560_Close()
+_VME.VME_Close()
Index: /trigger/v812.c
===================================================================
--- /trigger/v812.c	(revision 52)
+++ /trigger/v812.c	(revision 52)
@@ -0,0 +1,309 @@
+
+
+//******************************************************************************
+//Constants
+//******************************************************************************
+
+#define NMAX_V812_MODULES 10 //maximum 65535, probably more than enough...
+#define V812_CHANNELS 16
+#include "v812.h"
+//******************************************************************************
+//Type definitions
+//******************************************************************************
+
+
+//******************************************************************************
+//Global Variables
+//******************************************************************************
+
+v812_module_t v812_modules[NMAX_V812_MODULES];
+
+//******************************************************************************
+//Function Definitions
+//******************************************************************************
+
+VME_ErrorCode_t V812_Open(void)
+{
+	u_int tmp_virtual_address, tmp_base_address;
+	u_short i=0;
+	VME_ErrorCode_t error_code;
+	VME_MasterMap_t master_map;
+	
+	master_map.vmebus_address	= 0x00010000;
+	master_map.window_size		= 0x1000;
+	master_map.address_modifier	= VME_A24;
+	master_map.options			= 0;
+	
+	for(i=0; i<NMAX_V812_MODULES; i++) {
+		v812_modules[i].present = 0;
+	}
+	
+	//opening the file containing the base addresses
+	FILE *datfile = fopen("v812_base.dat","r");
+	char line[256];
+	
+	i=0;
+	if (datfile!=NULL) {
+		while(fgets(line,255,datfile)) {
+			
+			//excluding comment lines
+			if(line[0] == '%') {
+				continue;
+			}
+			
+			//reading the hex address
+			if(!sscanf(&line[2],"%8x",&tmp_base_address)) {
+				printf("Reading input file v812_base.dat: non-comment line without address found. Please delete or comment this line.\n");
+			}
+			
+			//check address, assign to the master map
+			if(tmp_base_address & 0x0000FFFF) {
+				printf("Reading input file v812_base.dat: 0x%08x is no valid base address (0xXXXX0000)\n",tmp_base_address);
+				continue;
+			}
+			if(i>=NMAX_V812_MODULES) {
+				printf("Reading input file v812_base.dat: More addresses found than memory space provided.\nIncrease NMAX_V812_MODULES in v812.h and v812.c.\n");
+				break;
+			}
+			master_map.vmebus_address = tmp_base_address;
+			
+			if(error_code = VME_MasterMap(&master_map,&v812_modules[i].master_mapping)) {
+				VME_ErrorPrint(error_code);
+				return error_code;
+			}
+
+			if(error_code = VME_MasterMapVirtualAddress(v812_modules[i].master_mapping,&tmp_virtual_address)) {
+				VME_ErrorPrint(error_code);
+				return error_code;
+			}
+			
+			v812_modules[i].registers = (v812_registers_t *) tmp_virtual_address;
+			
+			if(v812_modules[i].registers->manufacturer_type==0x0851) {
+				printf("v812-module %i found at address 0x%08x:\n\tMaster mapping: %i\n\tVirtual address: 0x%08x\n\n",i+1,tmp_base_address,v812_modules[i].master_mapping,v812_modules[i].registers);
+				v812_modules[i].present = 1;
+			}
+			else {
+				printf("Module %i at address 0x%08x is not of type v812, or module not found. Please check the v812_base.dat-file.\n\n",i+1,tmp_base_address);
+				v812_modules[i].present = 0;
+				if(error_code = VME_MasterUnmap(v812_modules[i].master_mapping)) {
+					VME_ErrorPrint(error_code);
+					return error_code;
+				}
+			}
+			
+			i++;
+		}
+		fclose(datfile);
+	}
+	else { printf("File v812_base.dat containing the base addresses of the v812-modules not found.\n"); error_code = VME_FILE; return error_code; }
+	
+	return VME_SUCCESS;
+}
+
+//******************************************************************************
+
+int V812_Set_Threshold(short module, short channel, short threshold)
+{
+	//return values
+	//0: threshold set successful
+	//1: module out of range or not present
+	//2: channel number out of range
+	//3: threshold out of range (threshold in mV between -1 mV and -255 mV)
+	
+	if((module>NMAX_V812_MODULES) || (v812_modules[module-1].present != 1)) { return 1; }
+	if(!((channel>=0) && (channel<=15))) { return 2; }
+	if(!((threshold>=1) && (channel<=255))) { return 3; }
+	v812_modules[module-1].registers->threshold_ch[channel] = threshold;
+	return 0;
+
+	/* comment on little/big endian: the Intel architecture uses little Endian coding,
+	whereas the VME-Standard uses big Endian (to my knowledge). Nonetheless the thresholds
+	can be written directly to the module memory since the thresholds are saved as 8 bit
+	words located at the adress of the short integer (according to the Technical Information
+	Manual MOD. V 812 Series, p 16). */
+}
+
+//******************************************************************************
+
+int V812_Set_Pattern_Inhibit(short module, char channels[16])
+{
+	//return values
+	//0: pattern of inhibit written successfully
+	//1: module out of range or not present
+	if((module>NMAX_V812_MODULES) || (v812_modules[module-1].present != 1)) { return 1; }
+	
+	//create the pattern of inhibit
+	u_short pattern = 0;
+	int i;
+	for(i=0; i<16; i++) {
+		if(channels[i]!=0) {
+			switch(i) {
+				case 0: pattern |= 0x0001; break;
+				case 1: pattern |= 0x0002; break;
+				case 2: pattern |= 0x0004; break;
+				case 3: pattern |= 0x0008; break;
+				case 4: pattern |= 0x0010; break;
+				case 5: pattern |= 0x0020; break;
+				case 6: pattern |= 0x0040; break;
+				case 7: pattern |= 0x0080; break;
+				case 8: pattern |= 0x0100; break;
+				case 9: pattern |= 0x0200; break;
+				case 10: pattern |= 0x0400; break;
+				case 11: pattern |= 0x0800; break;
+				case 12: pattern |= 0x1000; break;
+				case 13: pattern |= 0x2000; break;
+				case 14: pattern |= 0x4000; break;
+				case 15: pattern |= 0x8000; break;
+			}
+		}
+	}
+	v812_modules[module-1].registers->pattern_inhibit = pattern;
+	return 0;
+}
+int V812_Set_Pattern_Inhibit_Hex(short module, short pattern)
+{
+	//return values
+	//0: pattern of inhibit written successfully
+	//1: module out of range or not present
+	if((module>NMAX_V812_MODULES) || (v812_modules[module-1].present != 1)) { return 1; }
+	
+	v812_modules[module-1].registers->pattern_inhibit = pattern;
+	return 0;
+}
+//******************************************************************************
+
+int V812_Set_Output_Width(short module, char channel_block, short width)
+{
+	//channel_block: 0 for ch0-ch7, 1 for ch8-ch15
+	
+	//return values
+	//0: width set successful
+	//1: module out of range or not present
+	//2: channel_block out of range
+	//3: width out of range (width between 0 (15 ns) and 255 (250 ns), non-linear relation)
+	
+	if((module>NMAX_V812_MODULES) || (v812_modules[module-1].present != 1)) { return 1; }
+	if(!((channel_block>=0) && (channel_block<=1))) { return 2; }
+	if(!((width>=0) && (width<=255))) { return 3; }
+	v812_modules[module-1].registers->output_width[channel_block] = width;
+	return 0;
+}
+
+//******************************************************************************
+
+int V812_Set_Dead_Time(short module, short channel_block, short dead_time)
+{
+	//channel_block: 0 for ch0-ch7, 1 for ch8-ch15
+	
+	//return values
+	//0: dead time set successful
+	//1: module out of range or not present
+	//2: channel_block out of range
+	//3: dead time out of range (dead time between 0 (150 ns) and 255 (2 us))
+	
+	if((module>NMAX_V812_MODULES) || (v812_modules[module-1].present != 1)) { return 1; }
+	if(!((channel_block>=0) && (channel_block<=1))) { return 2; }
+	if(!((dead_time>=0) && (dead_time<=255))) { return 3; }
+	v812_modules[module-1].registers->dead_time[channel_block] = dead_time;
+	return 0;
+}
+
+//******************************************************************************
+
+int V812_Set_Majority_Level(short module, short majority_level)
+{
+	//majority_level according to Technical Information Manual, p. 17
+	
+	//return values
+	//0: majority level set succesful
+	//1: module out of range or not present
+	//2: majority level out of range (1 to 20)
+	
+	u_short majority_threshold;
+	
+	if((module>NMAX_V812_MODULES) || (v812_modules[module-1].present != 1)) { return 1; }
+	if(!((majority_level>=1) && (majority_level<=20))) { return 2; }
+	
+	majority_threshold = (double) (majority_level*50-25)/4 + 0.5;
+	//Why + 0.5? This is necessary for the correct calculation of the nearest integer since double-variables are truncated when converted to integer
+	
+	v812_modules[module-1].registers->majority_threshold = majority_threshold;
+	return 0;
+}
+int V812_Set_Majority_Threshold(short module, short majority_threshold)
+{
+	//majority_threshold according to Technical Information Manual, p. 17
+	
+	//return values
+	//0: majority threshold set succesful
+	//1: module out of range or not present
+	//2: majority threshold out of range (1 to 255)
+	
+	if((module>NMAX_V812_MODULES) || (v812_modules[module-1].present != 1)) { return 1; }
+	if(!((majority_threshold>=1) && (majority_threshold<=255))) { return 2; }
+	v812_modules[module-1].registers->majority_threshold = majority_threshold;
+	return 0;
+}
+
+//******************************************************************************
+
+int V812_Test_Pulse(short module)
+{
+	//return values
+	//0: test pulse generated successfully
+	//1: module out of range or not present
+	
+	if((module>NMAX_V812_MODULES) || (v812_modules[module-1].present != 1)) { return 1; }
+	v812_modules[module-1].registers->test_pulse = 0xFFFF;
+	return 0;
+}
+
+//******************************************************************************
+
+int V812_Print_Info(void)
+{
+	//return values
+	//0: print to stdio successful
+
+	u_short manufacturer, type, version, sn, i;
+	
+	for(i=0; i<NMAX_V812_MODULES; i++) {
+		if(v812_modules[i].present != 1) {
+			//printf("Module %i is not present.\n",i+1);
+			continue;
+		}
+		
+		printf("v812-module %i (master mapping %i) found:\n",i+1,v812_modules[i].master_mapping);
+		manufacturer = v812_modules[i].registers->manufacturer_type;		manufacturer &= 0xFC00; // 0b1111 1100 0000 0000
+		type = v812_modules[i].registers->manufacturer_type;				type &= 0x03FF;			// 0b0000 0011 1111 1111
+		version = v812_modules[i].registers->version_serialnumber;		version &= 0xF000;			// 0b1111 0000 0000 0000
+		sn = v812_modules[i].registers->version_serialnumber;			sn &= 0x0FFF;				// 0b0000 1111 1111 1111
+		printf("Manufacturer: 0x%04x\nType: 0x%04x\nVersion: 0x%04x\nSerial Number:0x%04x\n\n", manufacturer, type, version, sn);
+	}
+	return 0;
+}
+
+//******************************************************************************
+
+
+VME_ErrorCode_t V812_Close(void)
+{
+	VME_ErrorCode_t error_code;
+	u_short i;
+	
+	for(i=0; i<NMAX_V812_MODULES; i++) {
+		if(v812_modules[i].present != 1) continue;
+		
+		printf("Closing v812-module %i with master mapping %i...",i+1,v812_modules[i].master_mapping);
+		if(error_code = VME_MasterUnmap(v812_modules[i].master_mapping)) {
+			VME_ErrorPrint(error_code);
+			return error_code;
+		}
+		printf("closed.\n");
+	}
+	
+	return VME_SUCCESS;
+}
+
+//******************************************************************************
Index: /trigger/v812.h
===================================================================
--- /trigger/v812.h	(revision 52)
+++ /trigger/v812.h	(revision 52)
@@ -0,0 +1,73 @@
+/********************************************/
+/*Header file for the CAEN V812             */
+/*16 Channel constant fraction discriminator*/
+/*                                          */
+/*Author: Thomas Kraehenbuehl               */
+/* adapted by Michael Rissi to be wrapped by*/
+/* Python                                   */
+/*Date: 27 February 2008                    */
+/*Based on v792.h by Markus Joos            */
+/********************************************/
+
+#ifndef _V812_H
+#define _V812_H
+
+//******************************************************************************
+//Constants
+//******************************************************************************
+
+#define V812_CHANNELS 16
+#include "rcc_error/rcc_error.h"
+#include "vme_rcc/vme_rcc.h"
+//******************************************************************************
+//Type definitions
+//******************************************************************************
+
+//This struct maps the memory of a v812 module.
+typedef struct {
+//	Variable name							//Adress offset		//Read-/Write-Mode
+	u_short threshold_ch[V812_CHANNELS];	//0x00-0x1E			//w
+	u_short dummy1[16];						//0x20-0x3E			//none
+	u_short output_width[2];				//0x40-0x42			//w
+	u_short dead_time[2];					//0x44-0x46			//w
+	u_short majority_threshold;				//0x48				//w
+	u_short pattern_inhibit;				//0x4A				//w
+	u_short test_pulse;						//0x4C				//w
+	u_short dummy2[86];						//0x4E-0xF8			//none
+	u_short fixed_code;						//0xFA				//r
+	u_short manufacturer_type;				//0xFC				//r
+	u_short version_serialnumber;			//0xFE				//r
+} v812_registers_t;
+
+//This struct contains the information necessary to handle one module
+typedef struct {
+	v812_registers_t* registers;		//contains the virtual address of the module
+	int master_mapping;					//contains the handle of the module
+	char present;						//0 if module not present, 1 if present
+} v812_module_t;
+
+//******************************************************************************
+//Global Variables
+//******************************************************************************
+
+v812_module_t v812_modules[]; //TODO: not sure if this is correct
+
+//******************************************************************************
+//Function Definitions
+//******************************************************************************
+
+VME_ErrorCode_t V812_Open(void);
+int V812_Set_Threshold(short module, short channel, short threshold);
+int V812_Set_Pattern_Inhibit(short module, char channel[16]);
+int V812_Set_Output_Width(short module, char channel_block, short width);
+int V812_Set_Dead_Time(short module, short channel_block, short dead_time);
+int V812_Set_Majority_Level(short module, short majority_level);
+int V812_Set_Majority_Threshold(short module, short majority_threshold);
+int V812_Test_Pulse(short module);
+int V812_Print_Info(void);
+int V812_Set_Pattern_Inhibit_Hex(short module, short pattern);
+VME_ErrorCode_t V812_Close(void);
+
+//******************************************************************************
+
+#endif
Index: /trigger/v812_base.dat
===================================================================
--- /trigger/v812_base.dat	(revision 52)
+++ /trigger/v812_base.dat	(revision 52)
@@ -0,0 +1,15 @@
+%Lines starting with '%' are ignored.
+%This file contains the base addresses of the modules in the desired order:
+%First address: module nr. 1, second address: module nr. 2 ...
+%
+%Module #1
+0x00010000
+%
+%Module #2
+%0x00020000
+%
+%Module #3
+%0x00030000
+%
+%Module #4
+%0x00040000
