Esempio n. 1
0
    def to_script(self):
        lib = ScriptLibrary()
        obj, = self.outputs
        pgltype = str(self.pgltype).split(".")[-1][:-2]
        obj = lib.register(obj, "pglobj")

        script = "from vplants.plantgl.scenegraph import %s\n" % pgltype
        script += "%s = %s()\n" % (obj, pgltype)

        return script
Esempio n. 2
0
    def to_script(self):
        lib = ScriptLibrary()
        obj, = self.outputs
        pgltype = str(self.pgltype).split(".")[-1][:-2]
        obj = lib.register(obj, "pglobj")

        script = "from vplants.plantgl.scenegraph import %s\n" % pgltype
        script += "%s = %s()\n" % (obj, pgltype)

        return script
def call_script (inputs, outputs) :
    lib = ScriptLibrary()
    func, = inputs
    func,script = lib.name(func,"")
    val, = outputs
    val = lib.register(val,"val")
    
    script += "%s = %s()\n" % (val,func)
    
    return script
Esempio n. 4
0
def call_script(inputs, outputs):
    lib = ScriptLibrary()
    func, = inputs
    func, script = lib.name(func, "")
    val, = outputs
    val = lib.register(val, "val")

    script += "%s = %s()\n" % (val, func)

    return script
Esempio n. 5
0
def run_scheduler_script(inputs, outputs):
    lib = ScriptLibrary()
    sch, nb_step = inputs
    sch, script = lib.name(sch, "")

    script += "g = %s.run()\n" % sch
    script += "for i in range(%d) :\n" % nb_step
    script += "	g.next()\n\n"

    return script
def run_scheduler_script (inputs, outputs) :
    lib = ScriptLibrary()
    sch,nb_step = inputs
    sch,script = lib.name(sch,"")
    
    script += "g = %s.run()\n" % sch
    script += "for i in range(%d) :\n" % nb_step
    script += "	g.next()\n\n"
    
    return script
Esempio n. 7
0
def create_loop_script(inputs, outputs):
    lib = ScriptLibrary()
    sch, = inputs
    sch, script = lib.name(sch, "")
    loop, = outputs
    loop = lib.register(loop, "loop")

    script += "from openalea.scheduler import Loop\n"
    script += "%s = Loop(%s)\n" % (loop, sch)

    return script
def create_task_script (inputs, outputs) :
    lib = ScriptLibrary()
    function,delay,priority,name,start = inputs
    func,script = lib.name(function,"")
    (task,start), = outputs
    task = lib.register(task,"task_%s" % name)
    
    script += "from openalea.scheduler import Task\n"
    script += "%s = Task(%s,%d,%d,'%s')\n" % (task,func,delay,priority,name)
    
    return script
def create_loop_script (inputs, outputs) :
    lib = ScriptLibrary()
    sch, = inputs
    sch,script = lib.name(sch,"")
    loop, = outputs
    loop = lib.register(loop,"loop")
    
    script += "from openalea.scheduler import Loop\n"
    script += "%s = Loop(%s)\n" % (loop,sch)
    
    return script
Esempio n. 10
0
def create_task_script(inputs, outputs):
    lib = ScriptLibrary()
    function, delay, priority, name, start = inputs
    func, script = lib.name(function, "")
    (task, start), = outputs
    task = lib.register(task, "task_%s" % name)

    script += "from openalea.scheduler import Task\n"
    script += "%s = Task(%s,%d,%d,'%s')\n" % (task, func, delay, priority,
                                              name)

    return script
Esempio n. 11
0
def create_scheduler_script(inputs, outputs):
    lib = ScriptLibrary()
    tasks, = inputs
    sch, = outputs
    sch = lib.register(sch, "sch")

    script = "from openalea.scheduler import Scheduler\n"
    script += "%s = Scheduler()\n" % sch

    try:
        iter(tasks[1])
        for task, start_time in tasks:
            task, script = lib.name(task, script)
            script += "%s.register(%s,%s)\n" % (sch, task, start_time)
    except TypeError, IndexError:
        task, start_time = tasks
        task, script = lib.name(task, script)
        script += "%s.register(%s,%s)\n" % (sch, task, start_time)
Esempio n. 12
0
def create_scheduler_script (inputs, outputs) :
    lib = ScriptLibrary()
    tasks, = inputs
    sch, = outputs
    sch = lib.register(sch,"sch")
    
    script = "from openalea.scheduler import Scheduler\n"
    script += "%s = Scheduler()\n" % sch
    
    try :
        iter(tasks[1])
        for task,start_time in tasks :
            task,script = lib.name(task,script)
            script += "%s.register(%s,%s)\n" % (sch,task,start_time)
    except TypeError,IndexError :
        task,start_time = tasks
        task,script = lib.name(task,script)
        script += "%s.register(%s,%s)\n" % (sch,task,start_time)
Esempio n. 13
0
    def eval(self, *args, **kwds):
        """ Evaluate the whole dataflow starting from leaves"""
        df = self._dataflow

        # Unvalidate all the nodes
        self._evaluated.clear()
        ScriptLibrary().clear()

        # Eval from the leaf
        script = ""
        for vid in (vid for vid in df.vertices() if df.nb_out_edges(vid) == 0):
            script += self.eval_vertex(vid)

        return script