2023-11-13 09:05:34 +01:00
|
|
|
from datetime import timedelta
|
2023-08-17 11:33:42 +02:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from spacepackets.cfdp import ConditionCode
|
2023-11-13 09:05:34 +01:00
|
|
|
from spacepackets.util import UnsignedByteField
|
2023-08-17 11:33:42 +02:00
|
|
|
from tmtccmd.cfdp import CfdpUserBase, TransactionId
|
2023-11-13 09:05:34 +01:00
|
|
|
from tmtccmd.cfdp.mib import CheckTimerProvider, Countdown, EntityType
|
2023-08-17 11:33:42 +02:00
|
|
|
from tmtccmd.cfdp.user import (
|
|
|
|
TransactionFinishedParams,
|
|
|
|
MetadataRecvParams,
|
|
|
|
FileSegmentRecvdParams,
|
|
|
|
)
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2023-11-13 09:05:34 +01:00
|
|
|
class EiveCheckTimerProvider(CheckTimerProvider):
|
|
|
|
def provide_check_timer(
|
|
|
|
self,
|
|
|
|
local_entity_id: UnsignedByteField,
|
|
|
|
remote_entity_id: UnsignedByteField,
|
|
|
|
entity_type: EntityType,
|
|
|
|
) -> Countdown:
|
|
|
|
return Countdown(timedelta(seconds=5.0))
|
|
|
|
|
|
|
|
|
2023-08-17 11:33:42 +02:00
|
|
|
class EiveCfdpUser(CfdpUserBase):
|
|
|
|
def transaction_indication(self, transaction_id: TransactionId):
|
|
|
|
_LOGGER.info(f"CFDP User: Start of File {transaction_id}")
|
|
|
|
|
|
|
|
def eof_sent_indication(self, transaction_id: TransactionId):
|
|
|
|
_LOGGER.info(f"CFDP User: EOF sent for {transaction_id}")
|
|
|
|
|
|
|
|
def transaction_finished_indication(self, params: TransactionFinishedParams):
|
|
|
|
_LOGGER.info(f"CFDP User: {params.transaction_id} finished")
|
2023-09-08 17:49:59 +02:00
|
|
|
_LOGGER.info(f"Delivery Code: {params.delivery_code!r}")
|
|
|
|
_LOGGER.info(f"Condition code: {params.condition_code!r}")
|
|
|
|
_LOGGER.info(f"File delivery status: {params.delivery_code!r}")
|
2023-08-17 11:33:42 +02:00
|
|
|
|
|
|
|
def metadata_recv_indication(self, params: MetadataRecvParams):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def file_segment_recv_indication(self, params: FileSegmentRecvdParams):
|
2023-09-04 11:17:25 +02:00
|
|
|
_LOGGER.info(
|
2023-09-12 14:17:39 +02:00
|
|
|
f"CFDP User: Received File Data PDU for {params.transaction_id} | Offset:"
|
|
|
|
f" {params.offset} | Segment Length: {params.length}"
|
2023-09-04 11:17:25 +02:00
|
|
|
)
|
2023-08-17 11:33:42 +02:00
|
|
|
|
|
|
|
def report_indication(self, transaction_id: TransactionId, status_report: any):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def suspended_indication(
|
|
|
|
self, transaction_id: TransactionId, cond_code: ConditionCode
|
|
|
|
):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def resumed_indication(self, transaction_id: TransactionId, progress: int):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def fault_indication(
|
|
|
|
self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int
|
|
|
|
):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def abandoned_indication(
|
|
|
|
self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int
|
|
|
|
):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def eof_recv_indication(self, transaction_id: TransactionId):
|
2023-09-04 11:17:25 +02:00
|
|
|
_LOGGER.info(f"CFDP User: EOF received for {transaction_id}")
|