diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d147a454..64216f45d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Enhancements - [#240](https://github.com/arkedge/c2a-core/pull/240): code-generator の出力コードに,設定情報を残すようにする +- [#243](https://github.com/arkedge/c2a-core/pull/243): code-generator に max_tlm_num のアサーションを追加 ### Migration Guide - [#240](https://github.com/arkedge/c2a-core/pull/240): user 側でのコードレベルでの対応は不要 diff --git a/code-generator/my_mod/load_db.py b/code-generator/my_mod/load_db.py index b5fb3f8de..b0d0b4007 100644 --- a/code-generator/my_mod/load_db.py +++ b/code-generator/my_mod/load_db.py @@ -132,17 +132,27 @@ def LoadOtherObcTlm(settings): other_obc_dbs = {} for i in range(len(settings["other_obc_data"])): - if not settings["other_obc_data"][i]["is_enable"]: + other_obc_settings = settings["other_obc_data"][i] + if not other_obc_settings["is_enable"]: continue - tlm_db_path = settings["other_obc_data"][i]["path_to_db"] + r"TLM_DB/calced_data/" + + # max_tlm_num のアサーション + if other_obc_settings["max_tlm_num"] <= int(other_obc_settings["tlm_id_range"][1], 0): + print( + "Error: max_tlm_num is invalid at " + other_obc_settings["name"] + " DB.", + file=sys.stderr, + ) + sys.exit(1) + + tlm_db_path = other_obc_settings["path_to_db"] + r"TLM_DB/calced_data/" tlm_db = LoadTlmCSV_( tlm_db_path, - settings["other_obc_data"][i]["db_prefix"], - settings["other_obc_data"][i]["tlm_id_range"], - settings["other_obc_data"][i]["input_file_encoding"], + other_obc_settings["db_prefix"], + other_obc_settings["tlm_id_range"], + other_obc_settings["input_file_encoding"], ) - other_obc_dbs[settings["other_obc_data"][i]["name"]] = tlm_db + other_obc_dbs[other_obc_settings["name"]] = tlm_db # pprint.pprint(other_obc_dbs) return other_obc_dbs