Starting the Control Server

Introduction

Start a server for controlling COBOTTA.

Preparing a Python program

from cobotta2 import Config, CobottaCtrl
from cobotta2.server import CobottaRouterCtrl, cobotta_ctrl_api_spec
from ese774_frame import FastApiServer
from x_logger import XLogger

if __name__ == "__main__":
    Config.load_yaml("config_cobotta1.yaml")
    logger = XLogger(log_level="debug", logger_name=Config.SERVER_LOGGER_NAME)
    server = FastApiServer(
        device_cls=CobottaCtrl,  # Control class
        router_cls=CobottaRouterCtrl,  # Router class
        config=Config,
        api_spec=cobotta_ctrl_api_spec,
        device_kwargs={"cobotta_ip": Config.COBOTTA_IP},  # Constructor arguments
        logger=logger,
        logger_name=Config.SERVER_LOGGER_NAME,
        lifespan_msg_prefix="COBOTTA",
    )
    server.run(host=Config.SERVER_IP, port=Config.SERVER_PORT)

Notes on file paths

Running as a Windows service


Author

  • Kengo NAKADA