Exemplo n.º 1
0
    def initftp(self, auto_store=None):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """
        import tempfile
        import time
        from MDSplus.mdsExceptions import DevBAD_ACTIVE_CHAN
        from MDSplus.mdsExceptions import DevBAD_TRIG_SRC
        from MDSplus.mdsExceptions import DevBAD_CLOCK_SRC
        from MDSplus.mdsExceptions import DevBAD_PRE_TRIG
        from MDSplus.mdsExceptions import DevBAD_POST_TRIG
        from MDSplus.mdsExceptions import DevBAD_CLOCK_FREQ

        start=time.time()

        if self.debugging():
            print "starting init\n";
        path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot

        active_chan = self.getInteger(self.active_chan, DevBAD_ACTIVE_CHAN)
        if active_chan not in (4,8,16) :
            raise DevBAD_ACTIVE_CHAN()
        if self.debugging():
            print "have active chan\n";

        try:
            trig_src=self.trig_src.record.getOriginalPartName().getString()[1:]
        except Exception, e:
            raise DevBAD_TRIG_SRC(str(e))
Exemplo n.º 2
0
    def initftp(self, auto_store=None):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """
        import tempfile
        import time
        from MDSplus.mdsExceptions import DevBAD_ACTIVE_CHAN
        from MDSplus.mdsExceptions import DevBAD_TRIG_SRC
        from MDSplus.mdsExceptions import DevBAD_CLOCK_SRC
        from MDSplus.mdsExceptions import DevBAD_PRE_TRIG
        from MDSplus.mdsExceptions import DevBAD_POST_TRIG
        from MDSplus.mdsExceptions import DevBAD_CLOCK_FREQ

        start = time.time()
        if self.debugging():
            print("starting init")
        path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot
        if self.debugging():
            print('ACQ132 initftp path = %s tree = %s shot = %d' %
                  (path, tree, shot))

        active_chan = self.getInteger(self.active_chan, DevBAD_ACTIVE_CHAN)
        if active_chan not in (8, 16, 32):
            raise DevBAD_ACTIVE_CHAN()
        if self.debugging():
            print("have active chan")

        try:
            trig_src = str(self.trig_src.record.getOriginalPartName())[1:]
        except Exception as e:
            raise DevBAD_TRIG_SRC(str(e))
        if self.debugging():
            print("have trig_src")

        try:
            clock_src = str(self.clock_src.record.getOriginalPartName())[1:]
        except Exception as e:
            raise DevBAD_CLOCK_SRC(str(e))
        if self.debugging():
            print("have clock src")

        try:
            clock_out = str(self.clock_out.record.getOriginalPartName())[1:]
        except:
            clock_out = None

        pre_trig = self.getInteger(self.pre_trig, DevBAD_PRE_TRIG) * 1024
        if self.debugging():
            print("have pre trig")

        post_trig = self.getInteger(self.post_trig, DevBAD_POST_TRIG) * 1024
        if self.debugging():
            print("have post trig")

        clock_freq = self.getInteger(self.clock_freq, DevBAD_CLOCK_FREQ)
        try:
            clock_div = int(self.clock_div)
        except:
            clock_div = 1

        if self.debugging():
            print("have the settings")
#
# now create the post_shot ftp command file
#
        fd = tempfile.TemporaryFile()
        self.startInitializationFile(fd, trig_src, pre_trig, post_trig)
        if active_chan == 8:
            chan_mask = "11110000000000001111000000000000"
        elif active_chan == 16:
            chan_mask = "11111111000000001111111100000000"
        else:
            chan_mask = "11111111111111111111111111111111"
        fd.write("acqcmd  setChannelMask %s\n" % (chan_mask, ))
        if clock_src == 'INT_CLOCK':
            if clock_out == None:
                if self.debugging():
                    print("internal clock no clock out")
                fd.write("acqcmd setInternalClock %d" % clock_freq)
            else:
                clock_out_num_str = clock_out[-1]
                clock_out_num = int(clock_out_num_str)
                setDIOcmd = 'acqcmd -- setDIO '+'-' * \
                    clock_out_num+'1'+'-'*(6-clock_out_num)+'\n'
                if self.debugging():
                    print("internal clock clock out is %s setDIOcmd = %s" %
                          (clock_out, setDIOcmd))
                fd.write("acqcmd setInternalClock %d DO%s\n" % (
                    clock_freq,
                    clock_out_num_str,
                ))
                fd.write(setDIOcmd)
        else:
            fd.write("acqcmd -- setExternalClock --fin %d --fout %d %s\n" % (
                clock_freq / 1000,
                clock_freq / 1000 * clock_div,
                clock_src,
            ))

        fd.write("set.pre_post_mode %d %d %s %s\n" % (
            pre_trig,
            post_trig,
            trig_src,
            'rising',
        ))

        self.addGenericJSON(fd)

        fd.write("add_cmd 'get.vin 1:32'>> $settingsf\n")
        self.finishJSON(fd, auto_store)

        print("Time to make init file = %g" % (time.time() - start))
        start = time.time()
        self.doInit(fd)
        fd.close()

        print("Time for board to init = %g" % (time.time() - start))
        return 1
Exemplo n.º 3
0
    def initftp(self, auto_store=None):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """
        import tempfile
        import time

        from MDSplus.mdsExceptions import DevBAD_ACTIVE_CHAN
        from MDSplus.mdsExceptions import DevBAD_TRIG_SRC
        from MDSplus.mdsExceptions import DevBAD_CLOCK_SRC
        from MDSplus.mdsExceptions import DevBAD_PRE_TRIG
        from MDSplus.mdsExceptions import DevBAD_POST_TRIG
        from MDSplus.mdsExceptions import DevBAD_CLOCK_FREQ

        start = time.time()
        if self.debugging():
            print("starting init\n")
        path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot
        if self.debugging():
            print('ACQ196 initftp path = %s tree = %s shot = %d\n' %
                  (path, tree, shot))

        active_chan = self.getInteger(self.active_chan, DevBAD_ACTIVE_CHAN)
        if active_chan not in (32, 64, 96):
            raise DevBAD_ACTIVE_CHAN()
        if self.debugging():
            print("have active chan\n")

        try:
            trig_src = str(self.trig_src.record.getOriginalPartName())[1:]
        except Exception as e:
            raise DevBAD_TRIG_SRC(str(e))
        if self.debugging():
            print("have trig_src\n")

        try:
            clock_src = str(self.clock_src.record.getOriginalPartName())[1:]
        except Exception as e:
            raise DevBAD_CLOCK_SRC(str(e))
        if self.debugging():
            print("have clock src\n")

        try:
            clock_out = str(self.clock_out.record.getOriginalPartName())[1:]
        except:
            clock_out = None

        pre_trig = self.getInteger(self.pre_trig, DevBAD_PRE_TRIG) * 1024
        if self.debugging():
            print("have pre trig\n")

        post_trig = self.getInteger(self.post_trig, DevBAD_POST_TRIG) * 1024
        if self.debugging():
            print("have post trig\n")

        if clock_src == "INT_CLOCK":
            clock_freq = self.getInteger(self.clock_freq, DevBAD_CLOCK_FREQ)
        try:
            clock_div = int(self.clock_div)
        except:
            clock_div = 1
        if self.debugging():
            print("have the settings\n")

#
# now create the post_shot ftp command file
#
#            fd = tempfile.TemporaryFile()
        fd = tempfile.NamedTemporaryFile(mode='w+b',
                                         bufsize=-1,
                                         suffix='.tmp',
                                         prefix='tmp',
                                         dir='/tmp',
                                         delete=not self.debugging())
        if self.debugging():
            print('opened temporary file %s\n' % fd.name)
        self.startInitializationFile(fd, trig_src, pre_trig, post_trig)
        fd.write("acqcmd  setChannelMask " + '1' * active_chan + "\n")
        if clock_src == 'INT_CLOCK':
            if clock_out == None:
                if self.debugging():
                    print("internal clock no clock out\n")
                fd.write("acqcmd setInternalClock %d\n" % clock_freq)
            else:
                clock_out_num_str = clock_out[-1]
                clock_out_num = int(clock_out_num_str)
                setDIOcmd = 'acqcmd -- setDIO '+'-' * \
                    clock_out_num+'1'+'-'*(6-clock_out_num)+'\n'
                if self.debugging():
                    print("internal clock clock out is %s setDIOcmd = %s\n" % (
                        clock_out,
                        setDIOcmd,
                    ))
                fd.write("acqcmd setInternalClock %d DO%s\n" % (
                    clock_freq,
                    clock_out_num_str,
                ))
                fd.write(setDIOcmd)
        else:
            if (clock_out != None):
                clock_out_num_str = clock_out[-1]
                clock_out_num = int(clock_out_num_str)
                setDIOcmd = 'acqcmd -- setDIO '+'-' * \
                    clock_out_num+'1'+'-'*(6-clock_out_num)+'\n'
                fd.write("acqcmd setExternalClock %s %d DO%s\n" %
                         (clock_src, clock_div, clock_out_num_str))
                fd.write(setDIOcmd)
            else:
                fd.write("acqcmd setExternalClock %s %d\n" % (
                    clock_src,
                    clock_div,
                ))
#
# set the channel mask 2 times
#
        fd.write("acqcmd  setChannelMask " + '1' * active_chan + "\n")
        fd.write("acqcmd  setChannelMask " + '1' * active_chan + "\n")
        #
        #  set the pre_post mode last
        #
        fd.write("set.pre_post_mode %d %d %s %s\n" % (
            pre_trig,
            post_trig,
            trig_src,
            'rising',
        ))

        self.addGenericJSON(fd)

        fd.write("add_cmd 'get.vin 1:32'>> $settingsf\n")
        fd.write("add_cmd 'get.vin 33:64'>> $settingsf\n")
        fd.write("add_cmd 'get.vin 65:96'>> $settingsf\n")
        self.finishJSON(fd, auto_store)

        print("Time to make init file = %g\n" % (time.time() - start))
        start = time.time()
        self.doInit(fd)

        fd.close()

        print("Time for board to init = %g\n" % (time.time() - start))
        return 1
Exemplo n.º 4
0
    def initftp(self, auto_store=None):
        """
        Initialize the device
        Send parameters
        Arm hardware
        """
        import tempfile
        import time
        from MDSplus.mdsExceptions import DevBAD_ACTIVE_CHAN
        from MDSplus.mdsExceptions import DevBAD_TRIG_SRC
        from MDSplus.mdsExceptions import DevBAD_CLOCK_SRC
        from MDSplus.mdsExceptions import DevBAD_PRE_TRIG
        from MDSplus.mdsExceptions import DevBAD_POST_TRIG
        from MDSplus.mdsExceptions import DevBAD_CLOCK_FREQ

        start = time.time()

        if self.debugging():
            print("starting init\n")
        path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot

        active_chan = self.getInteger(self.active_chan, DevBAD_ACTIVE_CHAN)
        if active_chan not in (4, 8, 16):
            raise DevBAD_ACTIVE_CHAN()
        if self.debugging():
            print("have active chan\n")

        try:
            trig_src = str(self.trig_src.record.getOriginalPartName())[1:]
        except Exception as e:
            raise DevBAD_TRIG_SRC(str(e))
        if self.debugging():
            print("have trig_src\n")

        try:
            clock_src = str(self.clock_src.record.getOriginalPartName())[1:]
        except Exception as e:
            raise DevBAD_CLOCK_SRC(str(e))
        if self.debugging():
            print("have clock src\n")

        try:
            clock_out = str(self.clock_out.record.getOriginalPartName())[1:]
        except:
            clock_out = None

        pre_trig = self.getInteger(self.pre_trig, DevBAD_PRE_TRIG) * 1024
        if self.debugging():
            print("have pre trig\n")

        post_trig = self.getInteger(self.post_trig, DevBAD_POST_TRIG) * 1024
        if self.debugging():
            print("have post trig\n")

        if clock_src == "INT_CLOCK":
            clock_freq = self.getInteger(self.clock_freq, DevBAD_CLOCK_FREQ)
            clock_div = 1
        else:
            try:
                clock_div = int(self.clock_div)
            except:
                clock_div = 1
        if self.debugging():
            print("have the settings\n")

#
# now create the post_shot ftp command file
#
        try:
            fd = tempfile.TemporaryFile()
            self.startInitializationFile(fd, trig_src, pre_trig, post_trig)
            fd.write("acqcmd  setChannelMask " + '1' * active_chan + "\n")
            for chan in range(16):
                vin = self.__getattr__('input_%2.2d_vin' % (chan + 1, ))
                if (vin == 2.5):
                    vin_str = "2.5"
                elif (vin == 4):
                    vin_str = "4"
                elif (vin == 6):
                    vin_str = "6"
                elif (vin == 10):
                    vin_str = "10"
                else:
                    vin_str = "10"
                fd.write("set.vin %d %s\n" % (chan + 1, vin_str))
            if clock_src == 'INT_CLOCK':
                if clock_out == None:
                    if self.debugging():
                        print("internal clock no clock out\n")
                    fd.write("acqcmd setInternalClock %d\n" % clock_freq)
                else:
                    clock_out_num_str = clock_out[-1]
                    clock_out_num = int(clock_out_num_str)
                    setDIOcmd = 'acqcmd -- setDIO '+'-' * \
                        clock_out_num+'1'+'-'*(6-clock_out_num)+'\n'
                    #    force the routing for this clock output
                    #    regardless of the settings for this line
                    #    above
                    setRoutecmd = 'set.route d%1.1d in fpga out pxi\n' % (
                        clock_out_num, )
                    if self.debugging():
                        print(
                            "internal clock clock out is %s setDIOcmd = %s\n" %
                            (
                                clock_out,
                                setDIOcmd,
                            ))
                    fd.write("acqcmd setInternalClock %d DO%s\n" % (
                        clock_freq,
                        clock_out_num_str,
                    ))
                    fd.write(setDIOcmd)
                    fd.write(setRoutecmd)
            else:
                if (clock_out != None):
                    clock_out_num_str = clock_out[-1]
                    clock_out_num = int(clock_out_num_str)
                    setDIOcmd = 'acqcmd -- setDIO '+'-' * \
                        clock_out_num+'1'+'-'*(6-clock_out_num)+'\n'
                    fd.write("acqcmd setExternalClock %s %d DO%s\n" %
                             (clock_src, clock_div, clock_out_num_str))
                    fd.write(setDIOcmd)
                else:
                    fd.write("acqcmd setExternalClock %s\n" % clock_src)
#
# set the channel mask twice as per Peter Milne
#
            fd.write("acqcmd  setChannelMask " + '1' * active_chan + "\n")
            if self.debugging():
                print("routes all set now move on to pre-post\n")
                print("pre trig = %d\n" % (pre_trig, ))
                print("post trig = %d\n" % (post_trig, ))
                print("trig_src = %s\n" % (trig_src, ))
            fd.write("set.pre_post_mode %d %d %s %s\n" % (
                pre_trig,
                post_trig,
                trig_src,
                'rising',
            ))
            if self.debugging():
                print("pre-post all set now the JSON and commands\n")

            self.addGenericJSON(fd)

            fd.write("add_cmd 'get.vin'>> $settingsf\n")
            self.finishJSON(fd, auto_store)

            print("Time to make init file = %g\n" % (time.time() - start))
            start = time.time()

            self.doInit(fd)

        except Exception:
            try:
                fd.close()
            except:
                pass

            raise

        fd.close()

        print("Time for board to init = %g\n" % (time.time() - start))
        return 1