Add proof of concept for Trace(Action)
This commit is contained in:
parent
a859bb6aa6
commit
bd0f23ba37
2 changed files with 27 additions and 31 deletions
|
@ -1,24 +0,0 @@
|
||||||
|
|
||||||
from typing import List
|
|
||||||
from typing import Optional
|
|
||||||
from typing import Text
|
|
||||||
|
|
||||||
from launch.action import Action
|
|
||||||
from launch_context import LaunchContext
|
|
||||||
from launch_description_entity import LaunchDescriptionEntity
|
|
||||||
|
|
||||||
|
|
||||||
class Destroy(Action):
|
|
||||||
"""
|
|
||||||
Action for launch that destroys a tracing session.
|
|
||||||
|
|
||||||
It finalizes and destroys a tracing session that was setup with the Trace action.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, session_name: str, **kwargs) -> None:
|
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.__session_name = session_name
|
|
||||||
|
|
||||||
def execute(self, context: LaunchContext) -> Optional[List[Action]]:
|
|
||||||
pass
|
|
|
@ -1,11 +1,14 @@
|
||||||
|
|
||||||
|
import os
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Text
|
from typing import Text
|
||||||
|
|
||||||
from launch.action import Action
|
from launch.action import Action
|
||||||
from launch_context import LaunchContext
|
from launch.event import Event
|
||||||
from launch_description_entity import LaunchDescriptionEntity
|
from launch.event_handlers import OnShutdown
|
||||||
|
from launch.launch_context import LaunchContext
|
||||||
|
from tracetools_trace.tools import names
|
||||||
|
|
||||||
|
|
||||||
class Trace(Action):
|
class Trace(Action):
|
||||||
|
@ -15,15 +18,32 @@ class Trace(Action):
|
||||||
Sets up and enables tracing through a launch file description.
|
Sets up and enables tracing through a launch file description.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *,
|
def __init__(
|
||||||
|
self, *,
|
||||||
session_name: str,
|
session_name: str,
|
||||||
base_path: str,
|
base_path: str = '/tmp',
|
||||||
events_ust: List[str],
|
events_ust: List[str] = names.DEFAULT_EVENTS_ROS,
|
||||||
events_kernel: List[str],
|
events_kernel: List[str] = names.DEFAULT_EVENTS_KERNEL,
|
||||||
**kwargs) -> None:
|
**kwargs) -> None:
|
||||||
"""Constructor."""
|
"""Constructor."""
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
self.__session_name = session_name
|
||||||
|
self.__path = os.path.join(base_path, session_name)
|
||||||
|
self.__events_ust = events_ust
|
||||||
|
self.__events_kernel = events_kernel
|
||||||
|
|
||||||
def execute(self, context: LaunchContext) -> Optional[List[Action]]:
|
def execute(self, context: LaunchContext) -> Optional[List[Action]]:
|
||||||
|
# TODO make sure this is done as late as possible
|
||||||
|
context.register_event_handler(OnShutdown(
|
||||||
|
on_shutdown=self._destroy,
|
||||||
|
))
|
||||||
|
# TODO make sure this is done as early as possible
|
||||||
|
self._setup()
|
||||||
|
|
||||||
|
def _setup(self):
|
||||||
# TODO
|
# TODO
|
||||||
pass
|
print('setting up tracing!')
|
||||||
|
|
||||||
|
def _destroy(self, event: Event, context: LaunchContext):
|
||||||
|
# TODO
|
||||||
|
print('destroying tracing session!')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue