simplifications

This commit is contained in:
Robin Müller 2022-09-09 15:21:14 +02:00
parent 6a7a8bac47
commit d737ba90f9
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -142,27 +142,20 @@ class CfdpHandler:
): ):
self.dest_id = UnsignedByteField(EXAMPLE_PUS_APID, 2) self.dest_id = UnsignedByteField(EXAMPLE_PUS_APID, 2)
self.remote_cfg_table = RemoteEntityCfgTable() self.remote_cfg_table = RemoteEntityCfgTable()
self.remote_cfg_table.add_remote_entities(remote_cfg) self.remote_cfg_table.add_configs(remote_cfg)
self.dest_handler = DestHandler(cfg, user, self.remote_cfg_table) self.dest_handler = DestHandler(cfg, user, self.remote_cfg_table)
self.source_handler = SourceHandler(cfg, seq_cnt_provider, user) self.source_handler = SourceHandler(cfg, seq_cnt_provider, user)
def put_request_file( def put_request(
self, self,
source_path: Path, request: PutRequest
dest_path: Path,
trans_mode: TransmissionModes,
closure_requested: bool,
): ):
put_request_cfg = PutRequestCfg( if self.remote_cfg_table.get_cfg(request.cfg.destination_id):
destination_id=self.dest_id, raise ValueError(
source_file=source_path, f"No remote CFDP config found for entity ID {request.cfg.destination_id}"
dest_file=dest_path.as_posix(),
trans_mode=trans_mode,
closure_requested=closure_requested,
) )
put_request = PutRequest(put_request_cfg)
self.source_handler.put_request( self.source_handler.put_request(
put_request, self.remote_cfg_table.get_remote_entity(self.dest_id) request, self.remote_cfg_table.get_cfg(self.dest_id)
) )
def pull_next_dest_packet(self) -> Optional[PduHolder]: def pull_next_dest_packet(self) -> Optional[PduHolder]:
@ -237,7 +230,7 @@ class TcHandler(TcHandlerBase):
def __init__( def __init__(
self, self,
seq_count_provider: FileSeqCountProvider, seq_count_provider: FileSeqCountProvider,
cfdp_handler: CfdpCcsdsWrapper, cfdp_in_ccsds_wrapper: CfdpCcsdsWrapper,
pus_verificator: PusVerificator, pus_verificator: PusVerificator,
file_logger: logging.Logger, file_logger: logging.Logger,
raw_logger: RawTmtcTimedLogWrapper, raw_logger: RawTmtcTimedLogWrapper,
@ -253,7 +246,7 @@ class TcHandler(TcHandlerBase):
seq_cnt_provider=seq_count_provider, seq_cnt_provider=seq_count_provider,
pus_verificator=pus_verificator, pus_verificator=pus_verificator,
) )
self.cfdp_handler = cfdp_handler self.cfdp_in_ccsds_wrapper = cfdp_in_ccsds_wrapper
def feed_cb(self, info: ProcedureHelper, wrapper: FeedWrapper): def feed_cb(self, info: ProcedureHelper, wrapper: FeedWrapper):
self.queue_helper.queue_wrapper = wrapper.queue_wrapper self.queue_helper.queue_wrapper = wrapper.queue_wrapper
@ -287,8 +280,11 @@ class TcHandler(TcHandlerBase):
def handle_cfdp_procedure(self, info: ProcedureHelper): def handle_cfdp_procedure(self, info: ProcedureHelper):
cfdp_procedure = info.to_cfdp_procedure() cfdp_procedure = info.to_cfdp_procedure()
if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT: if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT:
# TODO: Start put request if there isn't one pending yet # TODO: Only start put request if there isn't one pending yet. The source handler
# self.cfdp_handler.handler.put_request_file(...) # state can probably be used for this.
self.cfdp_in_ccsds_wrapper.handler.put_request(
cfdp_procedure.request_wrapper.to_put_request()
)
pass pass
pass pass
@ -359,7 +355,7 @@ def setup_tmtc_handlers(
raw_logger=raw_logger, raw_logger=raw_logger,
pus_verificator=verif_wrapper.pus_verificator, pus_verificator=verif_wrapper.pus_verificator,
seq_count_provider=PusFileSeqCountProvider(), seq_count_provider=PusFileSeqCountProvider(),
cfdp_handler=cfdp_handler, cfdp_in_ccsds_wrapper=cfdp_handler,
) )
return ccsds_handler, tc_handler return ccsds_handler, tc_handler