in usb_monitor_pkg/usb_monitor_pkg/usb_monitor_node.py [0:0]
def __init__(self):
"""Create a USBMonitorNode.
"""
super().__init__("usb_monitor_node")
self.get_logger().info("usb_monitor_node started")
self.queue = queue.Queue()
self.stop_queue = threading.Event()
self.mount_point_map = dict()
self.subscribers = list()
# Service to add files/folders to the watchlist (subscribers).
self.file_system_service_cb_group = ReentrantCallbackGroup()
self.usb_file_system_subscriber_service = \
self.create_service(USBFileSystemSubscribeSrv,
constants.USB_FILE_SYSTEM_SUBSCRIBE_SERVICE_NAME,
self.usb_file_system_subscribe_cb,
callback_group=self.file_system_service_cb_group)
# Service exposing the functionality to safely increment/decrement the refernce
# counter for the mount point.
self.usb_mpm_cb_group = ReentrantCallbackGroup()
self.usb_mount_point_manager_service = \
self.create_service(USBMountPointManagerSrv,
constants.USB_MOUNT_POINT_MANAGER_SERVICE_NAME,
self.usb_mount_point_manager_cb,
callback_group=self.usb_mpm_cb_group)
# Publisher to broadcast the notification messages.
self.usb_file_system_notif_cb = ReentrantCallbackGroup()
self.usb_file_system_notification_publisher = \
self.create_publisher(USBFileSystemNotificationMsg,
constants.USB_FILE_SYSTEM_NOTIFICATION_TOPIC,
10,
callback_group=self.usb_file_system_notif_cb)
# Heartbeat timer.
self.timer_count = 0
self.timer = self.create_timer(5.0, self.timer_callback)
self.get_logger().info("USB Monitor node successfully created")