Skip to content

Commit

Permalink
include structure improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Sep 9, 2022
1 parent e45e5ca commit 82b33c3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions tmtccmd/cfdp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .defs import CfdpIndication, TransactionId
from .request import CfdpRequestWrapper
from .user import CfdpUserBase
from .filestore import HostFilestore
from .mib import (
Expand Down
2 changes: 1 addition & 1 deletion tmtccmd/cfdp/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from spacepackets.cfdp.pdu.file_data import RecordContinuationState
from spacepackets.cfdp.pdu.finished import DeliveryCode, FileDeliveryStatus
from spacepackets.util import UnsignedByteField
from tmtccmd import get_console_logger
from tmtccmd.logging import get_console_logger
from tmtccmd.cfdp.defs import TransactionId
from tmtccmd.cfdp.filestore import VirtualFilestore, HostFilestore

Expand Down
17 changes: 17 additions & 0 deletions tmtccmd/tc/procedure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import enum
from typing import Any, cast, Type, Optional

from tmtccmd.cfdp import CfdpRequestWrapper


class TcProcedureType(enum.Enum):
DEFAULT = 0
Expand Down Expand Up @@ -36,6 +38,16 @@ def __repr__(self):
return f"CmdInfo(service={self.service!r}, op_code={self.op_code!r})"


class CfdpProcedureInfo(TcProcedureBase):
def __init__(self):
super().__init__(TcProcedureType.CFDP)
self.request_wrapper = CfdpRequestWrapper(None)

@property
def cfdp_request_type(self):
return self.request_wrapper.request


class ProcedureHelper:
"""Procedure helper class. It wraps the concrete procedure object but allows easily casting
it to concrete types supported by the framework."""
Expand All @@ -62,6 +74,11 @@ def to_def_procedure(self) -> DefaultProcedureInfo:
DefaultProcedureInfo, self.base, TcProcedureType.DEFAULT
)

def to_cfdp_procedure(self) -> CfdpProcedureInfo:
return self.__cast_internally(
CfdpProcedureInfo, self.base, TcProcedureType.CFDP
)

def to_custom_procedure(self) -> CustomProcedureInfo:
return self.__cast_internally(
CustomProcedureInfo, self.base, TcProcedureType.CUSTOM
Expand Down

0 comments on commit 82b33c3

Please sign in to comment.