Skip to content

Commit

Permalink
Issue #10 and #11 - Renaming updates
Browse files Browse the repository at this point in the history
Update BLISS references to AIT. Switch main package naming over to
`ait.dsn` with subpackages for CFDP and SLE interfaces.
  • Loading branch information
MJJoyce committed May 21, 2018
1 parent 2fbbc53 commit 94947d8
Show file tree
Hide file tree
Showing 108 changed files with 756 additions and 483 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ branches:
- master

env:
# - AIT_CONFIG: ${TRAVIS_BUILD_DIR}/config/config.yaml
- BLISS_CONFIG: ${TRAVIS_BUILD_DIR}/config/config.yaml
- AIT_CONFIG: ${TRAVIS_BUILD_DIR}/config/config.yaml

install:
- pip install .[tests]
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
AMMOS Instrument Toolkit (AIT) Space Link Extension (SLE) Interface
===================================================================
AMMOS Instrument Toolkit (AIT) Deep Space Network (DSN) Interface
=================================================================

AIT SLE provides APIs for connecting to the Deep Space Network (DSN) via the Space Link
Extension interfaces. AIT SLE supports the following interfaces:
AIT DSN provides APIs for connecting to the Deep Space Network (DSN) via the Space Link
Extension interfaces. AIT DSN supports the following interfaces:

- Return All Frames (RAF) interface
- Return Channel Frames (RCF) interface
- Forward Communications Link Transmission Unit (CLTU) interface
- CCSDS File Delivery Protocol Class 1 interface

Getting Started
---------------

You can read through the [Installation Page](http://ait-dsn.readthedocs.io/en/latest/installation.html) for instruction on how to install AIT SLE.
You can read through the [Installation Page](http://ait-dsn.readthedocs.io/en/latest/installation.html) for instruction on how to install AIT DSN.

Join the Community
------------------
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bliss/cfdp/__init__.py → ait/dsn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

from cfdp import CFDP
__import__('pkg_resources').declare_namespace(__name__)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2017, by the California Institute of Technology. ALL RIGHTS
# Copyright 2018, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the Office of Technology Transfer
# at the California Institute of Technology.
Expand All @@ -29,4 +29,4 @@ def handle(sock, address):

if __name__ == '__main__':
server = gevent.server.StreamServer(('127.0.0.1', 8000), handle)
server.serve_forever()
server.serve_forever()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2017, by the California Institute of Technology. ALL RIGHTS
# Copyright 2018, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the Office of Technology Transfer
# at the California Institute of Technology.
Expand All @@ -14,17 +14,17 @@
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

import bliss.cfdp
import ait.dsn.cfdp
import os
import gevent
import traceback

from bliss.cfdp.primitives import TransmissionMode
import bliss.core.log
from ait.dsn.cfdp.primitives import TransmissionMode
import ait.core.log


if __name__ == '__main__':
cfdp = bliss.cfdp.CFDP(1)
cfdp = ait.dsn.cfdp.CFDP(1)
try:
# cfdp.connect(('127.0.0.1', 9001))
# # Set address of counterpart
Expand All @@ -35,7 +35,7 @@
destination_file = 'my/test/blah.txt'
cfdp.put(destination_id, source_file, destination_file, transmission_mode=TransmissionMode.NO_ACK)
while True:
# bliss.core.log.info('Sleeping...')
# ait.core.log.info('Sleeping...')
gevent.sleep(1)
except KeyboardInterrupt:
print "Disconnecting..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

from bliss.core import log

import bliss.sle
import bliss.sle.frames
from bliss.sle.pdu.raf import *
import ait.dsn.sle
import ait.dsn.sle.frames
from ait.dsn.sle.pdu.raf import *

def process_pdu(raf_mngr):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand Down Expand Up @@ -59,13 +59,13 @@ def process_pdu(raf_mngr):
# Object does not contain data or data is not initalized. Skipping ...
continue

tmf = bliss.sle.frames.TMTransFrame(trans_data)
tmf = ait.dsn.sle.frames.TMTransFrame(trans_data)
log.info('Emitting {} bytes of telemetry to GUI'.format(len(tmf._data[0])))
sock.sendto(tmf._data[0], ('localhost', 3076))


if __name__ == '__main__':
raf_mngr = bliss.sle.RAF(hostname='atb-ocio-sspsim.jpl.nasa.gov', port=5100,
raf_mngr = ait.dsn.sle.RAF(hostname='atb-ocio-sspsim.jpl.nasa.gov', port=5100,
auth_level="bind",
inst_id="sagr=LSE-SSC.spack=Test.rsl-fg=1.raf=onlc1")
raf_mngr.connect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import datetime as dt
import time

import bliss.sle
import ait.dsn.sle

cltu_mngr = bliss.sle.CLTU(
cltu_mngr = ait.dsn.sle.CLTU(
hostname='atb-ocio-sspsim.jpl.nasa.gov',
port=5100,
inst_id='sagr=LSE-SSC.spack=Test.fsl-fg=1.cltu=cltu1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
import datetime as dt
import time

import bliss.sle
import ait.dsn.sle

rcf_mngr = bliss.sle.RCF(
rcf_mngr = ait.dsn.sle.RCF(
hostname='atb-ocio-sspsim.jpl.nasa.gov',
port=5100,
inst_id='sagr=LSE-SSC.spack=Test.rsl-fg=1.rcf=onlc2',
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions bliss/cfdp/test/__init__.py → ait/dsn/cfdp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2017, by the California Institute of Technology. ALL RIGHTS
# Copyright 2018, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the Office of Technology Transfer
# at the California Institute of Technology.
Expand All @@ -10,4 +10,6 @@
# this software, the user agrees to comply with all applicable U.S. export
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.
# information to foreign countries or providing access to foreign persons.

from cfdp import CFDP
80 changes: 40 additions & 40 deletions bliss/cfdp/cfdp.py → ait/dsn/cfdp/cfdp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2017, by the California Institute of Technology. ALL RIGHTS
# Copyright 2018, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the Office of Technology Transfer
# at the California Institute of Technology.
Expand All @@ -21,24 +21,24 @@
import gevent.queue
import gevent.socket

from bliss.cfdp.events import Event
from bliss.cfdp.machines import Receiver1, Sender1
from bliss.cfdp.mib import MIB
from bliss.cfdp.pdu import make_pdu_from_bytes, Header
from bliss.cfdp.primitives import RequestType, TransmissionMode, FileDirective, Role, ConditionCode
from bliss.cfdp.request import create_request_from_type
from bliss.cfdp.util import write_to_file
from ait.dsn.cfdp.events import Event
from ait.dsn.cfdp.machines import Receiver1, Sender1
from ait.dsn.cfdp.mib import MIB
from ait.dsn.cfdp.pdu import make_pdu_from_bytes, Header
from ait.dsn.cfdp.primitives import RequestType, TransmissionMode, FileDirective, Role, ConditionCode
from ait.dsn.cfdp.request import create_request_from_type
from ait.dsn.cfdp.util import write_to_file
from exceptions import InvalidTransaction

import bliss.core
import bliss.core.log
import ait.core
import ait.core.log


class CFDP(object):
"""CFDP processor class. Handles sending and receiving of PDUs and management of transactions.
"""

mib = MIB(bliss.config.get('dsn.cfdp.mib.path', '/tmp/cfdp/mib'))
mib = MIB(ait.config.get('dsn.cfdp.mib.path', '/tmp/cfdp/mib'))
transaction_counter = 0
pdu_counter = 1
outgoing_pdu_queue = gevent.queue.Queue()
Expand All @@ -63,10 +63,10 @@ def __init__(self, entity_id, *args, **kwargs):
self.received_pdu_files = []

self._data_paths = {}
self._data_paths['pdusink'] = bliss.config.get('dsn.cfdp.datasink.pdusink.path')
self._data_paths['outgoing'] = bliss.config.get('dsn.cfdp.datasink.outgoing.path')
self._data_paths['incoming'] = bliss.config.get('dsn.cfdp.datasink.incoming.path')
self._data_paths['tempfiles'] = bliss.config.get('dsn.cfdp.datasink.tempfiles.path')
self._data_paths['pdusink'] = ait.config.get('dsn.cfdp.datasink.pdusink.path')
self._data_paths['outgoing'] = ait.config.get('dsn.cfdp.datasink.outgoing.path')
self._data_paths['incoming'] = ait.config.get('dsn.cfdp.datasink.incoming.path')
self._data_paths['tempfiles'] = ait.config.get('dsn.cfdp.datasink.tempfiles.path')

# create needed paths if they don't exist
for name, path in self._data_paths.iteritems():
Expand All @@ -82,7 +82,7 @@ def connect(self, host):
while not connected:
try:
self._socket.bind(host)
bliss.core.log.info('Connected to socket...')
ait.core.log.info('Connected to socket...')
connected = True
except socket.error as e:
gevent.sleep(1)
Expand All @@ -105,7 +105,7 @@ def send(self, pdu):
pdu:
An instance of a PDU subclass (EOF, MD, etc)
"""
bliss.core.log.debug('Adding pdu ' + str(pdu) + ' to queue')
ait.core.log.debug('Adding pdu ' + str(pdu) + ' to queue')
self.outgoing_pdu_queue.put(pdu)

def put(self, destination_id, source_path, destination_path, transmission_mode=None):
Expand All @@ -120,10 +120,10 @@ def put(self, destination_id, source_path, destination_path, transmission_mode=N
"""
# Do some file checks before starting anything
if source_path.startswith('/'):
bliss.core.log.error('Source path should be a relative path.')
ait.core.log.error('Source path should be a relative path.')
return
if destination_path.startswith('/'):
bliss.core.log.error('Destination path should be a relative path.')
ait.core.log.error('Destination path should be a relative path.')
return

# (A) Transaction Start Notification Procedure
Expand Down Expand Up @@ -163,7 +163,7 @@ def ingest(self, pdu_path):
"""Ingest pdu from file
"""
if pdu_path not in self.received_pdu_files:
bliss.core.log.debug("Ingesting PDU at path: {0}".format(pdu_path))
ait.core.log.debug("Ingesting PDU at path: {0}".format(pdu_path))
# cache file so that we know we read it
self.received_pdu_files.append(pdu_path)
# add to incoming so that receiving handler can deal with it
Expand Down Expand Up @@ -231,8 +231,8 @@ def read_pdus(instance):
instance.incoming_pdu_queue.put(pdu_file_bytes)
break
except Exception as e:
bliss.core.log.warn("EXCEPTION: " + e.message)
bliss.core.log.warn(traceback.format_exc())
ait.core.log.warn("EXCEPTION: " + e.message)
ait.core.log.warn(traceback.format_exc())
gevent.sleep(0.2)


Expand All @@ -245,27 +245,27 @@ def receiving_handler(instance):
try:
pdu_bytes = instance.incoming_pdu_queue.get(block=False)
pdu = read_incoming_pdu(pdu_bytes)
bliss.core.log.debug('Incoming PDU Type: ' + str(pdu.header.pdu_type))
ait.core.log.debug('Incoming PDU Type: ' + str(pdu.header.pdu_type))

if pdu.header.destination_entity_id != instance.mib.local_entity_id:
bliss.core.log.debug('Skipping PDU with mismatched destination entity id {0}'.format(pdu.header.destination_entity_id))
ait.core.log.debug('Skipping PDU with mismatched destination entity id {0}'.format(pdu.header.destination_entity_id))
continue

transaction_num = pdu.header.transaction_id
machine = instance._machines[transaction_num] if transaction_num in instance._machines else None

if pdu.header.pdu_type == Header.FILE_DATA_PDU:
# If its file data we'll concat to file
bliss.core.log.debug('Received File Data Pdu')
ait.core.log.debug('Received File Data Pdu')
if machine is None:
bliss.core.log.info(
ait.core.log.info(
'Ignoring File Data for transaction that doesn\'t exist: {}'.format(transaction_num))
else:
# Restart inactivity timer here when PDU is being given to a machine
machine.inactivity_timer.restart()
machine.update_state(Event.RECEIVED_FILEDATA_PDU, pdu=pdu)
elif pdu.header.pdu_type == Header.FILE_DIRECTIVE_PDU:
bliss.core.log.debug('Received File Directive Pdu: ' + str(pdu.file_directive_code))
ait.core.log.debug('Received File Directive Pdu: ' + str(pdu.file_directive_code))
if pdu.file_directive_code == FileDirective.METADATA:
# If machine doesn't exist, create a machine for this transaction
transmission_mode = pdu.header.transmission_mode
Expand All @@ -277,21 +277,21 @@ def receiving_handler(instance):
machine.update_state(Event.RECEIVED_METADATA_PDU, pdu=pdu)
elif pdu.file_directive_code == FileDirective.EOF:
if machine is None:
bliss.core.log.info('Ignoring EOF for transaction that doesn\'t exist: {}'
ait.core.log.info('Ignoring EOF for transaction that doesn\'t exist: {}'
.format(transaction_num))
else:
if pdu.condition_code == ConditionCode.CANCEL_REQUEST_RECEIVED:
machine.update_state(Event.RECEIVED_EOF_CANCEL_PDU, pdu=pdu)
elif pdu.condition_code == ConditionCode.NO_ERROR:
bliss.core.log.debug('Received EOF with checksum: {}'.format(pdu.file_checksum))
ait.core.log.debug('Received EOF with checksum: {}'.format(pdu.file_checksum))
machine.update_state(Event.RECEIVED_EOF_NO_ERROR_PDU, pdu=pdu)
else:
bliss.core.log.warn('Received EOF with strang condition code: {}'.format(pdu.condition_code))
ait.core.log.warn('Received EOF with strang condition code: {}'.format(pdu.condition_code))
except gevent.queue.Empty:
pass
except Exception as e:
bliss.core.log.warn("EXCEPTION: " + e.message)
bliss.core.log.warn(traceback.format_exc())
ait.core.log.warn("EXCEPTION: " + e.message)
ait.core.log.warn(traceback.format_exc())
gevent.sleep(0.2)


Expand Down Expand Up @@ -321,14 +321,14 @@ def write_outgoing_pdu(pdu, pdu_filename=None, output_directory=None):
pdu_bytes = pdu.to_bytes()

if output_directory is None:
bliss.core.log.info(str(pdu_bytes))
ait.core.log.info(str(pdu_bytes))
return

if pdu_filename is None:
# make a filename of destination id + time
pdu_filename = str(pdu.header.destination_entity_id) + '_' + str(int(time.time())) + '.pdu'
pdu_file_path = os.path.join(output_directory, pdu_filename)
bliss.core.log.debug('PDU file path ' + str(pdu_file_path))
ait.core.log.debug('PDU file path ' + str(pdu_file_path))
# https://stackoverflow.com/questions/17349918/python-write-string-of-bytes-to-file
# pdu_bytes is an array of integers that need to be converted to hex
write_to_file(pdu_file_path, bytearray(pdu_bytes))
Expand All @@ -343,14 +343,14 @@ def sending_handler(instance):
pdu = instance.outgoing_pdu_queue.get(block=False)
pdu_filename = 'entity{0}_tx{1}_{2}.pdu'.format(pdu.header.destination_entity_id, pdu.header.transaction_id, instance.pdu_counter)
instance.pdu_counter += 1
bliss.core.log.debug('Got PDU from outgoing queue: ' + str(pdu))
ait.core.log.debug('Got PDU from outgoing queue: ' + str(pdu))
write_outgoing_pdu(pdu, pdu_filename=pdu_filename, output_directory=instance._data_paths['pdusink'])
bliss.core.log.debug('PDU transmitted: ' + str(pdu))
ait.core.log.debug('PDU transmitted: ' + str(pdu))
except gevent.queue.Empty:
pass
except Exception as e:
bliss.core.log.warn('Sending handler exception: ' + e.message)
bliss.core.log.warn(traceback.format_exc())
ait.core.log.warn('Sending handler exception: ' + e.message)
ait.core.log.warn(traceback.format_exc())
gevent.sleep(0.2)


Expand All @@ -376,6 +376,6 @@ def transaction_handler(instance):
if machine.role == Role.CLASS_1_SENDER:
machine.update_state(Event.SEND_FILE_DATA)
except Exception as e:
bliss.core.log.warn("EXCEPTION: " + e.message)
bliss.core.log.warn(traceback.format_exc())
ait.core.log.warn("EXCEPTION: " + e.message)
ait.core.log.warn(traceback.format_exc())
gevent.sleep(0.2)
4 changes: 2 additions & 2 deletions bliss/cfdp/events.py → ait/dsn/cfdp/events.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2017, by the California Institute of Technology. ALL RIGHTS
# Copyright 2018, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the Office of Technology Transfer
# at the California Institute of Technology.
Expand Down Expand Up @@ -48,4 +48,4 @@ class Event(Enum):
# TIMER
ACK_TIMER_EXPIRED = "ACK_TIMER_EXPIRED"
NAK_TIMER_EXPIRED = "NAK_TIMER_EXPIRED"
INACTIVITY_TIMER_EXPIRED = "INACTIVITY_TIMER_EXPIRED"
INACTIVITY_TIMER_EXPIRED = "INACTIVITY_TIMER_EXPIRED"
Loading

0 comments on commit 94947d8

Please sign in to comment.