Index: /fact/trigger/CommSocket.py
===================================================================
--- /fact/trigger/CommSocket.py	(revision 9840)
+++ /fact/trigger/CommSocket.py	(revision 9840)
@@ -0,0 +1,203 @@
+#!/usr/bin/python
+# First the server
+
+
+
+"""
+"""
+
+import select
+import socket
+import sys
+import signal
+from communication import send, receive
+import threading
+import GlobalVariables
+import time
+BUFSIZ = 1024
+class Sender(threading.Thread):
+    """ Sends the messages """
+    outputs = []
+    oldmessage=''
+     
+    def run(self):
+        running = 1
+        while running:
+            time.sleep(0.001)
+            if(self.oldmessage!=GlobalVariables.ServerMessage):
+                self.oldmessage=GlobalVariables.ServerMessage
+             
+                for o in self.outputs:
+                    # o.send(msg)
+                    #print "sending (glob): ",GlobalVariables.ServerMessage,"\n"
+                    send(o,GlobalVariables.ServerMessage )
+                if(GlobalVariables.UserInput[1:]=='exit' or GlobalVariables.UserInput[1:]=='EXIT'):
+                    running=0
+              
+
+
+         
+class CommServer(threading.Thread):
+    """ Simple  server using select """
+    oldmessage=''
+    sender=Sender()
+    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)
+        self.sender.start()
+        # Trap keyboard interrupts
+        #signal.signal(signal.SIGINT, self.sighandler)
+        threading.Thread.__init__(self)
+    #def sighandler(self, signum, frame):
+    #    if(GlobalVariables.UserInput[1:]=='exit' or GlobalVariables.UserInput[1:]=='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.001)
+            #if(self.oldmessage!=GlobalVariables.ServerMessage):
+            #    self.oldmessage=GlobalVariables.ServerMessage
+            #    for o in self.outputs:
+            #        # o.send(msg)
+            #        #print "sending (glob): ",GlobalVariables.ServerMessage,"\n"
+            #        send(o,GlobalVariables.ServerMessage )
+            if(GlobalVariables.UserInput[1:]=='exit' or GlobalVariables.UserInput[1:]=='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)
+                    GlobalVariables.ServerMessage = 'SERVER: got connection %d from %s' %( client.fileno(), address)+"\n"
+                    # Read the login name
+                    cname="TESTUSER"
+                    #cname = receive(client).split('NAME: ')[1]
+                    #print cname
+                    # Compute client name and send back
+                    self.clients += 1
+                    #send(client, 'FROM SERVER: CLIENT: ' + str(address[0]))
+                    #send(client,"test");
+                    #send(client,"test2");
+                    
+                    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))
+                    GlobalVariables.ServerMessage=msg;
+                    time.sleep(0.001)
+                    #print "appending ", client
+                    self.outputs.append(client)
+                    self.sender.outputs=self.outputs
+                #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)
+                        #print data
+                        if data:
+                            GlobalVariables.counter += 1
+                            GlobalVariables.counter %= 10
+                            data = str(GlobalVariables.counter)+data
+                            # Send as new client's message...
+                            msg = 'SERVER: You sent: >> ' + data
+                            msg+="\n"
+                            GlobalVariables.UserInput=data
+                            #print "SERVER: recv data: "+data
+                            #print "msg is: ",msg
+
+                            #for o in self.outputs:
+                                #msg="TSTSTS"
+                             #   print "sending ",msg," to ",o
+                                
+                              #  send(o, msg)
+                            if(GlobalVariables.UserInput[1:]=='exit' or GlobalVariables.UserInput[1:]=='EXIT'):
+                                running=0
+                                # Send data to all except ourselves
+                                                            
+                        else:
+                            GlobalVariables.ServerMessage ='SERVER: %d hung up' % s.fileno()
+                            self.clients -= 1
+                            s.close()
+                            inputs.remove(s)
+                            self.outputs.remove(s)
+                            self.sender.outputs=self.outputs
+                            # 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)
+                        
+
+        GlobalVariables.ServerMessage ='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: /fact/trigger/CommunicateWithVME.py
===================================================================
--- /fact/trigger/CommunicateWithVME.py	(revision 9840)
+++ /fact/trigger/CommunicateWithVME.py	(revision 9840)
@@ -0,0 +1,498 @@
+#!/usr/bin/python
+##############################################################
+#
+#  CommunicateWithVME.py
+#  Handles the communication with the VME crate
+#  Sends commands to the VME crate
+#
+#  
+#  Michael Rissi 05/2009
+#
+#############################################################
+
+import GlobalVariables
+import threading
+import _VME
+import time
+import datetime
+
+def GetStatus():
+    print "Trigger thresholds: ", GlobalVariables.TriggerThresholds
+    print "Hex Pattern: ", GlobalVariables.HexPattern
+    print "Majority Level: ",GlobalVariables.MajorityLevel
+
+
+
+
+
+def GetRate(module,channel):
+    _VME.V560_Clear_Scales( module)
+    beginCounter=_VME. V560_Read_Counter( module,  channel)
+    GlobalVariables.ServerMessage = "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      =  ["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)
+        #GlobalVariables.ServerMessage = str(beginCounter[i])
+    #GlobalVariables.ServerMessage = "Evaluating rates..."
+    time.sleep(2)
+    for i in range(0,16):
+        endCounter[i] = _VME. V560_Read_Counter( module,  i)
+        #GlobalVariables.ServerMessage = str(endCounter[i])
+        rates[i+1] =(endCounter[i]-beginCounter[i])/2000.
+    return rates
+
+
+class GimmeRates(threading.Thread):
+    rates=["rates",
+        0,0,0,0,
+           0,0,0,0,
+           0,0,0,0,
+           0,0,0,0]
+    module = 1
+    def run(self):
+        oldcommand=GlobalVariables.UserInput
+        while(GlobalVariables.UserInput[1:]!="exit" and GlobalVariables.UserInput[1:] != "EXIT"):
+            time.sleep(0.001)
+            newrates = GetRates(self.module)
+            self.rates=newrates
+
+
+
+        
+class WriteOutput(threading.Thread):      #thread that writes the rates and threshold to a file.
+    rates=["rates",
+        0,0,0,0,
+           0,0,0,0,
+           0,0,0,0,
+           0,0,0,0]
+    interval = 2
+    filename = "test.txt"
+    #gimmeRates =GimmeRates()
+    gimmeRates=GimmeRates()
+    #File=open(filename,'a')
+    def __init__(self, filename="test.txt", interval = 10):
+        threading.Thread.__init__(self)
+        #self.OpenNewFile(filename)
+
+
+
+    def writeToFile(self):
+        File = open(self.filename,'a')
+        #print "writing", (GlobalVariables.Rates)
+        #year = datetime.date.today().year
+        #month = datetime.date.today().month
+        #day = datetime.date.today().day
+        year = time.localtime(time.time())[0]
+        month =time.localtime(time.time())[1]
+        day = time.localtime(time.time())[2]
+        hour = time.localtime(time.time())[3]
+        minute = time.localtime(time.time())[4]
+        seconds = time.localtime(time.time())[5]
+        ms = time.localtime(time.time())[6]
+        #date=str(year)
+        #if (hour>=12):
+        #    day = day+1
+
+        t = datetime.datetime.now()
+        EpochSeconds=int(time.mktime(t.timetuple()))
+
+        outstring = "Trigger " + " ThreshRate "+str(year) + " " + str(month) +" " + str(day) +" "+str(hour)+" " + str(minute) + " " + str(seconds)+ " "+str(ms)+" "+str(EpochSeconds)+" Thresh: "
+        File.write(outstring)
+        #print outstring
+        File.write(str(GlobalVariables.TriggerThresholds[0:]).strip('[]').replace(',', ''))
+        File.write(" rate: ")
+        GlobalVariables.Rates = self.gimmeRates.rates
+        File.write(str(GlobalVariables.Rates[0:]))#.strip('[]').replace(',', ''))
+        #print str(GlobalVariables.Rates[0:]).strip('[]').replace(',', ''))
+
+      
+        #print str(GlobalVariables.TriggerThresholds[0:]).strip('[]').replace(',', '')
+        #print "\n"
+        
+        File.write("\n")
+        File.close();
+
+
+
+    def run(self):
+        self.gimmeRates.start()
+        while(GlobalVariables.UserInput[1:]!="exit" and GlobalVariables.UserInput[1:] != "EXIT"):
+            time.sleep(0.001)
+            time.sleep(self.interval)
+            self.writeToFile() 
+
+
+
+
+
+
+
+        
+    
+
+
+class ParseUserInput(threading.Thread):
+    gimmeRates=GimmeRates()
+    writeOutput=WriteOutput()
+    def Parse(self,Command):
+        Command = Command[1:]
+        #GlobalVariables.ServerMessage = "PARSING: " + Command
+        sCommand=Command.split()
+        error_code=0
+        #python lacks switch...
+        try:
+            VMEModule=sCommand[0]
+            if(VMEModule == "help"):
+                GlobalVariables.ServerMessage = "please use \'<V812|V560|Triggerboard> help\' "
+                #GlobalVariables.ServerMessage="please use \'<V812|V560|Triggerboard> help\' "
+            
+            # now do the stuff for the V560:
+            if(VMEModule == "V560"):
+                V560Command=sCommand[1]
+                if(V560Command=="help"):
+                    GlobalVariables.ServerMessage = "available functions are: \n"
+                    GlobalVariables.ServerMessage += "V560 GetRate <module#> <channel#>\n"
+                    GlobalVariables.ServerMessage += "V560 GetRates <module#\n "
+                    time.sleep(0.05)
+                    
+                if(V560Command=="GetRate"):
+                    #GlobalVariables.ServerMessage = "trying to get rate"
+                    #time.sleep(0.05)
+                    
+
+                    try:
+                        module = int(sCommand[2])
+                        channel= int(sCommand[3])
+                        if(module!= self.gimmeRates.module):
+                            self.gimmeRates.module=module
+                            GlobalVariables.ServerMessage = "please wait... (5sec)"
+                            time.sleep(5)
+                        
+                        GlobalVariables.ServerMessage = str(self.gimmeRates.rates[channel])
+                        time.sleep(0.01)
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax Error (GetRate)"
+                        time.sleep(0.01)
+                    #GlobalVariables.Rates[int(channel)] = GetRates(int(module),int(channel))
+
+                if(V560Command=="GetRates" or V560Command=="GR"):
+                    #GlobalVariables.ServerMessage = "trying to get rates"
+                    #time.sleep(0.01)
+                    try:
+                        module = int(sCommand[2])
+                        if(module!= self.gimmeRates.module):
+                            self.gimmeRates.module=module
+                            GlobalVariables.ServerMessage = "please wait... (5sec)"
+                            time.sleep(5)
+                        #GlobalVariables.ServerMessage = "RATES:"
+                        GlobalVariables.ServerMessage = str(self.gimmeRates.rates)
+                        time.sleep(0.01)
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax Error (GetRates)"
+                        time.sleep(0.05)
+                    #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"):
+                    GlobalVariables.ServerMessage  = "available functions are: \n"
+                    GlobalVariables.ServerMessage += "V812 SetHexPat <module#[1-10]> <HexPattern[0x0000-0xFFFF>\n"
+                    GlobalVariables.ServerMessage += "V812 SetThresh <module#[1-10]> <channel#[0-15]> <thresh[0-255]>\n"
+                    GlobalVariables.ServerMessage += "V812 SetThreshDiff <module#[1-10]> <channel#[0-15]> <threshdiff[0-255]>\n"
+                    GlobalVariables.ServerMessage += "V812 SetAllThresh <module#[1-10]>  <thresh[0-255]>\n"
+                    GlobalVariables.ServerMessage += "V812 SetAllThreshDiff <module#[1-10]>  <threshdiff[0-255]>\n"
+                    GlobalVariables.ServerMessage += "V812 SetMajLevel <module#[1-10]> <MajLev[1-20]>\n"
+                    GlobalVariables.ServerMessage += "V812 SetMajThresh <module#[1-10]> <MajThr[0-255]>\n"
+                    GlobalVariables.ServerMessage += "V812 SetDeadTime <module#[1-10]> <Block [0-1]> <DeadTime[0-255]>\n"
+                    GlobalVariables.ServerMessage += "V812 SetOutputWidth <module#[1-10]> <Block [0-1]> <OutputWidth[0-255]>\n"
+                    GlobalVariables.ServerMessage += "V812 Status\n"
+                    GlobalVariables.ServerMessage += "V812 RateScan <module> <start> <step> <stop>\n"
+                    
+                    time.sleep(0.05)
+                #set the hexpattern:
+                elif(V812Command=="SetHexPat"):
+                    GlobalVariables.ServerMessage = "trying to set the hexpattern:"
+                    time.sleep(0.05)
+                    try:
+                        module = int(sCommand[2])
+                        hexpat = int(sCommand[3],16)
+                        #print hexpat
+                        # hexpat="ddd"
+                        GlobalVariables.ServerMessage = "setting module "+str(module)+" to hexpat: "+str(hex(hexpat))
+                        time.sleep(0.05)
+                        try:
+                            print "setting it now..."
+                            error_code=_VME.V812_Set_Pattern_Inhibit_Hex(module, hexpat)
+                            GlobalVariables.ServerMessage = "success! "
+                            GlobalVariables.HexPattern =str(hex(hexpat))
+                            time.sleep(0.05)
+                            
+                        except:
+                            VME_ErrorPrint(error_code)
+                            print "FAILED"
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax error (SetHexPat)"
+
+                        
+                        time.sleep(0.05)
+                elif(V812Command=="SetAllThresh"):
+                    print "trying to set the threshold:"
+                    try:
+                        module  = int(sCommand[2])
+                        thresh  = int(sCommand[3])
+                        GlobalVariables.ServerMessage="Setting all thresholds...\n"
+                        for channel in range(0,16):
+                            GlobalVariables.ServerMessage += "setting threshold of channel: "+str(channel)+ " in module "+str(module)+" to: "+str(thresh)+"\n"
+                            GlobalVariables.ServerMessage += "success: "+str(_VME.V812_Set_Threshold(module, channel,  thresh))+"\n"
+                            GlobalVariables.TriggerThresholds[channel] = thresh
+                        time.sleep(0.05)
+                            
+                            
+                    except:
+                        print "Syntax error (SetAllThresh) "
+
+                elif(V812Command=="SetAllThreshDiff"):
+                    print "trying to set all the threshold (diff):"
+                    try:
+                        module      = int(sCommand[2])
+                        threshdiff  = int(sCommand[3])
+                        GlobalVariables.ServerMessage="Setting all thresholds (diff)...\n"
+                        for channel in range(0,16):
+                            GlobalVariables.ServerMessage += "increase threshold of channel: "+str(channel)+ " in module "+str(module)+" by: "+str(threshdiff)+"\n"
+                            GlobalVariables.ServerMessage += "success: "+str(_VME.V812_Set_Threshold(module, channel, GlobalVariables.TriggerThresholds[channel]+ threshdiff))+"\n"
+                            GlobalVariables.TriggerThresholds[channel]+= threshdiff
+                        time.sleep(0.05)
+                            
+                            
+                    except:
+                        print "Syntax error (SetAllThreshDiff) "
+
+                elif(V812Command=="SetThreshDiff"):
+                    GlobalVariables.ServerMessage = "trying to set the threshold:"
+                    time.sleep(0.05)
+                    try:
+                        module      = int(sCommand[2])
+                        channel     = int(sCommand[3])
+                        threshdiff  = int(sCommand[4])
+                        #print module, channel, threshdiff
+                        #print GlobalVariables.TriggerThresholds[channel]
+                        newthresh = GlobalVariables.TriggerThresholds[channel] + threshdiff
+                        #print newthresh
+                        GlobalVariables.ServerMessage = "increase threshold of channel: "+str(channel)+ " in module "+str(module)+" by: "+str(threshdiff)+"\n"
+                        GlobalVariables.ServerMessage += "success: "+str(_VME.V812_Set_Threshold(module, channel,newthresh))
+                        GlobalVariables.TriggerThresholds[channel] = newthresh
+                        time.sleep(0.05)
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax error (SetThreshDiff) "
+                        time.sleep(0.05)
+            
+                elif(V812Command=="SetThresh"):
+                    GlobalVariables.ServerMessage = "trying to set the threshold:"
+                    time.sleep(0.05)
+                    try:
+                        module  = int(sCommand[2])
+                        channel = int(sCommand[3])
+                        thresh  = int(sCommand[4])
+                        GlobalVariables.ServerMessage = "setting threshold of channel: "+str(channel)+ " in module "+str(module)+" to: "+str(thresh)
+                        GlobalVariables.ServerMessage += "success: "+str(_VME.V812_Set_Threshold(module, channel,  thresh))
+                        GlobalVariables.TriggerThresholds[channel] = thresh
+                        time.sleep(0.05)
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax error (SetThresh) "
+                        time.sleep(0.05)
+                elif(V812Command=="SetMajLevel"):
+                    GlobalVariables.ServerMessage = "trying to set the majority level:"
+                    time.sleep(0.05)
+                    try:
+                        module  = int(sCommand[2])
+                        level   = int(sCommand[3])
+                        GlobalVariables.ServerMessage = "setting maj. level of module "+str(module)+" to: "+str(level)
+                        GlobalVariables.ServerMessage += "success: "+str(_VME.V812_Set_Majority_Level(module,level))
+                        GlobalVariables.MajorityLevel = level
+                        time.sleep(0.05)
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax error (SetMajLevel)"
+                        time.sleep(0.05)
+
+                elif(V812Command=="SetMajThresh"):
+                    GlobalVariables.ServerMessage = "trying to set the majority threshold:"
+                    time.sleep(0.05)
+                    try:
+                        module  = int(sCommand[2])
+                        thresh  = int(sCommand[3])
+                        GlobalVariables.ServerMessage = "setting maj. level of module "+str(module)+" to: "+str(thresh)
+                        GlobalVariables.ServerMessage += "success: "+str(_VME.V812_Set_Majority_Threshold(module,  thresh))
+                        time.sleep(0.05)
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax error (SetMajThresh)"
+                        time.sleep(0.05)
+
+                elif(V812Command=="SetDeadTime"):
+                    GlobalVariables.ServerMessage = "trying to set deadtime threshold:"
+                    time.sleep(0.05)
+                    try:
+                        module  = int(sCommand[2])
+                        block  = int(sCommand[3])
+                        deadtime= int(sCommand[4])
+                        GlobalVariables.ServerMessage = "setting deadtime of module "+str(module)+" block: "+str(block)+ " to: "+str(deadtime)
+                        GlobalVariables.ServerMessage += "success: "+str(_VME.V812_Set_Dead_Time(module, block, deadtime))
+                        time.sleep(0.05)
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax error (SetDeadTime)"
+                        time.sleep(0.05)
+                elif(V812Command=="SetOutputWidth"):
+                    GlobalVariables.ServerMessage = "trying to set output width "
+                    time.sleep(0.05)
+                    try:
+                        module  = int(sCommand[2])
+                        block  = int(sCommand[3])
+                        outputw= int(sCommand[4])
+                        GlobalVariables.ServerMessage = "setting output width of module "+str(module)+" block: "+str(block)+ " to: "+str(outputw)
+                        GlobalVariables.ServerMessage += "success: "+str(_VME.V812_Set_Output_Width(module, block, outputw))
+                        time.sleep(0.05)
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax error (SetOutputTime)"
+                        time.sleep(0.05)
+                elif(V812Command=="Status"):
+                    GetStatus();
+
+                elif(V812Command=="RateScan"):
+                    GlobalVariables.ServerMessage = "trying to scan the rates "
+                    time.sleep(0.05)
+                    try:
+                        module = int(sCommand[2])
+                        start  = int(sCommand[3])
+                        step   = int(sCommand[4])
+                        stop   = int(sCommand[5])
+                        print module, start, step, stop
+                        self.RateScan(module, start, step, stop)
+
+
+                    except:
+                        GlobalVariables.ServerMessage = "Syntax error (RateScan)"
+                        time.sleep(0.05)
+                        
+
+
+                    
+                else:
+                    GlobalVariables.ServerMessage = "Syntax Error (V812)"
+                    time.sleep(0.05)
+                
+                        
+        except:
+            GlobalVariables.ServerMessage = "syntax error"
+            time.sleep(0.05)
+    def RateScan(self,module, start, step, stop):
+        #print module, start, step,stop
+        #print "IN\n"
+        #First stop the automatic rate writeup
+        oldinterval = self.writeOutput.interval
+        self.writeOutput.interval=15
+        rates      =  ["rates",
+                   0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0]
+        print "rates:" ,rates
+        CurrentThresholds =[0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0,
+                   0,0,0,0]
+        for pix in range(0,16):
+            CurrentThresholds[pix] = GlobalVariables.TriggerThresholds[pix]
+        print "Threshs: ",CurrentThresholds,"\n"
+        NumberOfScanSteps = int((stop-start)/step) + 1
+        print "NumberOfScanSteps: ",  NumberOfScanSteps
+        for StepNumber in range(0,NumberOfScanSteps):
+            print "Step#" ,StepNumber
+            for pix in range(0,16):
+                #print (CurrentThresholds[pix] + start) + step*StepNumber
+                GlobalVariables.TriggerThresholds[pix] = (CurrentThresholds[pix] + start) + step*StepNumber
+                #print pix, GlobalVariables.TriggerThresholds[pix] 
+                _VME.V812_Set_Threshold(module, pix,   GlobalVariables.TriggerThresholds[pix])
+
+            time.sleep(2.1)
+            #print "Getting Rates: \n"
+            rates = self.gimmeRates.rates#GetRates(module);
+            self.writeOutput.writeToFile()
+            #print "Got rates..."
+            print  "Thresh: ",GlobalVariables.TriggerThresholds, " rates: ",rates    #_VME.V812_Set_Threshold(1, 0,  255)
+
+
+        self.writeOutput.interval = oldinterval
+    
+    def __init__(self):
+        #self.writeOutput.OpenNewFile("test.txt")
+        threading.Thread.__init__(self)
+    def run(self):
+        self.gimmeRates.start()
+        
+        self.writeOutput.start()
+        oldcommand=GlobalVariables.UserInput
+        while(GlobalVariables.UserInput[1:]!="exit" and GlobalVariables.UserInput[1:] != "EXIT"):
+            CommandToParse=GlobalVariables.UserInput
+            #Filename to write:
+            #year = datetime.date.today().year
+            #month = datetime.date.today().month
+            #day = datetime.date.today().day
+            MyTime = time.time()
+            #print MyTime
+        
+           
+            hour = time.gmtime(MyTime)[3]
+            minute = time.gmtime(MyTime)[4]
+            #print hour, minute
+            if(hour>=13):
+                MyTime+=12*60*60
+
+            year = time.gmtime(MyTime)[0]
+            month =time.gmtime(MyTime)[1]
+            day = time.gmtime(MyTime)[2]
+            date=str(year)
+            #if (hour>=12):
+            #    day = day+1
+            
+            date+="%(month)02d" % {"month":month}
+            date+="%(day)02d" % {"day":day}
+            #date+="_"
+            #date+="%(hour)02d" % {"hour":hour}
+            #date+="%(minute)02d" % {"minute":minute}
+            self.writeOutput.filename="/ct3data/SlowData/Trigger_"+date+".slow"
+
+            
+            #self.writeOutput.filename = "/ct3data/SlowData/Trigger_"
+            #self.writeOutput.filename
+            if(oldcommand!=CommandToParse):
+                self.Parse(CommandToParse)
+                oldcommand=CommandToParse
+            time.sleep(0.05)
+
+
+            
+        GlobalVariables.ServerMessage = "EXITING PARSER...press <enter> to exit"
+        time.sleep(0.05)
+            
Index: /fact/trigger/GlobalVariables.py
===================================================================
--- /fact/trigger/GlobalVariables.py	(revision 9840)
+++ /fact/trigger/GlobalVariables.py	(revision 9840)
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+
+#contains only the user input:
+
+#global UserInput
+UserInput =''
+Rates =             [0,0,0,0,
+                     0,0,0,0,
+                     0,0,0,0,
+                     0,0,0,0]
+
+ServerMessage=''
+Flag=1
+counter = 0
+TriggerThresholds = [0,0,0,0,
+                     0,0,0,0,
+                     0,0,0,0,
+                     0,0,0,0]
+HexPattern = '0x0000'
+MajorityLevel = 0
Index: /fact/trigger/ListenToArduino.py
===================================================================
--- /fact/trigger/ListenToArduino.py	(revision 9840)
+++ /fact/trigger/ListenToArduino.py	(revision 9840)
@@ -0,0 +1,45 @@
+import threading
+import GlobalVariables
+import serial
+import time
+import datetime
+class ListenToArduino(threading.Thread):
+    ser = serial.Serial('/dev/myArduino', 9600)
+    year = datetime.date.today().year
+    month = datetime.date.today().month
+    day = datetime.date.today().day
+    hour = time.localtime(time.time())[3]
+    minute = time.localtime(time.time())[4]
+    date=str(year)
+    
+
+    date+="%(month)02d" % {"month":month}
+    date+="%(day)02d" % {"day":day}
+    date+="_"
+    date+="%(hour)02d" % {"hour":hour}
+    date+="%(minute)02d" % {"minute":minute}
+    filename="/ct3data/SlowData/Trigger_"+date+".slow"
+    fileHandle = open ( filename, 'w' )
+    fileHandle.close()
+    
+    def run(self):
+        time.sleep(0.01)
+        while(GlobalVariables.UserInput[1:]!="exit" and GlobalVariables.UserInput[1:] != "EXIT"):
+            ArduinoMessage = self.ser.readline()
+            GlobalVariables.ServerMessage   = ArduinoMessage
+            #GlobalVariables.ServerMessage   = "[Temp ,28,10]"
+            time.sleep(0.05)
+
+            self.fileHandle = open ( self.filename, 'a' ) 
+            t = datetime.datetime.now()
+            EpochSeconds=time.mktime(t.timetuple())
+            now = datetime.datetime.fromtimestamp(EpochSeconds)
+            
+            if ArduinoMessage[0]=='[':
+                self.fileHandle.write(now.ctime())
+                self.fileHandle.write(" ")
+                self.fileHandle.write(str(EpochSeconds))
+                self.fileHandle.write(" ")
+                self.fileHandle.write(ArduinoMessage)
+            self.fileHandle.close()
+
Index: /fact/trigger/Main.py
===================================================================
--- /fact/trigger/Main.py	(revision 9840)
+++ /fact/trigger/Main.py	(revision 9840)
@@ -0,0 +1,69 @@
+#!/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 ReadTemperatures
+import time
+#connecting to the crates:
+print "\n\n\n"
+print "  ####################################"
+print "  #                                  #"
+print "  #      Trigger Control Program     #"
+print "  #      M. Rissi 2009               #"
+print "  #                                  #"
+print "  ####################################"
+print "\n\n\n"
+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()
+
+#print "listening to Arduino..."
+readTemperatures = ReadTemperatures.ReadTemperatures()
+readTemperatures.start()
+while(GlobalVariables.UserInput[1:]!="exit" and GlobalVariables.UserInput[1:] != "EXIT"):
+    time.sleep(0.1)
+    #do something
+#    dummy=1
+
+_VME.V812_Close()
+_VME.V560_Close()
+_VME.VME_Close()
Index: /fact/trigger/PythonShell.py
===================================================================
--- /fact/trigger/PythonShell.py	(revision 9840)
+++ /fact/trigger/PythonShell.py	(revision 9840)
@@ -0,0 +1,45 @@
+#!/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[1:]!="exit" and GlobalVariables.UserInput[1:] != "EXIT"):
+            dummy=raw_input("SHELL>>> ")
+            if(GlobalVariables.UserInput[1:]!="exit" and GlobalVariables.UserInput[1:] != "EXIT"):
+                GlobalVariables.counter +=1
+                GlobalVariables.counter%=10
+                GlobalVariables.UserInput = str(GlobalVariables.counter)+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"):
+            time.sleep(0.001)
+            if(GlobalVariables.ServerMessage!=self.lastvar):
+                #print "\n(SHELL) You entered:",GlobalVariables.ServerMessage
+                #sys.stdout.write( "SHELL2 >>>")
+                if GlobalVariables.ServerMessage[0]!="[":
+                    print GlobalVariables.ServerMessage
+                self.lastvar=GlobalVariables.ServerMessage
+              
+        print "EXITING OUTPUTSHELL...press <enter> to exit "
+        #sys.exit(0)
Index: /fact/trigger/ReadTemperatures.py
===================================================================
--- /fact/trigger/ReadTemperatures.py	(revision 9840)
+++ /fact/trigger/ReadTemperatures.py	(revision 9840)
@@ -0,0 +1,53 @@
+import threading
+import GlobalVariables
+import serial
+import time
+import datetime
+
+
+class ReadTemperatures(threading.Thread):
+
+   
+
+    filename=""
+    
+    def run(self):
+        time.sleep(0.01)
+        while(GlobalVariables.UserInput[1:]!="exit" and GlobalVariables.UserInput[1:] != "EXIT"):
+            MyTime = time.time()
+            hour = time.gmtime(MyTime)[3]
+            if(hour>=13):
+                MyTime+=12*60*60
+            year = time.gmtime(MyTime)[0]
+            month =time.gmtime(MyTime)[1]
+            day = time.gmtime(MyTime)[2]
+            date=str(year)
+            #if (hour>=12):
+            #    day = day+1
+        
+
+            date+="%(month)02d" % {"month":month}
+            date+="%(day)02d" % {"day":day}
+            #date+="_"
+            #date+="%(hour)02d" % {"hour":hour}
+            #date+="%(minute)02d" % {"minute":minute}
+            self.filename="/ct3data/SlowData/CLIM_"+date+".slow"
+            file = open(self.filename, 'r')
+            #ArduinoMessage = self.ser.readline()
+            Lines= file.readlines()
+            lastline=Lines[-1]
+            #print Lines[-1]
+            file.close()
+            
+            Message = lastline[lastline.find('['):]
+            GlobalVariables.ServerMessage   = Message
+            #print Message
+            time.sleep(15)
+
+
+
+
+            
+
+
+
Index: /fact/trigger/StartTrigger.sh
===================================================================
--- /fact/trigger/StartTrigger.sh	(revision 9840)
+++ /fact/trigger/StartTrigger.sh	(revision 9840)
@@ -0,0 +1,2 @@
+#!/bin/sh
+./Main.py
Index: /fact/trigger/TestClient.py
===================================================================
--- /fact/trigger/TestClient.py	(revision 9840)
+++ /fact/trigger/TestClient.py	(revision 9840)
@@ -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: /fact/trigger/TestClient2.py
===================================================================
--- /fact/trigger/TestClient2.py	(revision 9840)
+++ /fact/trigger/TestClient2.py	(revision 9840)
@@ -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: /fact/trigger/TestClient3.py
===================================================================
--- /fact/trigger/TestClient3.py	(revision 9840)
+++ /fact/trigger/TestClient3.py	(revision 9840)
@@ -0,0 +1,85 @@
+#!/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)
+            print data
+            # 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: /fact/trigger/TestClient_prov.py
===================================================================
--- /fact/trigger/TestClient_prov.py	(revision 9840)
+++ /fact/trigger/TestClient_prov.py	(revision 9840)
@@ -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: /fact/trigger/VME.i
===================================================================
--- /fact/trigger/VME.i	(revision 9840)
+++ /fact/trigger/VME.i	(revision 9840)
@@ -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, int  pattern);
+int V812_Set_Output_Width(short module, short 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: /fact/trigger/VME.py
===================================================================
--- /fact/trigger/VME.py	(revision 9840)
+++ /fact/trigger/VME.py	(revision 9840)
@@ -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: /fact/trigger/VME_wrap.c
===================================================================
--- /fact/trigger/VME_wrap.c	(revision 9840)
+++ /fact/trigger/VME_wrap.c	(revision 9840)
@@ -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 ;
+    int arg2 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hi: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 ;
+    short arg2 ;
+    short arg3 ;
+    int result;
+    
+    if(!PyArg_ParseTuple(args,(char *)"hhh: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: /fact/trigger/WrapVME.c
===================================================================
--- /fact/trigger/WrapVME.c	(revision 9840)
+++ /fact/trigger/WrapVME.c	(revision 9840)
@@ -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: /fact/trigger/communication.py
===================================================================
--- /fact/trigger/communication.py	(revision 9840)
+++ /fact/trigger/communication.py	(revision 9840)
@@ -0,0 +1,41 @@
+###############################################################################
+# The communication module (communication.py)
+###############################################################################
+import cPickle
+import socket
+import struct
+
+marshall = cPickle.dumps
+unmarshall = cPickle.loads
+
+def send(channel, args):
+    #print "will send: ", args
+    args+="\n"
+    buf = args #marshall(args)
+    #value = socket.htonl(len(buf))
+    value = str(len(buf))
+    #size = struct.pack("i",value)
+    #rint "length: ",len(buf)
+    #print "SIZE: ",repr(size)
+    #channel.send(value)
+    buf+="\0"
+    channel.send(buf)
+    #print 'sending: ',buf
+    #print 'sent'
+def receive(channel):
+
+    size = struct.calcsize("L")
+    size = channel.recv(size)
+    print "rec size: ",size
+    try:
+        size = socket.ntohl(struct.unpack("i", size)[0])
+        #print "unpacked: ",size
+    except struct.error, e:
+        return ''
+    
+    buf = ""
+
+    while len(buf) < size:
+        buf = channel.recv(size - len(buf))
+
+    return unmarshall(buf)[0]
Index: /fact/trigger/gui/t72/Makefile
===================================================================
--- /fact/trigger/gui/t72/Makefile	(revision 9840)
+++ /fact/trigger/gui/t72/Makefile	(revision 9840)
@@ -0,0 +1,248 @@
+#############################################################################
+# Makefile for building: t72
+# Generated by qmake (2.01a) (Qt 4.4.3) on: Tue Jun 30 09:10:50 2009
+# Project:  t72.pro
+# Template: app
+# Command: /usr/local/Trolltech/Qt-4.4.3/bin/qmake -unix -o Makefile t72.pro
+#############################################################################
+
+####### Compiler, tools and options
+
+CC            = gcc
+CXX           = g++
+DEFINES       = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
+CFLAGS        = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+INCPATH       = -I/usr/local/Trolltech/Qt-4.4.3/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.4.3/include/QtCore -I/usr/local/Trolltech/Qt-4.4.3/include/QtCore -I/usr/local/Trolltech/Qt-4.4.3/include/QtNetwork -I/usr/local/Trolltech/Qt-4.4.3/include/QtNetwork -I/usr/local/Trolltech/Qt-4.4.3/include/QtGui -I/usr/local/Trolltech/Qt-4.4.3/include/QtGui -I/usr/local/Trolltech/Qt-4.4.3/include -I. -I. -I.
+LINK          = g++
+LFLAGS        = -Wl,-rpath,/usr/local/Trolltech/Qt-4.4.3/lib
+LIBS          = $(SUBLIBS)  -L/usr/local/Trolltech/Qt-4.4.3/lib -lQtGui -L/usr/local/Trolltech/Qt-4.4.3/lib -L/usr/X11R6/lib -pthread -lpng -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lfreetype -lfontconfig -lXext -lX11 -lQtNetwork -pthread -pthread -lQtCore -lz -lm -pthread -lgthread-2.0 -lglib-2.0 -lrt -ldl -lpthread
+AR            = ar cqs
+RANLIB        = 
+QMAKE         = /usr/local/Trolltech/Qt-4.4.3/bin/qmake
+TAR           = tar -cf
+COMPRESS      = gzip -9f
+COPY          = cp -f
+SED           = sed
+COPY_FILE     = $(COPY)
+COPY_DIR      = $(COPY) -r
+INSTALL_FILE  = install -m 644 -p
+INSTALL_DIR   = $(COPY_DIR)
+INSTALL_PROGRAM = install -m 755 -p
+DEL_FILE      = rm -f
+SYMLINK       = ln -sf
+DEL_DIR       = rmdir
+MOVE          = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR         = mkdir -p
+
+####### Output directory
+
+OBJECTS_DIR   = ./
+
+####### Files
+
+SOURCES       = humidity.cpp \
+		main.cpp \
+		tempsens.cpp \
+		tpixel.cpp moc_humidity.cpp \
+		moc_main.cpp \
+		moc_tempsens.cpp \
+		moc_tpixel.cpp
+OBJECTS       = humidity.o \
+		main.o \
+		tempsens.o \
+		tpixel.o \
+		moc_humidity.o \
+		moc_main.o \
+		moc_tempsens.o \
+		moc_tpixel.o
+DIST          = /usr/local/Trolltech/Qt-4.4.3/mkspecs/common/g++.conf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/common/unix.conf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/common/linux.conf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/qconfig.pri \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt_functions.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt_config.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/exclusive_builds.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/default_pre.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/release.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/default_post.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/warn_on.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/unix/thread.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/moc.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/resources.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/uic.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/yacc.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/lex.prf \
+		t72.pro
+QMAKE_TARGET  = t72
+DESTDIR       = 
+TARGET        = t72
+
+first: all
+####### Implicit rules
+
+.SUFFIXES: .o .c .cpp .cc .cxx .C
+
+.cpp.o:
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cc.o:
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cxx.o:
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.C.o:
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.c.o:
+	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
+
+####### Build rules
+
+all: Makefile $(TARGET)
+
+$(TARGET):  $(OBJECTS)  
+	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
+
+Makefile: t72.pro  /usr/local/Trolltech/Qt-4.4.3/mkspecs/linux-g++/qmake.conf /usr/local/Trolltech/Qt-4.4.3/mkspecs/common/g++.conf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/common/unix.conf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/common/linux.conf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/qconfig.pri \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt_functions.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt_config.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/exclusive_builds.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/default_pre.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/release.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/default_post.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/warn_on.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/unix/thread.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/moc.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/resources.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/uic.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/yacc.prf \
+		/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/lex.prf \
+		/usr/local/Trolltech/Qt-4.4.3/lib/libQtGui.prl \
+		/usr/local/Trolltech/Qt-4.4.3/lib/libQtCore.prl \
+		/usr/local/Trolltech/Qt-4.4.3/lib/libQtNetwork.prl
+	$(QMAKE) -unix -o Makefile t72.pro
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/common/g++.conf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/common/unix.conf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/common/linux.conf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/qconfig.pri:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt_functions.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt_config.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/exclusive_builds.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/default_pre.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/release.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/default_post.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/warn_on.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/qt.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/unix/thread.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/moc.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/resources.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/uic.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/yacc.prf:
+/usr/local/Trolltech/Qt-4.4.3/mkspecs/features/lex.prf:
+/usr/local/Trolltech/Qt-4.4.3/lib/libQtGui.prl:
+/usr/local/Trolltech/Qt-4.4.3/lib/libQtCore.prl:
+/usr/local/Trolltech/Qt-4.4.3/lib/libQtNetwork.prl:
+qmake:  FORCE
+	@$(QMAKE) -unix -o Makefile t72.pro
+
+dist: 
+	@$(CHK_DIR_EXISTS) .tmp/t721.0.0 || $(MKDIR) .tmp/t721.0.0 
+	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/t721.0.0/ && $(COPY_FILE) --parents humidity.h main.h tempsens.h tpixel.h .tmp/t721.0.0/ && $(COPY_FILE) --parents humidity.cpp main.cpp tempsens.cpp tpixel.cpp .tmp/t721.0.0/ && (cd `dirname .tmp/t721.0.0` && $(TAR) t721.0.0.tar t721.0.0 && $(COMPRESS) t721.0.0.tar) && $(MOVE) `dirname .tmp/t721.0.0`/t721.0.0.tar.gz . && $(DEL_FILE) -r .tmp/t721.0.0
+
+
+clean:compiler_clean 
+	-$(DEL_FILE) $(OBJECTS)
+	-$(DEL_FILE) *~ core *.core
+
+
+####### Sub-libraries
+
+distclean: clean
+	-$(DEL_FILE) $(TARGET) 
+	-$(DEL_FILE) Makefile
+
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: moc_humidity.cpp moc_main.cpp moc_tempsens.cpp moc_tpixel.cpp
+compiler_moc_header_clean:
+	-$(DEL_FILE) moc_humidity.cpp moc_main.cpp moc_tempsens.cpp moc_tpixel.cpp
+moc_humidity.cpp: humidity.h
+	/usr/local/Trolltech/Qt-4.4.3/bin/moc $(DEFINES) $(INCPATH) humidity.h -o moc_humidity.cpp
+
+moc_main.cpp: tpixel.h \
+		tempsens.h \
+		humidity.h \
+		main.h
+	/usr/local/Trolltech/Qt-4.4.3/bin/moc $(DEFINES) $(INCPATH) main.h -o moc_main.cpp
+
+moc_tempsens.cpp: tempsens.h
+	/usr/local/Trolltech/Qt-4.4.3/bin/moc $(DEFINES) $(INCPATH) tempsens.h -o moc_tempsens.cpp
+
+moc_tpixel.cpp: tpixel.h
+	/usr/local/Trolltech/Qt-4.4.3/bin/moc $(DEFINES) $(INCPATH) tpixel.h -o moc_tpixel.cpp
+
+compiler_rcc_make_all:
+compiler_rcc_clean:
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+	-$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all:
+compiler_uic_clean:
+compiler_yacc_decl_make_all:
+compiler_yacc_decl_clean:
+compiler_yacc_impl_make_all:
+compiler_yacc_impl_clean:
+compiler_lex_make_all:
+compiler_lex_clean:
+compiler_clean: compiler_moc_header_clean 
+
+####### Compile
+
+humidity.o: humidity.cpp humidity.h
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o humidity.o humidity.cpp
+
+main.o: main.cpp main.h \
+		tpixel.h \
+		tempsens.h \
+		humidity.h
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
+
+tempsens.o: tempsens.cpp tempsens.h
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tempsens.o tempsens.cpp
+
+tpixel.o: tpixel.cpp tpixel.h
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tpixel.o tpixel.cpp
+
+moc_humidity.o: moc_humidity.cpp 
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_humidity.o moc_humidity.cpp
+
+moc_main.o: moc_main.cpp 
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_main.o moc_main.cpp
+
+moc_tempsens.o: moc_tempsens.cpp 
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_tempsens.o moc_tempsens.cpp
+
+moc_tpixel.o: moc_tpixel.cpp 
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_tpixel.o moc_tpixel.cpp
+
+####### Install
+
+install:   FORCE
+
+uninstall:   FORCE
+
+FORCE:
+
Index: /fact/trigger/gui/t72/humidity.cpp
===================================================================
--- /fact/trigger/gui/t72/humidity.cpp	(revision 9840)
+++ /fact/trigger/gui/t72/humidity.cpp	(revision 9840)
@@ -0,0 +1,51 @@
+#include <QColor>
+
+#include <QVBoxLayout>
+#include <QPainter>
+#include "humidity.h"
+
+ 
+Humidity::Humidity( QWidget *parent )  : QWidget( parent)
+{
+  //setPalette( QPalette( QColor( 250, 250, 200) ) );
+  //this->setPalette( QPalette( QColor( 250, 250, 200) ) );
+  bgColor= new QColor(200,200,200);
+  this->setAutoFillBackground (1);
+}  
+float Humidity::value() 
+{
+  return val;
+
+}
+void Humidity::paintEvent( QPaintEvent * )
+{
+  QString s = QString( "%1\%" ).arg((double)(val));
+  QFont sansFont( "Helvetica [Cronyx]", 12 );
+  
+    QPainter p( this );
+    p.setFont(sansFont);
+    p.setPen(Qt::white);
+    int width=this->width();
+    int height=this->height();
+    p.drawText(width/3 , height/2, s );
+}
+
+void Humidity::setValue( float vall )
+{
+  val=vall;
+  int bblue= (int)(((float)(val-MinVal)/(float)(MaxVal-MinVal))*255.);
+  //int white = 255-bblue;
+  //int bblue=255-(int)(((float)(val-MinVal)/(float)(MaxVal-MinVal))*255.);
+  //printf("%i %i\n",rred,bblue);
+  bgColor->setRgb(255,bblue,0);
+   //QPalette::ColorRole
+   QPalette *mypalette=new QPalette();
+   //   mypalette->setColor ( mypalette->Base, *bgColor );
+   mypalette->setColor ( mypalette->Base, Qt::red);
+   //this->setBackgroundRole (mypalette->Shadow);
+   //this->setBackgroundColor(*bgColor);
+   repaint();
+   this->setPalette( QPalette( *bgColor ) );
+  emit valueChanged(val);
+
+}
Index: /fact/trigger/gui/t72/humidity.h
===================================================================
--- /fact/trigger/gui/t72/humidity.h	(revision 9840)
+++ /fact/trigger/gui/t72/humidity.h	(revision 9840)
@@ -0,0 +1,41 @@
+#ifndef HUMIDITY_H
+#define HUMIDITY_H
+
+
+#include <QWidget>
+#include <QVBoxLayout>
+
+class Humidity : public QWidget
+{
+  float MaxVal;
+  float MinVal;
+    Q_OBJECT
+public:
+    Humidity( QWidget *parent=0 );
+    float value();
+    void setMaxVal(float val){MaxVal=val;};
+    void setMinVal(float val){MinVal=val;};
+    float getMaxVal(){return MaxVal;};
+    float getMinVal(){return MinVal;};
+ private:
+    float val;
+    
+    QVBoxLayout*  ColorWidg;
+ public slots:
+    void setValue( float );
+ 
+
+    
+ signals:
+    void valueChanged( float );
+
+ protected:
+    void paintEvent( QPaintEvent * );   
+ private:
+    QColor *bgColor;
+    //QSlider *slider;
+};
+
+
+#endif // HUMIDITY_H
+
Index: /fact/trigger/gui/t72/main.cpp
===================================================================
--- /fact/trigger/gui/t72/main.cpp	(revision 9840)
+++ /fact/trigger/gui/t72/main.cpp	(revision 9840)
@@ -0,0 +1,519 @@
+#include <QApplication>
+#include <QFont>
+#include <QGridLayout>
+
+#include <QPushButton>
+
+#include "main.h"
+#include <QThread>
+#include <QTimer>
+#include <time.h>
+
+
+
+void sleep_now(unsigned int mseconds)
+{
+  printf("in  %i\n",clock());
+  clock_t goal = mseconds + clock();
+
+  while (goal > clock());
+  printf("out %i\n",goal);
+}
+
+
+
+ MyWidget::MyWidget(QWidget *parent)
+     : QWidget(parent)
+ {
+   //PixelToTriggerPixel=new int[16];
+   
+
+   PixelToTriggerPixel=new int[16];
+   /* PixelToTriggerPixel[0]= 25;
+   PixelToTriggerPixel[1]= 26;
+   PixelToTriggerPixel[2]= 27;
+   PixelToTriggerPixel[3]= 28;
+   PixelToTriggerPixel[4]= 19;
+   PixelToTriggerPixel[5]= 20;
+   PixelToTriggerPixel[6]= 21;
+   PixelToTriggerPixel[7]= 22;
+   PixelToTriggerPixel[8]= 13;
+   PixelToTriggerPixel[9]= 14;
+   PixelToTriggerPixel[10]= 15;
+   PixelToTriggerPixel[11]= 16;
+   PixelToTriggerPixel[12]= 7;
+   PixelToTriggerPixel[13]= 8;
+   PixelToTriggerPixel[14]= 9;
+   PixelToTriggerPixel[15]= 10;*/
+   
+   PixelToTriggerPixel[0]= 25;
+   PixelToTriggerPixel[1]= 26;
+   PixelToTriggerPixel[2]= 27;
+   PixelToTriggerPixel[3]= 28;
+   PixelToTriggerPixel[4]= 19;
+   PixelToTriggerPixel[5]= 20;
+   PixelToTriggerPixel[6]= 21;
+   PixelToTriggerPixel[7]= 22;
+   PixelToTriggerPixel[8]= 13;
+   PixelToTriggerPixel[9]= 14;
+   PixelToTriggerPixel[10]= 15;
+   PixelToTriggerPixel[11]= 16;
+   PixelToTriggerPixel[12]= 7;
+   PixelToTriggerPixel[13]= 8;
+   PixelToTriggerPixel[14]= 9;
+   PixelToTriggerPixel[15]= 10;
+   ListToTemperaturePixel = new int[7];
+   ListToTemperaturePixel[0] = 5;
+   ListToTemperaturePixel[1] = 1;
+   ListToTemperaturePixel[2] = 0;
+   ListToTemperaturePixel[3] = 2;
+   ListToTemperaturePixel[4] = 3;
+   ListToTemperaturePixel[5] = 4;
+   ListToTemperaturePixel[6] = 6;
+    SocketWindow = new QWidget();
+   SocketWindow->setWindowTitle("trigger - Socket Interface");
+   Socket = new QTcpSocket(SocketWindow);
+   connect(Socket, SIGNAL(readyRead()), this, SLOT(ReadFromSocket()));
+   //connect(Socket, SIGNAL(disconnected()), this, SLOT(GotDisconnected()));
+   WaitForData=false;
+   ManualDisconnect=false;
+  
+   IPAddress = new QLineEdit(SocketWindow);
+   IPAddress->setText("eth-vme02");
+   IPAddress->setToolTip("Address of socket server");
+   AddressLayout = new QFormLayout;
+   AddressLayout->addRow("&Remote Address", IPAddress);
+   
+   Port = new QSpinBox(SocketWindow);
+   Port->setRange(0,65535);
+   Port->setValue(3492);
+   Port->setToolTip("Port number of socket server");
+   PortLayout = new QFormLayout;  
+   PortLayout->addRow("&Port", Port);
+  
+
+    // Button to make connection
+  Connect = new QPushButton("Connect", SocketWindow);
+  Connect->setFont(QFont("Times", 10, QFont::Bold));
+  connect(Connect, SIGNAL(clicked()), this, SLOT(MakeConnection()));
+  Connect->setToolTip("Connect to server");
+  SocketButton = new QPushButton("Socke&t\nInterface",this);
+  SocketButton->setFont(QFont("Times", 10, QFont::Bold));
+  connect(SocketButton, SIGNAL(clicked()), this, SLOT(OpenSocketWindow()));
+  SocketButton->setToolTip("Open window for socket communication");
+
+
+  connect(SocketButton, SIGNAL(clicked()), this, SLOT(OpenSocketWindow()));
+  QPushButton *quit = new QPushButton(tr("Quit"));
+  quit->setFont(QFont("Times", 18, QFont::Bold));
+  Command = new QLineEdit(SocketWindow);
+  CommandLayout = new QFormLayout;  
+  CommandLayout->addRow("&Command", Command);
+  Command->setEnabled(false);
+  connect(Command, SIGNAL(returnPressed()), this, SLOT(SendToSocket()));
+  Command->setToolTip("Command to send to socket server");
+
+   // Text box for socket output
+  SocketOutput= new QPlainTextEdit(SocketWindow);
+  SocketOutput->setReadOnly(true);
+  SocketOutput->setMaximumBlockCount(MAX_OUTPUT_LINES);
+  SocketOutput->setToolTip("Output of socket server");
+
+ // Layout of all widgets
+  SocketLayout = new QGridLayout(SocketWindow);
+  SocketLayout->addLayout(AddressLayout, 0, 0, 0, 1);
+  SocketLayout->addLayout(PortLayout, 0, 2);
+  SocketLayout->addWidget(Connect, 0, 3);
+  SocketLayout->addLayout(CommandLayout, 1, 0, 1, 4);
+  SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4);  
+
+  connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
+
+      QGridLayout *grid = new QGridLayout;
+
+    
+     pixels = new Tpixel*[36];
+     
+     int i=0;
+     for( int row = 0 ; row <6 ; row++ ) 
+       {
+	 for( int col = 0 ; col < 6 ; col++) 
+	   {
+
+	   
+	     //int i=row+6*col;
+	     pixels[i] = new Tpixel;
+	     grid->addWidget(pixels[i], row+1, col+1);
+	     
+	     //pixels[i]->setValue((int)((i)*255./36.));
+	     pixels[i]->setValue((int)(0));
+	     pixels[i]->setMaxVal(1000);
+	     pixels[i]->setMinimumSize ( 50, 50 );	 
+	     pixels[i]->setMaximumSize ( 50, 50 );	 
+	     i++;
+	   }
+	 
+       }
+
+     humidity = new Humidity*[1];
+     humidity[0] = new Humidity;
+     
+     humidity[0]->setMaxVal(100);
+     humidity[0]->setMinVal(0);
+     humidity[0]->setValue((int)(50));
+     humidity[0]->setMinimumSize ( 70, 40 );	 
+     humidity[0]->setMaximumSize ( 70, 40 );
+     tempsens=new Tempsens*[7];
+     for(int j=0;j<7;j++)
+       {
+	 tempsens[j]=new Tempsens;
+	 tempsens[j]->setMaxVal(35);
+	 tempsens[j]->setMinVal(5);
+	 tempsens[j]->setValue((int)(5+j));
+	 tempsens[j]->setMinimumSize ( 70, 70 );	 
+	 tempsens[j]->setMaximumSize ( 70, 70 );
+       }
+     QHBoxLayout *hlay = new QHBoxLayout;
+     //hlay->addWidget(tempsens[0]);
+     hlay->addWidget(SocketButton);
+     hlay->addWidget(quit);
+     //hlay->addWidget(tempsens[1]);
+     grid->addWidget(tempsens[0],0,0);
+     grid->addWidget(tempsens[1],0,7);
+     grid->addWidget(tempsens[2],7,0);
+     grid->addWidget(tempsens[3],7,7);
+     tempsens[4]->setMinimumSize ( 70, 50 );	 
+     tempsens[5]->setMinimumSize ( 70, 50 );	 
+     grid->addWidget(tempsens[4],1,8);
+     grid->addWidget(tempsens[5],5,8);
+
+     QVBoxLayout *humlay = new QVBoxLayout;
+  
+     tempsens[6]->setMinimumSize ( 70, 40 );	 
+     tempsens[6]->setMaximumSize ( 70, 40 );
+     humlay->addWidget(humidity[0]);
+     humlay->addWidget(tempsens[6]);
+     humlay->setSpacing (0); 
+     //humlay->setVerticalSpacing(0) ;
+     grid->addLayout(humlay,2,8,3,1);
+ 
+     //grid->addWidget(tempsens[6],4,8);
+
+     QVBoxLayout *layout = new QVBoxLayout;
+     layout->addLayout(hlay);
+     //layout->addWidget(SocketButton);
+     layout->addLayout(grid);
+
+     //layout->setColumnStretch(1, 10);
+
+     setLayout(layout);
+
+     //a time to update the pixel rates every 5 seconds:
+     QTimer *timer = new QTimer(this);
+     connect(timer, SIGNAL(timeout()),this , SLOT(updateRates()));
+     
+     timer->start(5000);
+
+
+
+
+ }
+void MyWidget::updateRates()
+{
+  if(Socket->state() == QAbstractSocket::ConnectedState)
+    {
+      char command[]= "V560 GetRates 1 \n\0";
+      SocketOutput->insertPlainText(command);
+      Socket->write(command);
+      //QByteArray   bytes  = command.toAscii();
+      //const char * ptr    = bytes.data();
+      printf(command);
+
+      //usleep(3000000);
+      //SleeperThread::msleep(1000);
+
+      /*const char tmp[]="V560 GetRate 1 5 \n\0";
+      printf(tmp);
+      Socket->write(tmp);
+      SocketOutput->insertPlainText(tmp);*/
+	
+	      
+    }
+}
+// +++ Open sub window handling the socket interface +++
+void MyWidget::OpenSocketWindow() {
+  SocketWindow->show();
+
+  //  if(SocketWindow->isVisible()) SocketWindow->hide();
+  //else SocketWindow->show();
+}
+
+// +++ Acquire data through socket (acquire botton only available if socket exists) +++
+void MyWidget::GetSignalFromSocket() {
+  char Command[MAX_COM_SIZE];
+
+  GetButton->setEnabled(false);
+  WaitForData = true;
+  sprintf(Command, "test");//, BoardNo->value(), ChannelNo->value()/10, ChannelNo->value()%10);
+  Socket->write(Command);
+}
+
+// Quit application when clicking close button on window
+
+
+// +++ Connecting or disconnecting from client +++
+void MyWidget::MakeConnection() {
+  printf("Connecting...\n");
+  if(Socket->state() == QAbstractSocket::ConnectedState) {
+    ManualDisconnect = true;
+    Socket->disconnectFromHost();
+    Connect->setText("Connect");
+  }
+  else {
+     
+    Socket->connectToHost(IPAddress->text(),Port->value());
+
+
+    
+    Connect->setEnabled(false);  // While waiting for connection, button not available
+    Socket->waitForConnected(SOCKET_TIMEOUT);
+    Connect->setEnabled(true);
+    if(Socket->state() != QAbstractSocket::ConnectedState)
+      QMessageBox::warning(this, "MyWidget Message","Could not connect to host.",QMessageBox::Ok);
+    else {
+      //Connect->setText("Disconnect");
+      //ConnectAction->setText("Disconnect");
+      Port->setEnabled(false);
+      IPAddress->setEnabled(false);
+      Command->setEnabled(true);
+      //GetButton->setEnabled(true);
+      ManualDisconnect = false;
+      Connect->setText("Disconnect");
+
+      /*      OpenAction->setEnabled(false);      
+      FilenameBox->setEnabled(false);
+      LoadButton->setEnabled(false);
+      FilenameBox->clear();
+      CloseDatafile();*/
+
+      /*      ChannelNo->setEnabled(true);
+      BoardNo->setEnabled(true);
+      PixelID->setEnabled(true);
+      ChannelNo->setRange(0, 65535);
+      BoardNo->setRange(0, 65535);
+      
+      TabWidget->setTabEnabled(1,false);
+      TabWidget->setTabEnabled(2,false);
+
+      RunHeaderDisplay->clear();
+      EventHeaderDisplay->clear();
+      Signal->hide();*/
+    }
+  }
+}
+
+// +++ Send command to socket (command button available only if socket existing) +++
+void MyWidget::SendToSocket() {
+  // QMessageBox::warning(this, "sdfsdf","sending to socket...",QMessageBox::Ok);
+  //QString
+  /*int length = strlen(Command->text().toAscii());
+  printf("send length: %i\n", length);
+  char buf[4];
+
+  buf[0] = (char) length;
+  buf[1] = (char) length >> 8;
+  buf[2] = (char) length >> 16;
+  buf[3] = (char) length >> 24;
+
+
+  Socket->write(buf);*/
+  Socket->write(Command->text().toAscii());
+  Command->clear();
+}
+
+// +++ Read data from socket and display +++
+void MyWidget::ParseData(QString data)
+{
+  data = data.remove(QChar('['));
+  data = data.remove(QChar(']'));
+data = data.remove(QChar('\ '));
+  data = data.trimmed();
+  QStringList list1 = data.split(",",QString::SkipEmptyParts);
+  int numberofelements = list1.count();
+  printf("%i\n",numberofelements);
+  numberofelements--;
+  
+  if(list1[0]=="Temp")
+    {
+      printf("updating temp...\n");
+      list1.removeAt(0);
+      float temperature[numberofelements];
+      if (numberofelements>7) numberofelements = 7;
+      for(int i =0;i<numberofelements;i++)
+	{ 
+	  temperature[i]= list1[i].toFloat();
+	  QString stri;
+	  stri=QString("%1").arg(ListToTemperaturePixel[i]);
+	  
+	  QString output = "Setting temperature of sensor  "+stri + " to " + list1[i]+"c\n";
+	  SocketOutput->insertPlainText(output);
+	  tempsens[ListToTemperaturePixel[i]]->setValue((float)(temperature[i]));
+	}
+      temperature[7]= list1[7].toFloat();
+      humidity[0]->setValue(temperature[7]);
+      //printf("hum: %i\n",temperature[7]);
+    }
+  if(list1[0]=="\'rates\'")
+    {
+      list1.removeAt(0);
+      float rates[numberofelements];
+      for(int j =0;j<numberofelements;j++)
+	{
+	  // pixels[j]->setMaxVal(1);
+	}
+      for(int i =0;i<numberofelements;i++)
+	{ 
+	  
+	  rates[i]= list1[i].toFloat();
+	  QString stri;
+	  stri=QString("%1").arg(PixelToTriggerPixel[i]);
+	  
+	  QString output = "Setting rates of trigger pixel "+stri + " to " + list1[i]+"\n";
+	  SocketOutput->insertPlainText(output);
+	  pixels[PixelToTriggerPixel[i]]->setValue((int)(rates[i]));
+	  /*if(rates[i]>pixels[i]->getMaxVal())
+	    {
+	    for(int j =0;j<numberofelements;j++)
+	    {
+	    pixels[j]->setMaxVal(rates[i]);
+	    }
+	    
+	    }*/
+	  // pixels[i]->setMaxVal(255);
+	}
+    }
+
+
+}
+void MyWidget::ReadFromSocket() {
+  // Check if channel data expected and error message arrived
+  /*char Data[1024];
+  printf("size of int: %i\n",sizeof(int));
+  char cSize[sizeof(int)];
+  int Size;
+  
+  int numBytes=Socket->read(cSize,sizeof(int));
+  Size=(int)(cSize);
+  printf ("numbytes: %i\n",numBytes);
+  printf("csize: %x\n",cSize);
+  printf("size: %i\n",Size);
+  
+  numBytes+http://www.google.ch/firefox?client=firefox-a&rls=org.mozilla:en-US:official=Socket->read(Data,Size);
+  printf("Data:%s\n",Data);/**/
+
+  //QByteArray command;
+  char command[1024];
+  Socket->read(command,1023);
+  printf("cc: %s\n",command);
+  QString temp(command);
+  //SocketOutput->insertPlainText(command);
+  if(temp[0]!=QChar('['))
+    SocketOutput->insertPlainText(temp);
+  else
+    ParseData(temp);
+
+
+
+   //QString qData(Data);
+
+  //char * cData = Data.constData ();
+  
+  //if (WaitForData && Data.contains("Error")) {
+  // WaitForData = false;
+    //GetButton->setEnabled(true);
+  // QMessageBox::warning(this, "MyWidget Message","Could not read waveform data from socket.",QMessageBox::Ok);
+  // return;
+  // }
+
+  // Check if channel data were transmitted, if yes and waiting for data, extract and plot them
+  /*printf("num bytes: %i",numBytes);
+   QString temp(numBytes);
+   SocketOutput->insertPlainText(temp);
+   SocketOutput->insertPlainText(Data);
+   SocketOutput->insertPlainText("TTT");
+  printf("Data\n");
+  printf("%s",Data);*/
+  //QString Text = SocketOutput->document()->toPlainText().trimmed();
+  /*usleep(100000);	// Wait to limit maximum update rate
+  GetSignalFromSocket();*/
+  /*if (WaitForData && Text.endsWith(QLatin1String("==END=="))) {
+    // Extract text between ==START== and ==END==
+    QByteArray Data=Text.mid(Text.lastIndexOf("==START==")+9,Text.length()-Text.lastIndexOf("==START==")-16).toAscii();
+
+    char *NextNumber = strtok(Data.data()," ");  // Number of entries that follow
+    int Count=0, NumberOfEntries = atoi(NextNumber);
+    double *x = new double [NumberOfEntries];
+    double *y = new double [NumberOfEntries];
+
+    // Convert all entries (separated by a whitespace) to numbers
+    while((NextNumber=strtok(NULL, " "))!=NULL && Count<NumberOfEntries)
+      *(y+Count++) = atof(NextNumber);
+    if (Count==NumberOfEntries && NextNumber!=0)
+      QMessageBox::warning(this, "MyWidget Message","Found too many numbers in data block, truncated.",QMessageBox::Ok);
+    // Apply sampling frequency and scaling factor 
+    for(int i=2; i<Count; i++) {
+      x[i] = (i-2) / y[0];
+      y[i] = y[i] * y[1];
+    }
+    if(NumberOfEntries>2) {
+      Signal->setData(x+2, y+2, NumberOfEntries-2); // Copies data, arrays can be deleted afterwards
+      Signal->show();
+      Zoomer->setZoomBase(Signal->boundingRect());
+    }  
+    delete[] x;   delete[] y;
+
+    if(ContinuousBox->isChecked()) {
+      usleep(100000);	// Wait to limit maximum update rate
+      GetSignalFromSocket();
+    }
+    else {
+      WaitForData = false;
+      GetButton->setEnabled(true);
+    }
+    }*/
+}
+
+// +++ Disconnect from socket +++
+void MyWidget::GotDisconnected() {
+  Connect->setText("Connect");
+  //ConnectAction->setText("Connect");
+  Port->setEnabled(true);
+  IPAddress->setEnabled(true);
+  Command->setEnabled(false);
+
+  GetButton->setEnabled(false);
+  /*FilenameBox->setEnabled(true);
+  OpenAction->setEnabled(true);    
+  LoadButton->setEnabled(true);
+  ChannelNo->setEnabled(false);
+  BoardNo->setEnabled(false);
+  PixelID->setEnabled(false);
+  Signal->hide();
+  TabWidget->setTabEnabled(1, true);
+  TabWidget->setTabEnabled(2, true);*/
+  
+  SocketOutput->clear();
+  if(!ManualDisconnect) QMessageBox::warning(this, "MyWidget Message","Socket disconnected, maybe host gone.",QMessageBox::Ok);
+}
+
+
+
+ int main(int argc, char *argv[])
+ {
+     QApplication app(argc, argv);
+     MyWidget widget;
+     widget.resize(400,400);
+     widget.show();
+     return app.exec();
+ }
+
Index: /fact/trigger/gui/t72/main.h
===================================================================
--- /fact/trigger/gui/t72/main.h	(revision 9840)
+++ /fact/trigger/gui/t72/main.h	(revision 9840)
@@ -0,0 +1,48 @@
+#include <QtNetwork/QTcpSocket>
+#include <QtNetwork/QAbstractSocket>
+#include <QWidget>
+#include <QtGui>
+#include "tpixel.h"
+#include "tempsens.h"
+#include "humidity.h"
+#include <QString>
+#define SOCKET_TIMEOUT 10000	// Milliseconds to wait for socket connection
+#define MAX_OUTPUT_LINES 200	// Maximum number of lines in socket output window
+#define MAX_COM_SIZE 10000
+#define INITIAL_DIRECTORY ""
+
+ class MyWidget : public QWidget
+ {
+
+   Q_OBJECT
+     Tpixel **pixels;
+   Tempsens **tempsens;
+   Humidity **humidity;
+ public:
+   int* PixelToTriggerPixel;
+   int* ListToTemperaturePixel;
+  MyWidget( QWidget *parent=0 );
+   QTcpSocket *Socket;
+   QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay, *SocketOutput;
+   QSpinBox *Port;
+   QLineEdit *IPAddress,*Command;
+   QWidget *SocketWindow;
+   QFormLayout *CommandLayout, *PortLayout, *AddressLayout;
+   QPushButton *GetButton, *SocketButton, *Connect;
+   QGridLayout *SocketLayout;
+   QAction *ConnectAction;
+ private:
+   void ParseData(QString data);
+   bool WaitForData,ManualDisconnect;
+   private slots:
+     void OpenSocketWindow();
+   void GetSignalFromSocket();
+   void MakeConnection();
+   void SendToSocket();
+   void ReadFromSocket();
+    void GotDisconnected();
+    void updateRates();
+    /*  void MenuAbout();*/
+};
+
+
Index: /fact/trigger/gui/t72/moc_humidity.cpp
===================================================================
--- /fact/trigger/gui/t72/moc_humidity.cpp	(revision 9840)
+++ /fact/trigger/gui/t72/moc_humidity.cpp	(revision 9840)
@@ -0,0 +1,83 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'humidity.h'
+**
+** Created: Tue Jun 30 09:13:29 2009
+**      by: The Qt Meta Object Compiler version 59 (Qt 4.4.3)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "humidity.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'humidity.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 59
+#error "This file was generated using the moc from 4.4.3. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_Humidity[] = {
+
+ // content:
+       1,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       2,   10, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+
+ // signals: signature, parameters, type, tag, flags
+      10,    9,    9,    9, 0x05,
+
+ // slots: signature, parameters, type, tag, flags
+      30,    9,    9,    9, 0x0a,
+
+       0        // eod
+};
+
+static const char qt_meta_stringdata_Humidity[] = {
+    "Humidity\0\0valueChanged(float)\0"
+    "setValue(float)\0"
+};
+
+const QMetaObject Humidity::staticMetaObject = {
+    { &QWidget::staticMetaObject, qt_meta_stringdata_Humidity,
+      qt_meta_data_Humidity, 0 }
+};
+
+const QMetaObject *Humidity::metaObject() const
+{
+    return &staticMetaObject;
+}
+
+void *Humidity::qt_metacast(const char *_clname)
+{
+    if (!_clname) return 0;
+    if (!strcmp(_clname, qt_meta_stringdata_Humidity))
+        return static_cast<void*>(const_cast< Humidity*>(this));
+    return QWidget::qt_metacast(_clname);
+}
+
+int Humidity::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QWidget::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        switch (_id) {
+        case 0: valueChanged((*reinterpret_cast< float(*)>(_a[1]))); break;
+        case 1: setValue((*reinterpret_cast< float(*)>(_a[1]))); break;
+        }
+        _id -= 2;
+    }
+    return _id;
+}
+
+// SIGNAL 0
+void Humidity::valueChanged(float _t1)
+{
+    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
+    QMetaObject::activate(this, &staticMetaObject, 0, _a);
+}
+QT_END_MOC_NAMESPACE
Index: /fact/trigger/gui/t72/moc_main.cpp
===================================================================
--- /fact/trigger/gui/t72/moc_main.cpp	(revision 9840)
+++ /fact/trigger/gui/t72/moc_main.cpp	(revision 9840)
@@ -0,0 +1,86 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'main.h'
+**
+** Created: Tue Jun 30 09:13:30 2009
+**      by: The Qt Meta Object Compiler version 59 (Qt 4.4.3)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "main.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'main.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 59
+#error "This file was generated using the moc from 4.4.3. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_MyWidget[] = {
+
+ // content:
+       1,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       7,   10, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+
+ // slots: signature, parameters, type, tag, flags
+      10,    9,    9,    9, 0x08,
+      29,    9,    9,    9, 0x08,
+      51,    9,    9,    9, 0x08,
+      68,    9,    9,    9, 0x08,
+      83,    9,    9,    9, 0x08,
+     100,    9,    9,    9, 0x08,
+     118,    9,    9,    9, 0x08,
+
+       0        // eod
+};
+
+static const char qt_meta_stringdata_MyWidget[] = {
+    "MyWidget\0\0OpenSocketWindow()\0"
+    "GetSignalFromSocket()\0MakeConnection()\0"
+    "SendToSocket()\0ReadFromSocket()\0"
+    "GotDisconnected()\0updateRates()\0"
+};
+
+const QMetaObject MyWidget::staticMetaObject = {
+    { &QWidget::staticMetaObject, qt_meta_stringdata_MyWidget,
+      qt_meta_data_MyWidget, 0 }
+};
+
+const QMetaObject *MyWidget::metaObject() const
+{
+    return &staticMetaObject;
+}
+
+void *MyWidget::qt_metacast(const char *_clname)
+{
+    if (!_clname) return 0;
+    if (!strcmp(_clname, qt_meta_stringdata_MyWidget))
+        return static_cast<void*>(const_cast< MyWidget*>(this));
+    return QWidget::qt_metacast(_clname);
+}
+
+int MyWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QWidget::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        switch (_id) {
+        case 0: OpenSocketWindow(); break;
+        case 1: GetSignalFromSocket(); break;
+        case 2: MakeConnection(); break;
+        case 3: SendToSocket(); break;
+        case 4: ReadFromSocket(); break;
+        case 5: GotDisconnected(); break;
+        case 6: updateRates(); break;
+        }
+        _id -= 7;
+    }
+    return _id;
+}
+QT_END_MOC_NAMESPACE
Index: /fact/trigger/gui/t72/moc_tempsens.cpp
===================================================================
--- /fact/trigger/gui/t72/moc_tempsens.cpp	(revision 9840)
+++ /fact/trigger/gui/t72/moc_tempsens.cpp	(revision 9840)
@@ -0,0 +1,83 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'tempsens.h'
+**
+** Created: Mon Jun 29 16:21:16 2009
+**      by: The Qt Meta Object Compiler version 59 (Qt 4.4.3)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "tempsens.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'tempsens.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 59
+#error "This file was generated using the moc from 4.4.3. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_Tempsens[] = {
+
+ // content:
+       1,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       2,   10, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+
+ // signals: signature, parameters, type, tag, flags
+      10,    9,    9,    9, 0x05,
+
+ // slots: signature, parameters, type, tag, flags
+      30,    9,    9,    9, 0x0a,
+
+       0        // eod
+};
+
+static const char qt_meta_stringdata_Tempsens[] = {
+    "Tempsens\0\0valueChanged(float)\0"
+    "setValue(float)\0"
+};
+
+const QMetaObject Tempsens::staticMetaObject = {
+    { &QWidget::staticMetaObject, qt_meta_stringdata_Tempsens,
+      qt_meta_data_Tempsens, 0 }
+};
+
+const QMetaObject *Tempsens::metaObject() const
+{
+    return &staticMetaObject;
+}
+
+void *Tempsens::qt_metacast(const char *_clname)
+{
+    if (!_clname) return 0;
+    if (!strcmp(_clname, qt_meta_stringdata_Tempsens))
+        return static_cast<void*>(const_cast< Tempsens*>(this));
+    return QWidget::qt_metacast(_clname);
+}
+
+int Tempsens::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QWidget::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        switch (_id) {
+        case 0: valueChanged((*reinterpret_cast< float(*)>(_a[1]))); break;
+        case 1: setValue((*reinterpret_cast< float(*)>(_a[1]))); break;
+        }
+        _id -= 2;
+    }
+    return _id;
+}
+
+// SIGNAL 0
+void Tempsens::valueChanged(float _t1)
+{
+    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
+    QMetaObject::activate(this, &staticMetaObject, 0, _a);
+}
+QT_END_MOC_NAMESPACE
Index: /fact/trigger/gui/t72/moc_tpixel.cpp
===================================================================
--- /fact/trigger/gui/t72/moc_tpixel.cpp	(revision 9840)
+++ /fact/trigger/gui/t72/moc_tpixel.cpp	(revision 9840)
@@ -0,0 +1,82 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'tpixel.h'
+**
+** Created: Mon Jun 29 16:21:17 2009
+**      by: The Qt Meta Object Compiler version 59 (Qt 4.4.3)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "tpixel.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'tpixel.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 59
+#error "This file was generated using the moc from 4.4.3. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_Tpixel[] = {
+
+ // content:
+       1,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       2,   10, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+
+ // signals: signature, parameters, type, tag, flags
+       8,    7,    7,    7, 0x05,
+
+ // slots: signature, parameters, type, tag, flags
+      26,    7,    7,    7, 0x0a,
+
+       0        // eod
+};
+
+static const char qt_meta_stringdata_Tpixel[] = {
+    "Tpixel\0\0valueChanged(int)\0setValue(int)\0"
+};
+
+const QMetaObject Tpixel::staticMetaObject = {
+    { &QWidget::staticMetaObject, qt_meta_stringdata_Tpixel,
+      qt_meta_data_Tpixel, 0 }
+};
+
+const QMetaObject *Tpixel::metaObject() const
+{
+    return &staticMetaObject;
+}
+
+void *Tpixel::qt_metacast(const char *_clname)
+{
+    if (!_clname) return 0;
+    if (!strcmp(_clname, qt_meta_stringdata_Tpixel))
+        return static_cast<void*>(const_cast< Tpixel*>(this));
+    return QWidget::qt_metacast(_clname);
+}
+
+int Tpixel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QWidget::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        switch (_id) {
+        case 0: valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
+        case 1: setValue((*reinterpret_cast< int(*)>(_a[1]))); break;
+        }
+        _id -= 2;
+    }
+    return _id;
+}
+
+// SIGNAL 0
+void Tpixel::valueChanged(int _t1)
+{
+    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
+    QMetaObject::activate(this, &staticMetaObject, 0, _a);
+}
+QT_END_MOC_NAMESPACE
Index: /fact/trigger/gui/t72/t72.pro
===================================================================
--- /fact/trigger/gui/t72/t72.pro	(revision 9840)
+++ /fact/trigger/gui/t72/t72.pro	(revision 9840)
@@ -0,0 +1,13 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Tue Jun 30 09:10:38 2009
+######################################################################
+
+TEMPLATE = app
+TARGET = 
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+HEADERS += humidity.h main.h tempsens.h tpixel.h
+SOURCES += humidity.cpp main.cpp tempsens.cpp tpixel.cpp
+QT += network
Index: /fact/trigger/gui/t72/tempsens.cpp
===================================================================
--- /fact/trigger/gui/t72/tempsens.cpp	(revision 9840)
+++ /fact/trigger/gui/t72/tempsens.cpp	(revision 9840)
@@ -0,0 +1,52 @@
+#include <QColor>
+
+#include <QVBoxLayout>
+#include <QPainter>
+ #include "tempsens.h"
+
+ 
+Tempsens::Tempsens( QWidget *parent )  : QWidget( parent)
+{
+  //setPalette( QPalette( QColor( 250, 250, 200) ) );
+  //this->setPalette( QPalette( QColor( 250, 250, 200) ) );
+  bgColor= new QColor(200,200,200);
+  this->setAutoFillBackground (1);
+}  
+float Tempsens::value() 
+{
+  return val;
+
+}
+void Tempsens::paintEvent( QPaintEvent * )
+{
+
+  QString s = QString( "%1c" ).arg((double)(val),0,'g',3);
+  QFont sansFont( "Helvetica [Cronyx]", 12 );
+  
+    QPainter p( this );
+    p.setFont(sansFont);
+    p.setPen(Qt::white);
+    int width=this->width();
+    int height=this->height();
+    p.drawText(width/4 , height/2, s );
+}
+
+void Tempsens::setValue( float vall )
+{
+  val=vall;
+  int rred= (int)(((float)(val-MinVal)/(float)(MaxVal-MinVal))*255.);
+
+  int bblue=255-(int)(((float)(val-MinVal)/(float)(MaxVal-MinVal))*255.);
+  //printf("%d \n",val);
+  bgColor->setRgb(rred,0,bblue);
+   //QPalette::ColorRole
+   QPalette *mypalette=new QPalette();
+   //   mypalette->setColor ( mypalette->Base, *bgColor );
+   mypalette->setColor ( mypalette->Base, Qt::red);
+   //this->setBackgroundRole (mypalette->Shadow);
+   //this->setBackgroundColor(*bgColor);
+   repaint();
+   this->setPalette( QPalette( *bgColor ) );
+  emit valueChanged(val);
+
+}
Index: /fact/trigger/gui/t72/tempsens.h
===================================================================
--- /fact/trigger/gui/t72/tempsens.h	(revision 9840)
+++ /fact/trigger/gui/t72/tempsens.h	(revision 9840)
@@ -0,0 +1,40 @@
+#ifndef TEMPSENS_H
+#define TEMPSENS_H
+
+
+#include <QWidget>
+#include <QVBoxLayout>
+
+class Tempsens : public QWidget
+{
+  float MaxVal;
+  float MinVal;
+    Q_OBJECT
+public:
+    Tempsens( QWidget *parent=0 );
+    float value();
+    void setMaxVal(float val){MaxVal=val;};
+    void setMinVal(float val){MinVal=val;};
+    float getMaxVal(){return MaxVal;};
+    float getMinVal(){return MinVal;};
+ private:
+    float val;
+    
+    QVBoxLayout*  ColorWidg;
+ public slots:
+    void setValue( float );
+ 
+
+    
+ signals:
+    void valueChanged( float );
+ protected:
+    void paintEvent( QPaintEvent * );   
+ private:
+    QColor *bgColor;
+    //QSlider *slider;
+};
+
+
+#endif // TEMPSENS_H
+
Index: /fact/trigger/gui/t72/tpixel.cpp
===================================================================
--- /fact/trigger/gui/t72/tpixel.cpp	(revision 9840)
+++ /fact/trigger/gui/t72/tpixel.cpp	(revision 9840)
@@ -0,0 +1,55 @@
+#include <QColor>
+
+#include <QVBoxLayout>
+#include <QPainter>
+ #include "tpixel.h"
+
+ 
+Tpixel::Tpixel( QWidget *parent )  : QWidget( parent)
+{
+  //setPalette( QPalette( QColor( 250, 250, 200) ) );
+  //this->setPalette( QPalette( QColor( 250, 250, 200) ) );
+  bgColor= new QColor(200,200,200);
+  this->setAutoFillBackground (1);
+  MaxVal=255;
+}  
+int Tpixel::value() 
+{
+  return val;
+
+}
+void Tpixel::paintEvent( QPaintEvent * )
+{
+  QString s = QString( "%1" ).arg((double)(val));
+  if(val==0)
+    s= QString("n/c");
+  QFont sansFont( "Helvetica [Cronyx]", 12 );
+  
+    QPainter p( this );
+    p.setFont(sansFont);
+    p.setPen(Qt::white);
+    int width=this->width();
+    int height=this->height();
+    p.drawText(width/3 , height/2, s );
+}
+
+void Tpixel::setValue( int vall )
+{
+  val=vall;
+  
+   bgColor->setRgb((int)(((float)(val)/(float)(MaxVal))*255.),0,0);
+   if(val>=MaxVal)
+     bgColor->setRgb(0,255,255);
+   //printf("%f\n",(((float)(val)/(float)(MaxVal))));
+   //QPalette::ColorRole
+   QPalette *mypalette=new QPalette();
+   //   mypalette->setColor ( mypalette->Base, *bgColor );
+   mypalette->setColor ( mypalette->Base, Qt::red);
+   //this->setBackgroundRole (mypalette->Shadow);
+   //this->setBackgroundColor(*bgColor);
+   repaint();
+   this->setPalette( QPalette( *bgColor ) );
+  emit valueChanged(val);
+
+}
+
Index: /fact/trigger/gui/t72/tpixel.h
===================================================================
--- /fact/trigger/gui/t72/tpixel.h	(revision 9840)
+++ /fact/trigger/gui/t72/tpixel.h	(revision 9840)
@@ -0,0 +1,36 @@
+#ifndef TPIXEL_H
+#define TPIXEL_H
+
+
+#include <QWidget>
+#include <QVBoxLayout>
+
+class Tpixel : public QWidget
+{
+  int MaxVal;
+    Q_OBJECT
+public:
+    Tpixel( QWidget *parent=0 );
+    int value();
+    void setMaxVal(int val){MaxVal=val;};
+    int getMaxVal(){return MaxVal;};
+ private:
+    int val;
+    QVBoxLayout*  ColorWidg;
+ public slots:
+    void setValue( int );
+ 
+
+    
+ signals:
+    void valueChanged( int );
+ protected:
+    void paintEvent( QPaintEvent * );   
+ private:
+    QColor *bgColor;
+    //QSlider *slider;
+};
+
+
+#endif // TPIXEL_H
+
Index: /fact/trigger/makefile
===================================================================
--- /fact/trigger/makefile	(revision 9840)
+++ /fact/trigger/makefile	(revision 9840)
@@ -0,0 +1,38 @@
+
+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: /fact/trigger/test.py
===================================================================
--- /fact/trigger/test.py	(revision 9840)
+++ /fact/trigger/test.py	(revision 9840)
@@ -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: /fact/trigger/v560.c
===================================================================
--- /fact/trigger/v560.c	(revision 9840)
+++ /fact/trigger/v560.c	(revision 9840)
@@ -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: /fact/trigger/v560.h
===================================================================
--- /fact/trigger/v560.h	(revision 9840)
+++ /fact/trigger/v560.h	(revision 9840)
@@ -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: /fact/trigger/v560_base.dat
===================================================================
--- /fact/trigger/v560_base.dat	(revision 9840)
+++ /fact/trigger/v560_base.dat	(revision 9840)
@@ -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: /fact/trigger/v560_dummy.c
===================================================================
--- /fact/trigger/v560_dummy.c	(revision 9840)
+++ /fact/trigger/v560_dummy.c	(revision 9840)
@@ -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: /fact/trigger/v560_test.c
===================================================================
--- /fact/trigger/v560_test.c	(revision 9840)
+++ /fact/trigger/v560_test.c	(revision 9840)
@@ -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: /fact/trigger/v560_test.py
===================================================================
--- /fact/trigger/v560_test.py	(revision 9840)
+++ /fact/trigger/v560_test.py	(revision 9840)
@@ -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: /fact/trigger/v812.c
===================================================================
--- /fact/trigger/v812.c	(revision 9840)
+++ /fact/trigger/v812.c	(revision 9840)
@@ -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, int 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, short 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: /fact/trigger/v812.h
===================================================================
--- /fact/trigger/v812.h	(revision 9840)
+++ /fact/trigger/v812.h	(revision 9840)
@@ -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,short 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, int pattern);
+VME_ErrorCode_t V812_Close(void);
+
+//******************************************************************************
+
+#endif
Index: /fact/trigger/v812_base.dat
===================================================================
--- /fact/trigger/v812_base.dat	(revision 9840)
+++ /fact/trigger/v812_base.dat	(revision 9840)
@@ -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
