Python Configuration and Execution

The Python configuration script is,

#!/usr/bin/env python

import Sniper
task = Sniper.Task("task")
task.setEvtMax(3)
task.setLogLevel(3)

import FirstSvc
task.createSvc("FirstSvc/MyService")

import SecondAlg
task.createAlg("SecondAlg")

task.run()

And the execution result is,

$ python run.py
*****************************************
***     Welcome to SNiPER Python      ***
*****************************************
Running @ lxslc603.ihep.ac.cn on Mon Dec 10 12:58:26 2017

task:SecondAlg.initialize      INFO: the IfMySvc instance is retrieved
task.initialize                INFO: initialized
task:SecondAlg.execute         INFO: loop 1
task:MyService.doSomeThing     INFO: Do some thing in a service
task:SecondAlg.execute         INFO: loop 2
task:SecondAlg.execute         INFO: loop 3
task:MyService.doSomeThing     INFO: Do some thing in a service
task.finalize                  INFO: finalized

***  SNiPER Terminated Successfully!  ***

Please notice that we retrieve the service instance via the name "MyService" in C++, which is not a fixed service type. Then in Python, we assigne the name of the FirstSvc instance as "MyService".

It's simple to implement a new service with the same API,

class SecondSvc : public SvcBase, public IfMySvc
{
    // the definations ...
}

And it's simple to replace FirstSvc by SecondSvc in the Python configuration,

#import FirstSvc
#task.createSvc("FirstSvc/MyService")
import SecondSvc
task.createSvc("SecondSvc/MyService")

In this way, we can flexibly assemble many DLE modules and add/remove/replace each one of them, just by configuration.

results matching ""

    No results matching ""