예제 #1
0
    def loadSettings(self):
        settingsfd = tempfile.TemporaryFile()
        ftp = ftplib.FTP(self.getBoardIp())
        ftp.login('dt100', 'dt100')
        ftp.retrlines("RETR /tmp/settings.xml", lambda s, w=settingsfd.write: w(s+"\n"))
        settingsfd.seek(0,0)
        if self.debugging():
            print "got the settings\n"
            
        try :
            settings = load(settingsfd)
        except Exception,e:
            settingsfd.close()
	    raise Exception, "Could not parse XML settings\n%s" %(e,)
예제 #2
0
파일: config.py 프로젝트: timfel/ftlk-stuff
 def load_config(self, win):
     self.configdatei = file(os.environ.get("HOME")+"/.pyflphoto", 'a+')
     try:
         self.configuration = generic.load(self.configdatei)
         #for i in self.configuration["alben"]:
         #    if self.configuration["alben"].count(i) > 1:
         #        self.configuration["alben"].remove(i)
     except:
         self.configuration["alben"] = []
         self.configuration["options"] = {}
         generic.dump(self.configuration, self.configdatei)
     self.configdatei.flush()
     self.configdatei.close()
     self.alben = self.configuration["alben"]
예제 #3
0
    def loadSettings(self):
        settingsfd = tempfile.TemporaryFile()
        ftp = ftplib.FTP(self.getBoardIp())
        ftp.login('dt100', 'dt100')
        ftp.retrlines("RETR /tmp/settings.xml",
                      lambda s, w=settingsfd.write: w(s + "\n"))
        settingsfd.seek(0, 0)
        if self.debugging():
            print "got the settings\n"

        try:
            settings = load(settingsfd)
        except Exception, e:
            settingsfd.close()
            raise Exception, "Could not parse XML settings\n%s" % (e, )
예제 #4
0
def pyxml_marshal():
    try:
        from xml.marshal import generic
    except ImportError:
        # Skip comparison with PyXML's xml.marshal if unavailable
        print("Skipping PyXML xml.marshal")
        return

    f = mk_foo()
    print("CREATE XML (xml.marshal style)")
    t1 = time()
    fh = open('bbb.xml','w')
    x = generic.dump(f,fh)
    fh.close()
    print("TIME = %f"%(time()-t1))
    print("Pickle len = ",os.stat('bbb.xml')[ST_SIZE])

    print("xml.marshal load")
    t1 = time()
    fh = open('bbb.xml','r')
    m = generic.load(fh)
    fh.close()
    print("TIME = %f"%(time()-t1))
    del m
예제 #5
0
def pyxml_marshal():
    try:
        from xml.marshal import generic
    except ImportError:
        # Skip comparison with PyXML's xml.marshal if unavailable
        print "Skipping PyXML xml.marshal"
        return

    f = mk_foo(6)
    print "CREATE XML (xml.marshal style)"
    t1 = time()
    fh = open('bbb.xml','w')
    x = generic.dump(f,fh)
    fh.close()
    print "TIME = %f"%(time()-t1)
    print "Pickle len = ",os.stat('bbb.xml')[ST_SIZE]

    print "xml.marshal load"
    t1 = time()
    fh = open('bbb.xml','r')
    m = generic.load(fh)
    fh.close()
    print "TIME = %f"%(time()-t1)
    del m
예제 #6
0
    def storeftp(self, arg):

        try:
            from xml.marshal.generic import dumps, loads, load
        except:
            print "you must install PyXML to use this deprecated device.  Please switch to acq216 device type"

        debug = os.getenv("DEBUG_DEVICES")

        path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot
        CPCIDataDir = os.getenv('CPCI_DATA_DIR')
        if not CPCIDataDir:
            raise 'CPCI_DATA_DIR environment variable must be defined'
        dataDir = "%s/%s/%s/%s" % (
            CPCIDataDir,
            tree,
            shot,
            path,
        )
        try:
            settingsf = open("%s/settings.xml" % (dataDir, ), "r")
        except:
            raise Exception, "Could not open Settings file %s/settings.xml" % (
                dataDir, )
        try:
            settings = load(settingsf)
        except:
            settingsf.close()
            raise Exception, "Could not parse XML settings"
        settingsf.close()
        if debug:
            print "xml is loaded\n"
        status = []
        cmds = self.status_cmds.record
        for cmd in cmds:
            cmd = cmd.strip()
            if debug:
                print "about to append answer for /%s/\n" % (cmd, )
                print "   which is /%s/\n" % (settings[cmd], )
            status.append(settings[cmd])
            if debug:
                print "%s returned %s\n" % (
                    cmd,
                    settings[cmd],
                )
        if debug:
            print "about to write board_status signal"
        self.board_status.record = Signal(cmds, None, status)

        numSampsStr = settings['getNumSamples']
        preTrig = self.getPreTrig(numSampsStr)
        postTrig = self.getPostTrig(numSampsStr)
        vins = makeArray(
            numpy.array(settings['get.vin'].split(',')).astype('float'))
        self.ranges.record = vins
        chanMask = settings['getChannelMask'].split('=')[-1]
        if self.clock_src.record.lower(
        ) == 'int' or self.clock_src.record.lower() == 'master':
            #intClkStr=settings['getInternalClock'].split()[0].split('=')[1]
            #intClock=int(intClikStr)
            intClock = float(settings['getInternalClock'].split()[1])
            delta = 1. / float(intClock)
        else:
            delta = 0

        trig_src = self.__getattr__(str(self.trig_src.record).lower())
        #
        # now store each channel
        #
        for chan in range(16):
            if debug:
                print "working on channel %d" % chan
            #chan_node = eval('self.input_%2.2d' % (chan+1,))
            chan_node = self.__getattr__('input_%2.2d' % (chan + 1, ))
            if chan_node.on:
                if debug:
                    print "it is on so ..."
                if chanMask[chan:chan + 1] == '1':
                    try:
                        start = max(
                            int(
                                self.__getattr__('input_%2.2d_startidx' %
                                                 (chan + 1, ))), -preTrig)
                    except:
                        start = -preTrig
                    try:
                        end = min(
                            int(
                                self.__getattr__('input_%2.2d_endidx' %
                                                 (chan + 1, ))), postTrig - 1)
                    except:
                        end = postTrig - 1
                    try:
                        inc = max(
                            int(
                                self.__getattr__('input_%2.2d_inc' %
                                                 (chan + 1, ))), 1)
                    except:
                        inc = 1
#
# could do the coeffs
#
                    chanFileName = "%s/%2.2d" % (
                        dataDir,
                        chan + 1,
                    )
                    buf = self.readRawData(chanFileName, preTrig, start, end,
                                           inc)
                    if delta != 0:
                        axis = Range(None, None, delta / inc)
                    else:
                        #clockExpr = 'self.%s'% str(self.clock_src.record)
                        #clock_src = eval(clockExpr.lower())
                        clock_src = self.__getattr__(
                            str(self.clock_src.record).lower())
                        axis = clock_src

                    if inc == 1:
                        dim = Dimension(Window(start, end, trig_src), axis)
                    else:
                        dim = Data.compile(
                            'Map($,$)',
                            Dimension(Window(start / inc, end / inc, trig_src),
                                      axis), Range(start, end, inc))
#                    dat = Data.compile('build_signal(build_with_units( $*(0. + $value), "V") ,build_with_units($,"Counts"),$)', coefficent, buf,dim)
                    dat = Data.compile(
                        '_v0=$, _v1=$, build_signal(build_with_units(( _v0+ (_v1-_v0)*($value - -32768)/(32767 - -32768 )), "V") ,build_with_units($,"Counts"),$)',
                        vins[chan * 2], vins[chan * 2 + 1], buf, dim)
                    exec('c=self.input_' + '%02d' % (chan + 1, ) +
                         '.record=dat')
        return 1
예제 #7
0
    def storeftp(self, arg):

        try:
            from xml.marshal.generic import dumps, loads, load
        except:
            print(
                "you must install PyXML to use this deprecated device.  Please switch to acq216 device type"
            )

        debug = self.debug

        path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot
        CPCIDataDir = os.getenv('CPCI_DATA_DIR')
        if not CPCIDataDir:
            raise 'CPCI_DATA_DIR environment variable must be defined'
        dataDir = "%s/%s/%s/%s" % (
            CPCIDataDir,
            tree,
            shot,
            path,
        )
        try:
            settingsf = open("%s/settings.xml" % (dataDir, ), "r")
        except:
            raise Exception("Could not open Settings file %s/settings.xml" %
                            (dataDir, ))
        try:
            settings = load(settingsf)
        except:
            settingsf.close()
            raise Exception("Could not parse XML settings")
        settingsf.close()
        numSampsStr = settings['getNumSamples']
        preTrig = self.getPreTrig(numSampsStr)
        postTrig = self.getPostTrig(numSampsStr)
        #        vins = makeArray(numpy.array(settings['get.vin'].split(',')).astype('float'))
        range_strs = settings['getVoltsRange'].split()[1].split('=')[1].split(
            ',')
        range_strs[0] = range_strs[0][:-1]
        range_strs[1] = range_strs[1][:-1]
        vins = makeArray(numpy.array(range_strs).astype('float32'))
        coefficent = (vins[1] - vins[0]) / (2**16 - 1)
        chanMask = settings['getChannelMask'].split('=')[-1]
        if not 'ACTIVE' in settings['get.ext_clk']:
            #intClkStr=settings['getInternalClock'].split()[0].split('=')[1]
            #intClock=int(intClikStr)
            intClock = float(settings['getInternalClock'].split()[1])
            delta = 1. / float(intClock)
        else:
            delta = 0

        #trigExpr = 'self.%s'% str(self.trig_src.record)
        #trig_src = eval(trigExpr.lower())
        trig_src = self.__getattr__(str(self.trig_src.record).lower())
        #
        # now store each channel
        #
        for chan in range(16):
            if debug:
                print("working on channel %d" % chan)
            #chan_node = eval('self.input_%2.2d' % (chan+1,))
            chan_node = self.__getattr__('input_%2.2d' % (chan + 1, ))
            if chan_node.on:
                if debug:
                    print("it is on so ...")
                if chanMask[chan:chan + 1] == '1':
                    try:
                        #start = max(eval('int(self.input_%2.2d:start_idx)'%(chan+1,)), preTrig)
                        start = max(
                            int(
                                self.__getattr__('input_%2.2d_startidx' %
                                                 (chan + 1, ))), -preTrig)
                    except:
                        start = -preTrig
                    try:
                        #end = min(eval('int(self.input_%2.2d:end_idx)'%(chan+1,)), postTrig)
                        end = min(
                            int(
                                self.__getattr__('input_%2.2d_endidx' %
                                                 (chan + 1, ))), postTrig - 1)
                    except:
                        end = postTrig - 1
                    try:
                        #inc =  max(eval('int(self.input_%2.2d:inc)'%(chan+1,)), 1)
                        inc = max(
                            int(
                                self.__getattr__('input_%2.2d_inc' %
                                                 (chan + 1, ))), 1)
                    except:
                        inc = 1
#
# could do the coeffs
#
                    chanFileName = "%s/%2.2d" % (
                        dataDir,
                        chan + 1,
                    )
                    buf = self.readRawData(chanFileName, preTrig, start, end,
                                           inc)
                    #                    try:
                    #                        buf = self.readRawData(chanFileName, start, end, inc)
                    #                    except:
                    #                        print "Error Reading Channel %d"%(chan+1,)
                    if delta != 0:
                        axis = Range(None, None, delta / inc)
                    else:
                        #clockExpr = 'self.%s'% str(self.clock_src.record)
                        #clock_src = eval(clockExpr.lower())
                        clock_src = self.__getattr__(
                            str(self.clock_src.record).lower())
                        axis = clock_src

                    if inc == 1:
                        dim = Dimension(Window(start, end, trig_src), axis)
                    else:
                        dim = Data.compile(
                            'Map($,$)',
                            Dimension(Window(start / inc, end / inc, trig_src),
                                      axis), Range(start, end, inc))
                    dat = Data.compile(
                        'build_signal(build_with_units( $*(0. + $value), "V") ,build_with_units($,"Counts"),$)',
                        coefficent, buf, dim)
                    exec('c=self.input_' + '%02d' % (chan + 1, ) +
                         '.record=dat')
        return 1
예제 #8
0
    def storeftp(self, arg):

        try:
            from xml.marshal.generic import load
        except:
            print "you must install PyXML to use this deprecated device.  Please switch to acq216 device type"

 	path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot
        CPCIDataDir = os.getenv('CPCI_DATA_DIR')
	if not CPCIDataDir:
	    raise 'CPCI_DATA_DIR environment variable must be defined'
        dataDir="%s/%s/%s/%s"%(CPCIDataDir, tree, shot, path,)
        try :
	    settingsf = open("%s/settings.xml"%(dataDir,), "r")
	except :
	    raise Exception,"Could not open Settings file %s/settings.xml"%(dataDir,)
        try :
            settings = load(settingsf)
        except:
            settingsf.close()
	    raise Exception, "Could not parse XML settings"
        settingsf.close()
	if self.debugging() :
	    print "xml is loaded\n"
        status = []
        cmds = self.status_cmds.record
        for cmd in cmds:
	    cmd = cmd.strip()
	    if self.debugging():
		print "about to append answer for /%s/\n" % (cmd,)
		print "   which is /%s/\n" %(settings[cmd],)
	    status.append(settings[cmd])
	    if self.debugging():
		print "%s returned %s\n" % (cmd, settings[cmd],)
	if self.debugging():
	    print "about to write board_status signal"
	self.board_status.record = MDSplus.Signal(cmds, None, status)

        numSampsStr = settings['getNumSamples']
	preTrig = self.getPreTrig(numSampsStr)
        postTrig = self.getPostTrig(numSampsStr)
        if self.debugging():
            print "got preTrig %d and postTrig %d\n" % (preTrig, postTrig,)
        vins = MDSplus.makeArray(numpy.array(settings['get.vin'].split(',')).astype('float'))
        if self.debugging:
            print "got the vins "
            print vins
	self.ranges.record = MDSplus.makeArray(numpy.array(settings['get.vin'].split(',')).astype('float'))
        chanMask = settings['getChannelMask'].split('=')[-1]
        if self.debugging():
            print "chan_mask = %s\n" % (chanMask,)
        clock_src=str(self.clock_src.record.getOriginalPartName())[1:]
        if self.debugging():
            print "clock_src = %s\n" % (clock_src,)
        if clock_src == 'INT_CLOCK' :
	    intClock = float(settings['getInternalClock'].split()[1])
            delta=1./float(intClock)
            self.clock.record = MDSplus.Range(None, None, delta)
        else:
            self.clock.record = self.clock_src

        clock = self.clock.record
#
# now store each channel
#
	for chan in range(16):
	    if self.debugging():
		print "working on channel %d" % chan
            chan_node = self.__getattr__('input_%2.2d' % (chan+1,))
            if chan_node.on :
                if self.debugging():
                    print "it is on so ..."
                if chanMask[chan:chan+1] == '1' :
                    try:
                        start = max(int(self.__getattr__('input_%2.2d_startidx'%(chan+1,))),-preTrig)
                    except:
                        start = -preTrig
                    try:
			end = min(int(self.__getattr__('input_%2.2d_endidx'%(chan+1,))),postTrig-1)
                    except:
                        end = postTrig-1
                    try:
                        inc = max(int(self.__getattr__('input_%2.2d_inc'%(chan+1,))),1)
                    except:
                        inc = 1
#
# could do the coeffs
#
		    chanFileName="%s/%2.2d"%(dataDir, chan+1,)
                    if self.debugging():
			print "about to readRawData(%s, preTrig=%d, start=%d, end=%d, inc=%d)" % (chanFileName, preTrig, start, end, inc)
                    buf = self.readRawData(chanFileName, preTrig, start, end, inc)
		    if inc == 1:
			dim = MDSplus.Dimension(MDSplus.Window(start, end, self.trig_src ), clock)
                    else:
			dim = MDSplus.Data.compile('Map($,$)', MDSplus.Dimension(MDSplus.Window(start/inc, end/inc, self.trig_src), clock), MDSplus.Range(start, end, inc))
		    dat = MDSplus.Data.compile(
                        '_v0=$, _v1=$, build_signal(build_with_units(( _v0+ (_v1-_v0)*($value - -32768)/(32767 - -32768 )), "V") ,build_with_units($,"Counts"),$)',
                        vins[chan*2], vins[chan*2+1], buf,dim)
                    exec('c=self.input_'+'%02d'%(chan+1,)+'.record=dat')
	return 1
예제 #9
0
파일: dt196a.py 프로젝트: LucyScott/mdsplus
    def storeftp(self, arg):

        debug=os.getenv("DEBUG_DEVICES")

 	path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot
        CPCIDataDir = os.getenv('CPCI_DATA_DIR')
	if not CPCIDataDir:
	    raise 'CPCI_DATA_DIR environment variable must be defined'
        dataDir="%s/%s/%s/%s"%(CPCIDataDir, tree, shot, path,)
        try :
	    settingsf = open("%s/settings.xml"%(dataDir,), "r")
	except :
	    raise Exception,"Could not open Settings file %s/settings.xml"%(dataDir,)
        try :
            settings = load(settingsf)
        except:
            settingsf.close()
	    raise Exception, "Could not parse XML settings"
        settingsf.close()
	if debug :
	    print "xml is loaded\n"
        status = []
        cmds = self.status_cmds.record
        for cmd in cmds:
	    cmd = cmd.strip()
	    if debug:
		print "about to append answer for /%s/\n" % (cmd,)
		print "   which is /%s/\n" %(settings[cmd],)
	    status.append(settings[cmd])
	    if debug:
		print "%s returned %s\n" % (cmd, settings[cmd],)
	if debug:
	    print "about to write board_status signal"
	self.board_status.record = Signal(cmds, None, status)

        numSampsStr = settings['getNumSamples']
	preTrig = self.getPreTrig(numSampsStr)
        postTrig = self.getPostTrig(numSampsStr)
        vins = makeArray(numpy.array(settings['get.vin'].split(',')).astype('float'))
	self.ranges.record = vins
        chanMask = settings['getChannelMask'].split('=')[-1]
	if self.clock_src.record.lower() == 'int' or self.clock_src.record.lower() == 'master':
	    #intClkStr=settings['getInternalClock'].split()[0].split('=')[1]
            #intClock=int(intClikStr)
	    intClock = float(settings['getInternalClock'].split()[1])
            delta=1./float(intClock)
	else:
	    delta = 0
        
        trig_src = self.__getattr__(str(self.trig_src.record).lower())
#
# now store each channel
#
	for chan in range(96):
	    if debug:
		print "working on channel %d" % chan
	    #chan_node = eval('self.input_%2.2d' % (chan+1,))
            chan_node = self.__getattr__('input_%2.2d' % (chan+1,))
            if chan_node.on :
                if debug:
                    print "it is on so ..."
                if chanMask[chan:chan+1] == '1' :
                    try:
                        start = max(int(self.__getattr__('input_%2.2d_startidx'%(chan+1,))),-preTrig)
                    except:
                        start = -preTrig
                    try:
			end = min(int(self.__getattr__('input_%2.2d_endidx'%(chan+1,))),postTrig-1)
                    except:
                        end = postTrig-1
                    try:
                        inc = max(int(self.__getattr__('input_%2.2d_inc'%(chan+1,))),1)
                    except:
                        inc = 1
#
# could do the coeffs
#
		    chanFileName="%s/%2.2d"%(dataDir, chan+1,)
                    buf = self.readRawData(chanFileName, preTrig, start, end, inc)
		    if delta != 0 :
			axis = Range(None, None, delta/inc)
		    else:
			#clockExpr = 'self.%s'% str(self.clock_src.record)
			#clock_src = eval(clockExpr.lower())
                        clock_src = self.__getattr__(str(self.clock_src.record).lower())
                        axis = clock_src

		    if inc == 1:
			dim = Dimension(Window(start, end, trig_src ), axis)
                    else:
			dim = Data.compile('Map($,$)', Dimension(Window(start/inc, end/inc, trig_src), axis), Range(start, end, inc))
#                    dat = Data.compile('build_signal(build_with_units( $*(0. + $value), "V") ,build_with_units($,"Counts"),$)', coefficent, buf,dim) 
		    dat = Data.compile('_v0=$, _v1=$, build_signal(build_with_units(( _v0+ (_v1-_v0)*($value - -32768)/(32767 - -32768 )), "V") ,build_with_units($,"Counts"),$)', vins[chan*2], vins[chan*2+1], buf,dim) 
                    exec('c=self.input_'+'%02d'%(chan+1,)+'.record=dat')
	return 1
예제 #10
0
파일: dt216.py 프로젝트: LucyScott/mdsplus
    def storeftp(self, arg):

        debug=os.getenv("DEBUG_DEVICES")

 	path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot
        CPCIDataDir = os.getenv('CPCI_DATA_DIR')
	if not CPCIDataDir:
	    raise 'CPCI_DATA_DIR environment variable must be defined'
        dataDir="%s/%s/%s/%s"%(CPCIDataDir, tree, shot, path,)
        try :
	    settingsf = open("%s/settings.xml"%(dataDir,), "r")
	except :
	    raise Exception,"Could not open Settings file %s/settings.xml"%(dataDir,)
        try :
            settings = load(settingsf)
        except:
            settingsf.close()
	    raise Exception, "Could not parse XML settings"
        settingsf.close()
        numSampsStr = settings['getNumSamples']
	preTrig = self.getPreTrig(numSampsStr)
        postTrig = self.getPostTrig(numSampsStr)
#        vins = makeArray(numpy.array(settings['get.vin'].split(',')).astype('float'))
        range_strs = settings['getVoltsRange'].split()[1].split('=')[1].split(',')
	range_strs[0] = range_strs[0][:-1]
	range_strs[1] = range_strs[1][:-1]
        vins = makeArray(numpy.array(range_strs).astype('float32'))
        coefficent = (vins[1]-vins[0])/(2**16-1)
        chanMask = settings['getChannelMask'].split('=')[-1]
	if not 'ACTIVE' in settings['get.ext_clk'] :
	    #intClkStr=settings['getInternalClock'].split()[0].split('=')[1]
            #intClock=int(intClikStr)
	    intClock = float(settings['getInternalClock'].split()[1])
            delta=1./float(intClock)
	else:
	    delta = 0
        
        #trigExpr = 'self.%s'% str(self.trig_src.record)
        #trig_src = eval(trigExpr.lower())
        trig_src = self.__getattr__(str(self.trig_src.record).lower())
#
# now store each channel
#
	for chan in range(16):
	    if debug:
		print "working on channel %d" % chan
	    #chan_node = eval('self.input_%2.2d' % (chan+1,))
            chan_node = self.__getattr__('input_%2.2d' % (chan+1,))
            if chan_node.on :
                if debug:
                    print "it is on so ..."
                if chanMask[chan:chan+1] == '1' :
                    try:
			#start = max(eval('int(self.input_%2.2d:start_idx)'%(chan+1,)), preTrig)
                        start = max(int(self.__getattr__('input_%2.2d_startidx'%(chan+1,))),-preTrig)
                    except:
                        start = -preTrig
                    try:
                        #end = min(eval('int(self.input_%2.2d:end_idx)'%(chan+1,)), postTrig)
			end = min(int(self.__getattr__('input_%2.2d_endidx'%(chan+1,))),postTrig-1)
                    except:
                        end = postTrig-1
                    try:
                        #inc =  max(eval('int(self.input_%2.2d:inc)'%(chan+1,)), 1)
                        inc = max(int(self.__getattr__('input_%2.2d_inc'%(chan+1,))),1)
                    except:
                        inc = 1
#
# could do the coeffs
#
		    chanFileName="%s/%2.2d"%(dataDir, chan+1,)
                    buf = self.readRawData(chanFileName, preTrig, start, end, inc)
#                    try:
#                        buf = self.readRawData(chanFileName, start, end, inc)
#                    except:
#			print "Error Reading Channel %d"%(chan+1,)
		    if delta != 0 :
			axis = Range(None, None, delta/inc)
		    else:
			#clockExpr = 'self.%s'% str(self.clock_src.record)
			#clock_src = eval(clockExpr.lower())
                        clock_src = self.__getattr__(str(self.clock_src.record).lower())
                        axis = clock_src

		    if inc == 1:
			dim = Dimension(Window(start, end, trig_src ), axis)
                    else:
			dim = Data.compile('Map($,$)', Dimension(Window(start/inc, end/inc, trig_src), axis), Range(start, end, inc))
                    dat = Data.compile('build_signal(build_with_units( $*(0. + $value), "V") ,build_with_units($,"Counts"),$)', coefficent, buf,dim) 
                    exec('c=self.input_'+'%02d'%(chan+1,)+'.record=dat')
	return 1
예제 #11
0
    def storeftp(self, arg):

 	path = self.local_path
        tree = self.local_tree
        shot = self.tree.shot
        CPCIDataDir = os.getenv('CPCI_DATA_DIR')
	if not CPCIDataDir:
	    raise 'CPCI_DATA_DIR environment variable must be defined'
        dataDir="%s/%s/%s/%s"%(CPCIDataDir, tree, shot, path,)
        try :
	    settingsf = open("%s/settings.xml"%(dataDir,), "r")
	except :
	    raise Exception,"Could not open Settings file %s/settings.xml"%(dataDir,)
        try :
            settings = load(settingsf)
        except:
            settingsf.close()
	    raise Exception, "Could not parse XML settings"
        settingsf.close()
	if self.debugging() :
	    print "xml is loaded\n"
        status = []
        cmds = self.status_cmds.record
        for cmd in cmds:
	    cmd = cmd.strip()
	    if self.debugging():
		print "about to append answer for /%s/\n" % (cmd,)
		print "   which is /%s/\n" %(settings[cmd],)
	    status.append(settings[cmd])
	    if self.debugging():
		print "%s returned %s\n" % (cmd, settings[cmd],)
	if self.debugging():
	    print "about to write board_status signal"
	self.board_status.record = MDSplus.Signal(cmds, None, status)

        numSampsStr = settings['getNumSamples']
	preTrig = self.getPreTrig(numSampsStr)
        postTrig = self.getPostTrig(numSampsStr)
        if self.debugging():
            print "got preTrig %d and postTrig %d\n" % (preTrig, postTrig,)
        vins = MDSplus.makeArray(numpy.array(settings['get.vin'].split(',')).astype('float'))
        if self.debugging:
            print "got the vins "
            print vins
	self.ranges.record = MDSplus.makeArray(numpy.array(settings['get.vin'].split(',')).astype('float'))
        chanMask = settings['getChannelMask'].split('=')[-1]
        if self.debugging():
            print "chan_mask = %s\n" % (chanMask,)
        clock_src=self.clock_src.record.getOriginalPartName().getString()[1:]
        if self.debugging():
            print "clock_src = %s\n" % (clock_src,)
        if clock_src == 'INT_CLOCK' :
	    intClock = float(settings['getInternalClock'].split()[1])
            delta=1./float(intClock)
            self.clock.record = MDSplus.Range(None, None, delta)
        else:
            self.clock.record = self.clock_src

        clock = self.clock.record
#
# now store each channel
#
	for chan in range(16):
	    if self.debugging():
		print "working on channel %d" % chan
            chan_node = self.__getattr__('input_%2.2d' % (chan+1,))
            if chan_node.on :
                if self.debugging():
                    print "it is on so ..."
                if chanMask[chan:chan+1] == '1' :
                    try:
                        start = max(int(self.__getattr__('input_%2.2d_startidx'%(chan+1,))),-preTrig)
                    except:
                        start = -preTrig
                    try:
			end = min(int(self.__getattr__('input_%2.2d_endidx'%(chan+1,))),postTrig-1)
                    except:
                        end = postTrig-1
                    try:
                        inc = max(int(self.__getattr__('input_%2.2d_inc'%(chan+1,))),1)
                    except:
                        inc = 1
#
# could do the coeffs
#
		    chanFileName="%s/%2.2d"%(dataDir, chan+1,)
                    if self.debugging():
			print "about to readRawData(%s, preTrig=%d, start=%d, end=%d, inc=%d)" % (chanFileName, preTrig, start, end, inc)
                    buf = self.readRawData(chanFileName, preTrig, start, end, inc)
		    if inc == 1:
			dim = MDSplus.Dimension(MDSplus.Window(start, end, self.trig_src ), clock)
                    else:
			dim = MDSplus.Data.compile('Map($,$)', MDSplus.Dimension(MDSplus.Window(start/inc, end/inc, self.trig_src), clock), MDSplus.Range(start, end, inc))
		    dat = MDSplus.Data.compile(
                        '_v0=$, _v1=$, build_signal(build_with_units(( _v0+ (_v1-_v0)*($value - -32768)/(32767 - -32768 )), "V") ,build_with_units($,"Counts"),$)',
                        vins[chan*2], vins[chan*2+1], buf,dim) 
                    exec('c=self.input_'+'%02d'%(chan+1,)+'.record=dat')
	return 1