-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from kmarwah/Issue-191
Issue #191 – Add SLE plugins
- Loading branch information
Showing
7 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
A plugin which adds CLTU start and tail bytes to incoming data | ||
""" | ||
from ait.core.server.plugins import Plugin | ||
|
||
class CreateCLTU(Plugin): | ||
""" | ||
Adds CLTU start and tail bytes to incoming data (frames) | ||
The input will normally be TC frames (either with or without BCH). | ||
The output is CLTUs with the CCSDS standard start and tail byte sequences. | ||
""" | ||
|
||
def __init__(self, inputs=None, outputs=None, zmq_args=None): | ||
super().__init__(inputs, outputs, zmq_args) | ||
self.cltu_start = bytearray(b"\xEB\x90") | ||
self.cltu_tail = bytearray(b"\xC5\xC5\xC5\xC5\xC5\xC5\xC5\x79") | ||
|
||
def process(self, input_data, topic=None): | ||
cltu_bytearray = self.cltu_start + input_data + self.cltu_tail | ||
self.publish(cltu_bytearray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
A plugin which creates an RAF connection with the DSN. | ||
Frames received via the RAF connection are sent to the output stream | ||
""" | ||
import time | ||
import ait | ||
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. | ||
All received frames are published to the output topic. | ||
""" | ||
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.connect() | ||
time.sleep(2) | ||
self.raf_object.bind() | ||
time.sleep(2) | ||
self.raf_object.start(None, None) | ||
time.sleep(2) | ||
|
||
def process(self, input_data, topic = None): | ||
pass | ||
|
||
def __del__(self): | ||
self.raf_object.stop() | ||
self.raf_object.unbind() | ||
self.raf_object.disconnect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
Creates a FCLTU instance and uploads any incoming CLTUs to the DSN via SLE | ||
""" | ||
|
||
import time | ||
from ait.core.server.plugins import Plugin | ||
import ait.core | ||
from ait.dsn.sle import CLTU | ||
|
||
class SendCLTU(Plugin): | ||
""" | ||
Creates a FCLTU instance and uploads any incoming CLTUs to the DSN via SLE | ||
The input stream should consist of CLTUs (with appropriate start and tail sequences). | ||
""" | ||
|
||
def __init__(self, inputs=None, outputs=None, zmq_args=None): | ||
super().__init__(inputs, outputs, zmq_args) | ||
self.cltu_manager = CLTU() | ||
self.cltu_manager.connect() | ||
time.sleep(2) | ||
self.cltu_manager.bind() | ||
time.sleep(2) | ||
self.cltu_manager.start() | ||
time.sleep(2) | ||
|
||
def process(self, input_data, topic=None): | ||
if self.cltu_manager._state == "ready": | ||
self.cltu_manager.upload_cltu(input_data) | ||
self.publish(input_data) | ||
ait.core.log.debug("uploaded CLTU") | ||
else: | ||
ait.core.log.error("CLTU Manager is not in ready state– check DSN connection") | ||
return input_data | ||
|
||
def __del__(self): | ||
self.cltu_manager.stop() | ||
self.cltu_manager.unbind() | ||
self.cltu_manager.disconnect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ait.dsn.plugins.create_cltu module | ||
====================================== | ||
|
||
.. automodule:: ait.dsn.plugins.create_cltu | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ait.dsn.plugins.raf_plugin module | ||
====================================== | ||
|
||
.. automodule:: ait.dsn.plugins.raf_plugin | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ait.dsn.plugins.send_cltu module | ||
====================================== | ||
|
||
.. automodule:: ait.dsn.plugins.send_cltu | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |