def functionXMLin(_strFilename):
    """Here we create the XML string to be passed to the EDNA plugin from the input strFilename
    This can / should be modified by the final user
    
    @param _strFilename: full path of the input file
    @type _strFilename: python string representing the path
    @return: string  
    """
    EDVerbose.screen("Starting processing of image %s" % (_strFilename))
    # First check if the filename end with .img or .mccd:
    strXML = None
    if _strFilename.endswith(".img") or _strFilename.endswith(".mccd") or _strFilename.endswith(".cbf"):
        xsDataInputGridScreening = XSDataInputGridScreening()
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
            XSDataTime(EDParallelExecuteGridScreening.fMaxExposureTime)
        )
        xsDataInputGridScreening.setDiffractionPlan(xsDataDiffractionPlan)
        xsDataFile = XSDataFile()
        xsDataFile.setPath(XSDataString(_strFilename))
        xsDataInputGridScreening.setImageFile(xsDataFile)
        if EDParallelExecuteGridScreening.bOnlyImageQualityIndicators:
            xsDataInputGridScreening.setDoOnlyImageQualityIndicators(XSDataBoolean(True))
        if EDParallelExecuteGridScreening.bStoreInISPyB:
            xsDataInputGridScreening.setStoreImageQualityIndicatorsInISPyB(XSDataBoolean(True))
        if EDParallelExecuteGridScreening.bDoOnlyIntegrationWithXMLOutput:
            xsDataInputGridScreening.setDoOnlyIntegrationWithXMLOutput(XSDataBoolean(True))
        strXML = xsDataInputGridScreening.marshal()
    else:
        EDVerbose.screen("File name not ending with .img or .mccd - ignored : %s" % _strFilename)
    return strXML
def functionXMLin(_strFilename):
    """Here we create the XML string to be passed to the EDNA plugin from the input strFilename
    This can / should be modified by the final user
    
    @param _strFilename: full path of the input file
    @type _strFilename: python string representing the path
    @return: string  
    """
    EDVerbose.screen("Starting processing of image %s" % (_strFilename))
    # First check if the filename end with .img or .mccd:
    strXML = None
    if (_strFilename.endswith(".img") or _strFilename.endswith(".mccd") or _strFilename.endswith(".cbf")):
        xsDataInputGridScreening = XSDataInputGridScreening()
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(EDParallelExecuteGridScreening.fMaxExposureTime))
        xsDataInputGridScreening.setDiffractionPlan(xsDataDiffractionPlan)
        xsDataFile = XSDataFile()
        xsDataFile.setPath(XSDataString(_strFilename))
        xsDataInputGridScreening.setImageFile(xsDataFile)
        if EDParallelExecuteGridScreening.bOnlyImageQualityIndicators:
            xsDataInputGridScreening.setDoOnlyImageQualityIndicators(XSDataBoolean(True))
        if EDParallelExecuteGridScreening.bStoreInISPyB:
            xsDataInputGridScreening.setStoreImageQualityIndicatorsInISPyB(XSDataBoolean(True))
        if EDParallelExecuteGridScreening.bDoOnlyIntegrationWithXMLOutput:
            xsDataInputGridScreening.setDoOnlyIntegrationWithXMLOutput(XSDataBoolean(True))
        strXML = xsDataInputGridScreening.marshal()
    else:
        EDVerbose.screen("File name not ending with .img or .mccd - ignored : %s" % _strFilename)
    return strXML
 def preProcess(self, _edObject=None):
     EDPluginControl.preProcess(self)
     self.DEBUG("EDPluginControlGridScreeningv1_0.preProcess")
     # Load the plugins
     self.edPluginControlReadImageHeader = self.loadPlugin(self.strControlReadImageHeaderPluginName, \
                                                                "ReadImageHeader")
     self.edPluginControlIndicators = self.loadPlugin(self.strControlledIndicatorsPluginName, \
                                                                "ControlIndicators")
     self.edPluginMOSFLMIndexing = self.loadPlugin(self.strIndexingMOSFLMPluginName, \
                                                                "IndexingMOSFLM")
     self.edPluginControlIntegration = self.loadPlugin(self.strPluginControlIntegration, \
                                                         "Integration")
     self.edPluginControlStrategy = self.loadPlugin(self.strPluginControlStrategy, \
                                                      "Strategy")
     # Input data
     self.strImageFile = self.getDataInput().getImageFile().getPath().getValue()
     self.xsDataGridScreeningFileNameParameters = self.getFileNameParameters(self.strImageFile)
     self.xsDataDiffractionPlan = self.getDataInput().getDiffractionPlan()
     if self.xsDataDiffractionPlan is None:
         self.xsDataDiffractionPlan = XSDataDiffractionPlan()
     if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection() is None:
         # Default max esposure time: 10000s
         self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(10000))
     self.xsDataDiffractionPlan.setEstimateRadiationDamage(XSDataBoolean(False))
     # Image quality indicators
     if self.getDataInput().getStoreImageQualityIndicatorsInISPyB():
         self.bStoreImageQualityIndicatorsInISPyB = self.getDataInput().getStoreImageQualityIndicatorsInISPyB().getValue()
     if self.getDataInput().getDoOnlyImageQualityIndicators():
         self.bDoOnlyImageQualityIndicators = self.getDataInput().getDoOnlyImageQualityIndicators().getValue()
     if self.bStoreImageQualityIndicatorsInISPyB:
         self.edPluginISPyBStoreImageQualityIndicators = self.loadPlugin(self.strISPyBStoreImageQualityIndicatorsPluginName, \
                                                      "ISPyBStoreImageQualityIndicators")
Esempio n. 4
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'imageFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setImageFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'diffractionPlan':
         obj_ = XSDataDiffractionPlan()
         obj_.build(child_)
         self.setDiffractionPlan(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'storeImageQualityIndicatorsInISPyB':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setStoreImageQualityIndicatorsInISPyB(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'doOnlyImageQualityIndicators':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoOnlyImageQualityIndicators(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'doOnlyIntegrationWithXMLOutput':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoOnlyIntegrationWithXMLOutput(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
Esempio n. 5
0
 def createInputCharacterisationFromSubWedges(self):
     self.DEBUG("EDPluginControlInterfacev1_2.createInputCharacterisationFromSubWedges")
     xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput()
     self.xsDataInputCharacterisation = XSDataInputCharacterisation()
     xsDataCollection = XSDataCollection()
     # Default exposure time (for the moment, this value should be
     # possible to read from the command line)
     if self.xsDataDiffractionPlan is None:
         self.xsDataDiffractionPlan = XSDataDiffractionPlan()
     if (not xsDataResultSubWedgeAssemble is None):
         pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
         xsDataCollection.setSubWedge(pyListSubWedge)
         for xsDataSubWedge in pyListSubWedge:
             if (self.strComplexity is not None):
                 self.xsDataDiffractionPlan.setComplexity(XSDataString(self.strComplexity))
             if (self.fFlux is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setFlux(XSDataFlux(self.fFlux))
             if (self.fBeamSizeX is not None) and (self.fBeamSizeY is not None):
                 xsDataSize = XSDataSize()
                 xsDataSize.setX(XSDataLength(self.fBeamSizeX))
                 xsDataSize.setY(XSDataLength(self.fBeamSizeY))
                 xsDataSubWedge.getExperimentalCondition().getBeam().setSize(xsDataSize)
             if (self.fBeamPosX is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionX(XSDataLength(self.fBeamPosX))
             if (self.fBeamPosY is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionY(XSDataLength(self.fBeamPosY))
             if (self.fMinExposureTimePerImage is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setMinExposureTimePerImage(XSDataTime(self.fMinExposureTimePerImage))
             if (self.fTransmission is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setTransmission(XSDataDouble(self.fTransmission))
             if (self.fWavelength is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setWavelength(XSDataWavelength(self.fWavelength))
             if self.fMinOscillationWidth != None:
                 xsDataSubWedge.getExperimentalCondition().getGoniostat().setMinOscillationWidth(XSDataAngle(self.fMinOscillationWidth))
             if self.fMaxOscillationSpeed != None:
                 xsDataSubWedge.getExperimentalCondition().getGoniostat().setMaxOscillationSpeed(XSDataAngularSpeed(self.fMaxOscillationSpeed))
     if (self.strForcedSpaceGroup is not None):
         self.xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.strForcedSpaceGroup))
     self.xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.bAnomalousData))
     self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.fMaxExposureTimePerDataCollection))
     if (self.strStrategyOption is not None):
         self.xsDataDiffractionPlan.setStrategyOption(XSDataString(self.strStrategyOption))
     xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
     if self.xsDataSample is not None:
         xsDataCollection.setSample(XSDataSampleCrystalMM.parseString(self.xsDataSample.marshal()))
     self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)
     self.xsDataInputCharacterisation.setToken(self.xsDataToken)
 def preProcess(self, _edObject=None):
     EDPluginControl.preProcess(self)
     self.DEBUG("EDPluginControlGridScreeningv1_0.preProcess")
     # Load the plugins
     self.edPluginControlReadImageHeader = self.loadPlugin(self.strControlReadImageHeaderPluginName, \
                                                                "ReadImageHeader")
     self.edPluginControlIndicators = self.loadPlugin(self.strControlledIndicatorsPluginName, \
                                                                "ControlIndicators")
     self.edPluginMOSFLMIndexing = self.loadPlugin(self.strIndexingMOSFLMPluginName, \
                                                                "IndexingMOSFLM")
     self.edPluginControlIntegration = self.loadPlugin(self.strPluginControlIntegration, \
                                                         "Integration")
     self.edPluginControlStrategy = self.loadPlugin(self.strPluginControlStrategy, \
                                                      "Strategy")
     self.edPluginExecMtz2Various = self.loadPlugin(self.strPluginExecMtz2Various, \
                                                      "Mtz2Various")
     # Input data
     self.strImageFile = self.getDataInput().getImageFile().getPath(
     ).getValue()
     self.xsDataGridScreeningFileNameParameters = self.getFileNameParameters(
         self.strImageFile)
     self.xsDataDiffractionPlan = self.getDataInput().getDiffractionPlan()
     if self.xsDataDiffractionPlan is None:
         self.xsDataDiffractionPlan = XSDataDiffractionPlan()
     if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
     ) is None:
         # Default max esposure time: 10000s
         self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
             XSDataTime(10000))
     self.xsDataDiffractionPlan.setEstimateRadiationDamage(
         XSDataBoolean(False))
     # Image quality indicators
     if self.getDataInput().getStoreImageQualityIndicatorsInISPyB():
         self.bStoreImageQualityIndicatorsInISPyB = self.getDataInput(
         ).getStoreImageQualityIndicatorsInISPyB().getValue()
     if self.getDataInput().getDoOnlyImageQualityIndicators():
         self.bDoOnlyImageQualityIndicators = self.getDataInput(
         ).getDoOnlyImageQualityIndicators().getValue()
     if self.getDataInput().getDoOnlyIntegrationWithXMLOutput():
         self.bDoOnlyIntegrationWithXMLOutput = self.getDataInput(
         ).getDoOnlyIntegrationWithXMLOutput().getValue()
     if self.bStoreImageQualityIndicatorsInISPyB:
         self.edPluginISPyBStoreImageQualityIndicators = self.loadPlugin(self.strISPyBStoreImageQualityIndicatorsPluginName, \
                                                      "ISPyBStoreImageQualityIndicators")
def functionXMLin(_strFilename):
    """Here we create the XML string to be passed to the EDNA plugin from the input strFilename
    This can / should be modified by the final user
    
    @param _strFilename: full path of the input file
    @type _strFilename: python string representing the path
    @return: string  
    """
    EDVerbose.screen("Starting processing of image %s" % (_strFilename))
    # First check if the filename end with .img or .mccd:
    strXML = None
    if (_strFilename.endswith(".img") or _strFilename.endswith(".mccd") or _strFilename.endswith(".cbf")):
        xsDataInputInterface = XSDataInputInterface()
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(EDParallelExecuteMXv1Characterisation.m_fMaxExposureTime))
        xsDataInputInterface.setDiffractionPlan(xsDataDiffractionPlan)
        xsDataFile = XSDataFile()
        xsDataFile.setPath(XSDataString(_strFilename))
        xsDataInputInterface.addImagePath(xsDataFile)
        strXML = xsDataInputInterface.marshal()
    else:
        EDVerbose.screen("File name not ending with .img or .mccd - ignored : %s" % _strFilename)
    return strXML
 def createInputCharacterisationFromSubWedges(self):
     self.DEBUG("EDPluginControlInterfacev1_3.createInputCharacterisationFromSubWedges")
     xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput()
     self.xsDataInputCharacterisation = XSDataInputCharacterisation()
     xsDataCollection = XSDataCollection()
     # Default exposure time (for the moment, this value should be
     # possible to read from the command line)
     if self.xsDataDiffractionPlan is None:
         self.xsDataDiffractionPlan = XSDataDiffractionPlan()
     if (not xsDataResultSubWedgeAssemble is None):
         pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
         xsDataCollection.setSubWedge(pyListSubWedge)
         for xsDataSubWedge in pyListSubWedge:
             if (self.strComplexity is not None):
                 self.xsDataDiffractionPlan.setComplexity(XSDataString(self.strComplexity))
             if (self.fFlux is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setFlux(XSDataFlux(self.fFlux))
             if (self.fBeamSizeX is not None) and (self.fBeamSizeY is not None):
                 xsDataSize = XSDataSize()
                 xsDataSize.setX(XSDataLength(self.fBeamSizeX))
                 xsDataSize.setY(XSDataLength(self.fBeamSizeY))
                 xsDataSubWedge.getExperimentalCondition().getBeam().setSize(xsDataSize)
             if (self.fApertureSize is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setApertureSize(XSDataLength(self.fApertureSize))
             if (self.fBeamPosX is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionX(XSDataLength(self.fBeamPosX))
             if (self.fBeamPosY is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionY(XSDataLength(self.fBeamPosY))
             if (self.fMinExposureTimePerImage is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setMinExposureTimePerImage(XSDataTime(self.fMinExposureTimePerImage))
             if (self.fTransmission is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setTransmission(XSDataDouble(self.fTransmission))
             if (self.fWavelength is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setWavelength(XSDataWavelength(self.fWavelength))
             if self.fMinOscillationWidth != None:
                 xsDataSubWedge.getExperimentalCondition().getGoniostat().setMinOscillationWidth(XSDataAngle(self.fMinOscillationWidth))
             if self.fMaxOscillationSpeed != None:
                 xsDataSubWedge.getExperimentalCondition().getGoniostat().setMaxOscillationSpeed(XSDataAngularSpeed(self.fMaxOscillationSpeed))
     if (self.strForcedSpaceGroup is not None):
         self.xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.strForcedSpaceGroup))
     self.xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.bAnomalousData))
     self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.fMaxExposureTimePerDataCollection))
     if (self.strStrategyOption is not None):
         self.xsDataDiffractionPlan.setStrategyOption(XSDataString(self.strStrategyOption))
     xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
     if self.xsDataSample is not None:
         xsDataCollection.setSample(XSDataSampleCrystalMM.parseString(self.xsDataSample.marshal()))
     self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)
class EDPluginControlGridScreeningv1_0(EDPluginControl):
    """
    This plugin is a "light-weight" characterisation to be used for processing
    images from grid scans.
    """


    def __init__(self):
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputGridScreening)
        self.strControlReadImageHeaderPluginName = "EDPluginControlReadImageHeaderv10"
        self.edPluginControlReadImageHeader = None
        self.strControlledIndicatorsPluginName = "EDPluginControlImageQualityIndicatorsv1_4"
        self.edPluginControlIndicators = None
        self.strISPyBStoreImageQualityIndicatorsPluginName = "EDPluginISPyBStoreImageQualityIndicatorsv1_4"
        self.edPluginISPyBStoreImageQualityIndicators = None
        self.strIndexingMOSFLMPluginName = "EDPluginMOSFLMIndexingv10"
        self.edPluginMOSFLMIndexing = None
        self.strPluginControlIntegration = "EDPluginControlIntegrationv10"
        self.edPluginControlIntegration = None
        self.strPluginControlStrategy = "EDPluginControlStrategyv1_2"
        self.edPluginControlStrategy = None
        self.strPluginExecMtz2Various = "EDPluginExecMtz2Variousv1_0"
        self.edPluginExecMtz2Various = None
        self.strImageFile = None
        self.xsDataIndexingResultMOSFLM = None
        self.xsDataCrystal = None
        self.strCharacterisationShortSummary = ""
        self.strStatusMessage = ""
        self.xsDataDiffractionPlan = None
        self.xsDataCollection = None
        self.xsDataIndexingResult = None
        self.xsDataStrategyResult = None
        self.xsDataImageQualityIndicators = None
        self.bStoreImageQualityIndicatorsInISPyB = False
        self.bDoOnlyImageQualityIndicators = False
        self.bDoOnlyIntegrationWithXMLOutput = False
        self.iImageQualityIndicatorsId = None
        self.xsDataGridScreeningResultIntegration = None


    def checkParameters(self):
        """
        Checks the mandatory parameters.
        """
        self.DEBUG("EDPluginControlGridScreeningv1_0.checkParameters")
        self.checkMandatoryParameters(self.getDataInput(), "Data Input is None")
        self.checkMandatoryParameters(self.getDataInput().getImageFile(), "imageFile")


    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlGridScreeningv1_0.preProcess")
        # Load the plugins
        self.edPluginControlReadImageHeader = self.loadPlugin(self.strControlReadImageHeaderPluginName, \
                                                                   "ReadImageHeader")
        self.edPluginControlIndicators = self.loadPlugin(self.strControlledIndicatorsPluginName, \
                                                                   "ControlIndicators")
        self.edPluginMOSFLMIndexing = self.loadPlugin(self.strIndexingMOSFLMPluginName, \
                                                                   "IndexingMOSFLM")
        self.edPluginControlIntegration = self.loadPlugin(self.strPluginControlIntegration, \
                                                            "Integration")
        self.edPluginControlStrategy = self.loadPlugin(self.strPluginControlStrategy, \
                                                         "Strategy")
        self.edPluginExecMtz2Various = self.loadPlugin(self.strPluginExecMtz2Various, \
                                                         "Mtz2Various")
        # Input data
        self.strImageFile = self.getDataInput().getImageFile().getPath().getValue()
        self.xsDataGridScreeningFileNameParameters = self.getFileNameParameters(self.strImageFile)
        self.xsDataDiffractionPlan = self.getDataInput().getDiffractionPlan()
        if self.xsDataDiffractionPlan is None:
            self.xsDataDiffractionPlan = XSDataDiffractionPlan()
        if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection() is None:
            # Default max esposure time: 10000s
            self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(10000))
        self.xsDataDiffractionPlan.setEstimateRadiationDamage(XSDataBoolean(False))
        # Image quality indicators
        if self.getDataInput().getStoreImageQualityIndicatorsInISPyB():
            self.bStoreImageQualityIndicatorsInISPyB = self.getDataInput().getStoreImageQualityIndicatorsInISPyB().getValue()
        if self.getDataInput().getDoOnlyImageQualityIndicators():
            self.bDoOnlyImageQualityIndicators = self.getDataInput().getDoOnlyImageQualityIndicators().getValue()
        if self.getDataInput().getDoOnlyIntegrationWithXMLOutput():
            self.bDoOnlyIntegrationWithXMLOutput = self.getDataInput().getDoOnlyIntegrationWithXMLOutput().getValue()
        if self.bStoreImageQualityIndicatorsInISPyB:
            self.edPluginISPyBStoreImageQualityIndicators = self.loadPlugin(self.strISPyBStoreImageQualityIndicatorsPluginName, \
                                                         "ISPyBStoreImageQualityIndicators")



    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlGridScreeningv1_0.process")
        xsDataInputReadImageHeader = XSDataInputReadImageHeader()
        xsDataInputReadImageHeader.setImage(image=XSDataFile(path=XSDataString(self.strImageFile)))
        self.edPluginControlReadImageHeader.setDataInput(xsDataInputReadImageHeader)
        self.edPluginControlReadImageHeader.connectSUCCESS(self.doSuccessReadImageHeader)
        self.edPluginControlReadImageHeader.connectFAILURE(self.doFailureReadImageHeader)
        self.executePluginSynchronous(self.edPluginControlReadImageHeader)


    def finallyProcess(self, _edObject=None):
        EDPluginControl.finallyProcess(self)
        self.DEBUG("EDPluginControlGridScreeningv1_0.finallyProcess")
        # Synchronise if necessary
        if self.edPluginISPyBStoreImageQualityIndicators is not None:
            self.edPluginISPyBStoreImageQualityIndicators.synchronize()
        # Build up the output object
        strComment = ""
        xsDataResultGridScreening = XSDataResultGridScreening()
        if self.xsDataGridScreeningFileNameParameters is not None:
            xsDataResultGridScreening.setFileNameParameters(self.xsDataGridScreeningFileNameParameters)
        if self.xsDataImageQualityIndicators is None:
            strComment = "No image quality indicators"
        else:
            xsDataResultGridScreening.setImageQualityIndicators(self.xsDataImageQualityIndicators)
            if self.xsDataImageQualityIndicators.getIceRings() is not None:
                if self.xsDataImageQualityIndicators.getIceRings().getValue() > 1:
                    strComment = "Ice rings detected"
        if self.xsDataIndexingResult is None:
            if strComment == "":
                strComment = "No indexing result"
            else:
                strComment += ", no indexing result"
        else:
            xsDataSelectedSolution = self.xsDataIndexingResult.getSelectedSolution()
            xsDataResultGridScreening.setMosaicity(xsDataSelectedSolution.getCrystal().getMosaicity())
            if self.xsDataStrategyResult is None:
                if strComment == "":
                    strComment = "No strategy result"
                else:
                    strComment += ", no strategy result"
            else:
                xsDataCollectionPlan = self.xsDataStrategyResult.getCollectionPlan()[0]
                xsDataStrategySummary = xsDataCollectionPlan.getStrategySummary()
                xsDataResultGridScreening.setRankingResolution(xsDataStrategySummary.getRankingResolution())
        xsDataResultGridScreening.setResultIntegration(self.xsDataGridScreeningResultIntegration)
        xsDataResultGridScreening.setComment(XSDataString(strComment))
        if self.iImageQualityIndicatorsId is not None:
            xsDataResultGridScreening.setImageQualityIndicatorsId(XSDataInteger(self.iImageQualityIndicatorsId))
        # print xsDataResultGridScreening.marshal()
        self.setDataOutput(xsDataResultGridScreening)



    def doSuccessReadImageHeader(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")
        xsDataResultReadImageHeader = self.edPluginControlReadImageHeader.getDataOutput()
        if xsDataResultReadImageHeader is not None:
            xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge()
            self.xsDataCollection = XSDataCollection()
            self.xsDataCollection.addSubWedge(xsDataSubWedge)
            self.xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
            if not self.bDoOnlyIntegrationWithXMLOutput:
                xsDataInputControlImageQualityIndicators = XSDataInputControlImageQualityIndicators()
                if self.bStoreImageQualityIndicatorsInISPyB:
                    xsDataInputControlImageQualityIndicators.doUploadToIspyb = XSDataBoolean(True)
                else:
                    xsDataInputControlImageQualityIndicators.doUploadToIspyb = XSDataBoolean(False)
                xsDataInputControlImageQualityIndicators.addImage(XSDataImage(path=XSDataString(self.strImageFile)))
                self.edPluginControlIndicators.setDataInput(xsDataInputControlImageQualityIndicators)
                self.edPluginControlIndicators.connectSUCCESS(self.doSuccessIndicators)
                self.edPluginControlIndicators.connectFAILURE(self.doFailureIndicators)
                self.executePluginSynchronous(self.edPluginControlIndicators)
            else:
                xsDataIndexingInput = XSDataIndexingInput()
                xsDataIndexingInput.setDataCollection(self.xsDataCollection)
                from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
                xsDataMOSFLMIndexingInput = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing(xsDataIndexingInput)
                self.edPluginMOSFLMIndexing.connectSUCCESS(self.doSuccessIndexingMOSFLM)
                self.edPluginMOSFLMIndexing.connectFAILURE(self.doFailureIndexingMOSFLM)
                self.edPluginMOSFLMIndexing.setDataInput(xsDataMOSFLMIndexingInput)
                self.edPluginMOSFLMIndexing.executeSynchronous()


    def doFailureReadImageHeader(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureReadImageHeader")
        self.retrieveFailureMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")



    def doSuccessIndicators(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessIndicators")
        # self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessIndexingIndicators")
        if self.edPluginControlIndicators.hasDataOutput():
            self.xsDataImageQualityIndicators = self.edPluginControlIndicators.getDataOutput().getImageQualityIndicators()[0]
            # Continue only if requested
            if not self.bDoOnlyImageQualityIndicators:
                xsDataIndexingInput = XSDataIndexingInput()
                xsDataIndexingInput.setDataCollection(self.xsDataCollection)
                from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
                xsDataMOSFLMIndexingInput = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing(xsDataIndexingInput)
                self.edPluginMOSFLMIndexing.connectSUCCESS(self.doSuccessIndexingMOSFLM)
                self.edPluginMOSFLMIndexing.connectFAILURE(self.doFailureIndexingMOSFLM)
                self.edPluginMOSFLMIndexing.setDataInput(xsDataMOSFLMIndexingInput)
                self.edPluginMOSFLMIndexing.executeSynchronous()


    def doFailureIndicators(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureIndicators")
        strErrorMessage = "Execution of Indexing and Indicators plugin failed. Execution of characterisation aborted."
        self.ERROR(strErrorMessage)
        self.addErrorMessage(strErrorMessage)


    def doSuccessISPyBStoreImageQualityIndicators(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessISPyBStoreImageQualityIndicators")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessISPyBStoreImageQualityIndicators")
        self.iImageQualityIndicatorsId = self.edPluginISPyBStoreImageQualityIndicators.getDataOutput().getImageQualityIndicatorsId().getValue()
        if self.iImageQualityIndicatorsId is None:
            self.WARNING("Image quality indicators result not stored in ISPyB!")

    def doFailureISPyBStoreImageQualityIndicators(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureISPyBStoreImageQualityIndicators")
        strErrorMessage = "Execution of store ISPyB image quality indicators plugin failed."
        self.ERROR(strErrorMessage)
        self.addErrorMessage(strErrorMessage)



    def doSuccessIndexingMOSFLM(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessIndexingMOSFLM")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doIntegrationToStrategyTransition")
        xsDataMOSFLMIndexingOutput = self.edPluginMOSFLMIndexing.getDataOutput()
        xsDataExperimentalConditionRefined = None
        if self.hasDataInput("refinedExperimentalCondition"):
            xsDataExperimentalConditionRefined = self.getDataInput("refinedExperimentalCondition")[0]
        else:
            # Use the experimental condition from the xsDataCollection
            xsDataExperimentalConditionRefined = self.xsDataCollection.getSubWedge()[0].getExperimentalCondition()
        from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
        self.xsDataIndexingResult = EDHandlerXSDataMOSFLMv10.generateXSDataIndexingResult(xsDataMOSFLMIndexingOutput, xsDataExperimentalConditionRefined)
        xsDataIntegrationInput = XSDataIntegrationInput()
        xsDataIntegrationInput.setDataCollection(self.xsDataCollection)
        xsDataIntegrationInput.setExperimentalConditionRefined(self.xsDataIndexingResult.getSelectedSolution().getExperimentalConditionRefined())
        xsDataIntegrationInput.setSelectedIndexingSolution(self.xsDataIndexingResult.getSelectedSolution())
        self.edPluginControlIntegration.connectSUCCESS(self.doSuccessIntegration)
        self.edPluginControlIntegration.connectFAILURE(self.doFailureIntegration)
        self.edPluginControlIntegration.setDataInput(xsDataIntegrationInput)
        self.executePluginSynchronous(self.edPluginControlIntegration)


    def doFailureIndexingMOSFLM(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureActionIndexing")
        self.retrieveFailureMessages(_edPlugin, "EDPluginControlCharacterisationv1_1.doFailureActionIndexing")


    def doSuccessIntegration(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessIntegration")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessIntegration")
        self.addStatusMessage("Integration successful.")
        self.xsDataIntegrationOutput = self.edPluginControlIntegration.getDataOutput()
        # Integration short summary
        if self.edPluginControlIntegration.hasDataOutput("integrationShortSummary"):
            self.strCharacterisationShortSummary += self.edPluginControlIntegration.getDataOutput("integrationShortSummary")[0].getValue()
        # self.DEBUG( self.xsDataExperimentCharacterisation.marshal() )
        if self.bDoOnlyIntegrationWithXMLOutput:
            # Run mtz2various
            xsDataInputMtz2Various = XSDataInputMtz2Various()
            xsDataInputMtz2Various.setMtzfile(self.edPluginControlIntegration.getDataOutput().getIntegrationSubWedgeResult()[0].getGeneratedMTZFile())
            xsDataInputMtz2Various.addLabin(XSDataString("I=I"))
            xsDataInputMtz2Various.addLabin(XSDataString("SIGI=SIGI"))
            xsDataInputMtz2Various.setOutput(XSDataString("USER '(3I4,2F10.1)'"))
            self.edPluginExecMtz2Various.setDataInput(xsDataInputMtz2Various)
            self.edPluginExecMtz2Various.executeSynchronous()
            strHklFilePath = self.edPluginExecMtz2Various.getDataOutput().getHklfile().getPath().getValue()
            strIntegration = EDUtilsFile.readFile(strHklFilePath)
            # Output the result in XML format
            self.xsDataGridScreeningResultIntegration = XSDataGridScreeningResultIntegration()
            self.xsDataGridScreeningResultIntegration.setFileName(os.path.basename(self.strImageFile))
            self.xsDataGridScreeningResultIntegration.setFileDirectory(os.path.dirname(self.strImageFile))
            self.xsDataGridScreeningResultIntegration.setIntegratedData(strIntegration)
        else:
            # We continue with the strategy calculation
            xsDataInputStrategy = XSDataInputStrategy()
            xsDataSolutionSelected = self.xsDataIndexingResult.getSelectedSolution()
            xsDataInputStrategy.setCrystalRefined(xsDataSolutionSelected.getCrystal())
            xsDataInputStrategy.setSample(self.xsDataCollection.getSample())
            xsDataIntegrationSubWedgeResultList = self.xsDataIntegrationOutput.getIntegrationSubWedgeResult()
            xsDataInputStrategy.setBestFileContentDat(xsDataIntegrationSubWedgeResultList[0].getBestfileDat())
            xsDataInputStrategy.setBestFileContentPar(xsDataIntegrationSubWedgeResultList[0].getBestfilePar())
            xsDataInputStrategy.setExperimentalCondition(xsDataIntegrationSubWedgeResultList[0].getExperimentalConditionRefined())
            xsDataInputStrategy.setDataCollection(self.xsDataCollection)
            for xsDataIntegrationSubWedgeResult in xsDataIntegrationSubWedgeResultList:
                xsDataInputStrategy.addBestFileContentHKL(xsDataIntegrationSubWedgeResult.getBestfileHKL())
            xsDataInputStrategy.setDiffractionPlan(self.xsDataDiffractionPlan)
            self.edPluginControlStrategy.connectSUCCESS(self.doSuccessStrategy)
            self.edPluginControlStrategy.connectFAILURE(self.doFailureStrategy)
            self.edPluginControlStrategy.setDataInput(xsDataInputStrategy)
            self.executePluginSynchronous(self.edPluginControlStrategy)



    def doFailureIntegration(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureIntegration")
        strErrorMessage = "Execution of integration plugin failed."
        self.addStatusMessage("Integration FAILURE.")
        self.ERROR(strErrorMessage)
        self.addErrorMessage(strErrorMessage)


    def doSuccessStrategy(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessStrategy")
        self.retrieveSuccessMessages(self.edPluginControlStrategy, "EDPluginControlGridScreeningv1_0.doSuccessStrategy")
        self.xsDataStrategyResult = self.edPluginControlStrategy.getDataOutput()


    def doFailureStrategy(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureStrategy")
        self.retrieveFailureMessages(self.edPluginControlStrategy, "EDPluginControlGridScreeningv1_0.doFailureStrategy")
        strErrorMessage = "Strategy calculation FAILURE."
        self.ERROR(strErrorMessage)
        self.addErrorMessage(strErrorMessage)

#    def generateExecutiveSummary(self, _edPlugin):
#        """
#        Generates a summary of the execution of the plugin.
#        """
#        self.DEBUG("EDPluginControlGridScreeningv1_0.generateExecutiveSummary")
#        self.addExecutiveSummaryLine("Summary of characterisation:")
#        xsDataInputStrategy = self.getDataInput()
#        xsDataCollection = xsDataInputStrategy.getDataCollection()
#        xsDataDiffractionPlan = xsDataCollection.getDiffractionPlan()
#        self.addExecutiveSummaryLine("Diffraction plan:")
#        if (xsDataDiffractionPlan.getComplexity() is not None):
#            self.addExecutiveSummaryLine("BEST complexity                       : %s" % xsDataDiffractionPlan.getComplexity().getValue())
#        if (xsDataDiffractionPlan.getAimedCompleteness() is not None):
#            self.addExecutiveSummaryLine("Aimed completeness                    : %6.1f [%%]" % (100.0 * xsDataDiffractionPlan.getAimedCompleteness().getValue()))
#        if (xsDataDiffractionPlan.getRequiredCompleteness() is not None):
#            self.addExecutiveSummaryLine("Required completeness                 : %6.1f [%%]" % (100.0 * xsDataDiffractionPlan.getRequiredCompleteness().getValue()))
#        if (xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution() is not None):
#            self.addExecutiveSummaryLine("Aimed I/sigma at highest resolution   : %6.1f" % xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution().getValue())
#        if (xsDataDiffractionPlan.getAimedResolution() is not None):
#            self.addExecutiveSummaryLine("Aimed resolution                      : %6.1f [A]" % xsDataDiffractionPlan.getAimedResolution().getValue())
#        if (xsDataDiffractionPlan.getRequiredResolution() is not None):
#            self.addExecutiveSummaryLine("Required resolution                   : %6.1f [A]" % xsDataDiffractionPlan.getRequiredResolution().getValue())
#        if (xsDataDiffractionPlan.getAimedMultiplicity() is not None):
#            self.addExecutiveSummaryLine("Aimed multiplicity                    : %6.1f" % xsDataDiffractionPlan.getAimedMultiplicity().getValue())
#        if (xsDataDiffractionPlan.getRequiredMultiplicity() is not None):
#            self.addExecutiveSummaryLine("Required multiplicity                 : %6.1f" % xsDataDiffractionPlan.getRequiredMultiplicity().getValue())
#        if (xsDataDiffractionPlan.getForcedSpaceGroup() is not None):
#            self.addExecutiveSummaryLine("Forced space group                    : %6s" % xsDataDiffractionPlan.getForcedSpaceGroup().getValue())
#        if (xsDataDiffractionPlan.getMaxExposureTimePerDataCollection() is not None):
#            self.addExecutiveSummaryLine("Max exposure time per data collection : %6.1f [s]" % xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue())
#        self.addExecutiveSummarySeparator()
#        if self.edPluginControlIndexingIndicators is not None:
#            self.appendExecutiveSummary(self.edPluginControlIndexingIndicators, "")
#        if self.edPluginControlIndexingLabelit is not None:
#            self.appendExecutiveSummary(self.edPluginControlIndexingLabelit, "")
#        if self.edPluginControlIntegration is not None:
#            self.appendExecutiveSummary(self.edPluginControlIntegration, "")
#        if self.edPluginControlStrategy is not None:
#            self.appendExecutiveSummary(self.edPluginControlStrategy, "")
#        self.addExecutiveSummarySeparator()
#        if self.strCharacterisationShortSummary is not None:
#            self.addExecutiveSummaryLine("Characterisation short summary:")
#            self.addExecutiveSummaryLine("")
#            if self.strStatusMessage != None:
#                for strLine in self.strStatusMessage.split(". "):
#                    if strLine.endswith("."):
#                        self.addExecutiveSummaryLine(strLine)
#                    else:
#                        self.addExecutiveSummaryLine(strLine + ".")
#            self.addExecutiveSummaryLine("")
#            for strLine in self.strCharacterisationShortSummary.split("\n"):
#                if strLine != "\n":
#                    self.addExecutiveSummaryLine(strLine)
#        self.addErrorWarningMessagesToExecutiveSummary("Characterisation error and warning messages: ")
#        self.addExecutiveSummarySeparator()



    def addStatusMessage(self, _strStatusMessage):
        if self.strStatusMessage != "":
            self.strStatusMessage += " "
        self.strStatusMessage += _strStatusMessage


    def getFileNameParameters(self, _strFileName):
        """Method for extracting the rotation start angle, the two motor positions and the grid scan image no from the file name"""
        # Typical file name: mesh_0_21.676_-0.051_22_001.mccd
        listParts = os.path.basename(_strFileName).split("_")
        xsDataGridScreeningFileNameParameters = XSDataGridScreeningFileNameParameters()
        try:
            strScanId1 = listParts[1]
            xsDataGridScreeningFileNameParameters.setScanId1(XSDataString(strScanId1))
            strMotorPosition1 = listParts[2]
            xsDataGridScreeningFileNameParameters.setMotorPosition1(XSDataString(strMotorPosition1))
            strMotorPosition2 = listParts[3]
            xsDataGridScreeningFileNameParameters.setMotorPosition2(XSDataString(strMotorPosition2))
            strScanId2 = listParts[4]
            xsDataGridScreeningFileNameParameters.setScanId2(XSDataString(strScanId2))
        except:
            xsDataGridScreeningFileNameParameters = None
        return xsDataGridScreeningFileNameParameters
Esempio n. 10
0
 def diffractionPlan(self):
     # Do we have a diffracionPlan?
     xsDataDiffractionPlan = self.xsDataResultCharacterisation.getDataCollection(
     ).getDiffractionPlan()
     if xsDataDiffractionPlan is None:
         xsDataDiffractionPlan = XSDataDiffractionPlan()
     strTitle = "Diffraction Plan"
     strExtraColumnTitle = None
     strExtraColumnValue = None
     if xsDataDiffractionPlan.strategyOption is not None:
         strStrategyOption = xsDataDiffractionPlan.strategyOption.value
         if strStrategyOption.find("-helic") != -1:
             strTitle = "Helical Diffraction Plan"
             self.bIsHelical = True
             strExtraColumnTitle = "Helical\ndistance (mm)"
             if self.dataInput.helicalDistance is not None:
                 fHelicalDistance = self.dataInput.helicalDistance.value
                 strExtraColumnValue = "%.3f" % fHelicalDistance
             else:
                 strExtraColumnValue = "Unknown"
         elif strStrategyOption.find("-Npos") != -1:
             strTitle = "Multi-positional Diffraction Plan"
             self.bIsMultiPositional = True
     dictTable = {
         "type": "table",
         "title": "Diffraction Plan",
         "columns": [],
         "data": []
     }
     dictTable["columns"].append("Forced\nspace group")
     dictTable["columns"].append("Anomalous\ndata")
     dictTable["columns"].append("Aimed\nmultiplicity")
     dictTable["columns"].append("Aimed\ncompleteness")
     dictTable["columns"].append("Aimed I/sigma\nat highest res.")
     dictTable["columns"].append("Aimed\nresolution (Å)")
     dictTable["columns"].append("Min osc.\nwidth")
     if strExtraColumnTitle is not None:
         dictTable["columns"].append(strExtraColumnTitle)
     listRow = []
     # Forced space group
     if xsDataDiffractionPlan.getForcedSpaceGroup() is None:
         strForcedSpaceGroup = "None"
     else:
         strForcedSpaceGroup = xsDataDiffractionPlan.getForcedSpaceGroup(
         ).getValue()
     listRow.append(strForcedSpaceGroup)
     # Anomalous data
     if xsDataDiffractionPlan.getAnomalousData(
     ) is None or xsDataDiffractionPlan.getAnomalousData().getValue(
     ) == False:
         strAnomalousData = "False"
     else:
         strAnomalousData = "True"
     listRow.append(strAnomalousData)
     # Aimed multiplicity
     if xsDataDiffractionPlan.getAimedMultiplicity() is None:
         strAimedMultiplicity = "Default\n(optimized)"
     else:
         strAimedMultiplicity = "%.2f" % xsDataDiffractionPlan.getAimedMultiplicity(
         ).getValue()
     listRow.append(strAimedMultiplicity)
     # Aimed completeness
     if xsDataDiffractionPlan.getAimedCompleteness() is None:
         strAimedCompleteness = "Default\n(>= 0.99)"
     else:
         strAimedCompleteness = "%.2f" % xsDataDiffractionPlan.getAimedCompleteness(
         ).getValue()
     listRow.append(strAimedCompleteness)
     # Aimed aimedIOverSigmaAtHighestResolution
     if xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution(
     ) is None:
         strAimedIOverSigmaAtHighestResolution = "BEST Default"
     else:
         strAimedIOverSigmaAtHighestResolution = "%.2f" % xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution(
         ).getValue()
     listRow.append(strAimedIOverSigmaAtHighestResolution)
     # Aimed resolution
     if xsDataDiffractionPlan.getAimedResolution() is None:
         strAimedResolution = "Default\n(highest possible)"
     else:
         strAimedResolution = "%0.2f" % xsDataDiffractionPlan.getAimedResolution(
         ).getValue()
     listRow.append(strAimedResolution)
     # Min osc width
     if xsDataDiffractionPlan.goniostatMinOscillationWidth is None:
         strMinOscWidth = "Default"
     else:
         strMinOscWidth = "%0.2f" % xsDataDiffractionPlan.goniostatMinOscillationWidth.value
     listRow.append(strMinOscWidth)
     if strExtraColumnValue is not None:
         listRow.append(strExtraColumnValue)
     #
     dictTable["data"].append(listRow)
     self.workflowStepReport.addTable(strTitle, dictTable["columns"],
                                      dictTable["data"])
 def createInputCharacterisationFromSubWedges(self):
     self.DEBUG("EDPluginControlInterfacev2_0.createInputCharacterisationFromSubWedges")
     xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput()
     self.xsDataInputCharacterisation = XSDataInputCharacterisation()
     xsDataCollection = XSDataCollection()
     # Default exposure time (for the moment, this value should be
     # possible to read from the command line)
     xsDataDiffractionPlan = XSDataDiffractionPlan()
     if (not xsDataResultSubWedgeAssemble is None):
         pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
         xsDataCollection.setSubWedge(pyListSubWedge)
         for xsDataSubWedge in pyListSubWedge:
             if (self.strComplexity is not None):
                 xsDataDiffractionPlan.setComplexity(XSDataString(self.strComplexity))
             if (self.fFlux is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setFlux(XSDataFloat(self.fFlux))
             if (self.fBeamSize is not None):
                 xsDataSize = XSDataSize()
                 xsDataSize.setX(XSDataLength(self.fBeamSize))
                 xsDataSize.setY(XSDataLength(self.fBeamSize))
                 xsDataSubWedge.getExperimentalCondition().getBeam().setSize(xsDataSize)
             if (self.fBeamPosX is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionX(XSDataLength(self.fBeamPosX))
             if (self.fBeamPosY is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionY(XSDataLength(self.fBeamPosY))
             if (self.fMinExposureTimePerImage is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setMinExposureTimePerImage(XSDataFloat(self.fMinExposureTimePerImage))
             if (self.fTransmission is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam().setTransmission(XSDataDouble(self.fTransmission))
     if (self.strForcedSpaceGroup is not None):
         xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.strForcedSpaceGroup))
     xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.bAnomalousData))
     xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.fMaxExposureTimePerDataCollection))
     if (self.strStrategyOption is not None):
         xsDataDiffractionPlan.setStrategyOption(XSDataString(self.strStrategyOption))
     xsDataCollection.setDiffractionPlan(xsDataDiffractionPlan)
     self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)
    def preProcess(self, _edPlugin=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev2_0.preProcess...")

        self.listImagePaths = []

        if (self.hasDataInput("diffractionPlan")):
            xsDataDiffractionPlan = XSDataDiffractionPlan()
            xsDataDiffractionPlans = self.getDataInput("diffractionPlan")
            if (not xsDataDiffractionPlans[0] is None):
                xsDataDiffractionPlan = xsDataDiffractionPlans[0]
                if (not xsDataDiffractionPlan.getForcedSpaceGroup() is None):
                    self.strForcedSpaceGroup = xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
                if (not xsDataDiffractionPlan.getMaxExposureTimePerDataCollection() is None):
                    self.fMaxExposureTimePerDataCollection = xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue()
                if (not xsDataDiffractionPlan.getAnomalousData() is None):
                    self.bAnomalousData = xsDataDiffractionPlan.getAnomalousData().getValue()
                if (not xsDataDiffractionPlan.getStrategyOption() is None):
                    self.strStrategyOption = xsDataDiffractionPlan.getStrategyOption().getValue()
                if (not xsDataDiffractionPlan.getComplexity() is None):
                    self.strComplexity = xsDataDiffractionPlan.getComplexity().getValue()

        if (self.hasDataInput("imagePaths")):
            for strImagePath in self.getDataInput("imagePaths"):
                self.listImagePaths.append(strImagePath)
        if (self.hasDataInput("flux")):
            self.fFlux = self.getDataInput("flux")[0].getValue()
        if (self.hasDataInput("minExposureTimePerImage")):
            self.fMinExposureTimePerImage = self.getDataInput("minExposureTimePerImage")[0].getValue()
        if (self.hasDataInput("beamSize")):
            self.fBeamSize = self.getDataInput("beamSize")[0].getValue()
        if (self.hasDataInput("templateMode")):
            self.bTemplateMode = self.getDataInput("templateMode")[0].getValue()
        if (self.hasDataInput("generatedTemplateFile")):
            self.strGeneratedTemplateFile = self.getDataInput("generatedTemplateFile")[0].getValue()
        if (self.hasDataInput("generatedTemplateFileMXv2")):
            self.strGeneratedTemplateFileMXv2 = self.getDataInput("generatedTemplateFileMXv2")[0].getValue()
        if (self.hasDataInput("resultsFilePath")):
            self.strResultsFilePath = self.getDataInput("resultsFilePath")[0].getValue()
        if (self.hasDataInput("beamPosX")):
            self.fBeamPosX = self.getDataInput("beamPosX")[0].getValue()
        if (self.hasDataInput("beamPosY")):
            self.fBeamPosY = self.getDataInput("beamPosY")[0].getValue()
        if (self.hasDataInput("transmission")):
            self.fTransmission = self.getDataInput("transmission")[0].getValue()
        if (self.hasDataInput("dataCollectionId")):
            self.iDataCollectionId = self.getDataInput("dataCollectionId")[0].getValue()
        if (self.hasDataInput("shortComments")):
            self.strShortComments = self.getDataInput("shortComments")[0].getValue()
        if (self.hasDataInput("comments")):
            self.strComments = self.getDataInput("comments")[0].getValue()
        if (self.hasDataInput("inputCharacterisation")):
            self.xsDataInputCharacterisation = self.getDataInput("inputCharacterisation")[0]
        if (self.hasDataInput("mxv2DataCollection")):
            self.xsDataCollectionMXv2 = self.getDataInput("mxv2DataCollection")[0]

        # Check if XML data is given as input :
        if (self.xsDataInputCharacterisation is None):
            self.edPluginControlSubWedgeAssemble = self.loadPlugin(self.strEDPluginControlSubWedgeAssembleName, "SubWedgeAssemble")

        self.edPluginControlCharacterisation = self.loadPlugin(self.strEDPluginControlCharacterisationName, "Characterisation")

        if (self.strEDPluginControlISPyBName is not None):
            self.edPluginControlISPyB = self.loadPlugin(self.strEDPluginControlISPyBName, "ISPyB")
Esempio n. 13
0
 def createInputCharacterisationFromSubWedges(self):
     EDVerbose.DEBUG(
         "EDPluginControlInterfacev2_0.createInputCharacterisationFromSubWedges"
     )
     xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput(
     )
     self.xsDataInputCharacterisation = XSDataInputCharacterisation()
     xsDataCollection = XSDataCollection()
     # Default exposure time (for the moment, this value should be
     # possible to read from the command line)
     xsDataDiffractionPlan = XSDataDiffractionPlan()
     if (not xsDataResultSubWedgeAssemble is None):
         pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
         xsDataCollection.setSubWedge(pyListSubWedge)
         for xsDataSubWedge in pyListSubWedge:
             if (self.strComplexity is not None):
                 xsDataDiffractionPlan.setComplexity(
                     XSDataString(self.strComplexity))
             if (self.fFlux is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setFlux(XSDataFloat(self.fFlux))
             if (self.fBeamSize is not None):
                 xsDataSize = XSDataSize()
                 xsDataSize.setX(XSDataLength(self.fBeamSize))
                 xsDataSize.setY(XSDataLength(self.fBeamSize))
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setSize(xsDataSize)
             if (self.fBeamPosX is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector(
                 ).setBeamPositionX(XSDataLength(self.fBeamPosX))
             if (self.fBeamPosY is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector(
                 ).setBeamPositionY(XSDataLength(self.fBeamPosY))
             if (self.fMinExposureTimePerImage is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setMinExposureTimePerImage(
                     XSDataFloat(self.fMinExposureTimePerImage))
             if (self.fTransmission is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setTransmission(XSDataDouble(self.fTransmission))
     if (self.strForcedSpaceGroup is not None):
         xsDataDiffractionPlan.setForcedSpaceGroup(
             XSDataString(self.strForcedSpaceGroup))
     xsDataDiffractionPlan.setAnomalousData(
         XSDataBoolean(self.bAnomalousData))
     xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
         XSDataTime(self.fMaxExposureTimePerDataCollection))
     if (self.strStrategyOption is not None):
         xsDataDiffractionPlan.setStrategyOption(
             XSDataString(self.strStrategyOption))
     xsDataCollection.setDiffractionPlan(xsDataDiffractionPlan)
     self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)
 def diffractionPlan(self):
     # Do we have a diffracionPlan?
     xsDataDiffractionPlan = self.xsDataResultCharacterisation.getDataCollection().getDiffractionPlan()
     if xsDataDiffractionPlan is None:
         xsDataDiffractionPlan = XSDataDiffractionPlan()
     strTitle = "Diffraction Plan"
     strExtraColumnTitle = None
     strExtraColumnValue = None
     if xsDataDiffractionPlan.strategyOption is not None:
         strStrategyOption = xsDataDiffractionPlan.strategyOption.value
         if strStrategyOption.find("-helic") != -1:
             strTitle = "Helical Diffraction Plan"
             self.bIsHelical = True
             strExtraColumnTitle = "Helical<br>distance (mm)"
             if self.dataInput.helicalDistance is not None:
                 fHelicalDistance = self.dataInput.helicalDistance.value
                 strExtraColumnValue = "%.3f" % fHelicalDistance
             else:
                 strExtraColumnValue = "Unknown"
         elif strStrategyOption.find("-Npos") != -1:
             strTitle = "Multi-positional Diffraction Plan"
             self.bIsMultiPositional = True
     dictTable = {"type": "table",
                  "title": "Diffraction Plan",
                  "columns": [],
                  "data": []}
     dictTable["columns"].append("Forced\nspace group")
     dictTable["columns"].append("Anomalous\ndata")
     dictTable["columns"].append("Aimed\nmultiplicity")
     dictTable["columns"].append("Aimed\ncompleteness")
     dictTable["columns"].append("Aimed I/sigma\nat highest res.")
     dictTable["columns"].append("Aimed\nresolution (&Aring;)")
     dictTable["columns"].append("Min osc.\nwidth")
     if strExtraColumnTitle is not None:
         dictTable["columns"].append(strExtraColumnTitle)
     listRow = []
     # Forced space group
     if xsDataDiffractionPlan.getForcedSpaceGroup() is None:
         strForcedSpaceGroup = "None"
     else:
         strForcedSpaceGroup = xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
     listRow.append(strForcedSpaceGroup)
     # Anomalous data
     if xsDataDiffractionPlan.getAnomalousData() is None or xsDataDiffractionPlan.getAnomalousData().getValue() == False:
         strAnomalousData = "False"
     else:
         strAnomalousData = "True"
     listRow.append(strAnomalousData)
     # Aimed multiplicity
     if xsDataDiffractionPlan.getAimedMultiplicity() is None:
         strAimedMultiplicity = "Default<br>(optimized)"
     else:
         strAimedMultiplicity = "%.2f" % xsDataDiffractionPlan.getAimedMultiplicity().getValue()
     listRow.append(strAimedMultiplicity)
     # Aimed completeness
     if xsDataDiffractionPlan.getAimedCompleteness() is None:
         strAimedCompleteness = "Default<br>(>= 0.99)"
     else:
         strAimedCompleteness = "%.2f" % xsDataDiffractionPlan.getAimedCompleteness().getValue()
     listRow.append(strAimedCompleteness)
     # Aimed aimedIOverSigmaAtHighestResolution
     if xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution() is None:
         strAimedIOverSigmaAtHighestResolution = "BEST Default"
     else:
         strAimedIOverSigmaAtHighestResolution = "%.2f" % xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution().getValue()
     listRow.append(strAimedIOverSigmaAtHighestResolution)
     # Aimed resolution
     if xsDataDiffractionPlan.getAimedResolution() is None:
         strAimedResolution = "Default<br>(highest possible)"
     else:
         strAimedResolution = "%0.2f" % xsDataDiffractionPlan.getAimedResolution().getValue()
     listRow.append(strAimedResolution)
     # Min osc width
     if xsDataDiffractionPlan.goniostatMinOscillationWidth is None:
         strMinOscWidth = "Default"
     else:
         strMinOscWidth = "%0.2f" % xsDataDiffractionPlan.goniostatMinOscillationWidth.value
     listRow.append(strMinOscWidth)
     if strExtraColumnValue is not None:
         listRow.append(strExtraColumnValue)
     #
     dictTable["data"].append(listRow)
     self.workflowStepReport.addTable(strTitle,
                                      dictTable["columns"],
                                      dictTable["data"])
class EDPluginControlInterfacev1_2(EDPluginControl):
    """
    This is the common class to all plugins managing user interfaces
    """

    def __init__ (self):
        """
        """
        EDPluginControl.__init__(self)

        self.setXSDataInputClass(XSDataInputInterface)

        self.setXSDataInputClass(XSDataExperimentalCondition, "experimentalCondition")
        self.setXSDataInputClass(XSDataDiffractionPlan, "diffractionPlan")
        self.setXSDataInputClass(XSDataSampleCrystalMM, "sample")
        self.setXSDataInputClass(XSDataString, "imagePaths")
        self.setXSDataInputClass(XSDataFloat, "flux")
        self.setXSDataInputClass(XSDataFloat, "minExposureTimePerImage")
        self.setXSDataInputClass(XSDataFloat, "beamSize")
        self.setXSDataInputClass(XSDataFloat, "beamSizeX")
        self.setXSDataInputClass(XSDataFloat, "beamSizeY")
        self.setXSDataInputClass(XSDataBoolean, "templateMode")
        self.setXSDataInputClass(XSDataString, "generatedTemplateFile")
        self.setXSDataInputClass(XSDataString, "resultsFilePath")
        self.setXSDataInputClass(XSDataFloat, "beamPosX")
        self.setXSDataInputClass(XSDataFloat, "beamPosY")
        self.setXSDataInputClass(XSDataDouble, "wavelength")
        self.setXSDataInputClass(XSDataDouble, "transmission")
        self.setXSDataInputClass(XSDataInteger, "dataCollectionId")
        self.setXSDataInputClass(XSDataString, "shortComments")
        self.setXSDataInputClass(XSDataString, "comments")
        self.setXSDataInputClass(XSDataInputCharacterisation, "inputCharacterisation")

        self.strEDPluginControlSubWedgeAssembleName = "EDPluginControlSubWedgeAssemblev1_1"
        self.strEDPluginControlCharacterisationName = "EDPluginControlCharacterisationv1_1"
        self.strEDPluginControlISPyBName = "EDPluginControlISPyBv1_1"

        self.edPluginControlSubWedgeAssemble = None
        self.edPluginControlCharacterisation = None
        self.edPluginControlISPyB = None

        self.pyListImagePaths = None
        self.xsDataInputCharacterisation = None
        self.strComplexity = "none"

        self.listImagePaths = []
        self.fFlux = None
        self.fMaxExposureTimePerDataCollection = 10000 # s, default prototype value
        self.fMinExposureTimePerImage = None
        self.fBeamSizeX = None
        self.fBeamSizeY = None
        self.bTemplateMode = False
        self.strGeneratedTemplateFile = None
        self.strResultsFilePath = None
        self.strForcedSpaceGroup = None
        self.bAnomalousData = False
        self.fBeamPosX = None
        self.fBeamPosY = None
        self.fMinOscillationWidth = None
        self.fMaxOscillationSpeed = None
        self.fWavelength = None
        self.fTransmission = None
        self.strStrategyOption = None
        self.iDataCollectionId = None
        self.strShortComments = None
        self.strComments = None
        self.strStatusMessage = None

        self.xsDataExperimentalCodition = None
        self.xsDataSample = None
        self.xsDataDiffractionPlan = None


    def configure(self):
        """
        Gets the configuration parameters (if any).
        """
        EDPluginControl.configure(self)
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.configure")
        pluginConfiguration = self.getConfiguration()

        if (pluginConfiguration is None):
            EDVerbose.DEBUG("No plugin configuration found for EDPluginControlInterfacev1_2.")
        else:
            if (self.getControlledPluginName("subWedgeAssemblePlugin") is not None):
                self.strEDPluginControlSubWedgeAssembleName = self.getControlledPluginName("subWedgeAssemblePlugin")
            if (self.getControlledPluginName("characterisationPlugin") is not None):
                self.strEDPluginControlCharacterisationName = self.getControlledPluginName("characterisationPlugin")
            if (self.getControlledPluginName("ispybPlugin") is not None):
                self.strEDPluginControlISPyBName = self.getControlledPluginName("ispybPlugin")

            bUseISPyBPlugin = EDConfiguration.getStringParamValue(pluginConfiguration, "useISPyBPlugin")
            if (bUseISPyBPlugin.lower() != "true"):
                self.strEDPluginControlISPyBName = None


    def preProcess(self, _edPlugin=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.preProcess...")

        self.listImagePaths = []

        # Check if XSDataInputInterface is given as input
        if self.hasDataInput():
            xsDataInputInterface = self.getDataInput()

            if xsDataInputInterface.getExperimentalCondition():
                self.xsDataExperimentalCodition = xsDataInputInterface.getExperimentalCondition()
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed().getValue()


            self.xsDataSample = xsDataInputInterface.getSample()

            self.xsDataDiffractionPlan = self.getDataInput().getDiffractionPlan()
            if self.xsDataDiffractionPlan:
                if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                    self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
                if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection():
                    self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue()
                if self.xsDataDiffractionPlan.getAnomalousData():
                    self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData().getValue()
                if self.xsDataDiffractionPlan.getStrategyOption():
                    self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption().getValue()
                if self.xsDataDiffractionPlan.getComplexity():
                    self.strComplexity = self.xsDataDiffractionPlan.getComplexity().getValue()
                if self.fMinOscillationWidth == None:
                    if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth().getValue()
                if self.fMaxOscillationSpeed == None:
                    if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed().getValue()


            self.xsDataSample = xsDataInputInterface.getSample()

            if xsDataInputInterface.getImagePath():
                for xsDataFile in xsDataInputInterface.getImagePath():
                    self.listImagePaths.append(xsDataFile.getPath())

            if xsDataInputInterface.getFlux():
                self.fFlux = xsDataInputInterface.getFlux().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux() != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam().getFlux().getValue()

            if xsDataInputInterface.getMinExposureTimePerImage():
                self.fMinExposureTimePerImage = xsDataInputInterface.getMinExposureTimePerImage().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and xsDataInputInterface.getDiffractionPlan():
                if xsDataInputInterface.getDiffractionPlan().getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = xsDataInputInterface.getdiffractionPlan().getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize() != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam().getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam().getSize().getY().getValue()

            if xsDataInputInterface.getBeamSize():
                self.fBeamSizeX = xsDataInputInterface.getBeamSize().getValue()
                self.fBeamSizeY = xsDataInputInterface.getBeamSize().getValue()

            if xsDataInputInterface.getBeamSizeX():
                self.fBeamSizeX = xsDataInputInterface.getBeamSizeX().getValue()

            if xsDataInputInterface.getBeamSizeY():
                self.fBeamSizeY = xsDataInputInterface.getBeamSizeY().getValue()

            if xsDataInputInterface.getTemplateMode():
                self.bTemplateMode = xsDataInputInterface.getTemplateMode().getValue()

            if xsDataInputInterface.getBeamPosX():
                self.fBeamPosX = xsDataInputInterface.getBeamPosX().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector().getBeamPositionX().getValue()

            if xsDataInputInterface.getBeamPosY():
                self.fBeamPosY = xsDataInputInterface.getBeamPosY().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector().getBeamPositionY().getValue()

            if xsDataInputInterface.getWavelength():
                self.fWavelength = xsDataInputInterface.getWavelength().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength() != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam().getWavelength().getValue()

            if xsDataInputInterface.getTransmission():
                self.fTransmission = xsDataInputInterface.getTransmission().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam().getTransmission().getValue()

            if xsDataInputInterface.getGeneratedTemplateFile():
                self.strGeneratedTemplateFile = xsDataInputInterface.getGeneratedTemplateFile().getPath().getValue()

            if xsDataInputInterface.getResultsFilePath():
                self.strResultsFilePath = xsDataInputInterface.getResultsFilePath().getPath().getValue()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId().getValue()

            if xsDataInputInterface.getShortComments():
                self.strShortComments = xsDataInputInterface.getShortComments().getValue()

            if xsDataInputInterface.getComments():
                self.strComments = xsDataInputInterface.getComments().getValue()

            if xsDataInputInterface.getInputCharacterisation():
                self.xsDataInputCharacterisation = xsDataInputInterface.getInputCharacterisation()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId().getValue()

        else:

            if self.hasDataInput("experimentalCondition"):
                self.xsDataExperimentalCodition = self.getDataInput("experimentalCondition")[0]
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed().getValue()


            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if (self.hasDataInput("diffractionPlan")):
                if self.xsDataDiffractionPlan is None:
                    self.xsDataDiffractionPlan = XSDataDiffractionPlan()
                xsDataDiffractionPlans = self.getDataInput("diffractionPlan")
                if (not xsDataDiffractionPlans[0] is None):
                    self.xsDataDiffractionPlan = xsDataDiffractionPlans[0]
                    if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                        self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
                    if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection():
                        self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue()
                    if self.xsDataDiffractionPlan.getAnomalousData():
                        self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData().getValue()
                    if self.xsDataDiffractionPlan.getStrategyOption():
                        self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption().getValue()
                    if self.xsDataDiffractionPlan.getComplexity():
                        self.strComplexity = self.xsDataDiffractionPlan.getComplexity().getValue()
                    if self.fMinOscillationWidth == None:
                        if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth():
                            self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth().getValue()
                    if self.fMaxOscillationSpeed == None:
                        if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed():
                            self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed().getValue()


            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if self.hasDataInput("imagePaths"):
                for strImagePath in self.getDataInput("imagePaths"):
                    self.listImagePaths.append(strImagePath)

            if self.hasDataInput("flux"):
                self.fFlux = self.getDataInput("flux")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux() != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam().getFlux().getValue()

            if self.hasDataInput("minExposureTimePerImage"):
                self.fMinExposureTimePerImage = self.getDataInput("minExposureTimePerImage")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and self.hasDataInput("diffractionPlan"):
                if self.getDataInput("diffractionPlan")[0].getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = self.getDataInput("diffractionPlan")[0].getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize() != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam().getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam().getSize().getY().getValue()

            if self.hasDataInput("beamSize"):
                self.fBeamSizeX = self.getDataInput("beamSize")[0].getValue()
                self.fBeamSizeY = self.getDataInput("beamSize")[0].getValue()

            if self.hasDataInput("beamSizeX"):
                self.fBeamSizeX = self.getDataInput("beamSizeX")[0].getValue()

            if self.hasDataInput("beamSizeY"):
                self.fBeamSizeY = self.getDataInput("beamSizeY")[0].getValue()

            if self.hasDataInput("templateMode"):
                self.bTemplateMode = self.getDataInput("templateMode")[0].getValue()

            if (self.hasDataInput("beamPosX")):
                self.fBeamPosX = self.getDataInput("beamPosX")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector().getBeamPositionX().getValue()

            if (self.hasDataInput("beamPosY")):
                self.fBeamPosY = self.getDataInput("beamPosY")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector().getBeamPositionY().getValue()

            if (self.hasDataInput("wavelength")):
                self.fWavelength = self.getDataInput("wavelength")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength() != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam().getWavelength().getValue()

            if (self.hasDataInput("transmission")):
                self.fTransmission = self.getDataInput("transmission")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam().getTransmission().getValue()

            if self.hasDataInput("generatedTemplateFile"):
                self.strGeneratedTemplateFile = self.getDataInput("generatedTemplateFile")[0].getValue()

            if self.hasDataInput("resultsFilePath"):
                self.strResultsFilePath = self.getDataInput("resultsFilePath")[0].getValue()

            if self.hasDataInput("dataCollectionId"):
                self.iDataCollectionId = self.getDataInput("dataCollectionId")[0].getValue()

            if self.hasDataInput("shortComments"):
                self.strShortComments = self.getDataInput("shortComments")[0].getValue()

            if self.hasDataInput("comments"):
                self.strComments = self.getDataInput("comments")[0].getValue()

            if self.hasDataInput("inputCharacterisation"):
                self.xsDataInputCharacterisation = self.getDataInput("inputCharacterisation")[0]

        # Check if XML data is given as input :
        if (self.xsDataInputCharacterisation is None):
            self.edPluginControlSubWedgeAssemble = self.loadPlugin(self.strEDPluginControlSubWedgeAssembleName, "SubWedgeAssemble")

        self.edPluginControlCharacterisation = self.loadPlugin(self.strEDPluginControlCharacterisationName, "Characterisation")

        if (self.strEDPluginControlISPyBName is not None):
            self.edPluginControlISPyB = self.loadPlugin(self.strEDPluginControlISPyBName, "ISPyB")


    def process(self, _edPlugin=None):
        EDPluginControl.process(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.process...")

        if (self.edPluginControlSubWedgeAssemble is not None):
            if(self.bTemplateMode == True):
                self.edPluginControlSubWedgeAssemble.connectSUCCESS(self.generateTemplateFile)
            else:
                self.edPluginControlSubWedgeAssemble.connectSUCCESS(self.doSubWedgeAssembleSUCCESS)
            self.edPluginControlSubWedgeAssemble.connectFAILURE(self.doSubWedgeAssembleFAILURE)

        if(self.edPluginControlCharacterisation is not None):
            self.edPluginControlCharacterisation.connectSUCCESS(self.doSuccessActionCharacterisation)
            self.edPluginControlCharacterisation.connectFAILURE(self.doFailureActionCharacterisation)

        if (self.edPluginControlISPyB is not None):
            self.edPluginControlISPyB.connectSUCCESS(self.doSuccessActionISPyB)
            self.edPluginControlISPyB.connectFAILURE(self.doFailureActionISPyB)

        if (self.xsDataInputCharacterisation is None):
            self.createInputCharacterisationFromImageHeaders(self.edPluginControlSubWedgeAssemble)
        else:
            self.runCharacterisationPlugin(self.edPluginControlCharacterisation)


    def finallyProcess(self, _edPlugin=None):
        EDPluginControl.finallyProcess(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.finallyProcess...")

        if (not self.edPluginControlCharacterisation is None):
            if (self.edPluginControlCharacterisation.hasDataOutput()):
                self.setDataOutput(self.edPluginControlCharacterisation.getDataOutput(), "characterisation")
        if (not self.edPluginControlISPyB is None):
            if (self.edPluginControlISPyB.hasDataOutput()):
                self.setDataOutput(self.edPluginControlISPyB.getDataOutput(), "ISPyB")
        if self.hasDataInput():
            xsDataResultInterface = XSDataResultInterface()
            if self.edPluginControlCharacterisation:
                xsDataResultInterface.setResultCharacterisation(self.edPluginControlCharacterisation.getDataOutput())
            if self.edPluginControlISPyB:
                xsDataResultInterface.setResultControlISPyB(self.edPluginControlISPyB.getDataOutput())
            self.setDataOutput(xsDataResultInterface)


    def createInputCharacterisationFromImageHeaders(self, _edPlugin):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.createInputCharacterisationFromImageHeaders")
        xsDataInputSubWedgeAssemble = XSDataInputSubWedgeAssemble()
        for xsDataStringImagePath in self.listImagePaths:
            xsDataFile = XSDataFile()
            xsDataFile.setPath(xsDataStringImagePath)
            xsDataInputSubWedgeAssemble.addFile(xsDataFile)
        _edPlugin.setDataInput(xsDataInputSubWedgeAssemble)
        _edPlugin.executeSynchronous()


    def runCharacterisationPlugin(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.runCharacterisationPlugin")
        self.edPluginControlCharacterisation.setDataInput(self.xsDataInputCharacterisation)
        self.edPluginControlCharacterisation.executeSynchronous()


    def storeResultsInISPyB(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.storeResultsInISPyB")
        if (self.edPluginControlISPyB is not None):
            # Execute the ISPyB control plugin
            xsDataInputControlISPyB = XSDataInputControlISPyB()
            xsDataInputControlISPyB.setCharacterisationResult(self.edPluginControlCharacterisation.getDataOutput())
            if (not self.iDataCollectionId is None):
                xsDataInputControlISPyB.setDataCollectionId(XSDataInteger(self.iDataCollectionId))
            if (not self.strShortComments is None):
                self.edPluginControlISPyB.setDataInput(XSDataString(self.strShortComments), "shortComments")
            if (not self.strComments is None):
                self.edPluginControlISPyB.setDataInput(XSDataString(self.strComments), "comments")
            if (not self.strStatusMessage is None):
                self.edPluginControlISPyB.setDataInput(XSDataString(self.strStatusMessage), "statusMessage")
            self.edPluginControlISPyB.setDataInput(xsDataInputControlISPyB)
            self.edPluginControlISPyB.executeSynchronous()


    def createInputCharacterisationFromSubWedges(self):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.createInputCharacterisationFromSubWedges")
        xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput()
        self.xsDataInputCharacterisation = XSDataInputCharacterisation()
        xsDataCollection = XSDataCollection()
        # Default exposure time (for the moment, this value should be
        # possible to read from the command line)
        if self.xsDataDiffractionPlan is None:
            self.xsDataDiffractionPlan = XSDataDiffractionPlan()
        if (not xsDataResultSubWedgeAssemble is None):
            pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
            xsDataCollection.setSubWedge(pyListSubWedge)
            for xsDataSubWedge in pyListSubWedge:
                if (self.strComplexity is not None):
                    self.xsDataDiffractionPlan.setComplexity(XSDataString(self.strComplexity))
                if (self.fFlux is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setFlux(XSDataFlux(self.fFlux))
                if (self.fBeamSizeX is not None) and (self.fBeamSizeY is not None):
                    xsDataSize = XSDataSize()
                    xsDataSize.setX(XSDataLength(self.fBeamSizeX))
                    xsDataSize.setY(XSDataLength(self.fBeamSizeY))
                    xsDataSubWedge.getExperimentalCondition().getBeam().setSize(xsDataSize)
                if (self.fBeamPosX is not None):
                    xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionX(XSDataLength(self.fBeamPosX))
                if (self.fBeamPosY is not None):
                    xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionY(XSDataLength(self.fBeamPosY))
                if (self.fMinExposureTimePerImage is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setMinExposureTimePerImage(XSDataTime(self.fMinExposureTimePerImage))
                if (self.fTransmission is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setTransmission(XSDataDouble(self.fTransmission))
                if (self.fWavelength is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setWavelength(XSDataWavelength(self.fWavelength))
                if self.fMinOscillationWidth != None:
                    xsDataSubWedge.getExperimentalCondition().getGoniostat().setMinOscillationWidth(XSDataAngle(self.fMinOscillationWidth))
                if self.fMaxOscillationSpeed != None:
                    xsDataSubWedge.getExperimentalCondition().getGoniostat().setMaxOscillationSpeed(XSDataAngularSpeed(self.fMaxOscillationSpeed))
        if (self.strForcedSpaceGroup is not None):
            self.xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.strForcedSpaceGroup))
        self.xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.bAnomalousData))
        self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.fMaxExposureTimePerDataCollection))
        if (self.strStrategyOption is not None):
            self.xsDataDiffractionPlan.setStrategyOption(XSDataString(self.strStrategyOption))
        xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
        if self.xsDataSample is not None:
            xsDataCollection.setSample(XSDataSampleCrystalMM.parseString(self.xsDataSample.marshal()))
        self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)


    def generateTemplateFile(self, _edPlugin):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.generateTemplateFile")
        self.createInputCharacterisationFromSubWedges()
        if(self.strGeneratedTemplateFile is None):
            EDVerbose.screen("No argument for command line --generateTemplate key word found!")
        elif (self.xsDataInputCharacterisation is None):
            EDVerbose.screen("ERROR! Cannot generate template file %s, please check the log files." % self.strGeneratedTemplateFile)
        else:
            EDVerbose.screen("Generating xml template input file for edna: " + self.strGeneratedTemplateFile + "...")
            self.xsDataInputCharacterisation.exportToFile(self.strGeneratedTemplateFile)


    def doSubWedgeAssembleSUCCESS(self, _edPlugin):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.doSubWedgeAssembleSUCCESS")
        self.createInputCharacterisationFromSubWedges()
        self.runCharacterisationPlugin(_edPlugin)

    def doSubWedgeAssembleFAILURE(self, _edPlugin):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.doSubWedgeAssembleFAILURE")
        EDVerbose.screen("Execution of " + self.strEDPluginControlSubWedgeAssembleName + "  failed.")
        EDVerbose.screen("Please inspect the log file for further information.")
        self.setFailure()

    def doFailureActionCharacterisation(self, _edPlugin=None):
        """
        retrieve the potential warning messages
        retrieve the potential error messages
        """
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.doFailureActionCharacterisation")
        self.retrieveFailureMessages(self.edPluginControlCharacterisation, "EDPluginControlInterfacev1_2.doSuccessActionISPyB")
        if _edPlugin.hasDataOutput("statusMessage"):
            self.strStatusMessage = _edPlugin.getDataOutput("statusMessage")[0].getValue()
        self.generateExecutiveSummary(self)
        self.storeResultsInISPyB(_edPlugin)
        self.setFailure()

    def doSuccessActionCharacterisation(self, _edPlugin=None):
        """
        retrieve the potential warning messages
        """
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.doSuccessActionCharacterisation")
        # Store the results if requested
        if (self.strResultsFilePath is not None):
            xsDataCharacterisationResult = _edPlugin.getDataOutput()
            if (xsDataCharacterisationResult is not None):
                xsDataCharacterisationResult.exportToFile(self.strResultsFilePath)
        if _edPlugin.hasDataOutput("statusMessage"):
            self.strStatusMessage = _edPlugin.getDataOutput("statusMessage")[0].getValue()
        self.storeResultsInISPyB(_edPlugin)

    def doSuccessActionISPyB(self, _edPlugin):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.doSuccessActionISPyB...")
        self.retrieveSuccessMessages(self.edPluginControlISPyB, "EDPluginControlInterfacev1_2.doSuccessActionISPyB")

    def doFailureActionISPyB(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.doFailureActionISpyB...")
        self.generateExecutiveSummary(self)
        self.setFailure()

    def generateExecutiveSummary(self, _edPlugin=None):
        """
        Prints the executive summary from the plugin
        """
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.generateExecutiveSummary")
        if (self.edPluginControlSubWedgeAssemble is not None):
            if self.edPluginControlSubWedgeAssemble.getListExecutiveSummaryLines() != []:
                self.addExecutiveSummaryLine("Summary of plugin %s:" % self.strEDPluginControlSubWedgeAssembleName)
                self.appendExecutiveSummary(self.edPluginControlSubWedgeAssemble)
        if (self.edPluginControlCharacterisation is not None):
            self.addExecutiveSummaryLine("Summary of plugin %s:" % self.strEDPluginControlCharacterisationName)
            self.appendExecutiveSummary(self.edPluginControlCharacterisation)
        if (self.edPluginControlISPyB is not None):
            self.addExecutiveSummaryLine("Summary of plugin %s:" % self.strEDPluginControlISPyBName)
            self.appendExecutiveSummary(self.edPluginControlISPyB)
        self.verboseScreenExecutiveSummary()
Esempio n. 16
0
class EDPluginControlInterfacev1_3(EDPluginControl):
    """
    This is the common class to all plugins managing user interfaces
    """
    def __init__(self):
        """
        """
        EDPluginControl.__init__(self)

        self.setXSDataInputClass(XSDataInputInterface)

        self.setXSDataInputClass(XSDataExperimentalCondition,
                                 "experimentalCondition")
        self.setXSDataInputClass(XSDataDiffractionPlan, "diffractionPlan")
        self.setXSDataInputClass(XSDataSampleCrystalMM, "sample")
        self.setXSDataInputClass(XSDataString, "imagePaths")
        self.setXSDataInputClass(XSDataFloat, "flux")
        self.setXSDataInputClass(XSDataFloat, "minExposureTimePerImage")
        self.setXSDataInputClass(XSDataFloat, "beamSize")
        self.setXSDataInputClass(XSDataFloat, "beamSizeX")
        self.setXSDataInputClass(XSDataFloat, "beamSizeY")
        self.setXSDataInputClass(XSDataBoolean, "templateMode")
        self.setXSDataInputClass(XSDataString, "generatedTemplateFile")
        self.setXSDataInputClass(XSDataString, "resultsFilePath")
        self.setXSDataInputClass(XSDataFloat, "beamPosX")
        self.setXSDataInputClass(XSDataFloat, "beamPosY")
        self.setXSDataInputClass(XSDataDouble, "wavelength")
        self.setXSDataInputClass(XSDataDouble, "transmission")
        self.setXSDataInputClass(XSDataInteger, "dataCollectionId")
        self.setXSDataInputClass(XSDataString, "shortComments")
        self.setXSDataInputClass(XSDataString, "comments")
        self.setXSDataInputClass(XSDataInputCharacterisation,
                                 "inputCharacterisation")

        self.strEDPluginControlSubWedgeAssembleName = "EDPluginControlSubWedgeAssemblev1_1"
        self.strEDPluginControlCharacterisationName = "EDPluginControlCharacterisationv1_5"
        self.strEDPluginControlISPyBName = "EDPluginControlISPyBv1_1"

        self.edPluginControlSubWedgeAssemble = None
        self.edPluginControlCharacterisation = None
        self.edPluginControlISPyB = None

        self.pyListImagePaths = None
        self.xsDataInputCharacterisation = None
        self.strComplexity = "none"

        self.listImagePaths = []
        self.fFlux = None
        self.fMaxExposureTimePerDataCollection = 10000  # s, default prototype value
        self.fMinExposureTimePerImage = None
        self.fBeamSizeX = None
        self.fBeamSizeY = None
        self.fApertureSize = None
        self.bTemplateMode = False
        self.strGeneratedTemplateFile = None
        self.strResultsFilePath = None
        self.strForcedSpaceGroup = None
        self.bAnomalousData = False
        self.fBeamPosX = None
        self.fBeamPosY = None
        self.fMinOscillationWidth = None
        self.fMaxOscillationSpeed = None
        self.fWavelength = None
        self.fTransmission = None
        self.strStrategyOption = None
        self.iDataCollectionId = None
        self.strShortComments = None
        self.strComments = None
        self.strStatusMessage = None

        self.xsDataExperimentalCodition = None
        self.xsDataSample = None
        self.xsDataDiffractionPlan = None

    def configure(self):
        """
        Gets the configuration parameters (if any).
        """
        EDPluginControl.configure(self)
        self.DEBUG("EDPluginControlInterfacev1_3.configure")
        if (self.getControlledPluginName("subWedgeAssemblePlugin")
                is not None):
            self.strEDPluginControlSubWedgeAssembleName = self.getControlledPluginName(
                "subWedgeAssemblePlugin")
        if (self.getControlledPluginName("characterisationPlugin")
                is not None):
            self.strEDPluginControlCharacterisationName = self.getControlledPluginName(
                "characterisationPlugin")
        if (self.getControlledPluginName("ispybPlugin") is not None):
            self.strEDPluginControlISPyBName = self.getControlledPluginName(
                "ispybPlugin")

        bUseISPyBPlugin = self.config.get("useISPyBPlugin")
        if not bUseISPyBPlugin:
            self.DEBUG(
                "EDPluginControlInterfacev1_3 configured to not use ISPyB")
            self.strEDPluginControlISPyBName = None

    def preProcess(self, _edPlugin=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev1_3.preProcess...")

        self.listImagePaths = []

        # Check if XSDataInputInterface is given as input
        if self.hasDataInput():
            xsDataInputInterface = self.getDataInput()

            if xsDataInputInterface.getExperimentalCondition():
                self.xsDataExperimentalCodition = xsDataInputInterface.getExperimentalCondition(
                )
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMaxOscillationSpeed().getValue()

            self.xsDataSample = xsDataInputInterface.getSample()

            self.xsDataDiffractionPlan = self.getDataInput(
            ).getDiffractionPlan()
            if self.xsDataDiffractionPlan:
                if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                    self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup(
                    ).getValue()
                if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                ):
                    self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                    ).getValue()
                if self.xsDataDiffractionPlan.getAnomalousData():
                    self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData(
                    ).getValue()
                if self.xsDataDiffractionPlan.getStrategyOption():
                    self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption(
                    ).getValue()
                if self.xsDataDiffractionPlan.getComplexity():
                    self.strComplexity = self.xsDataDiffractionPlan.getComplexity(
                    ).getValue()
                if self.fMinOscillationWidth == None:
                    if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                    ):
                        self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                        ).getValue()
                if self.fMaxOscillationSpeed == None:
                    if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                    ):
                        self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                        ).getValue()

            self.xsDataSample = xsDataInputInterface.getSample()

            if xsDataInputInterface.getImagePath():
                for xsDataFile in xsDataInputInterface.getImagePath():
                    self.listImagePaths.append(xsDataFile.getPath())

            if xsDataInputInterface.getFlux():
                self.fFlux = xsDataInputInterface.getFlux().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux(
                    ) != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam(
                        ).getFlux().getValue()

            if xsDataInputInterface.getMinExposureTimePerImage():
                self.fMinExposureTimePerImage = xsDataInputInterface.getMinExposureTimePerImage(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam(
                        ).getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and xsDataInputInterface.getDiffractionPlan(
            ):
                if xsDataInputInterface.getDiffractionPlan(
                ).getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = xsDataInputInterface.getDiffractionPlan(
                    ).getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize(
                    ) != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getY().getValue()
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getApertureSize() != None:
                        self.fApertureSize = self.xsDataExperimentalCodition.getBeam(
                        ).getApertureSize().getValue()

            if xsDataInputInterface.getBeamSize():
                self.fBeamSizeX = xsDataInputInterface.getBeamSize().getValue()
                self.fBeamSizeY = xsDataInputInterface.getBeamSize().getValue()

            if xsDataInputInterface.getApertureSize():
                self.fApertureSize = xsDataInputInterface.getApertureSize(
                ).getValue()

            if xsDataInputInterface.getBeamSizeX():
                self.fBeamSizeX = xsDataInputInterface.getBeamSizeX().getValue(
                )

            if xsDataInputInterface.getBeamSizeY():
                self.fBeamSizeY = xsDataInputInterface.getBeamSizeY().getValue(
                )

            if xsDataInputInterface.getApertureSize():
                self.fApertureSize = xsDataInputInterface.getApertureSize(
                ).getValue()

            if xsDataInputInterface.getTemplateMode():
                self.bTemplateMode = xsDataInputInterface.getTemplateMode(
                ).getValue()

            if xsDataInputInterface.getBeamPosX():
                self.fBeamPosX = xsDataInputInterface.getBeamPosX().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionX().getValue()

            if xsDataInputInterface.getBeamPosY():
                self.fBeamPosY = xsDataInputInterface.getBeamPosY().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionY().getValue()

            if xsDataInputInterface.getWavelength():
                self.fWavelength = xsDataInputInterface.getWavelength(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength(
                    ) != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam(
                        ).getWavelength().getValue()

            if xsDataInputInterface.getTransmission():
                self.fTransmission = xsDataInputInterface.getTransmission(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam(
                        ).getTransmission().getValue()

            if xsDataInputInterface.getGeneratedTemplateFile():
                self.strGeneratedTemplateFile = xsDataInputInterface.getGeneratedTemplateFile(
                ).getPath().getValue()

            if xsDataInputInterface.getResultsFilePath():
                self.strResultsFilePath = xsDataInputInterface.getResultsFilePath(
                ).getPath().getValue()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId(
                ).getValue()

            if xsDataInputInterface.getShortComments():
                self.strShortComments = xsDataInputInterface.getShortComments(
                ).getValue()

            if xsDataInputInterface.getComments():
                self.strComments = xsDataInputInterface.getComments().getValue(
                )

            if xsDataInputInterface.getInputCharacterisation():
                self.xsDataInputCharacterisation = xsDataInputInterface.getInputCharacterisation(
                )

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId(
                ).getValue()

        else:

            if self.hasDataInput("experimentalCondition"):
                self.xsDataExperimentalCodition = self.getDataInput(
                    "experimentalCondition")[0]
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMaxOscillationSpeed().getValue()

            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if (self.hasDataInput("diffractionPlan")):
                if self.xsDataDiffractionPlan is None:
                    self.xsDataDiffractionPlan = XSDataDiffractionPlan()
                xsDataDiffractionPlans = self.getDataInput("diffractionPlan")
                if (not xsDataDiffractionPlans[0] is None):
                    self.xsDataDiffractionPlan = xsDataDiffractionPlans[0]
                    if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                        self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                    ):
                        self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getAnomalousData():
                        self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getStrategyOption():
                        self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getComplexity():
                        self.strComplexity = self.xsDataDiffractionPlan.getComplexity(
                        ).getValue()
                    if self.fMinOscillationWidth == None:
                        if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                        ):
                            self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                            ).getValue()
                    if self.fMaxOscillationSpeed == None:
                        if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                        ):
                            self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                            ).getValue()

            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if self.hasDataInput("imagePaths"):
                for strImagePath in self.getDataInput("imagePaths"):
                    self.listImagePaths.append(strImagePath)

            if self.hasDataInput("flux"):
                self.fFlux = self.getDataInput("flux")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux(
                    ) != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam(
                        ).getFlux().getValue()

            if self.hasDataInput("minExposureTimePerImage"):
                self.fMinExposureTimePerImage = self.getDataInput(
                    "minExposureTimePerImage")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam(
                        ).getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and self.hasDataInput(
                    "diffractionPlan"):
                if self.getDataInput("diffractionPlan"
                                     )[0].getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = self.getDataInput(
                        "diffractionPlan")[0].getMinExposureTimePerImage(
                        ).getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize(
                    ) != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getY().getValue()
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getApertureSize() != None:
                        self.fApertureSize = self.xsDataExperimentalCodition.getBeam(
                        ).getApertureSize().getValue()

            if self.hasDataInput("beamSize"):
                self.fBeamSizeX = self.getDataInput("beamSize")[0].getValue()
                self.fBeamSizeY = self.getDataInput("beamSize")[0].getValue()

            if self.hasDataInput("apertureSize"):
                self.fApertureSize = self.getDataInput(
                    "apertureSize")[0].getValue()

            if self.hasDataInput("beamSizeX"):
                self.fBeamSizeX = self.getDataInput("beamSizeX")[0].getValue()

            if self.hasDataInput("beamSizeY"):
                self.fBeamSizeY = self.getDataInput("beamSizeY")[0].getValue()

            if self.hasDataInput("templateMode"):
                self.bTemplateMode = self.getDataInput(
                    "templateMode")[0].getValue()

            if (self.hasDataInput("beamPosX")):
                self.fBeamPosX = self.getDataInput("beamPosX")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionX().getValue()

            if (self.hasDataInput("beamPosY")):
                self.fBeamPosY = self.getDataInput("beamPosY")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionY().getValue()

            if (self.hasDataInput("wavelength")):
                self.fWavelength = self.getDataInput(
                    "wavelength")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength(
                    ) != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam(
                        ).getWavelength().getValue()

            if (self.hasDataInput("transmission")):
                self.fTransmission = self.getDataInput(
                    "transmission")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam(
                        ).getTransmission().getValue()

            if self.hasDataInput("generatedTemplateFile"):
                self.strGeneratedTemplateFile = self.getDataInput(
                    "generatedTemplateFile")[0].getValue()

            if self.hasDataInput("resultsFilePath"):
                self.strResultsFilePath = self.getDataInput(
                    "resultsFilePath")[0].getValue()

            if self.hasDataInput("dataCollectionId"):
                self.iDataCollectionId = self.getDataInput(
                    "dataCollectionId")[0].getValue()

            if self.hasDataInput("shortComments"):
                self.strShortComments = self.getDataInput(
                    "shortComments")[0].getValue()

            if self.hasDataInput("comments"):
                self.strComments = self.getDataInput("comments")[0].getValue()

            if self.hasDataInput("inputCharacterisation"):
                self.xsDataInputCharacterisation = self.getDataInput(
                    "inputCharacterisation")[0]

        # Check if XML data is given as input :
        if (self.xsDataInputCharacterisation is None):
            self.edPluginControlSubWedgeAssemble = self.loadPlugin(
                self.strEDPluginControlSubWedgeAssembleName,
                "SubWedgeAssemble")

        self.edPluginControlCharacterisation = self.loadPlugin(
            self.strEDPluginControlCharacterisationName, "Characterisation")

        if (self.strEDPluginControlISPyBName is not None):
            self.edPluginControlISPyB = self.loadPlugin(
                self.strEDPluginControlISPyBName, "ISPyB")

    def process(self, _edPlugin=None):
        EDPluginControl.process(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev1_3.process...")

        if (self.edPluginControlSubWedgeAssemble is not None):
            if (self.bTemplateMode == True):
                self.edPluginControlSubWedgeAssemble.connectSUCCESS(
                    self.generateTemplateFile)
            else:
                self.edPluginControlSubWedgeAssemble.connectSUCCESS(
                    self.doSubWedgeAssembleSUCCESS)
            self.edPluginControlSubWedgeAssemble.connectFAILURE(
                self.doSubWedgeAssembleFAILURE)

        if (self.edPluginControlCharacterisation is not None):
            self.edPluginControlCharacterisation.connectSUCCESS(
                self.doSuccessActionCharacterisation)
            self.edPluginControlCharacterisation.connectFAILURE(
                self.doFailureActionCharacterisation)

        if (self.edPluginControlISPyB is not None):
            self.edPluginControlISPyB.connectSUCCESS(self.doSuccessActionISPyB)
            self.edPluginControlISPyB.connectFAILURE(self.doFailureActionISPyB)

        if (self.xsDataInputCharacterisation is None):
            self.createInputCharacterisationFromImageHeaders(
                self.edPluginControlSubWedgeAssemble)
        else:
            self.runCharacterisationPlugin(
                self.edPluginControlCharacterisation)

    def finallyProcess(self, _edPlugin=None):
        EDPluginControl.finallyProcess(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev1_3.finallyProcess...")

        if (not self.edPluginControlCharacterisation is None):
            if (self.edPluginControlCharacterisation.hasDataOutput()):
                self.setDataOutput(
                    self.edPluginControlCharacterisation.getDataOutput(),
                    "characterisation")
        if (not self.edPluginControlISPyB is None):
            if (self.edPluginControlISPyB.hasDataOutput()):
                self.setDataOutput(self.edPluginControlISPyB.getDataOutput(),
                                   "ISPyB")
        if self.hasDataInput():
            xsDataResultInterface = XSDataResultInterface()
            if self.edPluginControlCharacterisation:
                xsDataResultInterface.setResultCharacterisation(
                    self.edPluginControlCharacterisation.getDataOutput())
            if self.edPluginControlISPyB:
                xsDataResultInterface.setResultControlISPyB(
                    self.edPluginControlISPyB.getDataOutput())
            self.setDataOutput(xsDataResultInterface)

    def createInputCharacterisationFromImageHeaders(self, _edPlugin):
        self.DEBUG(
            "EDPluginControlInterfacev1_3.createInputCharacterisationFromImageHeaders"
        )
        xsDataInputSubWedgeAssemble = XSDataInputSubWedgeAssemble()
        for xsDataStringImagePath in self.listImagePaths:
            xsDataFile = XSDataFile()
            xsDataFile.setPath(xsDataStringImagePath)
            xsDataInputSubWedgeAssemble.addFile(xsDataFile)
        _edPlugin.setDataInput(xsDataInputSubWedgeAssemble)
        _edPlugin.executeSynchronous()

    def runCharacterisationPlugin(self, _edPlugin=None):
        self.DEBUG("EDPluginControlInterfacev1_3.runCharacterisationPlugin")
        self.edPluginControlCharacterisation.setDataInput(
            self.xsDataInputCharacterisation)
        self.edPluginControlCharacterisation.executeSynchronous()

    def storeResultsInISPyB(self, _edPlugin=None):
        self.DEBUG("EDPluginControlInterfacev1_3.storeResultsInISPyB")
        if (self.edPluginControlISPyB is not None):
            # Execute the ISPyB control plugin
            xsDataInputControlISPyB = XSDataInputControlISPyB()
            xsDataInputControlISPyB.setCharacterisationResult(
                self.edPluginControlCharacterisation.getDataOutput())
            if (not self.iDataCollectionId is None):
                dataCollectionGroupId = self.getDataCollectionGroupId(
                    self.iDataCollectionId)
                xsDataInputControlISPyB.setDataCollectionGroupId(
                    XSDataInteger(dataCollectionGroupId))
            if (not self.strShortComments is None):
                self.edPluginControlISPyB.setDataInput(
                    XSDataString(self.strShortComments), "shortComments")
            if (not self.strComments is None):
                self.edPluginControlISPyB.setDataInput(
                    XSDataString(self.strComments), "comments")
            if (not self.strStatusMessage is None):
                self.edPluginControlISPyB.setDataInput(
                    XSDataString(self.strStatusMessage), "statusMessage")
            self.edPluginControlISPyB.setDataInput(xsDataInputControlISPyB)
            self.edPluginControlISPyB.executeSynchronous()
            self.checkDozorScores(
                self.edPluginControlCharacterisation.getDataOutput())

    def createInputCharacterisationFromSubWedges(self):
        self.DEBUG(
            "EDPluginControlInterfacev1_3.createInputCharacterisationFromSubWedges"
        )
        xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput(
        )
        self.xsDataInputCharacterisation = XSDataInputCharacterisation()
        xsDataCollection = XSDataCollection()
        # Default exposure time (for the moment, this value should be
        # possible to read from the command line)
        if self.xsDataDiffractionPlan is None:
            self.xsDataDiffractionPlan = XSDataDiffractionPlan()
        if (not xsDataResultSubWedgeAssemble is None):
            pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
            xsDataCollection.setSubWedge(pyListSubWedge)
            for xsDataSubWedge in pyListSubWedge:
                if (self.strComplexity is not None):
                    self.xsDataDiffractionPlan.setComplexity(
                        XSDataString(self.strComplexity))
                if (self.fFlux is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setFlux(XSDataFlux(self.fFlux))
                if (self.fBeamSizeX is not None) and (self.fBeamSizeY
                                                      is not None):
                    xsDataSize = XSDataSize()
                    xsDataSize.setX(XSDataLength(self.fBeamSizeX))
                    xsDataSize.setY(XSDataLength(self.fBeamSizeY))
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setSize(xsDataSize)
                if (self.fApertureSize is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setApertureSize(XSDataLength(self.fApertureSize))
                if (self.fBeamPosX is not None):
                    xsDataSubWedge.getExperimentalCondition().getDetector(
                    ).setBeamPositionX(XSDataLength(self.fBeamPosX))
                if (self.fBeamPosY is not None):
                    xsDataSubWedge.getExperimentalCondition().getDetector(
                    ).setBeamPositionY(XSDataLength(self.fBeamPosY))
                if (self.fMinExposureTimePerImage is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setMinExposureTimePerImage(
                        XSDataTime(self.fMinExposureTimePerImage))
                if (self.fTransmission is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setTransmission(XSDataDouble(self.fTransmission))
                if (self.fWavelength is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setWavelength(XSDataWavelength(self.fWavelength))
                if self.fMinOscillationWidth != None:
                    xsDataSubWedge.getExperimentalCondition().getGoniostat(
                    ).setMinOscillationWidth(
                        XSDataAngle(self.fMinOscillationWidth))
                if self.fMaxOscillationSpeed != None:
                    xsDataSubWedge.getExperimentalCondition().getGoniostat(
                    ).setMaxOscillationSpeed(
                        XSDataAngularSpeed(self.fMaxOscillationSpeed))
        if (self.strForcedSpaceGroup is not None):
            self.xsDataDiffractionPlan.setForcedSpaceGroup(
                XSDataString(self.strForcedSpaceGroup))
        self.xsDataDiffractionPlan.setAnomalousData(
            XSDataBoolean(self.bAnomalousData))
        self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
            XSDataTime(self.fMaxExposureTimePerDataCollection))
        if (self.strStrategyOption is not None):
            self.xsDataDiffractionPlan.setStrategyOption(
                XSDataString(self.strStrategyOption))
        xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
        if self.xsDataSample is not None:
            xsDataCollection.setSample(
                XSDataSampleCrystalMM.parseString(self.xsDataSample.marshal()))
        self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)

    def generateTemplateFile(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.generateTemplateFile")
        self.createInputCharacterisationFromSubWedges()
        if (self.strGeneratedTemplateFile is None):
            self.screen(
                "No argument for command line --generateTemplate key word found!"
            )
        elif (self.xsDataInputCharacterisation is None):
            self.screen(
                "ERROR! Cannot generate template file %s, please check the log files."
                % self.strGeneratedTemplateFile)
        else:
            self.screen("Generating xml template input file for edna: " +
                        self.strGeneratedTemplateFile + "...")
            self.xsDataInputCharacterisation.exportToFile(
                self.strGeneratedTemplateFile)

    def doSubWedgeAssembleSUCCESS(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.doSubWedgeAssembleSUCCESS")
        self.createInputCharacterisationFromSubWedges()
        self.runCharacterisationPlugin(_edPlugin)

    def doSubWedgeAssembleFAILURE(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.doSubWedgeAssembleFAILURE")
        self.screen("Execution of " +
                    self.strEDPluginControlSubWedgeAssembleName + "  failed.")
        self.screen("Please inspect the log file for further information.")
        self.setFailure()

    def doFailureActionCharacterisation(self, _edPlugin=None):
        """
        retrieve the potential warning messages
        retrieve the potential error messages
        """
        self.DEBUG(
            "EDPluginControlInterfacev1_3.doFailureActionCharacterisation")
        self.retrieveFailureMessages(
            self.edPluginControlCharacterisation,
            "EDPluginControlInterfacev1_3.doSuccessActionISPyB")
        if _edPlugin.hasDataOutput("statusMessage"):
            self.strStatusMessage = _edPlugin.getDataOutput(
                "statusMessage")[0].getValue()
        self.generateExecutiveSummary(self)
        self.storeResultsInISPyB(_edPlugin)
        self.setFailure()

    def doSuccessActionCharacterisation(self, _edPlugin=None):
        """
        retrieve the potential warning messages
        """
        self.DEBUG(
            "EDPluginControlInterfacev1_3.doSuccessActionCharacterisation")
        # Store the results if requested
        if (self.strResultsFilePath is not None):
            xsDataCharacterisationResult = _edPlugin.getDataOutput()
            if (xsDataCharacterisationResult is not None):
                xsDataCharacterisationResult.exportToFile(
                    self.strResultsFilePath)
        if _edPlugin.hasDataOutput("statusMessage"):
            self.strStatusMessage = _edPlugin.getDataOutput(
                "statusMessage")[0].getValue()
        self.storeResultsInISPyB(_edPlugin)

    def doSuccessActionISPyB(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.doSuccessActionISPyB...")
        self.retrieveSuccessMessages(
            self.edPluginControlISPyB,
            "EDPluginControlInterfacev1_3.doSuccessActionISPyB")

    def doFailureActionISPyB(self, _edPlugin=None):
        self.DEBUG("EDPluginControlInterfacev1_3.doFailureActionISpyB...")
        self.generateExecutiveSummary(self)
        self.setFailure()

    def generateExecutiveSummary(self, _edPlugin=None):
        """
        Prints the executive summary from the plugin
        """
        self.DEBUG("EDPluginControlInterfacev1_3.generateExecutiveSummary")
        if (self.edPluginControlSubWedgeAssemble is not None):
            if self.edPluginControlSubWedgeAssemble.getListExecutiveSummaryLines(
            ) != []:
                self.addExecutiveSummaryLine(
                    "Summary of plugin %s:" %
                    self.strEDPluginControlSubWedgeAssembleName)
                self.appendExecutiveSummary(
                    self.edPluginControlSubWedgeAssemble)
        if (self.edPluginControlCharacterisation is not None):
            self.addExecutiveSummaryLine(
                "Summary of plugin %s:" %
                self.strEDPluginControlCharacterisationName)
            self.appendExecutiveSummary(self.edPluginControlCharacterisation)
        if (self.edPluginControlISPyB is not None):
            self.addExecutiveSummaryLine("Summary of plugin %s:" %
                                         self.strEDPluginControlISPyBName)
            self.appendExecutiveSummary(self.edPluginControlISPyB)
        self.verboseScreenExecutiveSummary()

    def checkDozorScores(self, _xsDataResultCharacterisation):
        # Check Dozor scores
        listImageQualityIndicators = _xsDataResultCharacterisation.imageQualityIndicators
        noWeakDiffraction = 0
        noTotal = 0
        newComment = None
        referenceImagePath = None
        listImageNoWithNoDiffraction = []
        for imageQualityIndicators in listImageQualityIndicators:
            if referenceImagePath is None:
                referenceImagePath = imageQualityIndicators.image.path.value
            if imageQualityIndicators.dozor_score is not None:
                noTotal += 1
                dozorScore = imageQualityIndicators.dozor_score.value
                if dozorScore <= 0.001:
                    listImageNoWithNoDiffraction.append(
                        imageQualityIndicators.image.number.value)
                elif dozorScore < 1.0:
                    noWeakDiffraction += 1
        if noTotal > 0:
            if len(listImageNoWithNoDiffraction) == noTotal:
                newComment = "No diffraction."
            elif noWeakDiffraction + len(
                    listImageNoWithNoDiffraction) == noTotal:
                newComment = "Very weak diffraction."
            else:
                subComment = None
                if len(listImageNoWithNoDiffraction) == 1:
                    subComment = "image {0}".format(
                        listImageNoWithNoDiffraction[0])
                elif len(listImageNoWithNoDiffraction) == 2:
                    subComment = "images {0} and {1}".format(
                        listImageNoWithNoDiffraction[0],
                        listImageNoWithNoDiffraction[1])
                elif len(listImageNoWithNoDiffraction) > 2:
                    subComment = "images {0}".format(
                        listImageNoWithNoDiffraction[0])
                    for imageNo in listImageNoWithNoDiffraction[1:-1]:
                        subComment += ", {0}".format(imageNo)
                    subComment += " and {0}".format(
                        listImageNoWithNoDiffraction[-1])
                if subComment is not None:
                    newComment = "No diffraction detected in {0} - hint: sample might not be accurately centred.".format(
                        subComment)

            if newComment is not None and self.iDataCollectionId is not None:
                xsDataInput = XSDataInputISPyBUpdateDataCollectionGroupComment(
                )
                xsDataInput.newComment = XSDataString(newComment)
                xsDataInput.dataCollectionId = XSDataInteger(
                    self.iDataCollectionId)
                edPluginISPyBUpdateDataCollectionGroupComment = self.loadPlugin(
                    "EDPluginISPyBUpdateDataCollectionGroupCommentv1_4")
                edPluginISPyBUpdateDataCollectionGroupComment.dataInput = xsDataInput
                self.executePluginSynchronous(
                    edPluginISPyBUpdateDataCollectionGroupComment)

    def getDataCollectionGroupId(self, _dataCollectionId):
        self.DEBUG("EDPluginControlInterfacev1_2.getDataCollectionGroupId")
        self.DEBUG("dataCollectionId = {0}".format(_dataCollectionId))
        dataCollectionGroupId = None
        xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
        xsDataInputRetrieveDataCollection.dataCollectionId = XSDataInteger(
            _dataCollectionId)
        edPluginISPyBRetrieveDataCollection = self.loadPlugin(
            "EDPluginISPyBRetrieveDataCollectionv1_4")
        edPluginISPyBRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
        edPluginISPyBRetrieveDataCollection.executeSynchronous()
        xsDataResultRetrieveDataCollection = edPluginISPyBRetrieveDataCollection.dataOutput
        if xsDataResultRetrieveDataCollection is not None:
            dataCollection = xsDataResultRetrieveDataCollection.dataCollection
            if dataCollection is not None:
                dataCollectionGroupId = dataCollection.dataCollectionGroupId
        self.DEBUG("dataCollectionGroupId = {0}".format(dataCollectionGroupId))
        return dataCollectionGroupId
Esempio n. 17
0
 def diffractionPlan(self):
     # Do we have a diffracionPlan?
     xsDataDiffractionPlan = self.xsDataResultCharacterisation.getDataCollection().getDiffractionPlan()
     if xsDataDiffractionPlan is None:
         xsDataDiffractionPlan = XSDataDiffractionPlan()
     self.page.h2( "Diffraction Plan" )
     self.page.table( class_='diffractionPlan', border_="1", cellpadding_="0")
     self.page.tr( align_="CENTER", bgcolor_=self.strTableColourTitle2)
     self.page.th("Forced<br>space group")
     self.page.th("Anomalous<br>data")
     self.page.th("Aimed<br>multiplicity")
     self.page.th("Aimed<br>completeness")
     self.page.th("Aimed I/sigma<br>at highest res.")
     self.page.th("Aimed<br>resolution (&Aring;)")
     self.page.tr.close()
     self.page.tr( align_="CENTER", bgcolor_=self.strTableColourRows)
     # Forced space group               
     if xsDataDiffractionPlan.getForcedSpaceGroup() is None:
         strForcedSpaceGroup = "None"
     else:
         strForcedSpaceGroup = xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
     self.page.th(strForcedSpaceGroup)
     # Anomalous data
     if xsDataDiffractionPlan.getAnomalousData() is None or xsDataDiffractionPlan.getAnomalousData().getValue() == False:
         strAnomalousData = "False"
     else:
         strAnomalousData = "True"
     self.page.th(strAnomalousData)
     # Aimed multiplicity
     if xsDataDiffractionPlan.getAimedMultiplicity() is None:
         strAimedMultiplicity = "Default<br>(optimized)"
     else:
         strAimedMultiplicity = "%.2f" % xsDataDiffractionPlan.getAimedMultiplicity().getValue()
     self.page.th(strAimedMultiplicity)
     # Aimed completeness
     if xsDataDiffractionPlan.getAimedCompleteness() is None:
         strAimedCompleteness = "Default<br>(>= 0.99)"
     else:
         strAimedCompleteness = "%.2f" % xsDataDiffractionPlan.getAimedCompleteness().getValue()
     self.page.th(strAimedCompleteness)
     # Aimed aimedIOverSigmaAtHighestResolution
     if xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution() is None:
         strAimedIOverSigmaAtHighestResolution = "BEST Default"
     else:
         strAimedIOverSigmaAtHighestResolution = "%.2f" % xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution().getValue()
     self.page.th(strAimedIOverSigmaAtHighestResolution)
     # Aimed resolution              
     if xsDataDiffractionPlan.getAimedResolution() is None:
         strAimedResolution = "Default<br>(highest possible)"
     else:
         strAimedResolution = "%0.2f" % xsDataDiffractionPlan.getAimedResolution().getValue()
     self.page.th(strAimedResolution)
     # Close the table
     self.page.tr.close()
     self.page.table.close()     
Esempio n. 18
0
class EDPluginControlInterfacev1_2(EDPluginControl):
    """
    This is the common class to all plugins managing user interfaces
    """
    def __init__(self):
        """
        """
        EDPluginControl.__init__(self)

        self.setXSDataInputClass(XSDataInputInterface)

        self.setXSDataInputClass(XSDataExperimentalCondition,
                                 "experimentalCondition")
        self.setXSDataInputClass(XSDataDiffractionPlan, "diffractionPlan")
        self.setXSDataInputClass(XSDataSampleCrystalMM, "sample")
        self.setXSDataInputClass(XSDataString, "imagePaths")
        self.setXSDataInputClass(XSDataFloat, "flux")
        self.setXSDataInputClass(XSDataFloat, "minExposureTimePerImage")
        self.setXSDataInputClass(XSDataFloat, "beamSize")
        self.setXSDataInputClass(XSDataFloat, "beamSizeX")
        self.setXSDataInputClass(XSDataFloat, "beamSizeY")
        self.setXSDataInputClass(XSDataBoolean, "templateMode")
        self.setXSDataInputClass(XSDataString, "generatedTemplateFile")
        self.setXSDataInputClass(XSDataString, "resultsFilePath")
        self.setXSDataInputClass(XSDataFloat, "beamPosX")
        self.setXSDataInputClass(XSDataFloat, "beamPosY")
        self.setXSDataInputClass(XSDataDouble, "wavelength")
        self.setXSDataInputClass(XSDataDouble, "transmission")
        self.setXSDataInputClass(XSDataInteger, "dataCollectionId")
        self.setXSDataInputClass(XSDataString, "shortComments")
        self.setXSDataInputClass(XSDataString, "comments")
        self.setXSDataInputClass(XSDataInputCharacterisation,
                                 "inputCharacterisation")

        self.strEDPluginControlSubWedgeAssembleName = "EDPluginControlSubWedgeAssemblev1_1"
        self.strEDPluginControlCharacterisationName = "EDPluginControlCharacterisationv1_1"
        self.strEDPluginControlISPyBName = "EDPluginControlISPyBv1_1"

        self.edPluginControlSubWedgeAssemble = None
        self.edPluginControlCharacterisation = None
        self.edPluginControlISPyB = None

        self.pyListImagePaths = None
        self.xsDataInputCharacterisation = None
        self.strComplexity = "none"

        self.listImagePaths = []
        self.fFlux = None
        self.fMaxExposureTimePerDataCollection = 10000  # s, default prototype value
        self.fMinExposureTimePerImage = None
        self.fBeamSizeX = None
        self.fBeamSizeY = None
        self.bTemplateMode = False
        self.strGeneratedTemplateFile = None
        self.strResultsFilePath = None
        self.strForcedSpaceGroup = None
        self.bAnomalousData = False
        self.fBeamPosX = None
        self.fBeamPosY = None
        self.fMinOscillationWidth = None
        self.fMaxOscillationSpeed = None
        self.fWavelength = None
        self.fTransmission = None
        self.strStrategyOption = None
        self.iDataCollectionId = None
        self.strShortComments = None
        self.strComments = None
        self.strStatusMessage = None

        self.xsDataExperimentalCodition = None
        self.xsDataSample = None
        self.xsDataDiffractionPlan = None

    def configure(self):
        """
        Gets the configuration parameters (if any).
        """
        EDPluginControl.configure(self)
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.configure")
        pluginConfiguration = self.getConfiguration()

        if (pluginConfiguration is None):
            EDVerbose.DEBUG(
                "No plugin configuration found for EDPluginControlInterfacev1_2."
            )
        else:
            if (self.getControlledPluginName("subWedgeAssemblePlugin")
                    is not None):
                self.strEDPluginControlSubWedgeAssembleName = self.getControlledPluginName(
                    "subWedgeAssemblePlugin")
            if (self.getControlledPluginName("characterisationPlugin")
                    is not None):
                self.strEDPluginControlCharacterisationName = self.getControlledPluginName(
                    "characterisationPlugin")
            if (self.getControlledPluginName("ispybPlugin") is not None):
                self.strEDPluginControlISPyBName = self.getControlledPluginName(
                    "ispybPlugin")

            bUseISPyBPlugin = EDConfiguration.getStringParamValue(
                pluginConfiguration, "useISPyBPlugin")
            if (bUseISPyBPlugin.lower() != "true"):
                self.strEDPluginControlISPyBName = None

    def preProcess(self, _edPlugin=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.preProcess...")

        self.listImagePaths = []

        # Check if XSDataInputInterface is given as input
        if self.hasDataInput():
            xsDataInputInterface = self.getDataInput()

            if xsDataInputInterface.getExperimentalCondition():
                self.xsDataExperimentalCodition = xsDataInputInterface.getExperimentalCondition(
                )
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMaxOscillationSpeed().getValue()

            self.xsDataSample = xsDataInputInterface.getSample()

            self.xsDataDiffractionPlan = self.getDataInput(
            ).getDiffractionPlan()
            if self.xsDataDiffractionPlan:
                if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                    self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup(
                    ).getValue()
                if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                ):
                    self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                    ).getValue()
                if self.xsDataDiffractionPlan.getAnomalousData():
                    self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData(
                    ).getValue()
                if self.xsDataDiffractionPlan.getStrategyOption():
                    self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption(
                    ).getValue()
                if self.xsDataDiffractionPlan.getComplexity():
                    self.strComplexity = self.xsDataDiffractionPlan.getComplexity(
                    ).getValue()
                if self.fMinOscillationWidth == None:
                    if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                    ):
                        self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                        ).getValue()
                if self.fMaxOscillationSpeed == None:
                    if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                    ):
                        self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                        ).getValue()

            self.xsDataSample = xsDataInputInterface.getSample()

            if xsDataInputInterface.getImagePath():
                for xsDataFile in xsDataInputInterface.getImagePath():
                    self.listImagePaths.append(xsDataFile.getPath())

            if xsDataInputInterface.getFlux():
                self.fFlux = xsDataInputInterface.getFlux().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux(
                    ) != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam(
                        ).getFlux().getValue()

            if xsDataInputInterface.getMinExposureTimePerImage():
                self.fMinExposureTimePerImage = xsDataInputInterface.getMinExposureTimePerImage(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam(
                        ).getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and xsDataInputInterface.getDiffractionPlan(
            ):
                if xsDataInputInterface.getDiffractionPlan(
                ).getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = xsDataInputInterface.getdiffractionPlan(
                    ).getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize(
                    ) != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getY().getValue()

            if xsDataInputInterface.getBeamSize():
                self.fBeamSizeX = xsDataInputInterface.getBeamSize().getValue()
                self.fBeamSizeY = xsDataInputInterface.getBeamSize().getValue()

            if xsDataInputInterface.getBeamSizeX():
                self.fBeamSizeX = xsDataInputInterface.getBeamSizeX().getValue(
                )

            if xsDataInputInterface.getBeamSizeY():
                self.fBeamSizeY = xsDataInputInterface.getBeamSizeY().getValue(
                )

            if xsDataInputInterface.getTemplateMode():
                self.bTemplateMode = xsDataInputInterface.getTemplateMode(
                ).getValue()

            if xsDataInputInterface.getBeamPosX():
                self.fBeamPosX = xsDataInputInterface.getBeamPosX().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionX().getValue()

            if xsDataInputInterface.getBeamPosY():
                self.fBeamPosY = xsDataInputInterface.getBeamPosY().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionY().getValue()

            if xsDataInputInterface.getWavelength():
                self.fWavelength = xsDataInputInterface.getWavelength(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength(
                    ) != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam(
                        ).getWavelength().getValue()

            if xsDataInputInterface.getTransmission():
                self.fTransmission = xsDataInputInterface.getTransmission(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam(
                        ).getTransmission().getValue()

            if xsDataInputInterface.getGeneratedTemplateFile():
                self.strGeneratedTemplateFile = xsDataInputInterface.getGeneratedTemplateFile(
                ).getPath().getValue()

            if xsDataInputInterface.getResultsFilePath():
                self.strResultsFilePath = xsDataInputInterface.getResultsFilePath(
                ).getPath().getValue()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId(
                ).getValue()

            if xsDataInputInterface.getShortComments():
                self.strShortComments = xsDataInputInterface.getShortComments(
                ).getValue()

            if xsDataInputInterface.getComments():
                self.strComments = xsDataInputInterface.getComments().getValue(
                )

            if xsDataInputInterface.getInputCharacterisation():
                self.xsDataInputCharacterisation = xsDataInputInterface.getInputCharacterisation(
                )

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId(
                ).getValue()

        else:

            if self.hasDataInput("experimentalCondition"):
                self.xsDataExperimentalCodition = self.getDataInput(
                    "experimentalCondition")[0]
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMaxOscillationSpeed().getValue()

            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if (self.hasDataInput("diffractionPlan")):
                if self.xsDataDiffractionPlan is None:
                    self.xsDataDiffractionPlan = XSDataDiffractionPlan()
                xsDataDiffractionPlans = self.getDataInput("diffractionPlan")
                if (not xsDataDiffractionPlans[0] is None):
                    self.xsDataDiffractionPlan = xsDataDiffractionPlans[0]
                    if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                        self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                    ):
                        self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getAnomalousData():
                        self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getStrategyOption():
                        self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getComplexity():
                        self.strComplexity = self.xsDataDiffractionPlan.getComplexity(
                        ).getValue()
                    if self.fMinOscillationWidth == None:
                        if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                        ):
                            self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                            ).getValue()
                    if self.fMaxOscillationSpeed == None:
                        if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                        ):
                            self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                            ).getValue()

            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if self.hasDataInput("imagePaths"):
                for strImagePath in self.getDataInput("imagePaths"):
                    self.listImagePaths.append(strImagePath)

            if self.hasDataInput("flux"):
                self.fFlux = self.getDataInput("flux")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux(
                    ) != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam(
                        ).getFlux().getValue()

            if self.hasDataInput("minExposureTimePerImage"):
                self.fMinExposureTimePerImage = self.getDataInput(
                    "minExposureTimePerImage")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam(
                        ).getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and self.hasDataInput(
                    "diffractionPlan"):
                if self.getDataInput("diffractionPlan"
                                     )[0].getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = self.getDataInput(
                        "diffractionPlan")[0].getMinExposureTimePerImage(
                        ).getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize(
                    ) != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getY().getValue()

            if self.hasDataInput("beamSize"):
                self.fBeamSizeX = self.getDataInput("beamSize")[0].getValue()
                self.fBeamSizeY = self.getDataInput("beamSize")[0].getValue()

            if self.hasDataInput("beamSizeX"):
                self.fBeamSizeX = self.getDataInput("beamSizeX")[0].getValue()

            if self.hasDataInput("beamSizeY"):
                self.fBeamSizeY = self.getDataInput("beamSizeY")[0].getValue()

            if self.hasDataInput("templateMode"):
                self.bTemplateMode = self.getDataInput(
                    "templateMode")[0].getValue()

            if (self.hasDataInput("beamPosX")):
                self.fBeamPosX = self.getDataInput("beamPosX")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionX().getValue()

            if (self.hasDataInput("beamPosY")):
                self.fBeamPosY = self.getDataInput("beamPosY")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionY().getValue()

            if (self.hasDataInput("wavelength")):
                self.fWavelength = self.getDataInput(
                    "wavelength")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength(
                    ) != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam(
                        ).getWavelength().getValue()

            if (self.hasDataInput("transmission")):
                self.fTransmission = self.getDataInput(
                    "transmission")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam(
                        ).getTransmission().getValue()

            if self.hasDataInput("generatedTemplateFile"):
                self.strGeneratedTemplateFile = self.getDataInput(
                    "generatedTemplateFile")[0].getValue()

            if self.hasDataInput("resultsFilePath"):
                self.strResultsFilePath = self.getDataInput(
                    "resultsFilePath")[0].getValue()

            if self.hasDataInput("dataCollectionId"):
                self.iDataCollectionId = self.getDataInput(
                    "dataCollectionId")[0].getValue()

            if self.hasDataInput("shortComments"):
                self.strShortComments = self.getDataInput(
                    "shortComments")[0].getValue()

            if self.hasDataInput("comments"):
                self.strComments = self.getDataInput("comments")[0].getValue()

            if self.hasDataInput("inputCharacterisation"):
                self.xsDataInputCharacterisation = self.getDataInput(
                    "inputCharacterisation")[0]

        # Check if XML data is given as input :
        if (self.xsDataInputCharacterisation is None):
            self.edPluginControlSubWedgeAssemble = self.loadPlugin(
                self.strEDPluginControlSubWedgeAssembleName,
                "SubWedgeAssemble")

        self.edPluginControlCharacterisation = self.loadPlugin(
            self.strEDPluginControlCharacterisationName, "Characterisation")

        if (self.strEDPluginControlISPyBName is not None):
            self.edPluginControlISPyB = self.loadPlugin(
                self.strEDPluginControlISPyBName, "ISPyB")

    def process(self, _edPlugin=None):
        EDPluginControl.process(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.process...")

        if (self.edPluginControlSubWedgeAssemble is not None):
            if (self.bTemplateMode == True):
                self.edPluginControlSubWedgeAssemble.connectSUCCESS(
                    self.generateTemplateFile)
            else:
                self.edPluginControlSubWedgeAssemble.connectSUCCESS(
                    self.doSubWedgeAssembleSUCCESS)
            self.edPluginControlSubWedgeAssemble.connectFAILURE(
                self.doSubWedgeAssembleFAILURE)

        if (self.edPluginControlCharacterisation is not None):
            self.edPluginControlCharacterisation.connectSUCCESS(
                self.doSuccessActionCharacterisation)
            self.edPluginControlCharacterisation.connectFAILURE(
                self.doFailureActionCharacterisation)

        if (self.edPluginControlISPyB is not None):
            self.edPluginControlISPyB.connectSUCCESS(self.doSuccessActionISPyB)
            self.edPluginControlISPyB.connectFAILURE(self.doFailureActionISPyB)

        if (self.xsDataInputCharacterisation is None):
            self.createInputCharacterisationFromImageHeaders(
                self.edPluginControlSubWedgeAssemble)
        else:
            self.runCharacterisationPlugin(
                self.edPluginControlCharacterisation)

    def finallyProcess(self, _edPlugin=None):
        EDPluginControl.finallyProcess(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.finallyProcess...")

        if (not self.edPluginControlCharacterisation is None):
            if (self.edPluginControlCharacterisation.hasDataOutput()):
                self.setDataOutput(
                    self.edPluginControlCharacterisation.getDataOutput(),
                    "characterisation")
        if (not self.edPluginControlISPyB is None):
            if (self.edPluginControlISPyB.hasDataOutput()):
                self.setDataOutput(self.edPluginControlISPyB.getDataOutput(),
                                   "ISPyB")
        if self.hasDataInput():
            xsDataResultInterface = XSDataResultInterface()
            if self.edPluginControlCharacterisation:
                xsDataResultInterface.setResultCharacterisation(
                    self.edPluginControlCharacterisation.getDataOutput())
            if self.edPluginControlISPyB:
                xsDataResultInterface.setResultControlISPyB(
                    self.edPluginControlISPyB.getDataOutput())
            self.setDataOutput(xsDataResultInterface)

    def createInputCharacterisationFromImageHeaders(self, _edPlugin):
        EDVerbose.DEBUG(
            "EDPluginControlInterfacev1_2.createInputCharacterisationFromImageHeaders"
        )
        xsDataInputSubWedgeAssemble = XSDataInputSubWedgeAssemble()
        for xsDataStringImagePath in self.listImagePaths:
            xsDataFile = XSDataFile()
            xsDataFile.setPath(xsDataStringImagePath)
            xsDataInputSubWedgeAssemble.addFile(xsDataFile)
        _edPlugin.setDataInput(xsDataInputSubWedgeAssemble)
        _edPlugin.executeSynchronous()

    def runCharacterisationPlugin(self, _edPlugin=None):
        EDVerbose.DEBUG(
            "EDPluginControlInterfacev1_2.runCharacterisationPlugin")
        self.edPluginControlCharacterisation.setDataInput(
            self.xsDataInputCharacterisation)
        self.edPluginControlCharacterisation.executeSynchronous()

    def storeResultsInISPyB(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.storeResultsInISPyB")
        if (self.edPluginControlISPyB is not None):
            # Execute the ISPyB control plugin
            xsDataInputControlISPyB = XSDataInputControlISPyB()
            xsDataInputControlISPyB.setCharacterisationResult(
                self.edPluginControlCharacterisation.getDataOutput())
            if (not self.iDataCollectionId is None):
                xsDataInputControlISPyB.setDataCollectionId(
                    XSDataInteger(self.iDataCollectionId))
            if (not self.strShortComments is None):
                self.edPluginControlISPyB.setDataInput(
                    XSDataString(self.strShortComments), "shortComments")
            if (not self.strComments is None):
                self.edPluginControlISPyB.setDataInput(
                    XSDataString(self.strComments), "comments")
            if (not self.strStatusMessage is None):
                self.edPluginControlISPyB.setDataInput(
                    XSDataString(self.strStatusMessage), "statusMessage")
            self.edPluginControlISPyB.setDataInput(xsDataInputControlISPyB)
            self.edPluginControlISPyB.executeSynchronous()

    def createInputCharacterisationFromSubWedges(self):
        EDVerbose.DEBUG(
            "EDPluginControlInterfacev1_2.createInputCharacterisationFromSubWedges"
        )
        xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput(
        )
        self.xsDataInputCharacterisation = XSDataInputCharacterisation()
        xsDataCollection = XSDataCollection()
        # Default exposure time (for the moment, this value should be
        # possible to read from the command line)
        if self.xsDataDiffractionPlan is None:
            self.xsDataDiffractionPlan = XSDataDiffractionPlan()
        if (not xsDataResultSubWedgeAssemble is None):
            pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
            xsDataCollection.setSubWedge(pyListSubWedge)
            for xsDataSubWedge in pyListSubWedge:
                if (self.strComplexity is not None):
                    self.xsDataDiffractionPlan.setComplexity(
                        XSDataString(self.strComplexity))
                if (self.fFlux is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setFlux(XSDataFlux(self.fFlux))
                if (self.fBeamSizeX is not None) and (self.fBeamSizeY
                                                      is not None):
                    xsDataSize = XSDataSize()
                    xsDataSize.setX(XSDataLength(self.fBeamSizeX))
                    xsDataSize.setY(XSDataLength(self.fBeamSizeY))
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setSize(xsDataSize)
                if (self.fBeamPosX is not None):
                    xsDataSubWedge.getExperimentalCondition().getDetector(
                    ).setBeamPositionX(XSDataLength(self.fBeamPosX))
                if (self.fBeamPosY is not None):
                    xsDataSubWedge.getExperimentalCondition().getDetector(
                    ).setBeamPositionY(XSDataLength(self.fBeamPosY))
                if (self.fMinExposureTimePerImage is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setMinExposureTimePerImage(
                        XSDataTime(self.fMinExposureTimePerImage))
                if (self.fTransmission is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setTransmission(XSDataDouble(self.fTransmission))
                if (self.fWavelength is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam(
                    ).setWavelength(XSDataWavelength(self.fWavelength))
                if self.fMinOscillationWidth != None:
                    xsDataSubWedge.getExperimentalCondition().getGoniostat(
                    ).setMinOscillationWidth(
                        XSDataAngle(self.fMinOscillationWidth))
                if self.fMaxOscillationSpeed != None:
                    xsDataSubWedge.getExperimentalCondition().getGoniostat(
                    ).setMaxOscillationSpeed(
                        XSDataAngularSpeed(self.fMaxOscillationSpeed))
        if (self.strForcedSpaceGroup is not None):
            self.xsDataDiffractionPlan.setForcedSpaceGroup(
                XSDataString(self.strForcedSpaceGroup))
        self.xsDataDiffractionPlan.setAnomalousData(
            XSDataBoolean(self.bAnomalousData))
        self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
            XSDataTime(self.fMaxExposureTimePerDataCollection))
        if (self.strStrategyOption is not None):
            self.xsDataDiffractionPlan.setStrategyOption(
                XSDataString(self.strStrategyOption))
        xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
        if self.xsDataSample is not None:
            xsDataCollection.setSample(
                XSDataSampleCrystalMM.parseString(self.xsDataSample.marshal()))
        self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)

    def generateTemplateFile(self, _edPlugin):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.generateTemplateFile")
        self.createInputCharacterisationFromSubWedges()
        if (self.strGeneratedTemplateFile is None):
            EDVerbose.screen(
                "No argument for command line --generateTemplate key word found!"
            )
        elif (self.xsDataInputCharacterisation is None):
            EDVerbose.screen(
                "ERROR! Cannot generate template file %s, please check the log files."
                % self.strGeneratedTemplateFile)
        else:
            EDVerbose.screen("Generating xml template input file for edna: " +
                             self.strGeneratedTemplateFile + "...")
            self.xsDataInputCharacterisation.exportToFile(
                self.strGeneratedTemplateFile)

    def doSubWedgeAssembleSUCCESS(self, _edPlugin):
        EDVerbose.DEBUG(
            "EDPluginControlInterfacev1_2.doSubWedgeAssembleSUCCESS")
        self.createInputCharacterisationFromSubWedges()
        self.runCharacterisationPlugin(_edPlugin)

    def doSubWedgeAssembleFAILURE(self, _edPlugin):
        EDVerbose.DEBUG(
            "EDPluginControlInterfacev1_2.doSubWedgeAssembleFAILURE")
        EDVerbose.screen("Execution of " +
                         self.strEDPluginControlSubWedgeAssembleName +
                         "  failed.")
        EDVerbose.screen(
            "Please inspect the log file for further information.")
        self.setFailure()

    def doFailureActionCharacterisation(self, _edPlugin=None):
        """
        retrieve the potential warning messages
        retrieve the potential error messages
        """
        EDVerbose.DEBUG(
            "EDPluginControlInterfacev1_2.doFailureActionCharacterisation")
        self.retrieveFailureMessages(
            self.edPluginControlCharacterisation,
            "EDPluginControlInterfacev1_2.doSuccessActionISPyB")
        if _edPlugin.hasDataOutput("statusMessage"):
            self.strStatusMessage = _edPlugin.getDataOutput(
                "statusMessage")[0].getValue()
        self.generateExecutiveSummary(self)
        self.storeResultsInISPyB(_edPlugin)
        self.setFailure()

    def doSuccessActionCharacterisation(self, _edPlugin=None):
        """
        retrieve the potential warning messages
        """
        EDVerbose.DEBUG(
            "EDPluginControlInterfacev1_2.doSuccessActionCharacterisation")
        # Store the results if requested
        if (self.strResultsFilePath is not None):
            xsDataCharacterisationResult = _edPlugin.getDataOutput()
            if (xsDataCharacterisationResult is not None):
                xsDataCharacterisationResult.exportToFile(
                    self.strResultsFilePath)
        if _edPlugin.hasDataOutput("statusMessage"):
            self.strStatusMessage = _edPlugin.getDataOutput(
                "statusMessage")[0].getValue()
        self.storeResultsInISPyB(_edPlugin)

    def doSuccessActionISPyB(self, _edPlugin):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.doSuccessActionISPyB...")
        self.retrieveSuccessMessages(
            self.edPluginControlISPyB,
            "EDPluginControlInterfacev1_2.doSuccessActionISPyB")

    def doFailureActionISPyB(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlInterfacev1_2.doFailureActionISpyB...")
        self.generateExecutiveSummary(self)
        self.setFailure()

    def generateExecutiveSummary(self, _edPlugin=None):
        """
        Prints the executive summary from the plugin
        """
        EDVerbose.DEBUG(
            "EDPluginControlInterfacev1_2.generateExecutiveSummary")
        if (self.edPluginControlSubWedgeAssemble is not None):
            if self.edPluginControlSubWedgeAssemble.getListExecutiveSummaryLines(
            ) != []:
                self.addExecutiveSummaryLine(
                    "Summary of plugin %s:" %
                    self.strEDPluginControlSubWedgeAssembleName)
                self.appendExecutiveSummary(
                    self.edPluginControlSubWedgeAssemble)
        if (self.edPluginControlCharacterisation is not None):
            self.addExecutiveSummaryLine(
                "Summary of plugin %s:" %
                self.strEDPluginControlCharacterisationName)
            self.appendExecutiveSummary(self.edPluginControlCharacterisation)
        if (self.edPluginControlISPyB is not None):
            self.addExecutiveSummaryLine("Summary of plugin %s:" %
                                         self.strEDPluginControlISPyBName)
            self.appendExecutiveSummary(self.edPluginControlISPyB)
        self.verboseScreenExecutiveSummary()
    def testSetDataModelInput(self):
        from XSDataCCP4iv1_1 import XSDataInputCCP4i
        xsDataInputCCP4i = XSDataInputCCP4i()

        # Beam
        from XSDataCommon import XSDataFlux
        from XSDataCommon import XSDataSize
        from XSDataCommon import XSDataLength
        from XSDataCommon import XSDataFloat

        from XSDataMXv1 import XSDataBeam
        from XSDataMXv1 import XSDataExperimentalCondition

        xsExperimentalCondition = XSDataExperimentalCondition()

        xsBeam = XSDataBeam()
        xsBeam.setFlux(XSDataFlux(1e+12))
        xsBeam.setSize(XSDataSize(XSDataLength(0.1), XSDataLength(0.1)))
        xsBeam.setMinExposureTimePerImage(XSDataFloat(0.1))
        xsExperimentalCondition.setBeam(xsBeam)

        # Goniostat
        from XSDataCommon import XSDataSpeed
        from XSDataCommon import XSDataAngle

        from XSDataMXv1 import XSDataGoniostat

        xsDataGoniostat = XSDataGoniostat()
        xsDataGoniostat.setMaxOscillationSpeed(XSDataSpeed(0.2))
        xsDataGoniostat.setMinOscillationWidth(XSDataAngle(0.1))
        xsExperimentalCondition.setGoniostat(xsDataGoniostat)
        xsDataInputCCP4i.setExperimentalCondition(xsExperimentalCondition)

        # Sample
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataFloat
        from XSDataCommon import XSDataString

        from XSDataMXv1 import XSDataStructure
        from XSDataMXv1 import XSDataChain
        from XSDataMXv1 import XSDataAtom
        from XSDataMXv1 import XSDataLigand
        from XSDataMXv1 import XSDataSampleCrystalMM
        from XSDataMXv1 import XSDataChemicalCompositionMM
        from XSDataMXv1 import XSDataAtomicComposition
        from XSDataMXv1 import XSDataSolvent

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataFloat(2))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataFloat(4))
        xsDataAtomicComposition.addAtom(xsDataAtom1)

        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataChain.setNumberOfMonomers(XSDataFloat(100))
        xsDataStructure.addChain(xsDataChain)

        xsDataChain2 = XSDataChain()
        xsDataChain2.setType(XSDataString("rna"))
        xsDataChain2.setNumberOfCopies(XSDataFloat(1))
        xsDataChain2.setNumberOfMonomers(XSDataFloat(60))
        xsDataStructure.addChain(xsDataChain2)

        xsDataLigand = XSDataLigand()
        xsDataLigand.setNumberOfCopies(XSDataFloat(2))
        xsDataLigand.setNumberOfLightAtoms(XSDataFloat(42))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("Fe"))
        xsDataAtom2.setNumberOf(XSDataFloat(1))
        xsDataAtomicComposition.addAtom(xsDataAtom2)
        xsDataLigand.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addLigand(xsDataLigand)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataFloat(0.25))

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()

        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("Na"))
        xsDataAtom3.setConcentration(XSDataFloat(1000))
        xsDataAtom4 = XSDataAtom()
        xsDataAtom4.setSymbol(XSDataString("Cl"))
        xsDataAtom4.setConcentration(XSDataFloat(1000))

        xsDataAtomicComposition.addAtom(xsDataAtom3)
        xsDataAtomicComposition.addAtom(xsDataAtom4)
        xsDataSolvent.setAtoms(xsDataAtomicComposition)

        xsDataComposition.setStructure(xsDataStructure)
        xsDataComposition.setSolvent(xsDataSolvent)
        xsDataSampleCrystalMM.setChemicalComposition(xsDataComposition)

        xsDataSampleCrystalMM.setSize(XSDataSize(XSDataLength(0.2), XSDataLength(0.2), XSDataLength(0.2)))
        xsDataSampleCrystalMM.setSusceptibility(XSDataFloat(1.5))
        xsDataSampleCrystalMM.setShape(XSDataFloat(2))

        xsDataInputCCP4i.setSample(xsDataSampleCrystalMM)

        from XSDataMXv1 import XSDataDiffractionPlan

        xsDataDiffractionPlan = XSDataDiffractionPlan()

        xsDataDiffractionPlan.setAimedCompleteness(XSDataFloat(95.5))
        xsDataDiffractionPlan.setAimedIOverSigmaAtHighestResolution(XSDataFloat(2.5))
        xsDataDiffractionPlan.setAimedMultiplicity(XSDataFloat(95.5))
        xsDataDiffractionPlan.setAimedResolution(XSDataFloat(3))
        xsDataDiffractionPlan.setComplexity(XSDataString("full"))
        xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString("P222"))
        xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataFloat(10000))

        xsDataInputCCP4i.setDiffractionPlan(xsDataDiffractionPlan)

        from XSDataCommon import XSDataFile

        listInputDataFile = []
        xsDataFile = XSDataFile(XSDataString(self.strXSDataGenerateTemplateFile))
        listInputDataFile.append(xsDataFile)
        xsDataInputCCP4i.setDataFile(listInputDataFile)
Esempio n. 20
0
class EDPluginControlGridScreeningv1_0(EDPluginControl):
    """
    This plugin is a "light-weight" characterisation to be used for processing
    images from grid scans.
    """
    def __init__(self):
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputGridScreening)
        self.strControlReadImageHeaderPluginName = "EDPluginControlReadImageHeaderv10"
        self.edPluginControlReadImageHeader = None
        self.strControlledIndicatorsPluginName = "EDPluginControlImageQualityIndicatorsv1_1"
        self.edPluginControlIndicators = None
        self.strISPyBStoreImageQualityIndicatorsPluginName = "EDPluginISPyBStoreImageQualityIndicatorsv1_3"
        self.edPluginISPyBStoreImageQualityIndicators = None
        self.strIndexingMOSFLMPluginName = "EDPluginMOSFLMIndexingv10"
        self.edPluginMOSFLMIndexing = None
        self.strPluginControlIntegration = "EDPluginControlIntegrationv10"
        self.edPluginControlIntegration = None
        self.strPluginControlStrategy = "EDPluginControlStrategyv1_2"
        self.edPluginControlStrategy = None
        self.strPluginExecMtz2Various = "EDPluginExecMtz2Variousv1_0"
        self.edPluginExecMtz2Various = None
        self.strImageFile = None
        self.xsDataIndexingResultMOSFLM = None
        self.xsDataCrystal = None
        self.strCharacterisationShortSummary = ""
        self.strStatusMessage = ""
        self.xsDataDiffractionPlan = None
        self.xsDataCollection = None
        self.xsDataIndexingResult = None
        self.xsDataStrategyResult = None
        self.xsDataImageQualityIndicators = None
        self.bStoreImageQualityIndicatorsInISPyB = False
        self.bDoOnlyImageQualityIndicators = False
        self.bDoOnlyIntegrationWithXMLOutput = False
        self.iImageQualityIndicatorsId = None
        self.xsDataGridScreeningResultIntegration = None

    def checkParameters(self):
        """
        Checks the mandatory parameters.
        """
        self.DEBUG("EDPluginControlGridScreeningv1_0.checkParameters")
        self.checkMandatoryParameters(self.getDataInput(),
                                      "Data Input is None")
        self.checkMandatoryParameters(self.getDataInput().getImageFile(),
                                      "imageFile")

    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlGridScreeningv1_0.preProcess")
        # Load the plugins
        self.edPluginControlReadImageHeader = self.loadPlugin(self.strControlReadImageHeaderPluginName, \
                                                                   "ReadImageHeader")
        self.edPluginControlIndicators = self.loadPlugin(self.strControlledIndicatorsPluginName, \
                                                                   "ControlIndicators")
        self.edPluginMOSFLMIndexing = self.loadPlugin(self.strIndexingMOSFLMPluginName, \
                                                                   "IndexingMOSFLM")
        self.edPluginControlIntegration = self.loadPlugin(self.strPluginControlIntegration, \
                                                            "Integration")
        self.edPluginControlStrategy = self.loadPlugin(self.strPluginControlStrategy, \
                                                         "Strategy")
        self.edPluginExecMtz2Various = self.loadPlugin(self.strPluginExecMtz2Various, \
                                                         "Mtz2Various")
        # Input data
        self.strImageFile = self.getDataInput().getImageFile().getPath(
        ).getValue()
        self.xsDataGridScreeningFileNameParameters = self.getFileNameParameters(
            self.strImageFile)
        self.xsDataDiffractionPlan = self.getDataInput().getDiffractionPlan()
        if self.xsDataDiffractionPlan is None:
            self.xsDataDiffractionPlan = XSDataDiffractionPlan()
        if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
        ) is None:
            # Default max esposure time: 10000s
            self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
                XSDataTime(10000))
        self.xsDataDiffractionPlan.setEstimateRadiationDamage(
            XSDataBoolean(False))
        # Image quality indicators
        if self.getDataInput().getStoreImageQualityIndicatorsInISPyB():
            self.bStoreImageQualityIndicatorsInISPyB = self.getDataInput(
            ).getStoreImageQualityIndicatorsInISPyB().getValue()
        if self.getDataInput().getDoOnlyImageQualityIndicators():
            self.bDoOnlyImageQualityIndicators = self.getDataInput(
            ).getDoOnlyImageQualityIndicators().getValue()
        if self.getDataInput().getDoOnlyIntegrationWithXMLOutput():
            self.bDoOnlyIntegrationWithXMLOutput = self.getDataInput(
            ).getDoOnlyIntegrationWithXMLOutput().getValue()
        if self.bStoreImageQualityIndicatorsInISPyB:
            self.edPluginISPyBStoreImageQualityIndicators = self.loadPlugin(self.strISPyBStoreImageQualityIndicatorsPluginName, \
                                                         "ISPyBStoreImageQualityIndicators")

    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlGridScreeningv1_0.process")
        xsDataInputReadImageHeader = XSDataInputReadImageHeader()
        xsDataInputReadImageHeader.setImage(image=XSDataFile(
            path=XSDataString(self.strImageFile)))
        self.edPluginControlReadImageHeader.setDataInput(
            xsDataInputReadImageHeader)
        self.edPluginControlReadImageHeader.connectSUCCESS(
            self.doSuccessReadImageHeader)
        self.edPluginControlReadImageHeader.connectFAILURE(
            self.doFailureReadImageHeader)
        self.executePluginSynchronous(self.edPluginControlReadImageHeader)

    def finallyProcess(self, _edObject=None):
        EDPluginControl.finallyProcess(self)
        self.DEBUG("EDPluginControlGridScreeningv1_0.finallyProcess")
        # Synchronise if necessary
        if self.edPluginISPyBStoreImageQualityIndicators is not None:
            self.edPluginISPyBStoreImageQualityIndicators.synchronize()
        # Build up the output object
        strComment = ""
        xsDataResultGridScreening = XSDataResultGridScreening()
        if self.xsDataGridScreeningFileNameParameters is not None:
            xsDataResultGridScreening.setFileNameParameters(
                self.xsDataGridScreeningFileNameParameters)
        if self.xsDataImageQualityIndicators is None:
            strComment = "No image quality indicators"
        else:
            xsDataResultGridScreening.setImageQualityIndicators(
                self.xsDataImageQualityIndicators)
            if self.xsDataImageQualityIndicators.getIceRings().getValue() > 1:
                strComment = "Ice rings detected"
        if self.xsDataIndexingResult is None:
            if strComment == "":
                strComment = "No indexing result"
            else:
                strComment += ", no indexing result"
        else:
            xsDataSelectedSolution = self.xsDataIndexingResult.getSelectedSolution(
            )
            xsDataResultGridScreening.setMosaicity(
                xsDataSelectedSolution.getCrystal().getMosaicity())
            if self.xsDataStrategyResult is None:
                if strComment == "":
                    strComment = "No strategy result"
                else:
                    strComment += ", no strategy result"
            else:
                xsDataCollectionPlan = self.xsDataStrategyResult.getCollectionPlan(
                )[0]
                xsDataStrategySummary = xsDataCollectionPlan.getStrategySummary(
                )
                xsDataResultGridScreening.setRankingResolution(
                    xsDataStrategySummary.getRankingResolution())
        xsDataResultGridScreening.setResultIntegration(
            self.xsDataGridScreeningResultIntegration)
        xsDataResultGridScreening.setComment(XSDataString(strComment))
        if self.iImageQualityIndicatorsId is not None:
            xsDataResultGridScreening.setImageQualityIndicatorsId(
                XSDataInteger(self.iImageQualityIndicatorsId))
        #print xsDataResultGridScreening.marshal()
        self.setDataOutput(xsDataResultGridScreening)

    def doSuccessReadImageHeader(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")
        self.retrieveSuccessMessages(
            _edPlugin,
            "EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")
        xsDataResultReadImageHeader = self.edPluginControlReadImageHeader.getDataOutput(
        )
        if xsDataResultReadImageHeader is not None:
            xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge()
            self.xsDataCollection = XSDataCollection()
            self.xsDataCollection.addSubWedge(xsDataSubWedge)
            self.xsDataCollection.setDiffractionPlan(
                self.xsDataDiffractionPlan)
            if not self.bDoOnlyIntegrationWithXMLOutput:
                xsDataInputControlImageQualityIndicators = XSDataInputControlImageQualityIndicators(
                )
                xsDataInputControlImageQualityIndicators.addImage(
                    XSDataImage(path=XSDataString(self.strImageFile)))
                self.edPluginControlIndicators.setDataInput(
                    xsDataInputControlImageQualityIndicators)
                self.edPluginControlIndicators.connectSUCCESS(
                    self.doSuccessIndicators)
                self.edPluginControlIndicators.connectFAILURE(
                    self.doFailureIndicators)
                self.executePluginSynchronous(self.edPluginControlIndicators)
            else:
                xsDataIndexingInput = XSDataIndexingInput()
                xsDataIndexingInput.setDataCollection(self.xsDataCollection)
                from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
                xsDataMOSFLMIndexingInput = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing(
                    xsDataIndexingInput)
                self.edPluginMOSFLMIndexing.connectSUCCESS(
                    self.doSuccessIndexingMOSFLM)
                self.edPluginMOSFLMIndexing.connectFAILURE(
                    self.doFailureIndexingMOSFLM)
                self.edPluginMOSFLMIndexing.setDataInput(
                    xsDataMOSFLMIndexingInput)
                self.edPluginMOSFLMIndexing.executeSynchronous()

    def doFailureReadImageHeader(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureReadImageHeader")
        self.retrieveFailureMessages(
            _edPlugin,
            "EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")

    def doSuccessIndicators(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessIndicators")
        #self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessIndexingIndicators")
        if self.edPluginControlIndicators.hasDataOutput():
            self.xsDataImageQualityIndicators = self.edPluginControlIndicators.getDataOutput(
            ).getImageQualityIndicators()[0]
            # Store results in ISPyB if requested
            if self.bStoreImageQualityIndicatorsInISPyB:
                xsDataInputStoreImageQualityIndicators = XSDataInputStoreImageQualityIndicators(
                )
                xsDataISPyBImageQualityIndicators = XSDataISPyBImageQualityIndicators.parseString(
                    self.xsDataImageQualityIndicators.marshal())
                xsDataInputStoreImageQualityIndicators.setImageQualityIndicators(
                    xsDataISPyBImageQualityIndicators)
                self.edPluginISPyBStoreImageQualityIndicators.setDataInput(
                    xsDataInputStoreImageQualityIndicators)
                self.edPluginISPyBStoreImageQualityIndicators.connectSUCCESS(
                    self.doSuccessISPyBStoreImageQualityIndicators)
                self.edPluginISPyBStoreImageQualityIndicators.connectFAILURE(
                    self.doFailureISPyBStoreImageQualityIndicators)
                self.edPluginISPyBStoreImageQualityIndicators.execute()
            # Continue only if requested
            if not self.bDoOnlyImageQualityIndicators:
                xsDataIndexingInput = XSDataIndexingInput()
                xsDataIndexingInput.setDataCollection(self.xsDataCollection)
                from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
                xsDataMOSFLMIndexingInput = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing(
                    xsDataIndexingInput)
                self.edPluginMOSFLMIndexing.connectSUCCESS(
                    self.doSuccessIndexingMOSFLM)
                self.edPluginMOSFLMIndexing.connectFAILURE(
                    self.doFailureIndexingMOSFLM)
                self.edPluginMOSFLMIndexing.setDataInput(
                    xsDataMOSFLMIndexingInput)
                self.edPluginMOSFLMIndexing.executeSynchronous()

    def doFailureIndicators(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureIndicators")
        strErrorMessage = "Execution of Indexing and Indicators plugin failed. Execution of characterisation aborted."
        self.ERROR(strErrorMessage)
        self.addErrorMessage(strErrorMessage)

    def doSuccessISPyBStoreImageQualityIndicators(self, _edPlugin=None):
        self.DEBUG(
            "EDPluginControlGridScreeningv1_0.doSuccessISPyBStoreImageQualityIndicators"
        )
        self.retrieveSuccessMessages(
            _edPlugin,
            "EDPluginControlGridScreeningv1_0.doSuccessISPyBStoreImageQualityIndicators"
        )
        self.iImageQualityIndicatorsId = self.edPluginISPyBStoreImageQualityIndicators.getDataOutput(
        ).getImageQualityIndicatorsId().getValue()
        if self.iImageQualityIndicatorsId is None:
            self.WARNING(
                "Image quality indicators result not stored in ISPyB!")

    def doFailureISPyBStoreImageQualityIndicators(self, _edPlugin=None):
        self.DEBUG(
            "EDPluginControlGridScreeningv1_0.doFailureISPyBStoreImageQualityIndicators"
        )
        strErrorMessage = "Execution of store ISPyB image quality indicators plugin failed."
        self.ERROR(strErrorMessage)
        self.addErrorMessage(strErrorMessage)

    def doSuccessIndexingMOSFLM(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessIndexingMOSFLM")
        self.retrieveSuccessMessages(
            _edPlugin,
            "EDPluginControlGridScreeningv1_0.doIntegrationToStrategyTransition"
        )
        xsDataMOSFLMIndexingOutput = self.edPluginMOSFLMIndexing.getDataOutput(
        )
        xsDataExperimentalConditionRefined = None
        if self.hasDataInput("refinedExperimentalCondition"):
            xsDataExperimentalConditionRefined = self.getDataInput(
                "refinedExperimentalCondition")[0]
        else:
            # Use the experimental condition from the xsDataCollection
            xsDataExperimentalConditionRefined = self.xsDataCollection.getSubWedge(
            )[0].getExperimentalCondition()
        from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
        self.xsDataIndexingResult = EDHandlerXSDataMOSFLMv10.generateXSDataIndexingResult(
            xsDataMOSFLMIndexingOutput, xsDataExperimentalConditionRefined)
        xsDataIntegrationInput = XSDataIntegrationInput()
        xsDataIntegrationInput.setDataCollection(self.xsDataCollection)
        xsDataIntegrationInput.setExperimentalConditionRefined(
            self.xsDataIndexingResult.getSelectedSolution(
            ).getExperimentalConditionRefined())
        xsDataIntegrationInput.setSelectedIndexingSolution(
            self.xsDataIndexingResult.getSelectedSolution())
        self.edPluginControlIntegration.connectSUCCESS(
            self.doSuccessIntegration)
        self.edPluginControlIntegration.connectFAILURE(
            self.doFailureIntegration)
        self.edPluginControlIntegration.setDataInput(xsDataIntegrationInput)
        self.executePluginSynchronous(self.edPluginControlIntegration)

    def doFailureIndexingMOSFLM(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureActionIndexing")
        self.retrieveFailureMessages(
            _edPlugin,
            "EDPluginControlCharacterisationv1_1.doFailureActionIndexing")

    def doSuccessIntegration(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessIntegration")
        self.retrieveSuccessMessages(
            _edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessIntegration")
        self.addStatusMessage("Integration successful.")
        self.xsDataIntegrationOutput = self.edPluginControlIntegration.getDataOutput(
        )
        # Integration short summary
        if self.edPluginControlIntegration.hasDataOutput(
                "integrationShortSummary"):
            self.strCharacterisationShortSummary += self.edPluginControlIntegration.getDataOutput(
                "integrationShortSummary")[0].getValue()
        #self.DEBUG( self.xsDataExperimentCharacterisation.marshal() )
        if self.bDoOnlyIntegrationWithXMLOutput:
            # Run mtz2various
            xsDataInputMtz2Various = XSDataInputMtz2Various()
            xsDataInputMtz2Various.setMtzfile(
                self.edPluginControlIntegration.getDataOutput(
                ).getIntegrationSubWedgeResult()[0].getGeneratedMTZFile())
            xsDataInputMtz2Various.addLabin(XSDataString("I=I"))
            xsDataInputMtz2Various.addLabin(XSDataString("SIGI=SIGI"))
            xsDataInputMtz2Various.setOutput(
                XSDataString("USER '(3I4,2F10.1)'"))
            self.edPluginExecMtz2Various.setDataInput(xsDataInputMtz2Various)
            self.edPluginExecMtz2Various.executeSynchronous()
            strHklFilePath = self.edPluginExecMtz2Various.getDataOutput(
            ).getHklfile().getPath().getValue()
            strIntegration = EDUtilsFile.readFile(strHklFilePath)
            # Output the result in XML format
            self.xsDataGridScreeningResultIntegration = XSDataGridScreeningResultIntegration(
            )
            self.xsDataGridScreeningResultIntegration.setFileName(
                os.path.basename(self.strImageFile))
            self.xsDataGridScreeningResultIntegration.setFileDirectory(
                os.path.dirname(self.strImageFile))
            self.xsDataGridScreeningResultIntegration.setIntegratedData(
                strIntegration)
        else:
            # We continue with the strategy calculation
            xsDataInputStrategy = XSDataInputStrategy()
            xsDataSolutionSelected = self.xsDataIndexingResult.getSelectedSolution(
            )
            xsDataInputStrategy.setCrystalRefined(
                xsDataSolutionSelected.getCrystal())
            xsDataInputStrategy.setSample(self.xsDataCollection.getSample())
            xsDataIntegrationSubWedgeResultList = self.xsDataIntegrationOutput.getIntegrationSubWedgeResult(
            )
            xsDataInputStrategy.setBestFileContentDat(
                xsDataIntegrationSubWedgeResultList[0].getBestfileDat())
            xsDataInputStrategy.setBestFileContentPar(
                xsDataIntegrationSubWedgeResultList[0].getBestfilePar())
            xsDataInputStrategy.setExperimentalCondition(
                xsDataIntegrationSubWedgeResultList[0].
                getExperimentalConditionRefined())
            for xsDataIntegrationSubWedgeResult in xsDataIntegrationSubWedgeResultList:
                xsDataInputStrategy.addBestFileContentHKL(
                    xsDataIntegrationSubWedgeResult.getBestfileHKL())
            xsDataInputStrategy.setDiffractionPlan(self.xsDataDiffractionPlan)
            self.edPluginControlStrategy.connectSUCCESS(self.doSuccessStrategy)
            self.edPluginControlStrategy.connectFAILURE(self.doFailureStrategy)
            self.edPluginControlStrategy.setDataInput(xsDataInputStrategy)
            self.executePluginSynchronous(self.edPluginControlStrategy)

    def doFailureIntegration(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureIntegration")
        strErrorMessage = "Execution of integration plugin failed."
        self.addStatusMessage("Integration FAILURE.")
        self.ERROR(strErrorMessage)
        self.addErrorMessage(strErrorMessage)

    def doSuccessStrategy(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessStrategy")
        self.retrieveSuccessMessages(
            self.edPluginControlStrategy,
            "EDPluginControlGridScreeningv1_0.doSuccessStrategy")
        self.xsDataStrategyResult = self.edPluginControlStrategy.getDataOutput(
        )

    def doFailureStrategy(self, _edPlugin=None):
        self.DEBUG("EDPluginControlGridScreeningv1_0.doFailureStrategy")
        self.retrieveFailureMessages(
            self.edPluginControlStrategy,
            "EDPluginControlGridScreeningv1_0.doFailureStrategy")
        strErrorMessage = "Execution of strategy plugin failed."
        self.ERROR(strErrorMessage)
        self.addErrorMessage(strErrorMessage)

#    def generateExecutiveSummary(self, _edPlugin):
#        """
#        Generates a summary of the execution of the plugin.
#        """
#        self.DEBUG("EDPluginControlGridScreeningv1_0.generateExecutiveSummary")
#        self.addExecutiveSummaryLine("Summary of characterisation:")
#        xsDataInputStrategy = self.getDataInput()
#        xsDataCollection = xsDataInputStrategy.getDataCollection()
#        xsDataDiffractionPlan = xsDataCollection.getDiffractionPlan()
#        self.addExecutiveSummaryLine("Diffraction plan:")
#        if (xsDataDiffractionPlan.getComplexity() is not None):
#            self.addExecutiveSummaryLine("BEST complexity                       : %s" % xsDataDiffractionPlan.getComplexity().getValue())
#        if (xsDataDiffractionPlan.getAimedCompleteness() is not None):
#            self.addExecutiveSummaryLine("Aimed completeness                    : %6.1f [%%]" % (100.0 * xsDataDiffractionPlan.getAimedCompleteness().getValue()))
#        if (xsDataDiffractionPlan.getRequiredCompleteness() is not None):
#            self.addExecutiveSummaryLine("Required completeness                 : %6.1f [%%]" % (100.0 * xsDataDiffractionPlan.getRequiredCompleteness().getValue()))
#        if (xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution() is not None):
#            self.addExecutiveSummaryLine("Aimed I/sigma at highest resolution   : %6.1f" % xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution().getValue())
#        if (xsDataDiffractionPlan.getAimedResolution() is not None):
#            self.addExecutiveSummaryLine("Aimed resolution                      : %6.1f [A]" % xsDataDiffractionPlan.getAimedResolution().getValue())
#        if (xsDataDiffractionPlan.getRequiredResolution() is not None):
#            self.addExecutiveSummaryLine("Required resolution                   : %6.1f [A]" % xsDataDiffractionPlan.getRequiredResolution().getValue())
#        if (xsDataDiffractionPlan.getAimedMultiplicity() is not None):
#            self.addExecutiveSummaryLine("Aimed multiplicity                    : %6.1f" % xsDataDiffractionPlan.getAimedMultiplicity().getValue())
#        if (xsDataDiffractionPlan.getRequiredMultiplicity() is not None):
#            self.addExecutiveSummaryLine("Required multiplicity                 : %6.1f" % xsDataDiffractionPlan.getRequiredMultiplicity().getValue())
#        if (xsDataDiffractionPlan.getForcedSpaceGroup() is not None):
#            self.addExecutiveSummaryLine("Forced space group                    : %6s" % xsDataDiffractionPlan.getForcedSpaceGroup().getValue())
#        if (xsDataDiffractionPlan.getMaxExposureTimePerDataCollection() is not None):
#            self.addExecutiveSummaryLine("Max exposure time per data collection : %6.1f [s]" % xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue())
#        self.addExecutiveSummarySeparator()
#        if self.edPluginControlIndexingIndicators is not None:
#            self.appendExecutiveSummary(self.edPluginControlIndexingIndicators, "")
#        if self.edPluginControlIndexingLabelit is not None:
#            self.appendExecutiveSummary(self.edPluginControlIndexingLabelit, "")
#        if self.edPluginControlIntegration is not None:
#            self.appendExecutiveSummary(self.edPluginControlIntegration, "")
#        if self.edPluginControlStrategy is not None:
#            self.appendExecutiveSummary(self.edPluginControlStrategy, "")
#        self.addExecutiveSummarySeparator()
#        if self.strCharacterisationShortSummary is not None:
#            self.addExecutiveSummaryLine("Characterisation short summary:")
#            self.addExecutiveSummaryLine("")
#            if self.strStatusMessage != None:
#                for strLine in self.strStatusMessage.split(". "):
#                    if strLine.endswith("."):
#                        self.addExecutiveSummaryLine(strLine)
#                    else:
#                        self.addExecutiveSummaryLine(strLine + ".")
#            self.addExecutiveSummaryLine("")
#            for strLine in self.strCharacterisationShortSummary.split("\n"):
#                if strLine != "\n":
#                    self.addExecutiveSummaryLine(strLine)
#        self.addErrorWarningMessagesToExecutiveSummary("Characterisation error and warning messages: ")
#        self.addExecutiveSummarySeparator()

    def addStatusMessage(self, _strStatusMessage):
        if self.strStatusMessage != "":
            self.strStatusMessage += " "
        self.strStatusMessage += _strStatusMessage

    def getFileNameParameters(self, _strFileName):
        """Method for extracting the rotation start angle, the two motor positions and the grid scan image no from the file name"""
        # Typical file name: mesh_0_21.676_-0.051_22_001.mccd
        listParts = os.path.basename(_strFileName).split("_")
        xsDataGridScreeningFileNameParameters = XSDataGridScreeningFileNameParameters(
        )
        try:
            strScanId1 = listParts[1]
            xsDataGridScreeningFileNameParameters.setScanId1(
                XSDataString(strScanId1))
            strMotorPosition1 = listParts[2]
            xsDataGridScreeningFileNameParameters.setMotorPosition1(
                XSDataString(strMotorPosition1))
            strMotorPosition2 = listParts[3]
            xsDataGridScreeningFileNameParameters.setMotorPosition2(
                XSDataString(strMotorPosition2))
            strScanId2 = listParts[4]
            xsDataGridScreeningFileNameParameters.setScanId2(
                XSDataString(strScanId2))
        except:
            xsDataGridScreeningFileNameParameters = None
        return xsDataGridScreeningFileNameParameters
Esempio n. 21
0
    def preProcess(self, _edPlugin=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev1_3.preProcess...")

        self.listImagePaths = []

        # Check if XSDataInputInterface is given as input
        if self.hasDataInput():
            xsDataInputInterface = self.getDataInput()

            if xsDataInputInterface.getExperimentalCondition():
                self.xsDataExperimentalCodition = xsDataInputInterface.getExperimentalCondition(
                )
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMaxOscillationSpeed().getValue()

            self.xsDataSample = xsDataInputInterface.getSample()

            self.xsDataDiffractionPlan = self.getDataInput(
            ).getDiffractionPlan()
            if self.xsDataDiffractionPlan:
                if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                    self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup(
                    ).getValue()
                if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                ):
                    self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                    ).getValue()
                if self.xsDataDiffractionPlan.getAnomalousData():
                    self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData(
                    ).getValue()
                if self.xsDataDiffractionPlan.getStrategyOption():
                    self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption(
                    ).getValue()
                if self.xsDataDiffractionPlan.getComplexity():
                    self.strComplexity = self.xsDataDiffractionPlan.getComplexity(
                    ).getValue()
                if self.fMinOscillationWidth == None:
                    if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                    ):
                        self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                        ).getValue()
                if self.fMaxOscillationSpeed == None:
                    if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                    ):
                        self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                        ).getValue()

            self.xsDataSample = xsDataInputInterface.getSample()

            if xsDataInputInterface.getImagePath():
                for xsDataFile in xsDataInputInterface.getImagePath():
                    self.listImagePaths.append(xsDataFile.getPath())

            if xsDataInputInterface.getFlux():
                self.fFlux = xsDataInputInterface.getFlux().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux(
                    ) != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam(
                        ).getFlux().getValue()

            if xsDataInputInterface.getMinExposureTimePerImage():
                self.fMinExposureTimePerImage = xsDataInputInterface.getMinExposureTimePerImage(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam(
                        ).getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and xsDataInputInterface.getDiffractionPlan(
            ):
                if xsDataInputInterface.getDiffractionPlan(
                ).getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = xsDataInputInterface.getDiffractionPlan(
                    ).getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize(
                    ) != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getY().getValue()
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getApertureSize() != None:
                        self.fApertureSize = self.xsDataExperimentalCodition.getBeam(
                        ).getApertureSize().getValue()

            if xsDataInputInterface.getBeamSize():
                self.fBeamSizeX = xsDataInputInterface.getBeamSize().getValue()
                self.fBeamSizeY = xsDataInputInterface.getBeamSize().getValue()

            if xsDataInputInterface.getApertureSize():
                self.fApertureSize = xsDataInputInterface.getApertureSize(
                ).getValue()

            if xsDataInputInterface.getBeamSizeX():
                self.fBeamSizeX = xsDataInputInterface.getBeamSizeX().getValue(
                )

            if xsDataInputInterface.getBeamSizeY():
                self.fBeamSizeY = xsDataInputInterface.getBeamSizeY().getValue(
                )

            if xsDataInputInterface.getApertureSize():
                self.fApertureSize = xsDataInputInterface.getApertureSize(
                ).getValue()

            if xsDataInputInterface.getTemplateMode():
                self.bTemplateMode = xsDataInputInterface.getTemplateMode(
                ).getValue()

            if xsDataInputInterface.getBeamPosX():
                self.fBeamPosX = xsDataInputInterface.getBeamPosX().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionX().getValue()

            if xsDataInputInterface.getBeamPosY():
                self.fBeamPosY = xsDataInputInterface.getBeamPosY().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionY().getValue()

            if xsDataInputInterface.getWavelength():
                self.fWavelength = xsDataInputInterface.getWavelength(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength(
                    ) != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam(
                        ).getWavelength().getValue()

            if xsDataInputInterface.getTransmission():
                self.fTransmission = xsDataInputInterface.getTransmission(
                ).getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam(
                        ).getTransmission().getValue()

            if xsDataInputInterface.getGeneratedTemplateFile():
                self.strGeneratedTemplateFile = xsDataInputInterface.getGeneratedTemplateFile(
                ).getPath().getValue()

            if xsDataInputInterface.getResultsFilePath():
                self.strResultsFilePath = xsDataInputInterface.getResultsFilePath(
                ).getPath().getValue()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId(
                ).getValue()

            if xsDataInputInterface.getShortComments():
                self.strShortComments = xsDataInputInterface.getShortComments(
                ).getValue()

            if xsDataInputInterface.getComments():
                self.strComments = xsDataInputInterface.getComments().getValue(
                )

            if xsDataInputInterface.getInputCharacterisation():
                self.xsDataInputCharacterisation = xsDataInputInterface.getInputCharacterisation(
                )

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId(
                ).getValue()

        else:

            if self.hasDataInput("experimentalCondition"):
                self.xsDataExperimentalCodition = self.getDataInput(
                    "experimentalCondition")[0]
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat(
                    ).getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat(
                        ).getMaxOscillationSpeed().getValue()

            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if (self.hasDataInput("diffractionPlan")):
                if self.xsDataDiffractionPlan is None:
                    self.xsDataDiffractionPlan = XSDataDiffractionPlan()
                xsDataDiffractionPlans = self.getDataInput("diffractionPlan")
                if (not xsDataDiffractionPlans[0] is None):
                    self.xsDataDiffractionPlan = xsDataDiffractionPlans[0]
                    if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                        self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                    ):
                        self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getAnomalousData():
                        self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getStrategyOption():
                        self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption(
                        ).getValue()
                    if self.xsDataDiffractionPlan.getComplexity():
                        self.strComplexity = self.xsDataDiffractionPlan.getComplexity(
                        ).getValue()
                    if self.fMinOscillationWidth == None:
                        if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                        ):
                            self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth(
                            ).getValue()
                    if self.fMaxOscillationSpeed == None:
                        if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                        ):
                            self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed(
                            ).getValue()

            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if self.hasDataInput("imagePaths"):
                for strImagePath in self.getDataInput("imagePaths"):
                    self.listImagePaths.append(strImagePath)

            if self.hasDataInput("flux"):
                self.fFlux = self.getDataInput("flux")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux(
                    ) != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam(
                        ).getFlux().getValue()

            if self.hasDataInput("minExposureTimePerImage"):
                self.fMinExposureTimePerImage = self.getDataInput(
                    "minExposureTimePerImage")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam(
                        ).getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and self.hasDataInput(
                    "diffractionPlan"):
                if self.getDataInput("diffractionPlan"
                                     )[0].getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = self.getDataInput(
                        "diffractionPlan")[0].getMinExposureTimePerImage(
                        ).getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize(
                    ) != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam(
                        ).getSize().getY().getValue()
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getApertureSize() != None:
                        self.fApertureSize = self.xsDataExperimentalCodition.getBeam(
                        ).getApertureSize().getValue()

            if self.hasDataInput("beamSize"):
                self.fBeamSizeX = self.getDataInput("beamSize")[0].getValue()
                self.fBeamSizeY = self.getDataInput("beamSize")[0].getValue()

            if self.hasDataInput("apertureSize"):
                self.fApertureSize = self.getDataInput(
                    "apertureSize")[0].getValue()

            if self.hasDataInput("beamSizeX"):
                self.fBeamSizeX = self.getDataInput("beamSizeX")[0].getValue()

            if self.hasDataInput("beamSizeY"):
                self.fBeamSizeY = self.getDataInput("beamSizeY")[0].getValue()

            if self.hasDataInput("templateMode"):
                self.bTemplateMode = self.getDataInput(
                    "templateMode")[0].getValue()

            if (self.hasDataInput("beamPosX")):
                self.fBeamPosX = self.getDataInput("beamPosX")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionX().getValue()

            if (self.hasDataInput("beamPosY")):
                self.fBeamPosY = self.getDataInput("beamPosY")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector(
                    ).getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector(
                        ).getBeamPositionY().getValue()

            if (self.hasDataInput("wavelength")):
                self.fWavelength = self.getDataInput(
                    "wavelength")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength(
                    ) != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam(
                        ).getWavelength().getValue()

            if (self.hasDataInput("transmission")):
                self.fTransmission = self.getDataInput(
                    "transmission")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam(
                    ).getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam(
                        ).getTransmission().getValue()

            if self.hasDataInput("generatedTemplateFile"):
                self.strGeneratedTemplateFile = self.getDataInput(
                    "generatedTemplateFile")[0].getValue()

            if self.hasDataInput("resultsFilePath"):
                self.strResultsFilePath = self.getDataInput(
                    "resultsFilePath")[0].getValue()

            if self.hasDataInput("dataCollectionId"):
                self.iDataCollectionId = self.getDataInput(
                    "dataCollectionId")[0].getValue()

            if self.hasDataInput("shortComments"):
                self.strShortComments = self.getDataInput(
                    "shortComments")[0].getValue()

            if self.hasDataInput("comments"):
                self.strComments = self.getDataInput("comments")[0].getValue()

            if self.hasDataInput("inputCharacterisation"):
                self.xsDataInputCharacterisation = self.getDataInput(
                    "inputCharacterisation")[0]

        # Check if XML data is given as input :
        if (self.xsDataInputCharacterisation is None):
            self.edPluginControlSubWedgeAssemble = self.loadPlugin(
                self.strEDPluginControlSubWedgeAssembleName,
                "SubWedgeAssemble")

        self.edPluginControlCharacterisation = self.loadPlugin(
            self.strEDPluginControlCharacterisationName, "Characterisation")

        if (self.strEDPluginControlISPyBName is not None):
            self.edPluginControlISPyB = self.loadPlugin(
                self.strEDPluginControlISPyBName, "ISPyB")
Esempio n. 22
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalCondition':
         obj_ = XSDataExperimentalCondition()
         obj_.build(child_)
         self.setExperimentalCondition(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'diffractionPlan':
         obj_ = XSDataDiffractionPlan()
         obj_.build(child_)
         self.setDiffractionPlan(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'sample':
         obj_ = XSDataSampleCrystalMM()
         obj_.build(child_)
         self.setSample(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'imagePath':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.imagePath.append(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'flux':
         obj_ = XSDataFloat()
         obj_.build(child_)
         self.setFlux(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'minExposureTimePerImage':
         obj_ = XSDataTime()
         obj_.build(child_)
         self.setMinExposureTimePerImage(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamSize':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setBeamSize(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamSizeX':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setBeamSizeX(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamSizeY':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setBeamSizeY(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'apertureSize':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setApertureSize(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'templateMode':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setTemplateMode(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'generatedTemplateFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setGeneratedTemplateFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'resultsFilePath':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setResultsFilePath(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamPosX':
         obj_ = XSDataFloat()
         obj_.build(child_)
         self.setBeamPosX(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamPosY':
         obj_ = XSDataFloat()
         obj_.build(child_)
         self.setBeamPosY(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'wavelength':
         obj_ = XSDataWavelength()
         obj_.build(child_)
         self.setWavelength(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'transmission':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setTransmission(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dataCollectionId':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setDataCollectionId(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'shortComments':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setShortComments(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'comments':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setComments(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'inputCharacterisation':
         obj_ = XSDataInputCharacterisation()
         obj_.build(child_)
         self.setInputCharacterisation(obj_)
    def preProcess(self, _edPlugin=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev1_3.preProcess...")

        self.listImagePaths = []

        # Check if XSDataInputInterface is given as input
        if self.hasDataInput():
            xsDataInputInterface = self.getDataInput()

            if xsDataInputInterface.getExperimentalCondition():
                self.xsDataExperimentalCodition = xsDataInputInterface.getExperimentalCondition()
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed().getValue()


            self.xsDataSample = xsDataInputInterface.getSample()

            self.xsDataDiffractionPlan = self.getDataInput().getDiffractionPlan()
            if self.xsDataDiffractionPlan:
                if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                    self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
                if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection():
                    self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue()
                if self.xsDataDiffractionPlan.getAnomalousData():
                    self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData().getValue()
                if self.xsDataDiffractionPlan.getStrategyOption():
                    self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption().getValue()
                if self.xsDataDiffractionPlan.getComplexity():
                    self.strComplexity = self.xsDataDiffractionPlan.getComplexity().getValue()
                if self.fMinOscillationWidth == None:
                    if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth().getValue()
                if self.fMaxOscillationSpeed == None:
                    if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed().getValue()


            self.xsDataSample = xsDataInputInterface.getSample()

            if xsDataInputInterface.getImagePath():
                for xsDataFile in xsDataInputInterface.getImagePath():
                    self.listImagePaths.append(xsDataFile.getPath())

            if xsDataInputInterface.getFlux():
                self.fFlux = xsDataInputInterface.getFlux().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux() != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam().getFlux().getValue()

            if xsDataInputInterface.getMinExposureTimePerImage():
                self.fMinExposureTimePerImage = xsDataInputInterface.getMinExposureTimePerImage().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and xsDataInputInterface.getDiffractionPlan():
                if xsDataInputInterface.getDiffractionPlan().getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = xsDataInputInterface.getDiffractionPlan().getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize() != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam().getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam().getSize().getY().getValue()
                    if self.xsDataExperimentalCodition.getBeam().getApertureSize() != None:
                        self.fApertureSize = self.xsDataExperimentalCodition.getBeam().getApertureSize().getValue()

            if xsDataInputInterface.getBeamSize():
                self.fBeamSizeX = xsDataInputInterface.getBeamSize().getValue()
                self.fBeamSizeY = xsDataInputInterface.getBeamSize().getValue()

            if xsDataInputInterface.getApertureSize():
                self.fApertureSize = xsDataInputInterface.getApertureSize().getValue()
                
            if xsDataInputInterface.getBeamSizeX():
                self.fBeamSizeX = xsDataInputInterface.getBeamSizeX().getValue()

            if xsDataInputInterface.getBeamSizeY():
                self.fBeamSizeY = xsDataInputInterface.getBeamSizeY().getValue()

            if xsDataInputInterface.getApertureSize():
                self.fApertureSize = xsDataInputInterface.getApertureSize().getValue()

            if xsDataInputInterface.getTemplateMode():
                self.bTemplateMode = xsDataInputInterface.getTemplateMode().getValue()

            if xsDataInputInterface.getBeamPosX():
                self.fBeamPosX = xsDataInputInterface.getBeamPosX().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector().getBeamPositionX().getValue()

            if xsDataInputInterface.getBeamPosY():
                self.fBeamPosY = xsDataInputInterface.getBeamPosY().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector().getBeamPositionY().getValue()

            if xsDataInputInterface.getWavelength():
                self.fWavelength = xsDataInputInterface.getWavelength().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength() != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam().getWavelength().getValue()

            if xsDataInputInterface.getTransmission():
                self.fTransmission = xsDataInputInterface.getTransmission().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam().getTransmission().getValue()

            if xsDataInputInterface.getGeneratedTemplateFile():
                self.strGeneratedTemplateFile = xsDataInputInterface.getGeneratedTemplateFile().getPath().getValue()

            if xsDataInputInterface.getResultsFilePath():
                self.strResultsFilePath = xsDataInputInterface.getResultsFilePath().getPath().getValue()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId().getValue()

            if xsDataInputInterface.getShortComments():
                self.strShortComments = xsDataInputInterface.getShortComments().getValue()

            if xsDataInputInterface.getComments():
                self.strComments = xsDataInputInterface.getComments().getValue()

            if xsDataInputInterface.getInputCharacterisation():
                self.xsDataInputCharacterisation = xsDataInputInterface.getInputCharacterisation()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId().getValue()

        else:

            if self.hasDataInput("experimentalCondition"):
                self.xsDataExperimentalCodition = self.getDataInput("experimentalCondition")[0]
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed().getValue()


            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if (self.hasDataInput("diffractionPlan")):
                if self.xsDataDiffractionPlan is None:
                    self.xsDataDiffractionPlan = XSDataDiffractionPlan()
                xsDataDiffractionPlans = self.getDataInput("diffractionPlan")
                if (not xsDataDiffractionPlans[0] is None):
                    self.xsDataDiffractionPlan = xsDataDiffractionPlans[0]
                    if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                        self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
                    if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection():
                        self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue()
                    if self.xsDataDiffractionPlan.getAnomalousData():
                        self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData().getValue()
                    if self.xsDataDiffractionPlan.getStrategyOption():
                        self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption().getValue()
                    if self.xsDataDiffractionPlan.getComplexity():
                        self.strComplexity = self.xsDataDiffractionPlan.getComplexity().getValue()
                    if self.fMinOscillationWidth == None:
                        if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth():
                            self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth().getValue()
                    if self.fMaxOscillationSpeed == None:
                        if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed():
                            self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed().getValue()


            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if self.hasDataInput("imagePaths"):
                for strImagePath in self.getDataInput("imagePaths"):
                    self.listImagePaths.append(strImagePath)

            if self.hasDataInput("flux"):
                self.fFlux = self.getDataInput("flux")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux() != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam().getFlux().getValue()

            if self.hasDataInput("minExposureTimePerImage"):
                self.fMinExposureTimePerImage = self.getDataInput("minExposureTimePerImage")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and self.hasDataInput("diffractionPlan"):
                if self.getDataInput("diffractionPlan")[0].getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = self.getDataInput("diffractionPlan")[0].getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize() != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam().getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam().getSize().getY().getValue()
                    if self.xsDataExperimentalCodition.getBeam().getApertureSize() != None:
                        self.fApertureSize = self.xsDataExperimentalCodition.getBeam().getApertureSize().getValue()

            if self.hasDataInput("beamSize"):
                self.fBeamSizeX = self.getDataInput("beamSize")[0].getValue()
                self.fBeamSizeY = self.getDataInput("beamSize")[0].getValue()

            if self.hasDataInput("apertureSize"):
                self.fApertureSize = self.getDataInput("apertureSize")[0].getValue()

            if self.hasDataInput("beamSizeX"):
                self.fBeamSizeX = self.getDataInput("beamSizeX")[0].getValue()

            if self.hasDataInput("beamSizeY"):
                self.fBeamSizeY = self.getDataInput("beamSizeY")[0].getValue()

            if self.hasDataInput("templateMode"):
                self.bTemplateMode = self.getDataInput("templateMode")[0].getValue()

            if (self.hasDataInput("beamPosX")):
                self.fBeamPosX = self.getDataInput("beamPosX")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector().getBeamPositionX().getValue()

            if (self.hasDataInput("beamPosY")):
                self.fBeamPosY = self.getDataInput("beamPosY")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector().getBeamPositionY().getValue()

            if (self.hasDataInput("wavelength")):
                self.fWavelength = self.getDataInput("wavelength")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength() != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam().getWavelength().getValue()

            if (self.hasDataInput("transmission")):
                self.fTransmission = self.getDataInput("transmission")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam().getTransmission().getValue()

            if self.hasDataInput("generatedTemplateFile"):
                self.strGeneratedTemplateFile = self.getDataInput("generatedTemplateFile")[0].getValue()

            if self.hasDataInput("resultsFilePath"):
                self.strResultsFilePath = self.getDataInput("resultsFilePath")[0].getValue()

            if self.hasDataInput("dataCollectionId"):
                self.iDataCollectionId = self.getDataInput("dataCollectionId")[0].getValue()

            if self.hasDataInput("shortComments"):
                self.strShortComments = self.getDataInput("shortComments")[0].getValue()

            if self.hasDataInput("comments"):
                self.strComments = self.getDataInput("comments")[0].getValue()

            if self.hasDataInput("inputCharacterisation"):
                self.xsDataInputCharacterisation = self.getDataInput("inputCharacterisation")[0]

        # Check if XML data is given as input :
        if (self.xsDataInputCharacterisation is None):
            self.edPluginControlSubWedgeAssemble = self.loadPlugin(self.strEDPluginControlSubWedgeAssembleName, "SubWedgeAssemble")

        self.edPluginControlCharacterisation = self.loadPlugin(self.strEDPluginControlCharacterisationName, "Characterisation")

        if (self.strEDPluginControlISPyBName is not None):
            self.edPluginControlISPyB = self.loadPlugin(self.strEDPluginControlISPyBName, "ISPyB")
Esempio n. 24
0
    def setPluginInput(self, _edPlugin):
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        if (not self.__fMaxExposureTimePerDataCollection is None):
            xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.__fMaxExposureTimePerDataCollection))
        if (not self.__strForcedSpaceGroup is None):
            xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.__strForcedSpaceGroup))
        if (not self.__bAnomalousData is None):
            xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.__bAnomalousData))
        if (not self.__strStrategyOption is None):
            xsDataDiffractionPlan.setStrategyOption(XSDataString(self.__strStrategyOption))
        if (not self.__strComplexity is None):
            xsDataDiffractionPlan.setComplexity(XSDataString(self.__strComplexity))
        _edPlugin.setDataInput(xsDataDiffractionPlan, "diffractionPlan")

        if (not self.__listImagePaths is None):
            for strImagePath in self.__listImagePaths:
                _edPlugin.setDataInput(XSDataString(strImagePath), "imagePaths")

        if (not self.__xsDataInputCharacterisation is None):
            _edPlugin.setDataInput(self.__xsDataInputCharacterisation, "inputCharacterisation")
        if (not self.__fFlux is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fFlux), "flux")
        if (not self.__fMinExposureTimePerImage is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fMinExposureTimePerImage), "minExposureTimePerImage")
        if (not self.__fBeamSize is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamSize), "beamSize")
        if (not self.__bTemplateMode is None):
            _edPlugin.setDataInput(XSDataBoolean(self.__bTemplateMode), "templateMode")
        if (not self.__strGeneratedTemplateFile is None):
            _edPlugin.setDataInput(XSDataString(self.__strGeneratedTemplateFile), "generatedTemplateFile")
        if (not self.__strResultsFilePath is None):
            _edPlugin.setDataInput(XSDataString(self.__strResultsFilePath), "resultsFilePath")
        if (not self.__fBeamPosX is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamPosX), "beamPosX")
        if (not self.__fBeamPosY is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamPosY), "beamPosY")
        if (not self.__iDataCollectionId is None):
            _edPlugin.setDataInput(XSDataInteger(self.__iDataCollectionId), "dataCollectionId")
        if (not self.__strShortComments is None):
            _edPlugin.setDataInput(XSDataString(self.__strShortComments), "shortComments")
        if (not self.__strComments is None):
            _edPlugin.setDataInput(XSDataString(self.__strComments), "comments")
        if (not self.__fTransmission is None):
            _edPlugin.setDataInput(XSDataDouble(self.__fTransmission), "transmission")
class EDPluginControlInterfacev1_3(EDPluginControl):
    """
    This is the common class to all plugins managing user interfaces
    """

    def __init__ (self):
        """
        """
        EDPluginControl.__init__(self)

        self.setXSDataInputClass(XSDataInputInterface)

        self.setXSDataInputClass(XSDataExperimentalCondition, "experimentalCondition")
        self.setXSDataInputClass(XSDataDiffractionPlan, "diffractionPlan")
        self.setXSDataInputClass(XSDataSampleCrystalMM, "sample")
        self.setXSDataInputClass(XSDataString, "imagePaths")
        self.setXSDataInputClass(XSDataFloat, "flux")
        self.setXSDataInputClass(XSDataFloat, "minExposureTimePerImage")
        self.setXSDataInputClass(XSDataFloat, "beamSize")
        self.setXSDataInputClass(XSDataFloat, "beamSizeX")
        self.setXSDataInputClass(XSDataFloat, "beamSizeY")
        self.setXSDataInputClass(XSDataBoolean, "templateMode")
        self.setXSDataInputClass(XSDataString, "generatedTemplateFile")
        self.setXSDataInputClass(XSDataString, "resultsFilePath")
        self.setXSDataInputClass(XSDataFloat, "beamPosX")
        self.setXSDataInputClass(XSDataFloat, "beamPosY")
        self.setXSDataInputClass(XSDataDouble, "wavelength")
        self.setXSDataInputClass(XSDataDouble, "transmission")
        self.setXSDataInputClass(XSDataInteger, "dataCollectionId")
        self.setXSDataInputClass(XSDataString, "shortComments")
        self.setXSDataInputClass(XSDataString, "comments")
        self.setXSDataInputClass(XSDataInputCharacterisation, "inputCharacterisation")

        self.strEDPluginControlSubWedgeAssembleName = "EDPluginControlSubWedgeAssemblev1_1"
        self.strEDPluginControlCharacterisationName = "EDPluginControlCharacterisationv1_5"
        self.strEDPluginControlISPyBName = "EDPluginControlISPyBv1_1"

        self.edPluginControlSubWedgeAssemble = None
        self.edPluginControlCharacterisation = None
        self.edPluginControlISPyB = None

        self.pyListImagePaths = None
        self.xsDataInputCharacterisation = None
        self.strComplexity = "none"

        self.listImagePaths = []
        self.fFlux = None
        self.fMaxExposureTimePerDataCollection = 10000 # s, default prototype value
        self.fMinExposureTimePerImage = None
        self.fBeamSizeX = None
        self.fBeamSizeY = None
        self.fApertureSize = None
        self.bTemplateMode = False
        self.strGeneratedTemplateFile = None
        self.strResultsFilePath = None
        self.strForcedSpaceGroup = None
        self.bAnomalousData = False
        self.fBeamPosX = None
        self.fBeamPosY = None
        self.fMinOscillationWidth = None
        self.fMaxOscillationSpeed = None
        self.fWavelength = None
        self.fTransmission = None
        self.strStrategyOption = None
        self.iDataCollectionId = None
        self.strShortComments = None
        self.strComments = None
        self.strStatusMessage = None

        self.xsDataExperimentalCodition = None
        self.xsDataSample = None
        self.xsDataDiffractionPlan = None


    def configure(self):
        """
        Gets the configuration parameters (if any).
        """
        EDPluginControl.configure(self)
        self.DEBUG("EDPluginControlInterfacev1_3.configure")
        if (self.getControlledPluginName("subWedgeAssemblePlugin") is not None):
            self.strEDPluginControlSubWedgeAssembleName = self.getControlledPluginName("subWedgeAssemblePlugin")
        if (self.getControlledPluginName("characterisationPlugin") is not None):
            self.strEDPluginControlCharacterisationName = self.getControlledPluginName("characterisationPlugin")
        if (self.getControlledPluginName("ispybPlugin") is not None):
            self.strEDPluginControlISPyBName = self.getControlledPluginName("ispybPlugin")

        bUseISPyBPlugin = self.config.get("useISPyBPlugin")
        if not bUseISPyBPlugin:
            self.DEBUG("EDPluginControlInterfacev1_3 configured to not use ISPyB")
            self.strEDPluginControlISPyBName = None


    def preProcess(self, _edPlugin=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev1_3.preProcess...")

        self.listImagePaths = []

        # Check if XSDataInputInterface is given as input
        if self.hasDataInput():
            xsDataInputInterface = self.getDataInput()

            if xsDataInputInterface.getExperimentalCondition():
                self.xsDataExperimentalCodition = xsDataInputInterface.getExperimentalCondition()
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed().getValue()


            self.xsDataSample = xsDataInputInterface.getSample()

            self.xsDataDiffractionPlan = self.getDataInput().getDiffractionPlan()
            if self.xsDataDiffractionPlan:
                if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                    self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
                if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection():
                    self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue()
                if self.xsDataDiffractionPlan.getAnomalousData():
                    self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData().getValue()
                if self.xsDataDiffractionPlan.getStrategyOption():
                    self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption().getValue()
                if self.xsDataDiffractionPlan.getComplexity():
                    self.strComplexity = self.xsDataDiffractionPlan.getComplexity().getValue()
                if self.fMinOscillationWidth == None:
                    if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth().getValue()
                if self.fMaxOscillationSpeed == None:
                    if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed().getValue()


            self.xsDataSample = xsDataInputInterface.getSample()

            if xsDataInputInterface.getImagePath():
                for xsDataFile in xsDataInputInterface.getImagePath():
                    self.listImagePaths.append(xsDataFile.getPath())

            if xsDataInputInterface.getFlux():
                self.fFlux = xsDataInputInterface.getFlux().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux() != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam().getFlux().getValue()

            if xsDataInputInterface.getMinExposureTimePerImage():
                self.fMinExposureTimePerImage = xsDataInputInterface.getMinExposureTimePerImage().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and xsDataInputInterface.getDiffractionPlan():
                if xsDataInputInterface.getDiffractionPlan().getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = xsDataInputInterface.getDiffractionPlan().getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize() != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam().getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam().getSize().getY().getValue()
                    if self.xsDataExperimentalCodition.getBeam().getApertureSize() != None:
                        self.fApertureSize = self.xsDataExperimentalCodition.getBeam().getApertureSize().getValue()

            if xsDataInputInterface.getBeamSize():
                self.fBeamSizeX = xsDataInputInterface.getBeamSize().getValue()
                self.fBeamSizeY = xsDataInputInterface.getBeamSize().getValue()

            if xsDataInputInterface.getApertureSize():
                self.fApertureSize = xsDataInputInterface.getApertureSize().getValue()
                
            if xsDataInputInterface.getBeamSizeX():
                self.fBeamSizeX = xsDataInputInterface.getBeamSizeX().getValue()

            if xsDataInputInterface.getBeamSizeY():
                self.fBeamSizeY = xsDataInputInterface.getBeamSizeY().getValue()

            if xsDataInputInterface.getApertureSize():
                self.fApertureSize = xsDataInputInterface.getApertureSize().getValue()

            if xsDataInputInterface.getTemplateMode():
                self.bTemplateMode = xsDataInputInterface.getTemplateMode().getValue()

            if xsDataInputInterface.getBeamPosX():
                self.fBeamPosX = xsDataInputInterface.getBeamPosX().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector().getBeamPositionX().getValue()

            if xsDataInputInterface.getBeamPosY():
                self.fBeamPosY = xsDataInputInterface.getBeamPosY().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector().getBeamPositionY().getValue()

            if xsDataInputInterface.getWavelength():
                self.fWavelength = xsDataInputInterface.getWavelength().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength() != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam().getWavelength().getValue()

            if xsDataInputInterface.getTransmission():
                self.fTransmission = xsDataInputInterface.getTransmission().getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam().getTransmission().getValue()

            if xsDataInputInterface.getGeneratedTemplateFile():
                self.strGeneratedTemplateFile = xsDataInputInterface.getGeneratedTemplateFile().getPath().getValue()

            if xsDataInputInterface.getResultsFilePath():
                self.strResultsFilePath = xsDataInputInterface.getResultsFilePath().getPath().getValue()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId().getValue()

            if xsDataInputInterface.getShortComments():
                self.strShortComments = xsDataInputInterface.getShortComments().getValue()

            if xsDataInputInterface.getComments():
                self.strComments = xsDataInputInterface.getComments().getValue()

            if xsDataInputInterface.getInputCharacterisation():
                self.xsDataInputCharacterisation = xsDataInputInterface.getInputCharacterisation()

            if xsDataInputInterface.getDataCollectionId():
                self.iDataCollectionId = xsDataInputInterface.getDataCollectionId().getValue()

        else:

            if self.hasDataInput("experimentalCondition"):
                self.xsDataExperimentalCodition = self.getDataInput("experimentalCondition")[0]
                if self.xsDataExperimentalCodition.getGoniostat():
                    if self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth():
                        self.fMinOscillationWidth = self.xsDataExperimentalCodition.getGoniostat().getMinOscillationWidth().getValue()
                    if self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed():
                        self.fMaxOscillationSpeed = self.xsDataExperimentalCodition.getGoniostat().getMaxOscillationSpeed().getValue()


            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if (self.hasDataInput("diffractionPlan")):
                if self.xsDataDiffractionPlan is None:
                    self.xsDataDiffractionPlan = XSDataDiffractionPlan()
                xsDataDiffractionPlans = self.getDataInput("diffractionPlan")
                if (not xsDataDiffractionPlans[0] is None):
                    self.xsDataDiffractionPlan = xsDataDiffractionPlans[0]
                    if self.xsDataDiffractionPlan.getForcedSpaceGroup():
                        self.strForcedSpaceGroup = self.xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
                    if self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection():
                        self.fMaxExposureTimePerDataCollection = self.xsDataDiffractionPlan.getMaxExposureTimePerDataCollection().getValue()
                    if self.xsDataDiffractionPlan.getAnomalousData():
                        self.bAnomalousData = self.xsDataDiffractionPlan.getAnomalousData().getValue()
                    if self.xsDataDiffractionPlan.getStrategyOption():
                        self.strStrategyOption = self.xsDataDiffractionPlan.getStrategyOption().getValue()
                    if self.xsDataDiffractionPlan.getComplexity():
                        self.strComplexity = self.xsDataDiffractionPlan.getComplexity().getValue()
                    if self.fMinOscillationWidth == None:
                        if self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth():
                            self.fMinOscillationWidth = self.xsDataDiffractionPlan.getGoniostatMinOscillationWidth().getValue()
                    if self.fMaxOscillationSpeed == None:
                        if self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed():
                            self.fMaxOscillationSpeed = self.xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed().getValue()


            if self.hasDataInput("sample"):
                self.xsDataSample = self.getDataInput("sample")[0]

            if self.hasDataInput("imagePaths"):
                for strImagePath in self.getDataInput("imagePaths"):
                    self.listImagePaths.append(strImagePath)

            if self.hasDataInput("flux"):
                self.fFlux = self.getDataInput("flux")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getFlux() != None:
                        self.fFlux = self.xsDataExperimentalCodition.getBeam().getFlux().getValue()

            if self.hasDataInput("minExposureTimePerImage"):
                self.fMinExposureTimePerImage = self.getDataInput("minExposureTimePerImage")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage() != None:
                        self.fMinExposureTimePerImage = self.xsDataExperimentalCodition.getBeam().getMinExposureTimePerImage().getValue()
            if self.fMinExposureTimePerImage == None and self.hasDataInput("diffractionPlan"):
                if self.getDataInput("diffractionPlan")[0].getMinExposureTimePerImage() != None:
                    self.fMinExposureTimePerImage = self.getDataInput("diffractionPlan")[0].getMinExposureTimePerImage().getValue()

            if self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getSize() != None:
                        self.fBeamSizeX = self.xsDataExperimentalCodition.getBeam().getSize().getX().getValue()
                        self.fBeamSizeY = self.xsDataExperimentalCodition.getBeam().getSize().getY().getValue()
                    if self.xsDataExperimentalCodition.getBeam().getApertureSize() != None:
                        self.fApertureSize = self.xsDataExperimentalCodition.getBeam().getApertureSize().getValue()

            if self.hasDataInput("beamSize"):
                self.fBeamSizeX = self.getDataInput("beamSize")[0].getValue()
                self.fBeamSizeY = self.getDataInput("beamSize")[0].getValue()

            if self.hasDataInput("apertureSize"):
                self.fApertureSize = self.getDataInput("apertureSize")[0].getValue()

            if self.hasDataInput("beamSizeX"):
                self.fBeamSizeX = self.getDataInput("beamSizeX")[0].getValue()

            if self.hasDataInput("beamSizeY"):
                self.fBeamSizeY = self.getDataInput("beamSizeY")[0].getValue()

            if self.hasDataInput("templateMode"):
                self.bTemplateMode = self.getDataInput("templateMode")[0].getValue()

            if (self.hasDataInput("beamPosX")):
                self.fBeamPosX = self.getDataInput("beamPosX")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionX() != None:
                        self.fBeamPosX = self.xsDataExperimentalCodition.getDetector().getBeamPositionX().getValue()

            if (self.hasDataInput("beamPosY")):
                self.fBeamPosY = self.getDataInput("beamPosY")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getDetector() != None:
                    if self.xsDataExperimentalCodition.getDetector().getBeamPositionY() != None:
                        self.fBeamPosY = self.xsDataExperimentalCodition.getDetector().getBeamPositionY().getValue()

            if (self.hasDataInput("wavelength")):
                self.fWavelength = self.getDataInput("wavelength")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getWavelength() != None:
                        self.fWavelength = self.xsDataExperimentalCodition.getBeam().getWavelength().getValue()

            if (self.hasDataInput("transmission")):
                self.fTransmission = self.getDataInput("transmission")[0].getValue()
            elif self.xsDataExperimentalCodition != None:
                if self.xsDataExperimentalCodition.getBeam() != None:
                    if self.xsDataExperimentalCodition.getBeam().getTransmission() != None:
                        self.fTransmission = self.xsDataExperimentalCodition.getBeam().getTransmission().getValue()

            if self.hasDataInput("generatedTemplateFile"):
                self.strGeneratedTemplateFile = self.getDataInput("generatedTemplateFile")[0].getValue()

            if self.hasDataInput("resultsFilePath"):
                self.strResultsFilePath = self.getDataInput("resultsFilePath")[0].getValue()

            if self.hasDataInput("dataCollectionId"):
                self.iDataCollectionId = self.getDataInput("dataCollectionId")[0].getValue()

            if self.hasDataInput("shortComments"):
                self.strShortComments = self.getDataInput("shortComments")[0].getValue()

            if self.hasDataInput("comments"):
                self.strComments = self.getDataInput("comments")[0].getValue()

            if self.hasDataInput("inputCharacterisation"):
                self.xsDataInputCharacterisation = self.getDataInput("inputCharacterisation")[0]

        # Check if XML data is given as input :
        if (self.xsDataInputCharacterisation is None):
            self.edPluginControlSubWedgeAssemble = self.loadPlugin(self.strEDPluginControlSubWedgeAssembleName, "SubWedgeAssemble")

        self.edPluginControlCharacterisation = self.loadPlugin(self.strEDPluginControlCharacterisationName, "Characterisation")

        if (self.strEDPluginControlISPyBName is not None):
            self.edPluginControlISPyB = self.loadPlugin(self.strEDPluginControlISPyBName, "ISPyB")
            


    def process(self, _edPlugin=None):
        EDPluginControl.process(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev1_3.process...")

        if (self.edPluginControlSubWedgeAssemble is not None):
            if(self.bTemplateMode == True):
                self.edPluginControlSubWedgeAssemble.connectSUCCESS(self.generateTemplateFile)
            else:
                self.edPluginControlSubWedgeAssemble.connectSUCCESS(self.doSubWedgeAssembleSUCCESS)
            self.edPluginControlSubWedgeAssemble.connectFAILURE(self.doSubWedgeAssembleFAILURE)

        if(self.edPluginControlCharacterisation is not None):
            self.edPluginControlCharacterisation.connectSUCCESS(self.doSuccessActionCharacterisation)
            self.edPluginControlCharacterisation.connectFAILURE(self.doFailureActionCharacterisation)

        if (self.edPluginControlISPyB is not None):
            self.edPluginControlISPyB.connectSUCCESS(self.doSuccessActionISPyB)
            self.edPluginControlISPyB.connectFAILURE(self.doFailureActionISPyB)

        if (self.xsDataInputCharacterisation is None):
            self.createInputCharacterisationFromImageHeaders(self.edPluginControlSubWedgeAssemble)
        else:
            self.runCharacterisationPlugin(self.edPluginControlCharacterisation)


    def finallyProcess(self, _edPlugin=None):
        EDPluginControl.finallyProcess(self, _edPlugin)
        self.DEBUG("EDPluginControlInterfacev1_3.finallyProcess...")

        if (not self.edPluginControlCharacterisation is None):
            if (self.edPluginControlCharacterisation.hasDataOutput()):
                self.setDataOutput(self.edPluginControlCharacterisation.getDataOutput(), "characterisation")
        if (not self.edPluginControlISPyB is None):
            if (self.edPluginControlISPyB.hasDataOutput()):
                self.setDataOutput(self.edPluginControlISPyB.getDataOutput(), "ISPyB")
        if self.hasDataInput():
            xsDataResultInterface = XSDataResultInterface()
            if self.edPluginControlCharacterisation:
                xsDataResultInterface.setResultCharacterisation(self.edPluginControlCharacterisation.getDataOutput())
            if self.edPluginControlISPyB:
                xsDataResultInterface.setResultControlISPyB(self.edPluginControlISPyB.getDataOutput())
            self.setDataOutput(xsDataResultInterface)


    def createInputCharacterisationFromImageHeaders(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.createInputCharacterisationFromImageHeaders")
        xsDataInputSubWedgeAssemble = XSDataInputSubWedgeAssemble()
        for xsDataStringImagePath in self.listImagePaths:
            xsDataFile = XSDataFile()
            xsDataFile.setPath(xsDataStringImagePath)
            xsDataInputSubWedgeAssemble.addFile(xsDataFile)
        _edPlugin.setDataInput(xsDataInputSubWedgeAssemble)
        _edPlugin.executeSynchronous()


    def runCharacterisationPlugin(self, _edPlugin=None):
        self.DEBUG("EDPluginControlInterfacev1_3.runCharacterisationPlugin")
        self.edPluginControlCharacterisation.setDataInput(self.xsDataInputCharacterisation)
        self.edPluginControlCharacterisation.executeSynchronous()


    def storeResultsInISPyB(self, _edPlugin=None):
        self.DEBUG("EDPluginControlInterfacev1_3.storeResultsInISPyB")
        if (self.edPluginControlISPyB is not None):
            # Execute the ISPyB control plugin
            xsDataInputControlISPyB = XSDataInputControlISPyB()
            xsDataInputControlISPyB.setCharacterisationResult(self.edPluginControlCharacterisation.getDataOutput())
            if (not self.iDataCollectionId is None):
                dataCollectionGroupId = self.getDataCollectionGroupId(self.iDataCollectionId)
                xsDataInputControlISPyB.setDataCollectionGroupId(XSDataInteger(dataCollectionGroupId))
            if (not self.strShortComments is None):
                self.edPluginControlISPyB.setDataInput(XSDataString(self.strShortComments), "shortComments")
            if (not self.strComments is None):
                self.edPluginControlISPyB.setDataInput(XSDataString(self.strComments), "comments")
            if (not self.strStatusMessage is None):
                self.edPluginControlISPyB.setDataInput(XSDataString(self.strStatusMessage), "statusMessage")
            self.edPluginControlISPyB.setDataInput(xsDataInputControlISPyB)
            self.edPluginControlISPyB.executeSynchronous()
            self.checkDozorScores(self.edPluginControlCharacterisation.getDataOutput())


    def createInputCharacterisationFromSubWedges(self):
        self.DEBUG("EDPluginControlInterfacev1_3.createInputCharacterisationFromSubWedges")
        xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput()
        self.xsDataInputCharacterisation = XSDataInputCharacterisation()
        xsDataCollection = XSDataCollection()
        # Default exposure time (for the moment, this value should be
        # possible to read from the command line)
        if self.xsDataDiffractionPlan is None:
            self.xsDataDiffractionPlan = XSDataDiffractionPlan()
        if (not xsDataResultSubWedgeAssemble is None):
            pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
            xsDataCollection.setSubWedge(pyListSubWedge)
            for xsDataSubWedge in pyListSubWedge:
                if (self.strComplexity is not None):
                    self.xsDataDiffractionPlan.setComplexity(XSDataString(self.strComplexity))
                if (self.fFlux is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setFlux(XSDataFlux(self.fFlux))
                if (self.fBeamSizeX is not None) and (self.fBeamSizeY is not None):
                    xsDataSize = XSDataSize()
                    xsDataSize.setX(XSDataLength(self.fBeamSizeX))
                    xsDataSize.setY(XSDataLength(self.fBeamSizeY))
                    xsDataSubWedge.getExperimentalCondition().getBeam().setSize(xsDataSize)
                if (self.fApertureSize is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setApertureSize(XSDataLength(self.fApertureSize))
                if (self.fBeamPosX is not None):
                    xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionX(XSDataLength(self.fBeamPosX))
                if (self.fBeamPosY is not None):
                    xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionY(XSDataLength(self.fBeamPosY))
                if (self.fMinExposureTimePerImage is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setMinExposureTimePerImage(XSDataTime(self.fMinExposureTimePerImage))
                if (self.fTransmission is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setTransmission(XSDataDouble(self.fTransmission))
                if (self.fWavelength is not None):
                    xsDataSubWedge.getExperimentalCondition().getBeam().setWavelength(XSDataWavelength(self.fWavelength))
                if self.fMinOscillationWidth != None:
                    xsDataSubWedge.getExperimentalCondition().getGoniostat().setMinOscillationWidth(XSDataAngle(self.fMinOscillationWidth))
                if self.fMaxOscillationSpeed != None:
                    xsDataSubWedge.getExperimentalCondition().getGoniostat().setMaxOscillationSpeed(XSDataAngularSpeed(self.fMaxOscillationSpeed))
        if (self.strForcedSpaceGroup is not None):
            self.xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.strForcedSpaceGroup))
        self.xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.bAnomalousData))
        self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.fMaxExposureTimePerDataCollection))
        if (self.strStrategyOption is not None):
            self.xsDataDiffractionPlan.setStrategyOption(XSDataString(self.strStrategyOption))
        xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
        if self.xsDataSample is not None:
            xsDataCollection.setSample(XSDataSampleCrystalMM.parseString(self.xsDataSample.marshal()))
        self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)


    def generateTemplateFile(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.generateTemplateFile")
        self.createInputCharacterisationFromSubWedges()
        if(self.strGeneratedTemplateFile is None):
            self.screen("No argument for command line --generateTemplate key word found!")
        elif (self.xsDataInputCharacterisation is None):
            self.screen("ERROR! Cannot generate template file %s, please check the log files." % self.strGeneratedTemplateFile)
        else:
            self.screen("Generating xml template input file for edna: " + self.strGeneratedTemplateFile + "...")
            self.xsDataInputCharacterisation.exportToFile(self.strGeneratedTemplateFile)


    def doSubWedgeAssembleSUCCESS(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.doSubWedgeAssembleSUCCESS")
        self.createInputCharacterisationFromSubWedges()
        self.runCharacterisationPlugin(_edPlugin)

    def doSubWedgeAssembleFAILURE(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.doSubWedgeAssembleFAILURE")
        self.screen("Execution of " + self.strEDPluginControlSubWedgeAssembleName + "  failed.")
        self.screen("Please inspect the log file for further information.")
        self.setFailure()

    def doFailureActionCharacterisation(self, _edPlugin=None):
        """
        retrieve the potential warning messages
        retrieve the potential error messages
        """
        self.DEBUG("EDPluginControlInterfacev1_3.doFailureActionCharacterisation")
        self.retrieveFailureMessages(self.edPluginControlCharacterisation, "EDPluginControlInterfacev1_3.doSuccessActionISPyB")
        if _edPlugin.hasDataOutput("statusMessage"):
            self.strStatusMessage = _edPlugin.getDataOutput("statusMessage")[0].getValue()
        self.generateExecutiveSummary(self)
        self.storeResultsInISPyB(_edPlugin)
        self.setFailure()

    def doSuccessActionCharacterisation(self, _edPlugin=None):
        """
        retrieve the potential warning messages
        """
        self.DEBUG("EDPluginControlInterfacev1_3.doSuccessActionCharacterisation")
        # Store the results if requested
        if (self.strResultsFilePath is not None):
            xsDataCharacterisationResult = _edPlugin.getDataOutput()
            if (xsDataCharacterisationResult is not None):
                xsDataCharacterisationResult.exportToFile(self.strResultsFilePath)
        if _edPlugin.hasDataOutput("statusMessage"):
            self.strStatusMessage = _edPlugin.getDataOutput("statusMessage")[0].getValue()
        self.storeResultsInISPyB(_edPlugin)

    def doSuccessActionISPyB(self, _edPlugin):
        self.DEBUG("EDPluginControlInterfacev1_3.doSuccessActionISPyB...")
        self.retrieveSuccessMessages(self.edPluginControlISPyB, "EDPluginControlInterfacev1_3.doSuccessActionISPyB")

    def doFailureActionISPyB(self, _edPlugin=None):
        self.DEBUG("EDPluginControlInterfacev1_3.doFailureActionISpyB...")
        self.generateExecutiveSummary(self)
        self.setFailure()

    def generateExecutiveSummary(self, _edPlugin=None):
        """
        Prints the executive summary from the plugin
        """
        self.DEBUG("EDPluginControlInterfacev1_3.generateExecutiveSummary")
        if (self.edPluginControlSubWedgeAssemble is not None):
            if self.edPluginControlSubWedgeAssemble.getListExecutiveSummaryLines() != []:
                self.addExecutiveSummaryLine("Summary of plugin %s:" % self.strEDPluginControlSubWedgeAssembleName)
                self.appendExecutiveSummary(self.edPluginControlSubWedgeAssemble)
        if (self.edPluginControlCharacterisation is not None):
            self.addExecutiveSummaryLine("Summary of plugin %s:" % self.strEDPluginControlCharacterisationName)
            self.appendExecutiveSummary(self.edPluginControlCharacterisation)
        if (self.edPluginControlISPyB is not None):
            self.addExecutiveSummaryLine("Summary of plugin %s:" % self.strEDPluginControlISPyBName)
            self.appendExecutiveSummary(self.edPluginControlISPyB)
        self.verboseScreenExecutiveSummary()


    def checkDozorScores(self, _xsDataResultCharacterisation):
        # Check Dozor scores
        listImageQualityIndicators = _xsDataResultCharacterisation.imageQualityIndicators
        noWeakDiffraction = 0
        noTotal = 0
        newComment = None
        referenceImagePath = None
        listImageNoWithNoDiffraction = []
        for imageQualityIndicators in listImageQualityIndicators:
            if referenceImagePath is None:
                referenceImagePath = imageQualityIndicators.image.path.value
            if imageQualityIndicators.dozor_score is not None:
                noTotal += 1
                dozorScore = imageQualityIndicators.dozor_score.value
                if dozorScore <= 0.001:
                    listImageNoWithNoDiffraction.append(imageQualityIndicators.image.number.value)
                elif dozorScore < 1.0:
                    noWeakDiffraction += 1
        if noTotal > 0:
            if len(listImageNoWithNoDiffraction) == noTotal:
                newComment = "No diffraction."
            elif noWeakDiffraction + len(listImageNoWithNoDiffraction) == noTotal:
                newComment = "Very weak diffraction."
            else:
                subComment = None
                if len(listImageNoWithNoDiffraction) == 1:
                    subComment = "image {0}".format(listImageNoWithNoDiffraction[0])
                elif len(listImageNoWithNoDiffraction) == 2:
                    subComment = "images {0} and {1}".format(listImageNoWithNoDiffraction[0], listImageNoWithNoDiffraction[1])                    
                elif len(listImageNoWithNoDiffraction) > 2:
                    subComment = "images {0}".format(listImageNoWithNoDiffraction[0])
                    for imageNo in listImageNoWithNoDiffraction[1:-1]:
                        subComment += ", {0}".format(imageNo)
                    subComment += " and {0}".format(listImageNoWithNoDiffraction[-1])
                if subComment is not None:
                    newComment = "No diffraction detected in {0} - hint: sample might not be accurately centred.".format(subComment)
            
            if newComment is not None and self.iDataCollectionId is not None:
                xsDataInput = XSDataInputISPyBUpdateDataCollectionGroupComment()
                xsDataInput.newComment = XSDataString(newComment)
                xsDataInput.dataCollectionId = XSDataInteger(self.iDataCollectionId)
                edPluginISPyBUpdateDataCollectionGroupComment = self.loadPlugin("EDPluginISPyBUpdateDataCollectionGroupCommentv1_4")
                edPluginISPyBUpdateDataCollectionGroupComment.dataInput = xsDataInput
                self.executePluginSynchronous(edPluginISPyBUpdateDataCollectionGroupComment)

    def getDataCollectionGroupId(self, _dataCollectionId):
        self.DEBUG("EDPluginControlInterfacev1_2.getDataCollectionGroupId")
        self.DEBUG("dataCollectionId = {0}".format(_dataCollectionId))
        dataCollectionGroupId = None
        xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
        xsDataInputRetrieveDataCollection.dataCollectionId = XSDataInteger(_dataCollectionId)
        edPluginISPyBRetrieveDataCollection = self.loadPlugin("EDPluginISPyBRetrieveDataCollectionv1_4")
        edPluginISPyBRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
        edPluginISPyBRetrieveDataCollection.executeSynchronous()
        xsDataResultRetrieveDataCollection = edPluginISPyBRetrieveDataCollection.dataOutput
        if xsDataResultRetrieveDataCollection is not None:
            dataCollection = xsDataResultRetrieveDataCollection.dataCollection
            if dataCollection is not None:
                dataCollectionGroupId = dataCollection.dataCollectionGroupId
        self.DEBUG("dataCollectionGroupId = {0}".format(dataCollectionGroupId))
        return dataCollectionGroupId
 def diffractionPlan(self):
     # Do we have a diffracionPlan?
     xsDataDiffractionPlan = self.xsDataResultCharacterisation.getDataCollection().getDiffractionPlan()
     if xsDataDiffractionPlan is None:
         xsDataDiffractionPlan = XSDataDiffractionPlan()
     self.page.h2( "Diffraction Plan" )
     self.page.table( class_='diffractionPlan', border_="1", cellpadding_="0")
     self.page.tr( align_="CENTER", bgcolor_=self.strTableColourTitle2)
     self.page.th("Forced<br>space group")
     self.page.th("Anomalous<br>data")
     self.page.th("Aimed<br>multiplicity")
     self.page.th("Aimed<br>completeness")
     self.page.th("Aimed I/sigma<br>at highest res.")
     self.page.th("Aimed<br>resolution (&Aring;)")
     self.page.tr.close()
     self.page.tr( align_="CENTER", bgcolor_=self.strTableColourRows)
     # Forced space group               
     if xsDataDiffractionPlan.getForcedSpaceGroup() is None:
         strForcedSpaceGroup = "None"
     else:
         strForcedSpaceGroup = xsDataDiffractionPlan.getForcedSpaceGroup().getValue()
     self.page.th(strForcedSpaceGroup)
     # Anomalous data
     if xsDataDiffractionPlan.getAnomalousData() is None or xsDataDiffractionPlan.getAnomalousData().getValue() == False:
         strAnomalousData = "False"
     else:
         strAnomalousData = "True"
     self.page.th(strAnomalousData)
     # Aimed multiplicity
     if xsDataDiffractionPlan.getAimedMultiplicity() is None:
         strAimedMultiplicity = "Default<br>(optimized)"
     else:
         strAimedMultiplicity = "%.2f" % xsDataDiffractionPlan.getAimedMultiplicity().getValue()
     self.page.th(strAimedMultiplicity)
     # Aimed completeness
     if xsDataDiffractionPlan.getAimedCompleteness() is None:
         strAimedCompleteness = "Default<br>(>= 0.99)"
     else:
         strAimedCompleteness = "%.2f" % xsDataDiffractionPlan.getAimedCompleteness().getValue()
     self.page.th(strAimedCompleteness)
     # Aimed aimedIOverSigmaAtHighestResolution
     if xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution() is None:
         strAimedIOverSigmaAtHighestResolution = "BEST Default"
     else:
         strAimedIOverSigmaAtHighestResolution = "%.2f" % xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution().getValue()
     self.page.th(strAimedIOverSigmaAtHighestResolution)
     # Aimed resolution              
     if xsDataDiffractionPlan.getAimedResolution() is None:
         strAimedResolution = "Default<br>(highest possible)"
     else:
         strAimedResolution = "%0.2f" % xsDataDiffractionPlan.getAimedResolution().getValue()
     self.page.th(strAimedResolution)
     # Close the table
     self.page.tr.close()
     self.page.table.close()