-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
239 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .ctx import ModeContext | ||
from .base import BaseMode | ||
from .setup import ModeSetup | ||
from .proc import ProcMode | ||
from .test import TestMode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from amitools.vamos.log import log_mode | ||
|
||
|
||
class BaseMode: | ||
"""base class for all modes""" | ||
|
||
def __init__(self, name, gen_task_list_func): | ||
self.name = name | ||
self.gen_task_list_func = gen_task_list_func | ||
|
||
def run(self, ctx): | ||
log_mode.info("begin mode '%s'", self.name) | ||
|
||
# generate tasks | ||
task_list = self.gen_task_list_func(ctx) | ||
if task_list is None: | ||
return 0 | ||
|
||
# add tasks to scheduler | ||
for task in task_list: | ||
sched_task = task.get_sched_task() | ||
log_mode.info("add task '%s'", sched_task.get_name()) | ||
ctx.scheduler.add_task(sched_task) | ||
|
||
# --- main loop --- | ||
# schedule tasks... | ||
ctx.scheduler.schedule() | ||
|
||
# pick up exit codes and free task | ||
exit_codes = [] | ||
for task in task_list: | ||
# return code is limited to 0-255 | ||
sched_task = task.get_sched_task() | ||
exit_code = sched_task.get_exit_code() & 0xFF | ||
log_mode.info( | ||
"done task '%s''. exit code=%d", sched_task.get_name(), exit_code | ||
) | ||
exit_codes.append(exit_code) | ||
|
||
run_state = sched_task.get_run_result() | ||
log_mode.debug("run result: %r", run_state) | ||
|
||
# free task | ||
task.free() | ||
|
||
# only return first code | ||
log_mode.info("done mode '%s'. exit_code=%r", self.name, exit_codes) | ||
return exit_codes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ModeContext: | ||
"""context shared with all modes""" | ||
|
||
def __init__(self, proc_cfg, exec_ctx, dos_ctx, scheduler, def_runtime): | ||
self.proc_cfg = proc_cfg | ||
self.exec_ctx = exec_ctx | ||
self.dos_ctx = dos_ctx | ||
self.scheduler = scheduler | ||
self.def_runtime = def_runtime |
Oops, something went wrong.