Skip to content

Commit

Permalink
Merge pull request #45 from ut-issl/feature/set_db_path
Browse files Browse the repository at this point in the history
テレコマDBのパスを設定できるようにする
  • Loading branch information
chutaro authored Jul 25, 2023
2 parents bc90d33 + 5e8b525 commit e71c291
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion GenerateC2ACode.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def main():
with open(SETTING_FILE_PATH, mode="r") as fh:
settings = json.load(fh)
# print(settings["c2a_root_dir"]);
# print(settings["path_to_src"]);

cmd_db = my_mod.load_db.LoadCmdDb(settings)
tlm_db = my_mod.load_db.LoadTlmDb(settings)
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ $ python GenerateC2ACode.py

```
{
# C2A ROOTへ相対パス.
# C2A ROOTとは, `src_core`, `src_user` のあるディレクトリ
"c2a_root_dir" : "../../c2a/src/",
# `src_core`, `src_user` のあるディレクトリへのパス
"path_to_src" : "../../c2a/src/",
# テレコマ DB のあるディレクトリへのパス
"path_to_db" : "../../c2a/database/",
# TlmCmdDBのファイル名の接頭辞
"db_prefix" : "SAMPLE_MOBC",
# TLM ID の定義域
Expand All @@ -54,7 +55,7 @@ $ python GenerateC2ACode.py
"is_cmd_prefixed_in_db" : 0,
"input_file_encoding" : "utf-8",
# DBがあるディレクトリへのパス(絶対でも相対でもOK)
"db_path" : "../../c2a_sample_aobc/src/src_user/Settings/TlmCmd/DataBase/",
"path_to_db" : "../../c2a_sample_aobc/database/",
# MOBC で保持するテレメの TLM ID の最大値(=テレメ種類数)
"max_tlm_num" : 256,
"driver_path" : "Aocs/",
Expand All @@ -72,7 +73,7 @@ $ python GenerateC2ACode.py
"is_cmd_prefixed_in_db" : 0,
"input_file_encoding" : "utf-8",
# DBがあるディレクトリへのパス(絶対でも相対でもOK)
"db_path" : ""../../c2a_sample_tobc/src/src_user/Settings/TlmCmd/DataBase/",
"path_to_db" : ""../../c2a_sample_tobc/database/",
# MOBC で保持するテレメの TLM ID の最大値(=テレメ種類数)
"max_tlm_num" : 256,
"driver_path" : "Thermal/",
Expand Down
6 changes: 3 additions & 3 deletions my_mod/cmd_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def GenerateCmdDef(settings, sgc_db):
output_file_path = settings["c2a_root_dir"] + r"src_user/TlmCmd/"
output_file_path = settings["path_to_src"] + r"src_user/TlmCmd/"
output_file_name_base = "command_definitions"

DATA_SART_ROW = 3
Expand Down Expand Up @@ -97,7 +97,7 @@ def GenerateCmdDef(settings, sgc_db):


def GenerateBctDef(settings, bct_db):
output_file_path = settings["c2a_root_dir"] + r"src_user/TlmCmd/"
output_file_path = settings["path_to_src"] + r"src_user/TlmCmd/"
output_file_name = "block_command_definitions.h"

DATA_SART_ROW = 2
Expand Down Expand Up @@ -164,7 +164,7 @@ def GenerateOtherObcCmdDef(settings, other_obc_dbs):
body_h += " " + cmd_code + " = " + cmd_id + ",\n"
# print(body_h)
output_file_path = (
settings["c2a_root_dir"]
settings["path_to_src"]
+ r"src_user/Drivers/"
+ settings["other_obc_data"][i]["driver_path"]
+ name_lower
Expand Down
10 changes: 4 additions & 6 deletions my_mod/load_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def LoadCmdDb(settings):
cmd_db_path = settings["c2a_root_dir"] + r"src_user/Settings/TlmCmd/DataBase/CMD_DB/"
cmd_db_path = settings["path_to_db"] + r"CMD_DB/"

sgc_db, bct_db = LoadCmdCSV_(
cmd_db_path, settings["db_prefix"], settings["input_file_encoding"]
Expand Down Expand Up @@ -44,9 +44,7 @@ def LoadCmdCSV_(cmd_db_path, db_prefix, encoding):


def LoadTlmDb(settings):
tlm_db_path = (
settings["c2a_root_dir"] + r"src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/"
)
tlm_db_path = settings["path_to_db"] + r"TLM_DB/calced_data/"

tlm_db = LoadTlmCSV_(
tlm_db_path,
Expand Down Expand Up @@ -115,7 +113,7 @@ def LoadOtherObcCmd_(settings):
for i in range(len(settings["other_obc_data"])):
if not settings["other_obc_data"][i]["is_enable"]:
continue
cmd_db_path = settings["other_obc_data"][i]["db_path"] + r"CMD_DB/"
cmd_db_path = settings["other_obc_data"][i]["path_to_db"] + r"CMD_DB/"
sgc_db, bct_db = LoadCmdCSV_(
cmd_db_path,
settings["other_obc_data"][i]["db_prefix"],
Expand All @@ -136,7 +134,7 @@ def LoadOtherObcTlm(settings):
for i in range(len(settings["other_obc_data"])):
if not settings["other_obc_data"][i]["is_enable"]:
continue
tlm_db_path = settings["other_obc_data"][i]["db_path"] + r"TLM_DB/calced_data/"
tlm_db_path = settings["other_obc_data"][i]["path_to_db"] + r"TLM_DB/calced_data/"

tlm_db = LoadTlmCSV_(
tlm_db_path,
Expand Down
2 changes: 1 addition & 1 deletion my_mod/tlm_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def GenerateTlmBuffer(settings, other_obc_dbs):
body_c += "\n"

output_file_path = (
settings["c2a_root_dir"]
settings["path_to_src"]
+ r"src_user/Drivers/"
+ settings["other_obc_data"][i]["driver_path"]
)
Expand Down
4 changes: 2 additions & 2 deletions my_mod/tlm_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def GenerateTlmDef(settings, tlm_db):
output_file_path = settings["c2a_root_dir"] + r"src_user/TlmCmd/"
output_file_path = settings["path_to_src"] + r"src_user/TlmCmd/"
output_file_name_base = "telemetry_definitions"

DATA_START_ROW = 8
Expand Down Expand Up @@ -137,7 +137,7 @@ def GenerateOtherObcTlmDef(settings, other_obc_dbs):
+ ",\n"
)
output_file_path = (
settings["c2a_root_dir"]
settings["path_to_src"]
+ r"src_user/Drivers/"
+ settings["other_obc_data"][i]["driver_path"]
+ obc_name.lower()
Expand Down
7 changes: 4 additions & 3 deletions settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"c2a_root_dir" : "../../c2a/src/",
"path_to_src" : "../../c2a/src/",
"path_to_db" : "../../c2a/database/",
"db_prefix" : "SAMPLE_MOBC",
"tlm_id_range" : ["0x00", "0x100"],
"is_cmd_prefixed_in_db" : 0,
Expand All @@ -14,7 +15,7 @@
"tlm_id_range" : ["0x90", "0xc0"],
"is_cmd_prefixed_in_db" : 0,
"input_file_encoding" : "utf-8",
"db_path" : "C:/c2a_sample_aobc/src/src_user/Settings/TlmCmd/DataBase/",
"path_to_db" : "C:/c2a_sample_aobc/database/",
"max_tlm_num" : 256,
"driver_path" : "Aocs/",
"driver_type" : "AOBC_Driver",
Expand All @@ -28,7 +29,7 @@
"tlm_id_range" : ["0xc0", "0xf0"],
"is_cmd_prefixed_in_db" : 0,
"input_file_encoding" : "utf-8",
"db_path" : "C:/c2a_sample_tobc/src/src_user/Settings/TlmCmd/DataBase/",
"path_to_db" : "C:/c2a_sample_tobc/database/",
"max_tlm_num" : 256,
"driver_path" : "Thermal/",
"driver_type" : "TOBC_Driver",
Expand Down

0 comments on commit e71c291

Please sign in to comment.