Renamed wait plugin to sleep
This commit is contained in:
parent
7d30328e21
commit
203b513c9e
@ -2,7 +2,7 @@
|
||||
import os
|
||||
import sys
|
||||
from config import Config
|
||||
from plugins import WaitPlugin, SyncPlugin
|
||||
from plugins import SleepPlugin, SyncPlugin
|
||||
from plugin_repository import PluginRepository
|
||||
from program_executor import ProgramExecutor
|
||||
from http_server import ControllerHTTPServer
|
||||
@ -33,18 +33,18 @@ def main():
|
||||
http_server.start()
|
||||
|
||||
compiler_repo = PluginRepository()
|
||||
compiler_repo.register_plugin(WaitPlugin)
|
||||
compiler_repo.register_plugin(SleepPlugin)
|
||||
compiler_repo.register_plugin(SyncPlugin)
|
||||
|
||||
# Example code:
|
||||
compiler_repo.load_plugin("wait")
|
||||
compiler_repo.load_plugin("sleep")
|
||||
compiler_repo.load_plugin("sync")
|
||||
program = []
|
||||
program.append(compiler_repo.get_compiler("wait").compile(secs=2))
|
||||
program.append(compiler_repo.get_compiler("wait").compile(secs=3))
|
||||
program.append(compiler_repo.get_compiler("sleep").compile(secs=2))
|
||||
program.append(compiler_repo.get_compiler("sleep").compile(secs=3))
|
||||
program.append(compiler_repo.get_compiler("sync").compile(nodes=2, name="test"))
|
||||
program.append(compiler_repo.get_compiler("wait").compile(secs=10))
|
||||
program.append(compiler_repo.get_compiler("wait").compile(secs=10))
|
||||
program.append(compiler_repo.get_compiler("sleep").compile(secs=10))
|
||||
program.append(compiler_repo.get_compiler("sleep").compile(secs=10))
|
||||
|
||||
# prepare execution
|
||||
executor = ProgramExecutor(program, loop=True)
|
||||
|
@ -1,3 +1,3 @@
|
||||
from .abstract_plugin import AbstractCommand, AbstractCommandCompiler, AbstractPlugin
|
||||
from .wait_plugin import WaitPlugin
|
||||
from .sleep_plugin import SleepPlugin
|
||||
from .sync_plugin import SyncPlugin
|
@ -5,7 +5,7 @@ import logging
|
||||
import time
|
||||
|
||||
|
||||
class WaitCommand(AbstractCommand):
|
||||
class SleepCommand(AbstractCommand):
|
||||
|
||||
def __init__(self, logger: logging.Logger, secs: float):
|
||||
|
||||
@ -25,31 +25,31 @@ class WaitCommand(AbstractCommand):
|
||||
|
||||
def describe(self) -> dict:
|
||||
return {
|
||||
"command": "wait",
|
||||
"command": "sleep",
|
||||
"params": {
|
||||
"secs": self._secs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WaitCompiler(AbstractCommandCompiler):
|
||||
class SleepCompiler(AbstractCommandCompiler):
|
||||
|
||||
def __init__(self, logger: logging.Logger):
|
||||
self._logger = logger
|
||||
|
||||
def compile(self, secs: float) -> AbstractCommand:
|
||||
return WaitCommand(self._logger, secs)
|
||||
return SleepCommand(self._logger, secs)
|
||||
|
||||
|
||||
class WaitPlugin(AbstractPlugin):
|
||||
plugin_name = "wait"
|
||||
class SleepPlugin(AbstractPlugin):
|
||||
plugin_name = "sleep"
|
||||
|
||||
def __init__(self):
|
||||
self._logger = logging.getLogger("plugin").getChild("wait")
|
||||
self._logger = logging.getLogger("plugin").getChild("sleep")
|
||||
|
||||
def load_compilers(self) -> Dict[str, AbstractCommandCompiler]:
|
||||
return {
|
||||
"wait": WaitCompiler(self._logger)
|
||||
"sleep": SleepCompiler(self._logger)
|
||||
}
|
||||
|
||||
def close(self):
|
Loading…
Reference in New Issue
Block a user