コード例 #1
0
ファイル: WorkflowDS.py プロジェクト: DawnScience/dawn-tango
 def startJob(self, argin):
     print "In ", self.get_name(), "::startJob()"
     #    Add your own code here
     # Check if i preferred project
     strJobName = argin[0]
     strDataInput = argin[1]
     if not strJobName.endswith(".moml"):
         strJobName += ".moml"
     strWorkflowPath = os.path.join(self._strWorkflowLocation,
                                    self._strPreferredProject, strJobName)
     print strWorkflowPath
     if os.path.exists(strWorkflowPath):
         print "-" * 80
         self.set_state(PyTango.DevState.RUNNING)
         self._workflowProxyThread = WorkflowProxyThread(self)
         self._workflowProxyThread.setWorkspacePath(
             self._strWorkflowLocation)
         self.set_jobSuccess("None")
         self.set_jobFailure("None")
         self._workflowProxyThread.startJob(strWorkflowPath, strDataInput)
         strJobId = self._workflowProxyThread.getJobId()
     else:
         print "+" * 80
         self.set_jobFailure(strJobId)
     return strJobId
コード例 #2
0
 def test_connectToGateway(self):
     print "test_connectToGateway"
     workflowProxyThread = WorkflowProxyThread(None)
     workflowProxyThread.startJavaGatewayServer()
     workflowProxyThread.shutdownJavaGatewayServer()
     workflowProxyThread.startJavaGatewayServer()
     workflowProxyThread.shutdownJavaGatewayServer()
     return True
コード例 #3
0
 def test_connectToGateway(self):
     print "test_connectToGateway"
     workflowProxyThread = WorkflowProxyThread(None)
     workflowProxyThread.startJavaGatewayServer()
     workflowProxyThread.shutdownJavaGatewayServer()
     workflowProxyThread.startJavaGatewayServer()
     workflowProxyThread.shutdownJavaGatewayServer()
     return True
コード例 #4
0
ファイル: WorkflowDS.py プロジェクト: DawnScience/dawn-tango
 def startJob(self, argin):
     print "In ", self.get_name(), "::startJob()"
     #    Add your own code here
     # Check if i preferred project
     strJobName = argin[0]
     strDataInput = argin[1]
     if not strJobName.endswith(".moml"):
         strJobName += ".moml"
     strWorkflowPath = os.path.join(self._strWorkflowLocation, self._strPreferredProject, strJobName)
     print strWorkflowPath
     if os.path.exists(strWorkflowPath):
         print "-"*80
         self.set_state(PyTango.DevState.RUNNING)        
         self._workflowProxyThread = WorkflowProxyThread(self)
         self._workflowProxyThread.setWorkspacePath(self._strWorkflowLocation)
         self.set_jobSuccess("None")
         self.set_jobFailure("None")
         self._workflowProxyThread.startJob(strWorkflowPath, strDataInput)
         strJobId = self._workflowProxyThread.getJobId()
     else:
         print "+"*80
         self.set_jobFailure(strJobId)
     return strJobId
コード例 #5
0
 def test_runWorkflow(self):
     workflowProxyThread = WorkflowProxyThread(None)
     workflowProxyThread.start()
     workflowProxyThread.setWorkspacePath(self._strWorkspacePath)
     #workflowProxyThread.setWorkspacePath("/tmp/dawb_workspace_0QtIib")
     #workflowProxyThread.setWorkspacePath("/users/svensson/dawb_workspace")
     workflowProxyThread.startJob(self._strPathWorkflow, "2.0")
     workflowProxyThread.synchronizeWorkflow()
     result = workflowProxyThread.getDataOutput()
     workflowProxyThread.shutdownJavaGatewayServer()        
     workflowProxyThread.shutdown()
     print [result]
     self.assertEqual(result, unicode("3.0"), "Check of result of python test workflow")
コード例 #6
0
 def test_runWorkflow(self):
     workflowProxyThread = WorkflowProxyThread(None)
     workflowProxyThread.setWorkspacePath(self._strWorkspacePath)
     workflowProxyThread.startJob(self._strPathWorkflow, "XMLinput")
     workflowProxyThread.synchronize()
コード例 #7
0
ファイル: WorkflowDS.py プロジェクト: DawnScience/dawn-tango
class WorkflowDS(PyTango.Device_4Impl):

#--------- Add you global variables here --------------------------

#------------------------------------------------------------------
#    Device constructor
#------------------------------------------------------------------
    def __init__(self, cl, name):
        PyTango.Device_4Impl.__init__(self, cl, name)
        WorkflowDS.init_device(self)
        self._strActorSelected = "No actor selected"
        self._strDataInput = ""
        self._strDataOutput = "No workflow job executed yet"
        self._strJobSuccess = "No workflow job executed yet"
        self._strJobFailure = "No workflow job executed yet"
        self._workflowProxyThread = None

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------
    def delete_device(self):
        print "[Device delete_device method] for device", self.get_name()


#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------
    def init_device(self):
        print "In ", self.get_name(), "::init_device()"
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())
        self.set_change_event("jobSuccess", True, False)
        self.set_change_event("jobFailure", True, False)
        db = PyTango.Database()
        self._strWorkflowLocation = str(db.get_device_property(self.get_name(), "workspaceLocation")["workspaceLocation"][0])
        self._strPreferredProject = str(db.get_device_property(self.get_name(), "preferredProject")["preferredProject"][0])
        print self._strWorkflowLocation
        print self._strPreferredProject


#------------------------------------------------------------------
#    Always excuted hook method
#------------------------------------------------------------------
    def always_executed_hook(self):
        pass
        #print "In ", self.get_name(), "::always_excuted_hook()"



    def set_jobSuccess(self, _jobId):
        print "In ", self.get_name(), "::set_jobSuccess()"
        self._strJobSuccess = _jobId
        print _jobId
        self.push_change_event("jobSuccess", _jobId)
        self._strActorSelected = "No workflow running"
        self.push_change_event("actorSelected", self._strActorSelected)
        self.set_state(PyTango.DevState.ON)


    def set_jobFailure(self, _jobId):
        print "In ", self.get_name(), "::set_jobFailure()"
        self._strJobFailure = _jobId
        self.push_change_event("jobFailure", _jobId)
        self._strActorSelected = "No workflow running"
        self.push_change_event("actorSelected", self._strActorSelected)
        self.set_state(PyTango.DevState.ON)

#==================================================================
#
#    WorkflowDS read/write attribute methods
#
#==================================================================
#------------------------------------------------------------------
#    Read Attribute Hardware
#------------------------------------------------------------------
    def read_attr_hardware(self, data):
        pass
        #print "In ", self.get_name(), "::read_attr_hardware()"



#------------------------------------------------------------------
#    Read JobSuccess attribute
#------------------------------------------------------------------
    def read_jobSuccess(self, attr):
        #print "In ", self.get_name(), "::read_JobSuccess()"
        
        #    Add your own code here
        
        attr_JobSuccess_read = self._strJobSuccess
        attr.set_value(attr_JobSuccess_read)


#------------------------------------------------------------------
#    Read JobFailure attribute
#------------------------------------------------------------------
    def read_jobFailure(self, attr):
        #print "In ", self.get_name(), "::read_JobFailure()"
        
        #    Add your own code here
        
        attr_JobFailure_read = self._strJobFailure
        attr.set_value(attr_JobFailure_read)


#------------------------------------------------------------------
#    Read StatisticsCollected attribute
#------------------------------------------------------------------
    def read_statisticsCollected(self, attr):
        #print "In ", self.get_name(), "::read_StatisticsCollected()"
        
        #    Add your own code here
        
        attr_StatisticsCollected_read = "Hello Tango world"
        attr.set_value(attr_StatisticsCollected_read)


#------------------------------------------------------------------
#    Read testData attribute
#------------------------------------------------------------------
    def read_testData(self, attr):
        #print "In ", self.get_name(), "::read_testData()"
        
        #    Add your own code here
        
        attr_testData_read = "Hello Tango world"
        attr.set_value(attr_testData_read)


#------------------------------------------------------------------
#    Write testData attribute
#------------------------------------------------------------------
    def write_testData(self, attr):
        print "In ", self.get_name(), "::write_testData()"
        data = []
        attr.get_write_value(data)
        print "Attribute value = ", data

        #    Add your own code here


#------------------------------------------------------------------
#    Read ActorSelected attribute
#------------------------------------------------------------------
    def read_actorSelected(self, attr):
        #print "In ", self.get_name(), "::read_actorSelected()"
        
        #    Add your own code here
        
        attr_actorSelected_read = self._strActorSelected
        attr.set_value(attr_actorSelected_read)



#==================================================================
#
#    WorkflowDS command methods
#
#==================================================================

#------------------------------------------------------------------
#    startJob command:
#
#    Description: 
#    argin:  DevVarStringArray    [<Module to execute>,<XML input>]
#    argout: DevString    job id
#------------------------------------------------------------------
    def startJob(self, argin):
        print "In ", self.get_name(), "::startJob()"
        #    Add your own code here
        # Check if i preferred project
        strJobName = argin[0]
        strDataInput = argin[1]
        if not strJobName.endswith(".moml"):
            strJobName += ".moml"
        strWorkflowPath = os.path.join(self._strWorkflowLocation, self._strPreferredProject, strJobName)
        print strWorkflowPath
        if os.path.exists(strWorkflowPath):
            print "-"*80
            self.set_state(PyTango.DevState.RUNNING)        
            self._workflowProxyThread = WorkflowProxyThread(self)
            self._workflowProxyThread.setWorkspacePath(self._strWorkflowLocation)
            self.set_jobSuccess("None")
            self.set_jobFailure("None")
            self._workflowProxyThread.startJob(strWorkflowPath, strDataInput)
            strJobId = self._workflowProxyThread.getJobId()
        else:
            print "+"*80
            self.set_jobFailure(strJobId)
        return strJobId


#---- startJob command State Machine -----------------
    def is_startJob_allowed(self):
        if self.get_state() in [PyTango.DevState.RUNNING]:
            #    End of Generated Code
            #    Re-Start of Generated Code
            return False
        return True


#------------------------------------------------------------------
#    abort command:
#
#    Description: 
#    argin:  DevString    job id
#    argout: DevBoolean    
#------------------------------------------------------------------
    def abort(self, argin):
        print "In ", self.get_name(), "::abort()"
        #    Add your own code here
        argout = False
        return argout


#------------------------------------------------------------------
#    getJobState command:
#
#    Description: 
#    argin:  DevString    job_id
#    argout: DevString    job state
#------------------------------------------------------------------
    def getJobState(self, argin):
        print "In ", self.get_name(), "::getJobState()"
        #    Add your own code here
        argout = "Not implemented!"
        return argout


#------------------------------------------------------------------
#    initPlugin command:
#
#    Description: 
#    argin:  DevString    plugin name
#    argout: DevString    Message
#------------------------------------------------------------------
    def initPlugin(self, argin):
        print "In ", self.get_name(), "::initPlugin()"
        #    Add your own code here
        argout = "Not implemented!"        
        return argout


#------------------------------------------------------------------
#    cleanJob command:
#
#    Description: 
#    argin:  DevString    jobId
#    argout: DevString    Message
#------------------------------------------------------------------
    def cleanJob(self, argin):
        print "In ", self.get_name(), "::cleanJob()"
        #    Add your own code here
        argout = "Not implemented!"        
        return argout


#------------------------------------------------------------------
#    collectStatistics command:
#
#    Description: 
#------------------------------------------------------------------
    def collectStatistics(self):
        print "In ", self.get_name(), "::collectStatistics()"
        #    Add your own code here


#------------------------------------------------------------------
#    getStatistics command:
#
#    Description: 
#    argout: DevString    Retrieve statistics about jobs
#------------------------------------------------------------------
    def getStatistics(self):
        print "In ", self.get_name(), "::getStatistics()"
        #    Add your own code here
        argout = "Not implemented!"        
        return argout


#------------------------------------------------------------------
#    getJobOutput command:
#
#    Description: 
#    argin:  DevString    jobId
#    argout: DevString    job output xml
#------------------------------------------------------------------
    def getJobOutput(self, argin):
        print "In ", self.get_name(), "::getJobOutput()"
        #    Add your own code here
        argout = self._strDataOutput 
        return argout


#------------------------------------------------------------------
#    getJobInput command:
#
#    Description: 
#    argin:  DevString    jobId
#    argout: DevString    job input xml
#------------------------------------------------------------------
    def getJobInput(self, argin):
        print "In ", self.get_name(), "::getJobInput()"
        #    Add your own code here
        argout = self._strDataInput
        return argout


    def setJobOutput(self, _strDataOutput):
        self._strDataOutput = _strDataOutput
コード例 #8
0
ファイル: WorkflowDS.py プロジェクト: DawnScience/dawn-tango
class WorkflowDS(PyTango.Device_4Impl):

    #--------- Add you global variables here --------------------------

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, cl, name):
        PyTango.Device_4Impl.__init__(self, cl, name)
        WorkflowDS.init_device(self)
        self._strActorSelected = "No actor selected"
        self._strDataInput = ""
        self._strDataOutput = "No workflow job executed yet"
        self._strJobSuccess = "No workflow job executed yet"
        self._strJobFailure = "No workflow job executed yet"
        self._workflowProxyThread = None

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        print "[Device delete_device method] for device", self.get_name()

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    def init_device(self):
        print "In ", self.get_name(), "::init_device()"
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())
        self.set_change_event("jobSuccess", True, False)
        self.set_change_event("jobFailure", True, False)
        db = PyTango.Database()
        self._strWorkflowLocation = str(
            db.get_device_property(
                self.get_name(), "workspaceLocation")["workspaceLocation"][0])
        self._strPreferredProject = str(
            db.get_device_property(self.get_name(),
                                   "preferredProject")["preferredProject"][0])
        print self._strWorkflowLocation
        print self._strPreferredProject

#------------------------------------------------------------------
#    Always excuted hook method
#------------------------------------------------------------------

    def always_executed_hook(self):
        pass
        #print "In ", self.get_name(), "::always_excuted_hook()"

    def set_jobSuccess(self, _jobId):
        print "In ", self.get_name(), "::set_jobSuccess()"
        self._strJobSuccess = _jobId
        print _jobId
        self.push_change_event("jobSuccess", _jobId)
        self._strActorSelected = "No workflow running"
        self.push_change_event("actorSelected", self._strActorSelected)
        self.set_state(PyTango.DevState.ON)

    def set_jobFailure(self, _jobId):
        print "In ", self.get_name(), "::set_jobFailure()"
        self._strJobFailure = _jobId
        self.push_change_event("jobFailure", _jobId)
        self._strActorSelected = "No workflow running"
        self.push_change_event("actorSelected", self._strActorSelected)
        self.set_state(PyTango.DevState.ON)

#==================================================================
#
#    WorkflowDS read/write attribute methods
#
#==================================================================
#------------------------------------------------------------------
#    Read Attribute Hardware
#------------------------------------------------------------------

    def read_attr_hardware(self, data):
        pass
        #print "In ", self.get_name(), "::read_attr_hardware()"

#------------------------------------------------------------------
#    Read JobSuccess attribute
#------------------------------------------------------------------

    def read_jobSuccess(self, attr):
        #print "In ", self.get_name(), "::read_JobSuccess()"

        #    Add your own code here

        attr_JobSuccess_read = self._strJobSuccess
        attr.set_value(attr_JobSuccess_read)

#------------------------------------------------------------------
#    Read JobFailure attribute
#------------------------------------------------------------------

    def read_jobFailure(self, attr):
        #print "In ", self.get_name(), "::read_JobFailure()"

        #    Add your own code here

        attr_JobFailure_read = self._strJobFailure
        attr.set_value(attr_JobFailure_read)

#------------------------------------------------------------------
#    Read StatisticsCollected attribute
#------------------------------------------------------------------

    def read_statisticsCollected(self, attr):
        #print "In ", self.get_name(), "::read_StatisticsCollected()"

        #    Add your own code here

        attr_StatisticsCollected_read = "Hello Tango world"
        attr.set_value(attr_StatisticsCollected_read)

#------------------------------------------------------------------
#    Read testData attribute
#------------------------------------------------------------------

    def read_testData(self, attr):
        #print "In ", self.get_name(), "::read_testData()"

        #    Add your own code here

        attr_testData_read = "Hello Tango world"
        attr.set_value(attr_testData_read)

#------------------------------------------------------------------
#    Write testData attribute
#------------------------------------------------------------------

    def write_testData(self, attr):
        print "In ", self.get_name(), "::write_testData()"
        data = []
        attr.get_write_value(data)
        print "Attribute value = ", data

        #    Add your own code here

#------------------------------------------------------------------
#    Read ActorSelected attribute
#------------------------------------------------------------------

    def read_actorSelected(self, attr):
        #print "In ", self.get_name(), "::read_actorSelected()"

        #    Add your own code here

        attr_actorSelected_read = self._strActorSelected
        attr.set_value(attr_actorSelected_read)

#==================================================================
#
#    WorkflowDS command methods
#
#==================================================================

#------------------------------------------------------------------
#    startJob command:
#
#    Description:
#    argin:  DevVarStringArray    [<Module to execute>,<XML input>]
#    argout: DevString    job id
#------------------------------------------------------------------

    def startJob(self, argin):
        print "In ", self.get_name(), "::startJob()"
        #    Add your own code here
        # Check if i preferred project
        strJobName = argin[0]
        strDataInput = argin[1]
        if not strJobName.endswith(".moml"):
            strJobName += ".moml"
        strWorkflowPath = os.path.join(self._strWorkflowLocation,
                                       self._strPreferredProject, strJobName)
        print strWorkflowPath
        if os.path.exists(strWorkflowPath):
            print "-" * 80
            self.set_state(PyTango.DevState.RUNNING)
            self._workflowProxyThread = WorkflowProxyThread(self)
            self._workflowProxyThread.setWorkspacePath(
                self._strWorkflowLocation)
            self.set_jobSuccess("None")
            self.set_jobFailure("None")
            self._workflowProxyThread.startJob(strWorkflowPath, strDataInput)
            strJobId = self._workflowProxyThread.getJobId()
        else:
            print "+" * 80
            self.set_jobFailure(strJobId)
        return strJobId

#---- startJob command State Machine -----------------

    def is_startJob_allowed(self):
        if self.get_state() in [PyTango.DevState.RUNNING]:
            #    End of Generated Code
            #    Re-Start of Generated Code
            return False
        return True

#------------------------------------------------------------------
#    abort command:
#
#    Description:
#    argin:  DevString    job id
#    argout: DevBoolean
#------------------------------------------------------------------

    def abort(self, argin):
        print "In ", self.get_name(), "::abort()"
        #    Add your own code here
        argout = False
        return argout

#------------------------------------------------------------------
#    getJobState command:
#
#    Description:
#    argin:  DevString    job_id
#    argout: DevString    job state
#------------------------------------------------------------------

    def getJobState(self, argin):
        print "In ", self.get_name(), "::getJobState()"
        #    Add your own code here
        argout = "Not implemented!"
        return argout

#------------------------------------------------------------------
#    initPlugin command:
#
#    Description:
#    argin:  DevString    plugin name
#    argout: DevString    Message
#------------------------------------------------------------------

    def initPlugin(self, argin):
        print "In ", self.get_name(), "::initPlugin()"
        #    Add your own code here
        argout = "Not implemented!"
        return argout

#------------------------------------------------------------------
#    cleanJob command:
#
#    Description:
#    argin:  DevString    jobId
#    argout: DevString    Message
#------------------------------------------------------------------

    def cleanJob(self, argin):
        print "In ", self.get_name(), "::cleanJob()"
        #    Add your own code here
        argout = "Not implemented!"
        return argout

#------------------------------------------------------------------
#    collectStatistics command:
#
#    Description:
#------------------------------------------------------------------

    def collectStatistics(self):
        print "In ", self.get_name(), "::collectStatistics()"
        #    Add your own code here

#------------------------------------------------------------------
#    getStatistics command:
#
#    Description:
#    argout: DevString    Retrieve statistics about jobs
#------------------------------------------------------------------

    def getStatistics(self):
        print "In ", self.get_name(), "::getStatistics()"
        #    Add your own code here
        argout = "Not implemented!"
        return argout

#------------------------------------------------------------------
#    getJobOutput command:
#
#    Description:
#    argin:  DevString    jobId
#    argout: DevString    job output xml
#------------------------------------------------------------------

    def getJobOutput(self, argin):
        print "In ", self.get_name(), "::getJobOutput()"
        #    Add your own code here
        argout = self._strDataOutput
        return argout

#------------------------------------------------------------------
#    getJobInput command:
#
#    Description:
#    argin:  DevString    jobId
#    argout: DevString    job input xml
#------------------------------------------------------------------

    def getJobInput(self, argin):
        print "In ", self.get_name(), "::getJobInput()"
        #    Add your own code here
        argout = self._strDataInput
        return argout

    def setJobOutput(self, _strDataOutput):
        self._strDataOutput = _strDataOutput
コード例 #9
0
 def test_runWorkflow(self):
     workflowProxyThread = WorkflowProxyThread(None)
     workflowProxyThread.setWorkspacePath(self._strWorkspacePath)
     workflowProxyThread.startJob(self._strPathWorkflow, "XMLinput")
     workflowProxyThread.synchronize()