Exemple #1
0
    def trigger(self):
        from MDSplus.mdsExceptions import DevTRIGGER_FAILED

        if self.debugging():
            print("starting trigger")
        try:
            boardip = self.getBoardIp()
            trig_src = self.trig_src.record.getOriginalPartName().getString(
            )[1:]
            if self.debugging():
                print("executing trigger on board %s, trig_src is %s." % (
                    boardip,
                    trig_src,
                ))
            trig_src = trig_src[2:]

            UUT = acq200.ACQ200(transport.factory(boardip))
            route = UUT.uut.acq2sh('get.route D%s' % (trig_src, ))

            d1 = UUT.uut.acq2sh('set.route d%s in fpga out' % (trig_src, ))
            d2 = UUT.uut.acq2sh('set.dtacq dio_bit %s P' % (trig_src, ))
            d3 = UUT.uut.acq2sh('set.route %s' % (route, ))
            d4 = UUT.uut.acq2sh('set.dtacq dio_bit %s -' % (trig_src, ))

            if self.debugging():
                print("got back: %s" % (route, ))
                print("     and: %s" % (d1, ))
                print("     and: %s" % (d2, ))
                print("     and: %s" % (d3, ))
                print("     and: %s" % (d4, ))
        except Exception as e:
            print("Error doing Trigger method")
            raise DevTRIGGER_FAILED(str(e))
        return 1
Exemple #2
0
    def trigger(self, arg):
        if self.debugging():
            print "starting trigger"
        boardip = self.getBoardIp()
        try:
            trig_src=self.trig_src.record.getOriginalPartName().getString()[1:]
        except:
            print "could not read trigger source"
            return 0
        if self.debugging() :
            print "executing trigger on board %s, trig_src is %s."% (boardip, trig_src,)
        trig_src = trig_src[2:]
        
        try:
            UUT = acq200.Acq200(transport.factory(boardip))
        except:
            print "could not connect to the board %s"% (boardip,)
        try:
            route = UUT.uut.acq2sh('get.route D%s'%(trig_src,))
            d1 = UUT.uut.acq2sh('set.route d%s in fpga out'%(trig_src,))
            d2 = UUT.uut.acq2sh('set.dtacq dio_bit %s P'%(trig_src,))
            d3 = UUT.uut.acq2sh('set.route %s' %(route,))
            d4 = UUT.uut.acq2sh('set.dtacq dio_bit %s -'%(trig_src,))
            
        except:
            print "could not send command to the board"
        if self.debugging():
            print "got back: %s\n" % (route,)
	    print "     and: %s\n" % (d1,)
	    print "     and: %s\n" % (d2,)
	    print "     and: %s\n" % (d3,)
	    print "     and: %s\n" % (d4,)
        return 1
Exemple #3
0
 def trigger(self, arg):
     boardip = self.getBoardIp()
     try:
         trig_src=str(self.trig_src.record.getOriginalPartName())[1:]
     except:
         print("could not read trigger source")
         return 0
     if self.debugging() :
         print("executing trigger on board %s, trig_src is %s."% (boardip, trig_src,))
     trig_src = trig_src[2:]
     cmd = "set.dtacq dio_bit %s P" % (trig_src,)
     if self.debugging() :
         print("sending command %s."%(cmd,))
     try:
         UUT = acq200.ACQ200(transport.factory(boardip))
     except:
         print("could not connect to the board %s"% (boardip,))
     try:
         a = UUT.uut.acq2sh(cmd)
         b = UUT.uut.acqcmd('-- setDIO -------')
     except:
         print("could not send %s to the board" %(cmd,))
     if self.debugging():
         print("got back: %s\n" % (a,))
         print("     and: %s\n" % (b,))
     return 1
Exemple #4
0
    def acq2sh(self, arg):
        from MDSplus.mdsExceptions import DevACQ2SH_FAILED
        boardip = self.getBoardIp()

        try:
            UUT = acq200.ACQ200(transport.factory(boardip))
            a = UUT.uut.acq2sh(str(arg))
        except Exception as e:
            print("could not connect to the board %s" % (boardip,))
            raise DevACQ2SH_FAILED(str(e))
        print("%s  %s -> %s" % (boardip, arg, a,))
        return 1
Exemple #5
0
 def acq2sh(self, arg):
     boardip = self.getBoardIp()
     
     try:
         UUT = acq200.Acq200(transport.factory(boardip))
     except:
         print "could not connect to the board %s"% (boardip,)
     try:
         a = UUT.uut.acq2sh(str(arg))
     except:
         print "could not send %s to the board" %(str(arg),)
         return 0
     print "%s  %s -> %s"%(boardip, arg, a,)
     return 1
Exemple #6
0
    def acq2sh(self, arg):
        boardip = self.getBoardIp()

        try:
            UUT = acq200.ACQ200(transport.factory(boardip))
        except:
            print("could not connect to the board %s"% (boardip,))
        try:
            a = UUT.uut.acq2sh(str(arg))
        except:
            print("could not send %s to the board" %(str(arg),))
            return 0
        print("%s  %s -> %s"%(boardip, arg, a,))
        return 1
Exemple #7
0
 def getBoardState(self):
     from MDSplus.mdsExceptions import DevCANNOT_GET_BOARD_STATE
     boardip = self.getBoardIp()
     last_error = None
     for t in range(10):
         try:
             UUT = acq200.ACQ200(transport.factory(boardip))
         except Exception as e:
             print("could not connect to the board %s" % (boardip, ))
             last_error = e
         try:
             if not UUT == None:
                 a = UUT.uut.acqcmd('getState')
                 return "ACQ32:%s" % a
         except Exception as e:
             print("could not send getState to the board try %d" % t)
             last_error = e
     if not last_error == None:
         raise DevCANNOT_GET_BOARD_STATE(str(last_error))
     else:
         return 'unkown'
Exemple #8
0
    def trigger(self, arg):
        if self.debugging():
            print "starting trigger"
        boardip = self.getBoardIp()
        try:
            trig_src = self.trig_src.record.getOriginalPartName().getString(
            )[1:]
        except:
            print "could not read trigger source"
            return 0
        if self.debugging():
            print "executing trigger on board %s, trig_src is %s." % (
                boardip,
                trig_src,
            )
        trig_src = trig_src[2:]

        try:
            UUT = acq200.Acq200(transport.factory(boardip))
        except:
            print "could not connect to the board %s" % (boardip, )
        try:
            route = UUT.uut.acq2sh('get.route D%s' % (trig_src, ))
            d1 = UUT.uut.acq2sh('set.route d%s in fpga out' % (trig_src, ))
            d2 = UUT.uut.acq2sh('set.dtacq dio_bit %s P' % (trig_src, ))
            d3 = UUT.uut.acq2sh('set.route %s' % (route, ))
            d4 = UUT.uut.acq2sh('set.dtacq dio_bit %s -' % (trig_src, ))

        except:
            print "could not send command to the board"
        if self.debugging():
            print "got back: %s\n" % (route, )
            print "     and: %s\n" % (d1, )
            print "     and: %s\n" % (d2, )
            print "     and: %s\n" % (d3, )
            print "     and: %s\n" % (d4, )
        return 1
Exemple #9
0
    def store(self, arg):
        """
        Store the data from the device
        Fetch and store the device status (firmware etc)
        If the device is finished
        For each channel that is on and active in the mask
        read the data
        store the data into the raw nodes
        store the expression into the data nodes
        """

        debug = os.getenv("DEBUG_DEVICES")
        try:
            error = "Must specify a board ipaddress"
            boardip = str(self.boardip.record)
            error = None
            UUT = acq200.ACQ200(transport.factory(boardip))
            try:
                ans = []
                cmds = self.status_cmds.record
                for cmd in cmds:
                    print cmd
                    a = UUT.uut.acq2sh(cmd)
                    ans.append(a)
                self.board_status.record = Signal(makeArray(ans), None,
                                                  makeArray(cmds))
            except Exception, e:
                pass

            complete = 0
            tries = 0
            while not complete and tries < 60:
                if UUT.get_state().split()[-1] == "ST_POSTPROCESS":
                    tries += 1
                    sleep(1)
                else:
                    complete = 1
            if UUT.get_state().split()[-1] != "ST_STOP":
                raise Exception, "Device not Triggered \n device returned -%s-" % UUT.get_state(
                ).split()[-1]
            if debug:
                print "about to get the vins\n"
            vins = self.getVins(UUT)
            self.ranges.record = vins
            (tot, pre, post, run) = UUT.get_numSamples()
            pre = int(pre) * -1
            post = int(post) - 1
            mask = UUT.uut.acqcmd('getChannelMask').split('=')[-1]
            error = "Clock source must be a string"
            clock_src = self.clock_src.record.getOriginalPartName().getString(
            )[1:]
            error = None
            if clock_src == 'INT_CLOCK':
                self.clock.record = Range(delta=1. /
                                          self.getInternalClock(UUT))
            else:
                self.clock.record = self.clock_src

            clock = self.clock.record
            if debug:
                print "about to ask it to mdsconnect"
            UUT.uut.acq2sh("mdsConnect %s" % str(self.hostip.record))
            if debug:
                print "about to ask it to mdsopen"
            UUT.uut.acq2sh('mdsOpen %s %d' % (
                self.boardip.tree.name,
                self.boardip.tree.shot,
            ))
            for chan in range(32):
                if debug:
                    print "working on channel %d" % chan
                chan_node = self.__getattr__('input_%2.2d' % (chan + 1, ))
                chan_raw_node = self.__getattr__('input_%2.2d_raw' %
                                                 (chan + 1, ))
                if chan_node.on:
                    if debug:
                        print "it is on so ..."
                    if mask[chan:chan + 1] == '1':
                        try:
                            start = max(
                                int(
                                    self.__getattr__('input_%2.2d_start_idx' %
                                                     (chan + 1))), pre)
                            print "start = %d" % start
                        except:
                            start = pre
                        try:
                            end = min(
                                int(
                                    self.__getattr__('input_%2.2d_end_idx' %
                                                     (chan + 1))), post)
                            print "end = %d" % end
                        except:
                            end = post
                        try:
                            inc = int(
                                self.__getattr__('input_%2.2d_inc' %
                                                 (chan + 1)))
                            print "inc = %d" % inc
                        except:
                            inc = 1
                        if debug:
                            print "build the command"
                        command = "mdsPutCh --field %s:raw --expr %%calsig --timebase %d,%d,%d %d" % (
                            chan_node.getFullPath(), int(start - pre),
                            int(end - pre), int(inc), chan + 1)
                        command = command.replace('\\', '\\\\')
                        if debug:
                            print "about to execute %s" % command
                        UUT.uut.acq2sh(command)
                        if inc > 1:
                            clk = ''
                            delta = ''
                            begin = ''
                            end = ''
                            try:
                                clk = self.clock.evaluate()
                                delta = clk.delta
                                begin = clk.begin
                                ending = clk.end
                            except:
                                pass
                            if delta:
                                axis = Range(begin, ending, delta / inc)
                                window = Window(start / inc, end / inc,
                                                trigger)
                                dim = Dimension(window, axis)
                            else:
                                dim = Data.Compile(
                                    'Map($,$)',
                                    Dimension(
                                        Window(start / inc, end / inc,
                                               trigger), clock),
                                    Range(start, end, inc))
                                raw = Data.compile('data($)', chan_raw_node)
                                chan_node.record = Signal(raw, None, dim)
                        else:
                            raw = Data.compile('data($)', chan_raw_node)
                            chan_node.record = Signal(
                                raw, None,
                                Dimension(Window(start, end, self.trig_src),
                                          clock))

            UUT.uut.acq2sh('mdsClose %s' % (self.boardip.tree.name, ))
Exemple #10
0
    def store(self, arg):
        """
        Store the data from the device
        Fetch and store the device status (firmware etc)
        If the device is finished
        For each channel that is on and active in the mask
        read the data
        store the data into the raw nodes
        store the expression into the data nodes
        """


        debug=os.getenv("DEBUG_DEVICES")
        try:
            boardip=self.check( 'str(self.boardip.record)', "Must specify a board ipaddress")
            UUT = acq200.Acq200(transport.factory(boardip))
            try:
                ans = []
                cmds = self.status_cmds.record
                for cmd in cmds:
                    print cmd
                    a = UUT.uut.acq2sh(cmd)
                    ans.append(a)
                self.board_status.record = Data.compile('build_signal($,*, $)', a, cmds)
            except Exception, e:
                pass

            complete = 0
            tries = 0
            while not complete and tries < 60 :
                if UUT.get_state().split()[-1] == "ST_POSTPROCESS" :
                    tries +=1
                    sleep(1)
                else:
                    complete=1
            if UUT.get_state().split()[-1] != "ST_STOP" :
                raise Exception, "Device not Triggered \n device returned -%s-" % UUT.get_state().split()[-1]
            if debug:
                print "about to get the vins\n"
            vins = self.getVins(UUT)
            self.ranges.record = vins
            (tot, pre, post, run) = UUT.get_numSamples()
            pre = int(pre)
            post = int(post)
            mask = UUT.uut.acqcmd('getChannelMask').split('=')[-1]
        
            clock_src=self.check('self.clock_src.record.getOriginalPartName().getString()[1:]', "Clock source must be a string")
            if clock_src == 'INT_CLOCK' :
                self.clock.record = Range(delta=1./self.getInternalClock(UUT))
            else:
                self.clock.record = self.clock_src

            clock = self.clock.record
            if debug:
                print "about to ask it to mdsconnect"
            UUT.uut.acq2sh("mdsConnect %s" % str(self.hostip.record))
            if debug:
                print "about to ask it to mdsopen"
            UUT.uut.acq2sh('mdsOpen %s %d'  % (self.boardip.tree.name, self.boardip.tree.shot,))
            for chan in range(32):
                if debug:
                    print "working on channel %d" % chan
                chan_node = eval('self.input_%2.2d' % (chan+1,))
                chan_raw_node = eval('self.input_%2.2d_raw' % (chan+1,))
                if chan_node.on :
                    if debug:
                        print "it is on so ..."
                    if mask[chan:chan+1] == '1' :
                        try:
                            start = eval('int(self.input_%2.2d:start_idx)'%chan+1)
                        except:
                            start = pre
                        try:
                            end = eval('int(self.input_%2.2d:end_idx)'%chan+1)
                        except:
                            end = post
                        try:
                            inc =  eval('int(self.input_%2.2d:inc)'%chan+1)
                        except:
                            inc = 1
                        if debug:
                            print "build the command"
                        command = "mdsPutCh --field %s:raw --expr %%calsig --timebase %d,%d,%d %d" % (chan_node.getFullPath(), int(start), int(end), int(inc), chan+1)
                        command = command.replace('\\','\\\\')
                        if debug:
                            print "about to execute %s" % command
                        UUT.uut.acq2sh(command)
                        if inc > 1 :
                            clk=''
                            delta=''
                            begin=''
                            end=''
                            try :
                                clk = self.clock.evaluate()
                                delta = clk.delta
                                begin = clk.begin
                                ending = clk.end
                            except:
                                pass
                            if delta :
                                axis = Range(begin, ending, delta/inc)
                                window = Window(start/inc, end/inc, trigger)
                                dim = Dimension(window, axis)
                            else:
                                dim = Data.Compile('Map($,$)', Dimension(Window(start/inc, end/inc, trigger), clock), Range(start, end, inc))
                                raw = Data.compile('data($)', chan_raw_node)
                                chan_node.record = eval('Signal(raw, "", dim)' % chan_node.getPath())
                        else:
			    raw = Data.compile('data($)', chan_raw_node)
                            chan_node.record = Signal(raw, "", Dimension(Window(start, end, self.trig_src), clock))
        
            UUT.uut.acq2sh('mdsClose %s' % (self.boardip.tree.name,))
Exemple #11
0
    def store(self, arg):
        """
        Store the data from the device
        Fetch and store the device status (firmware etc)
        If the device is finished
        For each channel that is on and active in the mask
        read the data
        store the data into the raw nodes
        store the expression into the data nodes
        """

        debug = os.getenv("DEBUG_DEVICES")
        try:
            boardip = self.check('str(self.boardip.record)',
                                 "Must specify a board ipaddress")
            UUT = acq200.Acq200(transport.factory(boardip))
            try:
                ans = []
                cmds = self.status_cmds.record
                for cmd in cmds:
                    print(cmd)
                    a = UUT.uut.acq2sh(cmd)
                    ans.append(a)
                self.board_status.record = Data.compile(
                    'build_signal($,*, $)', ans, cmds)
            except Exception:
                pass

            complete = 0
            tries = 0
            if UUT.get_state().split()[-1] == "ST_RUN":
                raise Exception(
                    "Device not Triggered \n device returned -%s-" %
                    UUT.get_state().split()[-1])
            if debug:
                print("about to get the vins\n")
            vins = self.getVins(UUT)
            self.ranges.record = vins
            (tot, pre, post, run) = UUT.get_numSamples()
            pre = int(pre)
            post = int(post)
            if pre == 0 and post == 0:
                return 662480266  # DT196B$_NO_SAMPLES
            mask = UUT.uut.acqcmd('getChannelMask').split('=')[-1]
            if debug:
                print("pre = %d, post = %d" % (
                    pre,
                    post,
                ))
            clock_src = self.check(
                'str(self.clock_src.record.getOriginalPartName())[1:]',
                "Clock source must be a string")
            if clock_src == 'INT_CLOCK':
                self.clock.record = Range(delta=1. /
                                          self.getInternalClock(UUT))
            else:
                self.clock.record = self.clock_src

            clock = self.clock.record
            if debug:
                print("about to start the script")

            (fd, fname) = mkstemp('.sh')
            f = open(fname, 'w')
            f.write("#!/bin/sh\n")
            f.write("touch /tmp/starting_%d\n" % self.boardip.tree.shot)
            f.write("acqcmd --until ST_STOP\n")
            f.write("mdsConnect %s\n" % str(self.hostip.record))
            cmd = "mdsValue \"job_start('%s', %d)\"" % (self.path,
                                                        self.tree.shot)
            cmd = cmd.replace('\\', '\\\\\\\\\\\\\\')
            f.write("%s\n" % (cmd, ))
            f.write("mdsOpen %s %d\n" % (
                self.boardip.tree.name,
                self.boardip.tree.shot,
            ))
            for chan in range(96):
                chan_node = eval('self.input_%2.2d' % (chan + 1, ))
                chan_raw_node = eval('self.input_%2.2d_raw' % (chan + 1, ))
                if chan_node.on:
                    if debug:
                        print("it is on so ...")
                    if mask[chan:chan + 1] == '1':
                        try:
                            start = eval("int(self.input_%2.2d_start_idx)" %
                                         (chan + 1))
                        except:
                            start = pre
                        try:
                            end = eval("int(self.input_%2.2d_end_idx" %
                                       (chan + 1))
                        except:
                            end = post - 1
                        try:
                            inc = eval("int(self.input_%2.2d_inc)" %
                                       (chan + 1))
                        except:
                            inc = 1
                        if debug:
                            print("build the command")
                        command = "mdsPutCh --field %s:raw --expr %%calsig --timebase %d,%d,%d %d\n" % (
                            chan_node.getFullPath(), int(start), int(end),
                            int(inc), chan + 1)
                        command = command.replace('\\', '\\\\')
                        if debug:
                            print("about to execute %s" % command)
                        f.write(command)
                        if inc > 1:
                            clk = None
                            delta = None
                            begin = None
                            ending = None
                            try:
                                clk = self.clock.evaluate()
                                delta = clk.delta
                                begin = clk.begin
                                ending = clk.ending
                            except:
                                pass
                            if delta:
                                axis = Range(begin, ending, delta * inc)
                                window = Window(start / inc, end / inc,
                                                self.trig_src)
                                dim = Dimension(window, axis)
                            else:
                                dim = Data.compile(
                                    'Map($,$)',
                                    Dimension(
                                        Window(start / inc, end / inc,
                                               trig_src), clock),
                                    Range(start, end, inc))
                            raw = Data.compile('data($)', chan_raw_node)
                            chan_node.record = eval('Signal(raw, "", dim)')
                        else:
                            raw = Data.compile('data($)', chan_raw_node)
                            chan_node.record = Signal(
                                raw, "",
                                Dimension(
                                    Window(start, end - 1, self.trig_src),
                                    clock))
            f.write('mdsClose %s\n' % (self.boardip.tree.name, ))
            f.write("touch /tmp/finished_%d\n" % self.boardip.tree.shot)
            cmd = "mdsValue \"job_finish('%s', %d)\"" % (self.path,
                                                         self.tree.shot)
            cmd = cmd.replace('\\', '\\\\\\\\\\\\\\')
            f.write("%s\n" % (cmd, ))
            f.write("rm $0\n")
            f.close()
            cmd = 'curl -s -T %s ftp://%s/%s' % (fname, boardip,
                                                 'post_shot.sh')
            pipe = os.popen(cmd)
            pipe.close()
            UUT.uut.acq2sh("chmod a+rx /home/ftp/post_shot.sh")
            UUT.uut.acq2sh("/home/ftp/post_shot.sh&")
        except Exception as e:
            print("Error storing DT196B Device\n%s" % (str(e), ))
            return 0

        return 1
Exemple #12
0
    def init(self, arg):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """

        debug = os.getenv("DEBUG_DEVICES")
        try:
            boardip = self.check('str(self.boardip.record)',
                                 "Must specify a board ipaddress")
            UUT = acq200.Acq200(transport.factory(boardip))
            active_chans = self.check(
                "int(self.active_chans)",
                "Must specify active chans as int in (32,64,96)")
            if active_chans not in (32, 64, 96):
                print("active chans must be in (32, 64, 96 )")
                active_chans = 96
            trig_src = self.check(
                'str(self.trig_src.record.getOriginalPartName())[1:]',
                "Trig source must be a string")
            print("trig_src is %s\n" % trig_src)
            if not trig_src in self.trig_sources:
                raise Exception("Trig_src must be in %s" %
                                str(self.trig_sources))
            trig_edge = self.check('self.trig_edge.record.getString()',
                                   'Trig edge must be a string')
            clock_src = self.check(
                'str(self.clock_src.record.getOriginalPartName())[1:]',
                "Clock source must be a string")
            if debug:
                print("clock_src is %s\n" % clock_src)
            if not clock_src in self.clock_sources:
                raise Exception("Clock_src must be in %s" %
                                str(self.clock_sources))
            if clock_src == 'INT_CLOCK' or clock_src == 'MASTER':
                clock_freq = self.check(
                    'int(self.clock_freq)',
                    "Must specify a frequency for internal clock")
            else:
                clock_freq = self.check(
                    'int(self.clock_freq)',
                    "Must specify a frequency for external clock")
                clock_div = self.check(
                    'int(self.clock_div)',
                    "Must specify a divisor for external clock")
            pre_trig = self.check('int(self.pre_trig.data()*1024)',
                                  "Must specify pre trigger samples")
            post_trig = self.check('int(self.post_trig.data()*1024)',
                                   "Must specify post trigger samples")
            UUT.set_abort()
            UUT.clear_routes()

            for i in range(6):
                line = 'd%1.1d' % i
                try:
                    wire = eval('str(self.di%1.1d_wire.record)' % i)
                    if wire not in self.wires:
                        print("DI%d:wire must be in %s" % (
                            i,
                            str(self.wires),
                        ))
                        wire = 'fpga'
                except:
                    wire = 'fpga'
                try:
                    bus = eval('str(self.di%1.1d_bus.record)' % i)
                    if bus not in self.wires:
                        print("DI%d:bus must be in %s" % (
                            i,
                            str(self.wires),
                        ))
                        bus = ''
                except:
                    bus = ''
                UUT.set_route(line, 'in %s out %s' % (
                    wire,
                    bus,
                ))
            UUT.setChannelCount(active_chans)

            if clock_src == 'INT_CLOCK' or clock_src == 'MASTER':
                UUT.uut.acqcmd("setInternalClock %d" % clock_freq)
                if clock_src == 'MASTER':
                    UUT.uut.acqcmd('-- setDIO -1-----')
            else:
                if (clock_div != 1):
                    UUT.uut.acqcmd("setExternalClock %s %d D02" % (
                        clock_src,
                        clock_div,
                    ))
                    #
                    # the following is not generic
                    # the clock is output on d2 and comes from DI0
                    #
                    UUT.set_route('d2', 'in fpga out pxi')
                    UUT.uut.acqcmd('-- setDIO --1-----')
                    UUT.uut.acq2sh('set.ext_clk DI0')

                else:
                    UUT.uut.acqcmd("setExternalClock %s" % clock_src)

            UUT.setPrePostMode(pre_trig, post_trig, trig_src, trig_edge)
            mask = UUT.uut.acqcmd('getChannelMask').split('=')[-1]
            UUT.set_arm()
            return 1

        except Exception as e:
            print("%s\n" % (str(e), ))
            return 0
Exemple #13
0
    def store(self, arg):
        """
        Store the data from the device
        Fetch and store the device status (firmware etc)
        If the device is finished
        For each channel that is on and active in the mask
        read the data
        store the data into the raw nodes
        store the expression into the data nodes
        """
        print "=========== ANUDEVICES SH edited dt132.py 13/06/2012 ==========="
        stall=os.getenv("Shaun_Stall")
        debug=os.getenv("DEBUG_DEVICES")
        try:
            error="Must specify a board ipaddress"
            boardip=str(self.boardip.record)
            error=None
            UUT = acq200.Acq200(transport.factory(boardip))
            try:
                ans = []
                cmds = self.status_cmds.record
                for cmd in cmds:
                    print cmd
                    a = UUT.uut.acq2sh(cmd)
                    ans.append(a)
                self.board_status.record = Signal(makeArray(ans),None,makeArray(cmds))
            except Exception, e:
                pass

            complete = 0
            tries = 0
            complete2=0
            tries2 = 0
            #SHAUN MODIFICATION SO THAT IT CAN BE RUN IN A LOOP AND WILL STALL HERE UNTIL CARD GOES TO POSTPROCESS
            if stall=="YES":
                print "stall is yes"
                while complete2==0:
                    if UUT.get_state().split()[-1] != "ST_STOP" :
                        tries2 +=1
                        sleep(1)
                        #print 'Still in run state'
                    else:
                        complete2=1
                        print 'Finished'
            #End Shaun Modification
            while not complete and tries < 60 :
                if UUT.get_state().split()[-1] == "ST_POSTPROCESS" :
                    tries +=1
                    sleep(1)
                else:
                    complete=1
            if UUT.get_state().split()[-1] != "ST_STOP" :
                raise Exception, "Device not Triggered \n device returned -%s-" % UUT.get_state().split()[-1]
            if debug:
                print "about to get the vins\n"
            vins = self.getVins(UUT)
            self.ranges.record = vins
            (tot, pre, post, run) = UUT.get_numSamples()
            pre = int(pre)*-1
            post = int(post)-1
            mask = UUT.uut.acqcmd('getChannelMask').split('=')[-1]
            print mask
            error="Clock source must be a string"
            #clock_src=self.clock_src.record.getOriginalPartName().getString()[1:]
            clock_src=str(self.clock_src.record)[-3:] #edit!!
            #print "clock_src:", clock_src
            error=None
            if clock_src == 'INT_CLOCK' :
                self.clock.record = Range(delta=1./self.getInternalClock(UUT))
            else:
                self.clock.record = Range(delta=1./self.getInternalClock(UUT)) #TEST FOR 32MHZ clock!!! - getInternalCock is deceptively named - it also works for external clock and is the second value that is given when setting it
                
                #self.clock.record = Range(delta=1./self.clock_src.data()) #SHAUN EDIT!!!!!

                #SHAUN FAST DTACQ EDIT
#                if os.getenv('DTACQFAST')=='YES16' and boardip=='192.168.1.9':
#                    self.clock.record = Range(delta=1./(16000000)) #SHAUN EDIT!!!!!
#                if os.getenv('DTACQFAST')=='YES32' and boardip=='192.168.1.9':
#                    self.clock.record = Range(delta=1./(32000000)) #SHAUN EDIT!!!!!

                #print self.clock_src.data()
                #self.clock.record = self.clock_src
            clock = self.clock.record
            #print 'clock record being used is : '#SHAUN EDIT
            if debug:
                print "about to ask it to mdsconnect"
            #print "mdsConnect %s" % str(self.hostip.record)
            UUT.uut.acq2sh("mdsConnect %s" % str(self.hostip.record))
            if debug:
                print "about to ask it to mdsopen"
            #print 'mdsOpen %s %d'  % (self.boardip.tree.name, self.boardip.tree.shot,)
            UUT.uut.acq2sh('mdsOpen %s %d'  % (self.boardip.tree.name, self.boardip.tree.shot,))

            #SHAUN EDIT START
            mdsputchsent=0 #Remember if command has been sent - initialise to be 0
            listofchannels="" #Initialise list of channels to be used by bulk command
            for spot in range(32):#Build list of channels to be used
                chan_node = self.__getattr__('input_%2.2d' % (spot+1,))
                if chan_node.on:
                    listofchannels=listofchannels + str(spot+1) + ","
            if listofchannels[len(listofchannels)-1]==",": #remove the last comma
                listofchannels=listofchannels[:len(listofchannels)-1]

            #Shaun edit for DTACQ Fast Sampling
            if os.getenv('DTACQFAST')=='YES16' and boardip=='192.168.1.9':
                listofchannels='1,5,17,21'
            if os.getenv('DTACQFAST')=='YES32' and boardip=='192.168.1.9':
                listofchannels='1,17'
                
            mdsputchbulkcommand=1 #switch to use bulk mdsputch or not
            #SHAUN EDIT END
            
            for chan in range(32):
                if debug:
                    print "working on channel %d" % chan
                chan_node = self.__getattr__('input_%2.2d' % (chan+1,))
                chan_raw_node = self.__getattr__('input_%2.2d_raw' % (chan+1,))
                if chan_node.on :
                    if debug:
                        print "it is on so ..."
                    if mask[chan:chan+1] == '1' :
                        try:
                            start = max(int(self.__getattr__('input_%2.2d_start_idx'%(chan+1))), pre)
                            print "start = %d" %start
                        except:
                            start = pre
                        try:
                            end = min(int(self.__getattr__('input_%2.2d_end_idx'%(chan+1))), post)
                        except:
                            end = post
                        try:
                            inc = int(self.__getattr__('input_%2.2d_inc'%(chan+1)))
                            print "inc = %d" % inc
                        except:
                            inc = 1
                        if debug:
                            print "build the command"
                        #!!!!!!!!!!!!!!! SHAUN MODIFIED THE FOLLOWING LINE (ADDED the +1 on the third argument to fix 1 more sample in time/data - ORIGINALLY WASN"T THERE - also replaced %%calsig with %%CAL to reduce complexity of the created tree - Boyd???)
                        command = "mdsPutCh --field %s:raw --expr %%CAL --timebase %d,%d,%d %d" % (chan_node.getFullPath(), int(start-pre), int(end-pre)+1, int(inc), chan+1)
                        command = command.replace('\\','\\\\')
                        if debug:
                            print "about to execute %s" % command

                        #START Shaun EDIT TO USE MDSPUTCH TO DO LOTS OF CHANNELS (mdsputchbulkcommand decides if it is used)
                        if mdsputchbulkcommand==1:
                            if mdsputchsent==0: #Check to see if command has already been sent
                                fieldstring=str(chan_node.getFullPath()) #building the string
                                fieldstring=fieldstring[0:len(fieldstring)-2]+"%02d" #building the string
                                bulkcommand = "mdsPutCh --field %s:raw --expr %%CAL --timebase %d,%d,%d %s" % (fieldstring, int(start-pre), int(end-pre)+1, int(inc), listofchannels)
                                bulkcommand = bulkcommand.replace('\\','\\\\')
                                print bulkcommand
                                UUT.uut.acq2sh(bulkcommand) #send command
                                mdsputchsent=1 #Remember the command has been sent                        
                        else:
                            UUT.uut.acq2sh(command) #ORIGINAL COMMAND
                        #END SHAUN EDIT
                        if inc > 1 :
                            clk=''
                            delta=''
                            begin=''
                            end=''
                            try :
                                clk = self.clock.evaluate()
                                delta = clk.delta
                                begin = clk.begin
                                ending = clk.end
                            except:
                                pass
                            if delta :
                                axis = Range(begin, ending, delta/inc)
                                window = Window(start/inc, end/inc, trigger)
                                dim = Dimension(window, axis)
                            else:
                                dim = Data.Compile('Map($,$)', Dimension(Window(start/inc, end/inc, trigger), clock), Range(start, end, inc))
                                raw = Data.compile('data($)', chan_raw_node)
                                chan_node.record = Signal(raw, None, dim)
                        else:
			    raw = Data.compile('data($)', chan_raw_node)
                            chan_node.record = Signal(raw, None, Dimension(Window(start, end, self.trig_src), clock))
            UUT.uut.acq2sh('mdsClose %s' % (self.boardip.tree.name,))
Exemple #14
0
    def init(self, arg):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """
        print "ANUDEVICES : this is the edited one2 13/06/2012"
        debug=os.getenv("DEBUG_DEVICES")
        try:
            error="Must specify a board ipaddress"
            boardip=str(self.boardip.record)
            error=None
            error="Must specify active chans as int in (8,16,32)"
            active_chans = int(self.active_chans)
            error=None
            if active_chans not in (8,16,32) :
                print "active chans must be in (8, 16, 32)"
                active_chans = 32
            error="Trig source must be a string"
            trig_src = str(self.trig_src.record)[-3:] #NEW
            #print "trig_src :", trig_src
            #trig_src=self.trig_src.record.getOriginalPartName().getString()[1:]
            error=None
            if debug:
                print "trig_src is %s\n" % trig_src
            if not trig_src in self.trig_sources:
                raise Exception, "Trig_src must be in %s" % str(self.trig_sources)
            error='Trig edge must be a string'
            trig_edge=self.trig_edge.record.getString()
            #print "trig_edge:", trig_edge
            error=None
            error="Clock source must be a string"
            #clock_src=self.clock_src.record.getOriginalPartName().getString()[1:]
            clock_src = str(self.clock_src.record)[-3:] #NEW
            #print "clock_src:",clock_src
            error=None
            if debug:
                print "clock_src is %s\n" % clock_src
            if not clock_src in self.clock_sources:
                raise Exception, "Clock_src must be in %s" % str(self.clock_sources)
            if (clock_src == 'INT_CLOCK'):
                error="Must specify a frequency for internal clock"
                clock_freq = int(self.clock_freq)
                error=None
            else:
                error="Must specify a frequency for external clock"
                clock_freq = int(self.clock_freq)
                error="Must specify a divisor for external clock"
                clock_div = int(self.clock_div)
                error=None
            error="Must specify pre trigger samples"
            pre_trig=int(self.pre_trig.data()*1024)
            error="Must specify post trigger samples"
            post_trig=int(self.post_trig.data()*1024)
            #print "connecting to board ip:", boardip
            error="Unable to connect to digitiser - is it on??"
            start_time = time.time()
            UUT = acq200.Acq200(transport.factory(boardip))
            UUT.set_abort()
            UUT.clear_routes()
            #print 'make UUT :', time.time() - start_time
            #start_time = time.time()
            error=None
            #print "connected"
            for i in range(6):
                line = 'd%1.1d' % i
                try:
                    wire = str(self.__getattr__('di%1.1d_wire'%i).record)
                    if wire not in self.wires :
                        print "DI%d:wire must be in %s" % (i, str(self.wires), )
                        wire = 'fpga'
                except:
                    wire = 'fpga'
                try:
                    bus = str(self.__getattr__('di%1.1d_bus'%i).record)
                    if bus not in self.wires :
                        print "DI%d:bus must be in %s" % (i, str(self.wires),)
                        bus = ''
                except:
                    bus = ''
                UUT.set_route(line, 'in %s out %s' % (wire, bus,))
                #print 'set_route', line, wire, bus
            #print 'make setup lines :', time.time() - start_time
            #start_time = time.time()
            UUT.setChannelCount(active_chans)
            #print "set active channels:", active_chans

            #SHAUN EDIT FOR FAST DTACQ
            if os.getenv('DTACQFAST')=='YES16' and boardip=='192.168.1.9':
                UUT.uut.acq2sh('set.channelSpeedMask 80008000000000008000800000000000')
                print 'FAST SPEED MASK 1'
            if os.getenv('DTACQFAST')=='YES32' and boardip=='192.168.1.9':
                UUT.uut.acq2sh('set.channelSpeedMask G000000000000000G000000000000000')
                print 'FAST SPEED MASK 2'



            if clock_src == 'INT_CLOCK' :
                print "INT_CLOCK"
                #UUT.uut.acqcmd("setInternalClock %d" % clock_freq) - SHAUN ALTERATION (two commands below)
                UUT.uut.acqcmd("setInternalClock %d DO1" % clock_freq)
                UUT.uut.acqcmd("-- setDIO -1-----")
            #SHAUN EDIT FOR FAST DTACQ
            elif os.getenv('DTACQFAST')=='YES16' and boardip=='192.168.1.9':
                 UUT.uut.acqcmd("-- setExternalClock --fin %d --fout %d DI0" % (1000, 16000,)) #SHAUN TEMPORARY EXT CLOCK TEST!!!
            elif os.getenv('DTACQFAST')=='YES32' and boardip=='192.168.1.9':
                 UUT.uut.acqcmd("-- setExternalClock --fin %d --fout %d DI0" % (1000, 32000,)) #SHAUN TEMPORARY EXT CLOCK TEST!!!
            else:
                print 'clock external'
                #UUT.uut.acqcmd("-- setExternalClock --fin %d --fout %d DI0" % (clock_freq/1000, clock_freq/1000,))- SHAUN ALTERATION
                #UUT.uut.acqcmd("-- setExternalClock --fin %d --fout %d DI1" % (clock_freq/1000, clock_freq/1000,))
                UUT.uut.acqcmd("-- setExternalClock --fin %d --fout %d DI0" % (1000, 2000,)) #SHAUN TEMPORARY EXT CLOCK TEST!!!
                print "-- setExternalClock --fin %d --fout %d DI0" % (1000, 2000,)


            if os.getenv('DTACQFAST')=='YES16' and boardip=='192.168.1.9':
                pre_trig=pre_trig*8
                post_trig=post_trig*8
            if os.getenv('DTACQFAST')=='YES32' and boardip=='192.168.1.9':
                pre_trig=pre_trig*16
                post_trig=post_trig*16

            #print "prePostMode:", pre_trig, post_trig, trig_src,trig_edge
            UUT.setPrePostMode(pre_trig, post_trig, trig_src, trig_edge)
            #print 'everything else :', time.time() - start_time
            #start_time = time.time()

            UUT.set_arm()
            #print 'arm :', time.time() - start_time
            #start_time = time.time()
            print 'armed'
            # UUT.uut.acq.p.sendline('bye')
            # UUT.uut.sh.p.sendline('bye')
            # UUT.uut.statemon.sendline('bye')
            # print 'hello'

            # print UUT.uut.acq.p.isalive()
            # print 'blah'
            # UUT.uut.acq.p.close()
            # print 'finished 1'
            # time_mod.sleep(10)
            # UUT.uut.sh.p.close()
            # print 'finished 2'
            # time_mod.sleep(10)
            # UUT.uut.statemon.close()

            # UUT.uut.acq.p.sendline('bye')
            # UUT.uut.sh.p.sendline('bye')
            # UUT.uut.statemon.sendline('bye')
            # print 'sleeping'
            # import time as time_mod
            # time_mod.sleep(10)
            # print 'blah'
            # import pexpect
            # UUT.uut.acq.p.expect(pexpect.EOF)
            # print 'blah2'

            # #UUT.uut.acq.p.flush()
            # print 'close acq'
            # print 'close acq'
            # del UUT.uut.acq.p
            # #UUT.uut.acq.p.close(False)
            # print 'close acq'
            # #UUT.uut.sh.p.close()
            # print 'close sh'
            # #UUT.uut.statemon.close()
            # print 'close statemon'
            return  1

        except Exception,e:
            print 'some kind of error'
            if error is not None:
                e=error
            print "%s\n" % (str(e),)
            raise RuntimeError('!!! EXCEPTION - %s'%(str(e)))
            return 0
Exemple #15
0
    def init(self, arg):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """

        debug=os.getenv("DEBUG_DEVICES")
        try:
            boardip=self.check( 'str(self.boardip.record)', "Must specify a board ipaddress")
            UUT = acq200.Acq200(transport.factory(boardip))
            active_chans = self.check("int(self.active_chans)", "Must specify active chans as int in (2, 4, 8, 16)")
            if active_chans not in (2,4,8,16) :
                print "active chans must be in (2, 4,8, 16 )"
                active_chans = 16
            trig_src=self.check('self.trig_src.record.getOriginalPartName().getString()[1:]', "Trig source must be a string")
            print "trig_src is %s\n" % trig_src
            if not trig_src in self.trig_sources:
                raise Exception, "Trig_src must be in %s" % str(self.trig_sources)
            trig_edge=self.check('self.trig_edge.record.getString()', 'Trig edge must be a string')
            clock_src=self.check('self.clock_src.record.getOriginalPartName().getString()[1:]', "Clock source must be a string")
            if debug:
                print "clock_src is %s\n" % clock_src
            if not clock_src in self.clock_sources:
                raise Exception, "Clock_src must be in %s" % str(self.clock_sources)
            if clock_src == 'INT_CLOCK' or clock_src == 'MASTER':
                clock_freq = self.check('int(self.clock_freq)', "Must specify a frequency for internal clock")
            else:
                clock_freq = self.check('int(self.clock_freq)', "Must specify a frequency for external clock")                
                clock_div = self.check('int(self.clock_div)', "Must specify a divisor for external clock")
            pre_trig=self.check('int(self.pre_trig.data()*1024)', "Must specify pre trigger samples")
            post_trig=self.check('int(self.post_trig.data()*1024)', "Must specify post trigger samples")
            UUT.set_abort()
            UUT.clear_routes()
            
            for i in range(6):
                line = 'd%1.1d' % i
                try:
                    wire = eval('str(self.di%1.1d_wire.record)' %i)
                    if wire not in self.wires :
                        print "DI%d:wire must be in %s" % (i, str(self.wires), )
                        wire = 'fpga'
                except:
                    wire = 'fpga'
                try:
                    bus = eval('str(self.di%1.1d_bus.record)' % i)
                    if bus not in self.wires :
                        print "DI%d:bus must be in %s" % (i, str(self.wires),)
                        bus = ''
                except:
                    bus = ''
                UUT.set_route(line, 'in %s out %s' % (wire, bus,))
            UUT.setChannelCount(active_chans)

            if clock_src == 'INT_CLOCK' or clock_src == 'MASTER' :
                UUT.uut.acqcmd("setInternalClock %d DO1" % clock_freq)
		if clock_src == 'MASTER' :
		    UUT.uut.acqcmd('-- setDIO -1-----')
            else:
		UUT.uut.acqcmd("setExternalClock %s" % clock_src)
            UUT.setPrePostMode(pre_trig, post_trig)
            mask = UUT.uut.acqcmd('getChannelMask').split('=')[-1]
            UUT.set_arm() 
            return  1

        except Exception,e:
            print "%s\n" % (str(e),)
            return 0
Exemple #16
0
    def init(self, arg):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """

        debug = os.getenv("DEBUG_DEVICES")
        try:
            error = "Must specify a board ipaddress"
            boardip = str(self.boardip.record)
            error = None
            error = "Must specify active chans as int in (8,16,32)"
            active_chans = int(self.active_chans)
            error = None
            if active_chans not in (8, 16, 32):
                print "active chans must be in (8, 16, 32)"
                active_chans = 32
            error = "Trig source must be a string"
            trig_src = self.trig_src.record.getOriginalPartName().getString(
            )[1:]
            error = None
            if debug:
                print "trig_src is %s\n" % trig_src
            if not trig_src in self.trig_sources:
                raise Exception, "Trig_src must be in %s" % str(
                    self.trig_sources)
            error = 'Trig edge must be a string'
            trig_edge = self.trig_edge.record.getString()
            error = None
            error = "Clock source must be a string"
            clock_src = self.clock_src.record.getOriginalPartName().getString(
            )[1:]
            error = None
            if debug:
                print "clock_src is %s\n" % clock_src
            if not clock_src in self.clock_sources:
                raise Exception, "Clock_src must be in %s" % str(
                    self.clock_sources)
            if (clock_src == 'INT_CLOCK'):
                error = "Must specify a frequency for internal clock"
                clock_freq = int(self.clock_freq)
                error = None
            else:
                error = "Must specify a frequency for external clock"
                clock_freq = int(self.clock_freq)
                error = "Must specify a divisor for external clock"
                clock_div = int(self.clock_div)
                error = None
            error = "Must specify pre trigger samples"
            pre_trig = int(self.pre_trig.data() * 1024)
            error = "Must specify post trigger samples"
            post_trig = int(self.post_trig.data() * 1024)
            UUT = acq200.ACQ200(transport.factory(boardip))
            UUT.set_abort()
            UUT.clear_routes()

            for i in range(6):
                line = 'd%1.1d' % i
                try:
                    wire = str(self.__getattr__('di%1.1d_wire' % i).record)
                    if wire not in self.wires:
                        print "DI%d:wire must be in %s" % (
                            i,
                            str(self.wires),
                        )
                        wire = 'fpga'
                except:
                    wire = 'fpga'
                try:
                    bus = str(self.__getattr__('di%1.1d_bus' % i).record)
                    if bus not in self.wires:
                        print "DI%d:bus must be in %s" % (
                            i,
                            str(self.wires),
                        )
                        bus = ''
                except:
                    bus = ''
                UUT.set_route(line, 'in %s out %s' % (
                    wire,
                    bus,
                ))
            UUT.setChannelCount(active_chans)

            if clock_src == 'INT_CLOCK':
                UUT.uut.acqcmd("setInternalClock %d" % clock_freq)
            else:
                UUT.uut.acqcmd("-- setExternalClock --fin %d --fout %d DI0" % (
                    clock_freq / 1000,
                    clock_freq / 1000,
                ))
            UUT.setPrePostMode(pre_trig, post_trig, trig_src, trig_edge)
            UUT.set_arm()
            return 1

        except Exception, e:
            if error is not None:
                e = error
            print "%s\n" % (str(e), )
            return 0
Exemple #17
0
    def store(self, arg):
        """
        Store the data from the device
        Fetch and store the device status (firmware etc)
        If the device is finished
        For each channel that is on and active in the mask
        read the data
        store the data into the raw nodes
        store the expression into the data nodes
        """


        debug=os.getenv("DEBUG_DEVICES")
        try:
            boardip=self.check( 'str(self.boardip.record)', "Must specify a board ipaddress")
            UUT = acq200.Acq200(transport.factory(boardip))
            try:
                ans = []
                cmds = self.status_cmds.record
                for cmd in cmds:
                    print cmd
                    a = UUT.uut.acq2sh(cmd)
                    ans.append(a)
                self.board_status.record = Data.compile('build_signal($,*, $)', ans, cmds)
            except Exception, e:
                pass

            complete = 0
            tries = 0
	    if UUT.get_state().split()[-1] == "ST_RUN" :
		raise Exception, "Device not Triggered \n device returned -%s-" % UUT.get_state().split()[-1]
            if debug:
                print "about to get the vins\n"
            vins = self.getVins(UUT)
            self.ranges.record = vins
            (tot, pre, post, run) = UUT.get_numSamples()
            pre = int(pre)
            post = int(post)
            mask = UUT.uut.acqcmd('getChannelMask').split('=')[-1]
            if debug:
                print "pre = %d, post = %d" % (pre, post, )
            clock_src=self.check('self.clock_src.record.getOriginalPartName().getString()[1:]', "Clock source must be a string") 
            if clock_src == 'INT_CLOCK' or clock_src == 'MASTER' :
                self.clock.record = Range(delta=1./self.getInternalClock(UUT))
            else:
                self.clock.record = self.clock_src

            clock = self.clock.record
            if debug:
                print "about to start the script"

            (fd,fname) = mkstemp('.sh')
            f=open(fname, 'w')
            f.write("#!/bin/sh\n")
            f.write("touch /tmp/starting_%d\n" % self.boardip.tree.shot)
	    f.write("acqcmd --until ST_STOP\n")
            f.write("mdsConnect %s\n" %str(self.hostip.record))
            cmd = "mdsValue \"job_start('%s', %d)\"" % (self.path, self.tree.shot)
            cmd = cmd.replace('\\', '\\\\\\\\\\\\\\')
	    f.write("%s\n"%( cmd,))
            f.write("mdsOpen %s %d\n" % (self.boardip.tree.name, self.boardip.tree.shot,))
            for chan in range(16) :
                chan_node = eval('self.input_%2.2d' % (chan+1,))
                chan_raw_node = eval('self.input_%2.2d_raw' % (chan+1,))
                if chan_node.on :
                    if debug:
                        print "it is on so ..."
                    if mask[chan:chan+1] == '1' :
                        try:
			    start =  eval("int(self.input_%2.2d_start_idx)"%(chan+1))
                        except:
                            start = pre
                        try:
			    end =  eval("int(self.input_%2.2d_end_idx)"%(chan+1))
                        except:
                            end = post
                        try:
			    inc =  eval("int(self.input_%2.2d_inc)"%(chan+1))
                        except:
                            inc = 1
                        if debug:
                            print "build the command"
                        command = "mdsPutCh --field %s:raw --expr %%calsig --timebase %d,%d,%d %d\n" % (chan_node.getFullPath(), int(start), int(end-start+1), int(inc), chan+1)
                        command = command.replace('\\','\\\\')
                        if debug:
                            print "about to execute %s" % command
			f.write(command)
                        if inc > 1 :
                            clk=None
                            delta=None
                            begin=None
                            ending=None
                            try :
                                clk = self.clock.evaluate()
                                delta = clk.delta
                                begin = clk.begin
                                ending = clk.ending
                            except:
                                pass
                            if delta :
                                axis = Range(begin, ending, delta*inc)
                                window = Window(start/inc, end/inc, self.trig_src)
                                dim = Dimension(window, axis)
                            else:
                                dim = Data.compile('Map($,$)', Dimension(Window(start/inc, end/inc, trig_src), clock), Range(start, end, inc))
                            raw = Data.compile('data($)', chan_raw_node)
                            chan_node.record = eval('Signal(raw, "", dim)')
                        else:
                            raw = Data.compile('data($)', chan_raw_node)
                            chan_node.record = Signal(raw, "", Dimension(Window(start, end, self.trig_src), clock))
	    f.write('mdsClose %s\n' % (self.boardip.tree.name,))
            f.write("touch /tmp/finished_%d\n" % self.boardip.tree.shot)
            cmd = "mdsValue \"job_finish('%s', %d)\"" % (self.path, self.tree.shot)
            cmd = cmd.replace('\\', '\\\\\\\\\\\\\\')
            f.write("%s\n"%( cmd,))
	    f.write("rm $0\n")
            f.close()
            cmd = 'curl -s -T %s ftp://%s/%s' %(fname, boardip, 'post_shot.sh')
            pipe = os.popen(cmd)
            pipe.close()
	    UUT.uut.acq2sh("chmod a+rx /home/ftp/post_shot.sh")
	    UUT.uut.acq2sh("/home/ftp/post_shot.sh&")
Exemple #18
0
    def init(self, arg):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """

        debug=os.getenv("DEBUG_DEVICES")
        try:
            error="Must specify a board ipaddress"
            boardip=str(self.boardip.record)
            error=None
            error="Must specify active chans as int in (8,16,32)"
            active_chans = int(self.active_chans)
            error=None
            if active_chans not in (8,16,32) :
                print "active chans must be in (8, 16, 32)"
                active_chans = 32
            error="Trig source must be a string"
            trig_src=self.trig_src.record.getOriginalPartName().getString()[1:]
            error=None
            if debug:
                print "trig_src is %s\n" % trig_src
            if not trig_src in self.trig_sources:
                raise Exception, "Trig_src must be in %s" % str(self.trig_sources)
            error='Trig edge must be a string'
            trig_edge=self.trig_edge.record.getString()
            error=None
            error="Clock source must be a string"
            clock_src=self.clock_src.record.getOriginalPartName().getString()[1:]
            error=None
            if debug:
                print "clock_src is %s\n" % clock_src
            if not clock_src in self.clock_sources:
                raise Exception, "Clock_src must be in %s" % str(self.clock_sources)
            if (clock_src == 'INT_CLOCK'):
                error="Must specify a frequency for internal clock"
                clock_freq = int(self.clock_freq)
                error=None
            else:
                error="Must specify a frequency for external clock"
                clock_freq = int(self.clock_freq)
                error="Must specify a divisor for external clock"
                clock_div = int(self.clock_div)
                error=None
            error="Must specify pre trigger samples"
            pre_trig=int(self.pre_trig.data()*1024)
            error="Must specify post trigger samples"
            post_trig=int(self.post_trig.data()*1024)
            UUT = acq200.Acq200(transport.factory(boardip))
            UUT.set_abort()
            UUT.clear_routes()
            
            for i in range(6):
                line = 'd%1.1d' % i
                try:
                    wire = str(self.__getattr__('di%1.1d_wire'%i).record)
                    if wire not in self.wires :
                        print "DI%d:wire must be in %s" % (i, str(self.wires), )
                        wire = 'fpga'
                except:
                    wire = 'fpga'
                try:
                    bus = str(self.__getattr__('di%1.1d_bus'%i).record)
                    if bus not in self.wires :
                        print "DI%d:bus must be in %s" % (i, str(self.wires),)
                        bus = ''
                except:
                    bus = ''
                UUT.set_route(line, 'in %s out %s' % (wire, bus,))
            UUT.setChannelCount(active_chans)

            if clock_src == 'INT_CLOCK' :
                UUT.uut.acqcmd("setInternalClock %d" % clock_freq)
            else:
                 UUT.uut.acqcmd("-- setExternalClock --fin %d --fout %d DI0" % (clock_freq/1000, clock_freq/1000,))
            UUT.setPrePostMode(pre_trig, post_trig, trig_src, trig_edge)
            UUT.set_arm()
            return  1

        except Exception,e:
            if error is not None:
                e=error
            print "%s\n" % (str(e),)
            return 0