Skip to content
Snippets Groups Projects
Commit f9bbe024 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

Refactor: extract chunk type functionality into separate file

Move chunk type determination logic from cmp_icu.c into its own file
parent d00f6836
No related branches found
No related tags found
1 merge request!34Update cmp_tool to version v0.13
/**
* @file cmp_chunk_type.h
* @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
* @date 2024
*
* @copyright GPLv2
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* @brief functions and definitions for determining the chunk type of PLATO data
*/
#include "cmp_chunk_type.h"
#include "../common/cmp_debug.h"
#include "../common/cmp_data_types.h"
/**
* @brief get the chunk_type of a collection
* @details map a sub-service to a chunk service according to
* DetailedBudgetWorking_2023-10-11
*
* @param col pointer to a collection header
*
* @returns chunk type of the collection, CHUNK_TYPE_UNKNOWN on
* failure
*/
enum chunk_type cmp_col_get_chunk_type(const struct collection_hdr *col)
{
enum chunk_type chunk_type;
switch (cmp_col_get_subservice(col)) {
case SST_NCxx_S_SCIENCE_IMAGETTE:
chunk_type = CHUNK_TYPE_NCAM_IMAGETTE;
break;
case SST_NCxx_S_SCIENCE_SAT_IMAGETTE:
chunk_type = CHUNK_TYPE_SAT_IMAGETTE;
break;
case SST_NCxx_S_SCIENCE_OFFSET:
case SST_NCxx_S_SCIENCE_BACKGROUND:
chunk_type = CHUNK_TYPE_OFFSET_BACKGROUND;
break;
case SST_NCxx_S_SCIENCE_SMEARING:
chunk_type = CHUNK_TYPE_SMEARING;
break;
case SST_NCxx_S_SCIENCE_S_FX:
case SST_NCxx_S_SCIENCE_S_FX_EFX:
case SST_NCxx_S_SCIENCE_S_FX_NCOB:
case SST_NCxx_S_SCIENCE_S_FX_EFX_NCOB_ECOB:
chunk_type = CHUNK_TYPE_SHORT_CADENCE;
break;
case SST_NCxx_S_SCIENCE_L_FX:
case SST_NCxx_S_SCIENCE_L_FX_EFX:
case SST_NCxx_S_SCIENCE_L_FX_NCOB:
case SST_NCxx_S_SCIENCE_L_FX_EFX_NCOB_ECOB:
chunk_type = CHUNK_TYPE_LONG_CADENCE;
break;
case SST_FCx_S_SCIENCE_IMAGETTE:
case SST_FCx_S_SCIENCE_OFFSET_VALUES:
case SST_FCx_S_BACKGROUND_VALUES:
chunk_type = CHUNK_TYPE_F_CHAIN;
break;
case SST_NCxx_S_SCIENCE_F_FX:
case SST_NCxx_S_SCIENCE_F_FX_EFX:
case SST_NCxx_S_SCIENCE_F_FX_NCOB:
case SST_NCxx_S_SCIENCE_F_FX_EFX_NCOB_ECOB:
debug_print("Error: No chunk is defined for fast cadence subservices");
/* fall through */
default:
chunk_type = CHUNK_TYPE_UNKNOWN;
break;
}
return chunk_type;
}
/**
* @file cmp_chunk_type.h
* @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
* @date 2024
*
* @copyright GPLv2
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* @brief functions and definitions for determining the chunk type of PLATO data
*/
#ifndef CMP_CHUNK_TYPE_H
#define CMP_CHUNK_TYPE_H
#include "../common/cmp_data_types.h"
/**
* @brief types of chunks containing different types of collections
* according to DetailedBudgetWorking_2023-10-11
*/
enum chunk_type {
CHUNK_TYPE_UNKNOWN,
CHUNK_TYPE_NCAM_IMAGETTE,
CHUNK_TYPE_SHORT_CADENCE,
CHUNK_TYPE_LONG_CADENCE,
CHUNK_TYPE_SAT_IMAGETTE,
CHUNK_TYPE_OFFSET_BACKGROUND, /* N-CAM */
CHUNK_TYPE_SMEARING,
CHUNK_TYPE_F_CHAIN
};
enum chunk_type cmp_col_get_chunk_type(const struct collection_hdr *col);
#endif /* CMP_CHUNK_TYPE_H */
......@@ -30,6 +30,7 @@
#include "../common/cmp_entity.h"
#include "../common/cmp_error.h"
#include "../common/leon_inttypes.h"
#include "cmp_chunk_type.h"
#include "../cmp_icu.h"
#include "../cmp_chunk.h"
......@@ -1901,84 +1902,6 @@ static uint32_t cmp_ent_build_chunk_header(uint32_t *entity, uint32_t chunk_size
}
/**
* @brief types of chunks containing different types of collections
* according to DetailedBudgetWorking_2023-10-11
*/
enum chunk_type {
CHUNK_TYPE_UNKNOWN,
CHUNK_TYPE_NCAM_IMAGETTE,
CHUNK_TYPE_SHORT_CADENCE,
CHUNK_TYPE_LONG_CADENCE,
CHUNK_TYPE_SAT_IMAGETTE,
CHUNK_TYPE_OFFSET_BACKGROUND, /* N-CAM */
CHUNK_TYPE_SMEARING,
CHUNK_TYPE_F_CHAIN
};
/**
* @brief get the chunk_type of a collection
* @details map a sub-service to a chunk service according to
* DetailedBudgetWorking_2023-10-11
*
* @param col pointer to a collection header
*
* @returns chunk type of the collection, CHUNK_TYPE_UNKNOWN on
* failure
*/
static enum chunk_type cmp_col_get_chunk_type(const struct collection_hdr *col)
{
enum chunk_type chunk_type;
switch (cmp_col_get_subservice(col)) {
case SST_NCxx_S_SCIENCE_IMAGETTE:
chunk_type = CHUNK_TYPE_NCAM_IMAGETTE;
break;
case SST_NCxx_S_SCIENCE_SAT_IMAGETTE:
chunk_type = CHUNK_TYPE_SAT_IMAGETTE;
break;
case SST_NCxx_S_SCIENCE_OFFSET:
case SST_NCxx_S_SCIENCE_BACKGROUND:
chunk_type = CHUNK_TYPE_OFFSET_BACKGROUND;
break;
case SST_NCxx_S_SCIENCE_SMEARING:
chunk_type = CHUNK_TYPE_SMEARING;
break;
case SST_NCxx_S_SCIENCE_S_FX:
case SST_NCxx_S_SCIENCE_S_FX_EFX:
case SST_NCxx_S_SCIENCE_S_FX_NCOB:
case SST_NCxx_S_SCIENCE_S_FX_EFX_NCOB_ECOB:
chunk_type = CHUNK_TYPE_SHORT_CADENCE;
break;
case SST_NCxx_S_SCIENCE_L_FX:
case SST_NCxx_S_SCIENCE_L_FX_EFX:
case SST_NCxx_S_SCIENCE_L_FX_NCOB:
case SST_NCxx_S_SCIENCE_L_FX_EFX_NCOB_ECOB:
chunk_type = CHUNK_TYPE_LONG_CADENCE;
break;
case SST_FCx_S_SCIENCE_IMAGETTE:
case SST_FCx_S_SCIENCE_OFFSET_VALUES:
case SST_FCx_S_BACKGROUND_VALUES:
chunk_type = CHUNK_TYPE_F_CHAIN;
break;
case SST_NCxx_S_SCIENCE_F_FX:
case SST_NCxx_S_SCIENCE_F_FX_EFX:
case SST_NCxx_S_SCIENCE_F_FX_NCOB:
case SST_NCxx_S_SCIENCE_F_FX_EFX_NCOB_ECOB:
debug_print("Error: No chunk is defined for fast cadence subservices");
/* fall through */
default:
chunk_type = CHUNK_TYPE_UNKNOWN;
break;
}
return chunk_type;
}
/**
* @brief Set the compression configuration from the compression parameters
* based on the chunk type of the collection
......
icu_compress_sources = files([
'cmp_chunk_type.c',
'cmp_icu.c'
])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment