Ejemplo n.º 1
0
def analyserscan_v1(*args):
    starttime = time.ctime()
    if PRINTTIME: print "=== Scan started: " + starttime
    newargs = []
    i = 0
    while i < len(args):
        arg = args[i]
        newargs.append(arg)
        i = i + 1
        if isinstance(arg, RegionScannable):
            controller = Finder.find("SequenceFileObserver")
            xmldir = InterfaceProvider.getPathConstructor(
            ).createFromDefaultProperty() + "xml" + os.sep
            filename = xmldir + args[i]
            if (OsUtil.isWindows()):
                FilenameUtil.setPrefix("D:")
                filename = FilenameUtil.convertSeparator(filename)
            controller.update(controller, SequenceFileChangeEvent(filename))
            sleep(1.0)
            while (InterfaceProvider.getScanStatusHolder().getScanStatus() ==
                   JythonStatus.PAUSED):
                sleep(1.0)
            newargs.append(RegionPositionProvider(filename))
            #newargs.append( arg ) # to read the actual position
            i = i + 1
    scan(newargs)
    if PRINTTIME:
        print("=== Scan ended: " + time.ctime() +
              ". Elapsed time: %.0f seconds" % (time.time() - starttime))
Ejemplo n.º 2
0
def analyserpathscan_v1(scannables, path, *args):
    '''
    perform a single region analyser data collection at each point on the specified path,
    and produce a single scan data files recording scannables' poistions and metadata, and 
    analyser data for the active region defined in your sequence definition file under ew4001 node.
    
    implementation details:
    This function pre-process sequence file to set up Region Position Provider for scannable 
    'regions' ready for data collection using analyser 'ew4001', then delegate the scan 
    process to 'pathscan'.
    '''
    newargs = []
    i = 0
    while i < len(args):
        arg = args[i]
        newargs.append(arg)
        i = i + 1
        if isinstance(arg, RegionScannable):
            controller = Finder.find("SequenceFileObserver")
            xmldir = InterfaceProvider.getPathConstructor(
            ).createFromDefaultProperty() + "xml" + os.sep
            filename = xmldir + args[i]
            if (OsUtil.isWindows()):
                FilenameUtil.setPrefix("D:")
                filename = FilenameUtil.convertSeparator(filename)
            controller.update(controller, SequenceFileChangeEvent(filename))
            sleep(1.0)
            while (InterfaceProvider.getScanStatusHolder().getScanStatus() ==
                   JythonStatus.PAUSED):
                sleep(1.0)
            newargs.append(RegionPositionProvider(filename))
            #newargs.append( arg ) # to read the actual position
            i = i + 1
    pathscan(scannables, path, newargs)
Ejemplo n.º 3
0
def analyserpathscan(*args):
    '''
    perform single/multiple regions analyser data collection at each point on the specified path,
    and produce a single scan file recording all scannables' poistions and metadata, along with
    analyser scan data under region's name as NXdetector node.
    
    implementation details:
    This function pre-process sequence file to set up analyser 'ew4000' ready for data collection.
    It creates scannable group to support point-to-point concurrent scan.
    '''
    starttime = time.ctime()
    if PRINTTIME: print "=== Scan started: " + starttime
    newargs = []
    i = 0
    while i < len(args):
        arg = args[i]
        if type(arg) == TupleType:
            if allElementsAreScannable(arg):
                scannableGroup = ScannableGroup("pathgroup")
                for each in arg:
                    scannableGroup.addGroupMember(each)
                newargs.append(scannableGroup)
            elif allElementsAreListOfNumber(arg):
                newargs.append(arg)
            else:
                raise TypeError, "Only tuple of scannables and tuple of list of numbers are supported."
        else:
            newargs.append(arg)
        i = i + 1
        if isinstance(arg, EW4000):
            controller = Finder.find("SequenceFileObserver")
            xmldir = InterfaceProvider.getPathConstructor(
            ).createFromDefaultProperty() + "xml" + os.sep
            filename = xmldir + args[i]
            if (OsUtil.isWindows()):
                FilenameUtil.setPrefix("D:")
                filename = FilenameUtil.convertSeparator(filename)
            controller.update(controller, SequenceFileChangeEvent(filename))
            sleep(2.0)
            jythonServerStatus = InterfaceProvider.getJythonServerStatusProvider(
            ).getJythonServerStatus()
            while (jythonServerStatus.isScriptOrScanPaused()):
                sleep(1.0)
            arg.setSequenceFilename(filename)
            sequence = arg.loadSequenceData(filename)
            if isinstance(arg.getCollectionStrategy(),
                          EW4000CollectionStrategy):
                arg.getCollectionStrategy().setSequence(sequence)
            i = i + 1
    scan(newargs)
    if PRINTTIME:
        print("=== Scan ended: " + time.ctime() +
              ". Elapsed time: %.0f seconds" % (time.time() - starttime))
Ejemplo n.º 4
0
def analyserpathscan(scannables, path, *args):
    '''
    perform single/multiple regions analyser data collection at each point on the specified path,
    and produce a single scan file recording all scannables' poistions and metadata, along with
    analyser scann data under region's name as NXdetector node.
    
    implementation details:
    This function pre-process sequence file to set up analyser 'ew4000' ready for data collection, 
    then delegate the scan process to 'pathscan'.    
    '''
    starttime = time.ctime()
    if PRINTTIME: print "=== Scan started: " + starttime
    newargs = []
    i = 0
    while i < len(args):
        arg = args[i]
        newargs.append(arg)
        i = i + 1
        if isinstance(arg, EW4000):
            controller = Finder.find("SequenceFileObserver")
            xmldir = InterfaceProvider.getPathConstructor(
            ).createFromDefaultProperty() + "xml" + os.sep
            filename = xmldir + args[i]
            if (OsUtil.isWindows()):
                FilenameUtil.setPrefix("D:")
                filename = FilenameUtil.convertSeparator(filename)
            controller.update(controller, SequenceFileChangeEvent(filename))
            sleep(2.0)
            jythonServerStatus = InterfaceProvider.getJythonServerStatusProvider(
            ).getJythonServerStatus()
            while (jythonServerStatus.isScriptOrScanPaused()):
                sleep(1.0)
            arg.setSequenceFilename(filename)
            sequence = arg.loadSequenceData(filename)
            if isinstance(arg.getCollectionStrategy(),
                          EW4000CollectionStrategy):
                arg.getCollectionStrategy().setSequence(sequence)
            i = i + 1
    pathscan(scannables, path, newargs)
    if PRINTTIME:
        print("=== Scan ended: " + time.ctime() +
              ". Elapsed time: %.0f seconds" % (time.time() - starttime))
Ejemplo n.º 5
0
def getSequenceFilename(arg, xmldir):
    filename = xmldir + arg
    if (OsUtil.isWindows()):
        FilenameUtil.setPrefix("D:")
        filename = FilenameUtil.convertSeparator(filename)
    return filename
Ejemplo n.º 6
0
def analyserscan(*args):
    ''' a more generalised scan that extends standard GDA scan syntax to support 
    1. scannable tuple (e.g. (s1,s2,...) argument) as scannable group and 
    2. its corresponding path tuple (e.g. tuple of position lists), if exist, and
    3. EW4000 analyser detector that takes a reion sequence file name as input, if exist, and
    4. syntax 'analyserscan ew4000 "user.seq ...' for analyser scan only
    It parses input parameters described above before delegating to the standard GDA scan to do the actual data collection.
    Thus it can be used anywhere the standard GDA 'scan' is used.
    '''
    starttime = time.ctime()
    if PRINTTIME: print "=== Scan started: " + starttime
    newargs = []
    i = 0
    while i < len(args):
        arg = args[i]
        if i == 0 and isinstance(arg, EW4000):
            newargs.append(zeroScannable)
            newargs.append(0)
            newargs.append(0)
            newargs.append(1)
            newargs.append(arg)
        elif type(arg) == TupleType:
            if allElementsAreScannable(arg):
                #parsing (scannable1, scannable2,...) as scannable group
                scannableGroup = ScannableGroup()
                for each in arg:
                    scannableGroup.addGroupMember(each)
                scannableGroup.setName("pathgroup")
                newargs.append(scannableGroup)
            elif allElementsAreListOfNumber(arg):
                #parsing scannable group's position lists
                newargs.append(arg)
            elif allElementsAreNumber(arg):
                #parsing scannable group's position lists
                newargs.append(arg)
            elif allElementsAreTuplesOfNumbers(arg):
                # This case is to fix BLIX-206 when using a scannable group with a tuple of tuples of positions
                newargs.append(arg)
            else:
                raise TypeError, "Only tuple of scannables, tuple of numbers, tuple of tuples of numbers, or list of numbers are supported."
        else:
            newargs.append(arg)
        i = i + 1
        if isinstance(arg, EW4000):
            controller = Finder.find("SequenceFileObserver")
            xmldir = InterfaceProvider.getPathConstructor(
            ).getVisitSubdirectory('xml') + os.sep
            filename = xmldir + args[i]
            if (OsUtil.isWindows()):
                FilenameUtil.setPrefix("D:")
                filename = FilenameUtil.convertSeparator(filename)
            controller.update(controller, SequenceFileChangeEvent(
                filename))  #update client sequence view
            sleep(2.0)
            jythonServerStatus = InterfaceProvider.getJythonServerStatusProvider(
            ).getJythonServerStatus()
            while (jythonServerStatus.isScriptOrScanPaused()):
                sleep(1.0)  # wait for user saving dirty file
            arg.setSequenceFilename(filename)
            sequence = arg.loadSequenceData(filename)
            if isinstance(arg.getCollectionStrategy(),
                          EW4000CollectionStrategy):
                arg.getCollectionStrategy().setSequence(sequence)
            i = i + 1
    scan(newargs)
    if ENABLEZEROSUPPLIES:
        zerosupplies()  # @UndefinedVariable

    if PRINTTIME:
        print("=== Scan ended: " + time.ctime() +
              ". Elapsed time: %.0f seconds" % (time.time() - starttime))