From 8bc744614e0212903b75bb88a4dca094d97bb5bb Mon Sep 17 00:00:00 2001 From: Kabir Marwah <kabir.marwah97@gmail.com> Date: Mon, 22 Aug 2022 14:14:02 -0700 Subject: [PATCH] Rearchitect RAFPlugin to fix bug --- ait/dsn/plugins/raf_plugin.py | 42 ++++++++++++++--------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/ait/dsn/plugins/raf_plugin.py b/ait/dsn/plugins/raf_plugin.py index ace36e3..a944659 100644 --- a/ait/dsn/plugins/raf_plugin.py +++ b/ait/dsn/plugins/raf_plugin.py @@ -7,30 +7,6 @@ from ait.dsn.sle import RAF from ait.core.server.plugins import Plugin -class RAFModified(RAF): - """ - A modified version of the RAF class which publishes received frames to a plugin"s output topic - (instead of sending them to a UDP socket) - """ - def __init__(self, publish_function, *args, **kwargs): - super().__init__(self, *args, **kwargs) - self.publish = publish_function - - def _transfer_data_invoc_handler(self, pdu): - """""" - frame = pdu.getComponent() - if "data" in frame and frame["data"].isValue: - tm_data = frame["data"].asOctets() - else: - err = ( - "RafTransferBuffer received but data cannot be located. " - "Skipping further processing of this PDU ..." - ) - ait.core.log.info(err) - return - - self.publish(tm_data) - class RAFPlugin(Plugin): """ A plugin which creates a RAF instance using the SLE parameters specified in config.yaml. @@ -38,7 +14,8 @@ class RAFPlugin(Plugin): """ def __init__(self, inputs=None, outputs=None, zmq_args=None): super().__init__(inputs, outputs, zmq_args) - self.raf_object = RAFModified(publish_function= self.publish) + self.raf_object = RAF() + self.raf_object._handlers['AnnotatedFrame']=[self._transfer_data_invoc_handler] self.raf_object.connect() time.sleep(2) self.raf_object.bind() @@ -53,3 +30,18 @@ def __del__(self): self.raf_object.stop() self.raf_object.unbind() self.raf_object.disconnect() + + def _transfer_data_invoc_handler(self, pdu): + """""" + frame = pdu.getComponent() + if "data" in frame and frame["data"].isValue: + tm_data = frame["data"].asOctets() + else: + err = ( + "RafTransferBuffer received but data cannot be located. " + "Skipping further processing of this PDU ..." + ) + ait.core.log.info(err) + return + + self.publish(tm_data) \ No newline at end of file