From 816858191ee68040b205cd932c7ec240c2e734dc Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Thu, 23 May 2024 18:32:00 +0200 Subject: [PATCH] Generalize API exposed enum generation --- software/.gitignore | 3 + software/pio_hooks.py | 80 ++++++++- software/src/modules/automation/.gitignore | 1 - .../Automation Action ID.uint8.enum | 16 ++ .../Automation Trigger ID.uint8.enum | 19 ++ .../src/modules/automation/automation.cpp | 8 +- software/src/modules/automation/automation.h | 5 +- software/src/modules/automation/prepare.py | 94 ---------- .../src/modules/meters_modbus_tcp/.gitignore | 2 +- ...ybrid Inverter Virtual Meter ID.uint8.enum | 5 + .../Meter Modbus TCP Table ID.uint8.enum | 7 + .../Modbus Register Address Mode.uint8.enum | 2 + .../Modbus Register Type.uint8.enum | 2 + ...ax Max Storage Virtual Meter ID.uint8.enum | 4 + ...ybrid Inverter Virtual Meter ID.uint8.enum | 5 + ...tring Inverter Virtual Meter ID.uint8.enum | 4 + ...tron Energy GX Virtual Meter ID.uint8.enum | 5 + .../generic_modbus_tcp_client.h | 2 +- .../meters_modbus_tcp/meter_modbus_tcp.cpp | 31 ++-- .../meters_modbus_tcp/meter_modbus_tcp.h | 9 +- .../meters_modbus_tcp/meters_modbus_tcp.cpp | 1 + .../meters_modbus_tcp/meters_modbus_tcp.h | 2 +- .../src/modules/meters_modbus_tcp/prepare.py | 165 +++--------------- .../web/src/modules/automation/.gitignore | 1 - software/web/src/modules/automation/main.tsx | 5 +- .../automation/plugin_automation_action.tsx | 2 +- .../automation/plugin_automation_trigger.tsx | 2 +- .../plugin_automation_action.tsx | 2 +- .../plugin_automation_trigger.tsx | 2 +- .../plugin_automation_action.tsx | 2 +- .../plugin_automation_trigger.tsx | 2 +- .../plugin_automation_action.tsx | 3 +- .../plugin_automation_action.tsx | 2 +- .../plugin_automation_trigger.tsx | 2 +- .../evse_common/plugin_automation_action.tsx | 2 +- .../evse_common/plugin_automation_trigger.tsx | 2 +- .../evse_v2/plugin_automation_action.tsx | 2 +- .../evse_v2/plugin_automation_trigger.tsx | 2 +- .../meters/plugin_automation_action.tsx | 2 +- .../src/modules/meters_modbus_tcp/.gitignore | 1 - .../plugin_meters_config.tsx | 18 +- .../modules/mqtt/plugin_automation_action.tsx | 2 +- .../mqtt/plugin_automation_trigger.tsx | 2 +- .../modules/nfc/plugin_automation_action.tsx | 2 +- .../modules/nfc/plugin_automation_trigger.tsx | 2 +- .../plugin_automation_action.tsx | 2 +- .../plugin_automation_trigger.tsx | 2 +- .../plugin_automation_trigger.tsx | 2 +- 48 files changed, 240 insertions(+), 300 deletions(-) delete mode 100644 software/src/modules/automation/.gitignore create mode 100644 software/src/modules/automation/Automation Action ID.uint8.enum create mode 100644 software/src/modules/automation/Automation Trigger ID.uint8.enum delete mode 100644 software/src/modules/automation/prepare.py create mode 100644 software/src/modules/meters_modbus_tcp/Deye Hybrid Inverter Virtual Meter ID.uint8.enum create mode 100644 software/src/modules/meters_modbus_tcp/Meter Modbus TCP Table ID.uint8.enum create mode 100644 software/src/modules/meters_modbus_tcp/Modbus Register Address Mode.uint8.enum create mode 100644 software/src/modules/meters_modbus_tcp/Modbus Register Type.uint8.enum create mode 100644 software/src/modules/meters_modbus_tcp/Solarmax Max Storage Virtual Meter ID.uint8.enum create mode 100644 software/src/modules/meters_modbus_tcp/Sungrow Hybrid Inverter Virtual Meter ID.uint8.enum create mode 100644 software/src/modules/meters_modbus_tcp/Sungrow String Inverter Virtual Meter ID.uint8.enum create mode 100644 software/src/modules/meters_modbus_tcp/Victron Energy GX Virtual Meter ID.uint8.enum delete mode 100644 software/web/src/modules/meters_modbus_tcp/.gitignore diff --git a/software/.gitignore b/software/.gitignore index ef9c0dcbb..6aec7191b 100644 --- a/software/.gitignore +++ b/software/.gitignore @@ -11,6 +11,8 @@ src/**/*.embedded.h src/**/*.embedded.cpp src/modules/*/module_available.h src/modules/*/module_dependencies.h +src/modules/*/*.enum.h +src/modules/*/*.enum.cpp src/modules.h src/modules.cpp src/build.h @@ -32,6 +34,7 @@ web/src/ts/api_defs.ts web/src/ts/branding.ts web/src/ts/translation.tsx web/src/ts/translation.json +web/src/modules/*/*.enum.ts web/**/*.embedded.ts coredump_py_gdb_cmds api_info.json diff --git a/software/pio_hooks.py b/software/pio_hooks.py index 12bfca20b..873aa49d9 100644 --- a/software/pio_hooks.py +++ b/software/pio_hooks.py @@ -745,7 +745,7 @@ def include_bindings(path): mod_path = os.path.join('src', 'modules', backend_module.under) if not os.path.exists(mod_path) or not os.path.isdir(mod_path): - print("Backend module {} not found.".format(backend_module.space, mod_path)) + print("Backend module {} not found.".format(backend_module.space)) for root, dirs, files in os.walk(mod_path): for name in files: @@ -1076,6 +1076,84 @@ def format_translation(translation, type_only, indent): with ChangedDirectory('web'): subprocess.check_call([env.subst('$PYTHONEXE'), "-u", "check_override_completeness.py"]) + # Generate enums + for backend_module in backend_modules: + mod_path = os.path.join('src', 'modules', backend_module.under) + + if not os.path.exists(mod_path) or not os.path.isdir(mod_path): + print("Backend module {} not found.".format(backend_module.space)) + else: + for name in os.listdir(mod_path): + if not name.endswith(".enum"): + continue + + name_parts = name.split('.') + + if len(name_parts) != 3: + print('Error: Invalid enum file "{}" in backend {}'.format(name, mod_path)) + sys.exit(1) + + enum_name = util.FlavoredName(name_parts[0]).get() + enum_values = [] + enum_cases = [] + value_number = -1 + value_count = 0 + + with open(os.path.join(mod_path, name), 'r', encoding='utf-8') as f: + for line in f.readlines(): + line = line.strip() + + if len(line) == 0 or line.startswith('#'): + continue + + line_parts = line.split('=', 1) + value_name = util.FlavoredName(line_parts[0].strip()).get() + + if len(line_parts) > 1: + value_number = int(line_parts[1].strip()) + value_count = None + else: + value_number += 1 + + if value_count != None: + value_count += 1 + + enum_values.append(' {0} = {1},\n'.format(value_name.camel, value_number)) + enum_cases.append(' case {0}::{1}: return "{2}";\n'.format(enum_name.camel, value_name.camel, value_name.space)) + + with open(os.path.join(mod_path, enum_name.under + '.enum.h'), 'w', encoding='utf-8') as f: + f.write(f'// WARNING: This file is generated from "{name}"\n\n') + f.write('#include \n\n') + f.write('#pragma once\n\n') + f.write(f'enum class {enum_name.camel} : {name_parts[1]}_t {{\n') + f.write(''.join(enum_values)) + f.write('};\n\n') + + if value_count != None: + f.write(f'#define {enum_name.upper}_COUNT {value_count}\n\n') + + f.write(f'const char *get_{enum_name.under}_name({enum_name.camel} value);\n') + + with open(os.path.join(mod_path, enum_name.under + '.enum.cpp'), 'w', encoding='utf-8') as f: + f.write(f'// WARNING: This file is generated from {name}.\n\n') + f.write(f'#include "{enum_name.under}.enum.h"\n\n') + f.write(f'const char *get_{enum_name.under}_name({enum_name.camel} value)\n') + f.write('{\n') + f.write(' switch (value) {\n') + f.write(''.join(enum_cases)) + f.write(' default: return "Unknown";\n') + f.write(' }\n') + f.write('}\n') + + frontend_mod_path = os.path.join('web', 'src', 'modules', backend_module.under) + + if os.path.exists(frontend_mod_path) and os.path.isdir(frontend_mod_path): + with open(os.path.join(frontend_mod_path, enum_name.under + '.enum.ts'), 'w', encoding='utf-8') as f: + f.write(f'// WARNING: This file is generated from "{name}"\n\n') + f.write(f'export const enum {enum_name.camel} {{\n') + f.write(''.join(enum_values)) + f.write('}\n') + # Generate web interface util.log('Checking web interface dependencies') diff --git a/software/src/modules/automation/.gitignore b/software/src/modules/automation/.gitignore deleted file mode 100644 index 452860d8e..000000000 --- a/software/src/modules/automation/.gitignore +++ /dev/null @@ -1 +0,0 @@ -automation_defs.h diff --git a/software/src/modules/automation/Automation Action ID.uint8.enum b/software/src/modules/automation/Automation Action ID.uint8.enum new file mode 100644 index 000000000..2a436be8f --- /dev/null +++ b/software/src/modules/automation/Automation Action ID.uint8.enum @@ -0,0 +1,16 @@ +None +Print +MQTT +Set Current +LED +Meter Reset +Set Manager Current +NFC Inject Tag +Charge Limits +EVSE GP Output +Charge Tracker Reset +PM Phase Switch +PM Charge Mode Switch +EM Relay Switch +PM Limit Max Current +PM Block Charge diff --git a/software/src/modules/automation/Automation Trigger ID.uint8.enum b/software/src/modules/automation/Automation Trigger ID.uint8.enum new file mode 100644 index 000000000..3424322ea --- /dev/null +++ b/software/src/modules/automation/Automation Trigger ID.uint8.enum @@ -0,0 +1,19 @@ +None +Cron +Charger State +MQTT +EVSE Button +NFC +Charge Limits +EVSE Shutdown Input +EVSE GP Input +EVSE External Current Wd +Require Meter +Charge Manager Wd +EM Input Three +EM Input Four +EM Phase Switch +EM Contactor Monitoring +PM Power Available +PM Grid Power Draw +HTTP diff --git a/software/src/modules/automation/automation.cpp b/software/src/modules/automation/automation.cpp index 111a5ebe9..3b76ad560 100644 --- a/software/src/modules/automation/automation.cpp +++ b/software/src/modules/automation/automation.cpp @@ -113,10 +113,10 @@ void Automation::pre_setup() }; state = Config::Object({ - {"registered_triggers", Config::Array({}, new Config{Config::Uint8(0)}, 0, static_cast(AutomationTriggerID::Count), Config::type_id())}, - {"registered_actions", Config::Array({}, new Config{Config::Uint8(0)}, 0, static_cast(AutomationActionID::Count), Config::type_id())}, - {"enabled_triggers", Config::Array({}, new Config{Config::Uint8(0)}, 0, static_cast(AutomationTriggerID::Count), Config::type_id())}, - {"enabled_actions", Config::Array({}, new Config{Config::Uint8(0)}, 0, static_cast(AutomationActionID::Count), Config::type_id())}, + {"registered_triggers", Config::Array({}, new Config{Config::Uint8(0)}, 0, AUTOMATION_TRIGGER_ID_COUNT, Config::type_id())}, + {"registered_actions", Config::Array({}, new Config{Config::Uint8(0)}, 0, AUTOMATION_ACTION_ID_COUNT, Config::type_id())}, + {"enabled_triggers", Config::Array({}, new Config{Config::Uint8(0)}, 0, AUTOMATION_TRIGGER_ID_COUNT, Config::type_id())}, + {"enabled_actions", Config::Array({}, new Config{Config::Uint8(0)}, 0, AUTOMATION_ACTION_ID_COUNT, Config::type_id())}, }); for (auto const &trigger : trigger_map) { diff --git a/software/src/modules/automation/automation.h b/software/src/modules/automation/automation.h index 045fd9087..fd9f3af9d 100644 --- a/software/src/modules/automation/automation.h +++ b/software/src/modules/automation/automation.h @@ -23,14 +23,15 @@ #include "config.h" #include #include -#include "automation_defs.h" +#include "automation_trigger_id.enum.h" +#include "automation_action_id.enum.h" #include "automation_backend.h" class Automation : public IModule, public IAutomationBackend { public: typedef std::function ActionCb; - typedef std::function ValidatorCb; + typedef std::function ValidatorCb; struct ActionValue { ActionCb callback; diff --git a/software/src/modules/automation/prepare.py b/software/src/modules/automation/prepare.py deleted file mode 100644 index e1dba5b0a..000000000 --- a/software/src/modules/automation/prepare.py +++ /dev/null @@ -1,94 +0,0 @@ -import os -import sys -import importlib.util -import importlib.machinery -import csv - -software_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..', '..')) - -def create_software_module(): - software_spec = importlib.util.spec_from_file_location('software', os.path.join(software_dir, '__init__.py')) - software_module = importlib.util.module_from_spec(software_spec) - - software_spec.loader.exec_module(software_module) - - sys.modules['software'] = software_module - -if 'software' not in sys.modules: - create_software_module() - -from software import util - -# NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! -triggers = [ - ('None', 0), - ('Cron', 1), - ('Charger State', 2), - ('MQTT', 3), - ('EVSE Button', 4), - ('NFC', 5), - ('Charge Limits', 6), - ('EVSE Shutdown Input', 7), - ('EVSE GP Input', 8), - ('EVSE External Current Wd', 9), - ('Require Meter', 10), - ('Charge Manager Wd', 11), - ('EM Input Three', 12), - ('EM Input Four', 13), - ('EM Phase Switch', 14), - ('EM Contactor Monitoring', 15), - ('PM Power Available', 16), - ('PM Grid Power Draw', 17), - ('HTTP', 18) -] - -# NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! -actions = [ - ('None', 0), - ('Print', 1), - ('MQTT', 2), - ('Set Current', 3), - ('LED', 4), - ('Meter Reset', 5), - ('Set Manager Current', 6), - ('NFC Inject Tag', 7), - ('Charge Limits', 8), - ('EVSE GP Output', 9), - ('Charge Tracker Reset', 10), - ('PM Phase Switch', 11), - ('PM Charge Mode Switch', 12), - ('EM Relay Switch', 13), - ('PM Limit Max Current', 14), - ('PM Block Charge', 15), -] - -trigger_values = [] -action_values = [] - -for trigger in triggers: - trigger_values.append(' {0} = {1},\n'.format(util.FlavoredName(trigger[0]).get().camel, trigger[1])) - -for action in actions: - action_values.append(' {0} = {1},\n'.format(util.FlavoredName(action[0]).get().camel, action[1])) - -with open('automation_defs.h', 'w', encoding='utf-8') as f: - f.write('// WARNING: This file is generated.\n\n') - f.write('#include \n\n') - f.write('#pragma once\n\n') - f.write('enum class AutomationTriggerID : uint8_t {\n') - f.write(''.join(trigger_values)) - f.write(f'\n Count = {len(triggers)},\n') - f.write('};\n\n') - f.write('enum class AutomationActionID : uint8_t {\n') - f.write(''.join(action_values)) - f.write(f'\n Count = {len(actions)},\n') - f.write('};\n') - -with open('../../../web/src/modules/automation/automation_defs.ts', 'w', encoding='utf-8') as f: - f.write('// WARNING: This file is generated.\n\n') - f.write('export const enum AutomationTriggerID {\n') - f.write(''.join(trigger_values)) - f.write('}\n\n') - f.write('export const enum AutomationActionID {\n') - f.write(''.join(action_values)) - f.write('}\n') diff --git a/software/src/modules/meters_modbus_tcp/.gitignore b/software/src/modules/meters_modbus_tcp/.gitignore index e412fe72c..57f256a37 100644 --- a/software/src/modules/meters_modbus_tcp/.gitignore +++ b/software/src/modules/meters_modbus_tcp/.gitignore @@ -1,2 +1,2 @@ -meters_modbus_tcp_defs.h +Modbus Value Type.uint8.enum meters_modbus_tcp_defs.inc diff --git a/software/src/modules/meters_modbus_tcp/Deye Hybrid Inverter Virtual Meter ID.uint8.enum b/software/src/modules/meters_modbus_tcp/Deye Hybrid Inverter Virtual Meter ID.uint8.enum new file mode 100644 index 000000000..7c927eb2e --- /dev/null +++ b/software/src/modules/meters_modbus_tcp/Deye Hybrid Inverter Virtual Meter ID.uint8.enum @@ -0,0 +1,5 @@ +None +Inverter +Grid +Battery +Load diff --git a/software/src/modules/meters_modbus_tcp/Meter Modbus TCP Table ID.uint8.enum b/software/src/modules/meters_modbus_tcp/Meter Modbus TCP Table ID.uint8.enum new file mode 100644 index 000000000..3d3ee8a31 --- /dev/null +++ b/software/src/modules/meters_modbus_tcp/Meter Modbus TCP Table ID.uint8.enum @@ -0,0 +1,7 @@ +None +Custom +Sungrow Hybrid Inverter +Sungrow String Inverter +Solarmax Max Storage +Victron Energy GX +Deye Hybrid Inverter diff --git a/software/src/modules/meters_modbus_tcp/Modbus Register Address Mode.uint8.enum b/software/src/modules/meters_modbus_tcp/Modbus Register Address Mode.uint8.enum new file mode 100644 index 000000000..08dd7c1f3 --- /dev/null +++ b/software/src/modules/meters_modbus_tcp/Modbus Register Address Mode.uint8.enum @@ -0,0 +1,2 @@ +Address +Number diff --git a/software/src/modules/meters_modbus_tcp/Modbus Register Type.uint8.enum b/software/src/modules/meters_modbus_tcp/Modbus Register Type.uint8.enum new file mode 100644 index 000000000..3eaf763b8 --- /dev/null +++ b/software/src/modules/meters_modbus_tcp/Modbus Register Type.uint8.enum @@ -0,0 +1,2 @@ +Holding Register +Input Register diff --git a/software/src/modules/meters_modbus_tcp/Solarmax Max Storage Virtual Meter ID.uint8.enum b/software/src/modules/meters_modbus_tcp/Solarmax Max Storage Virtual Meter ID.uint8.enum new file mode 100644 index 000000000..28c8615f1 --- /dev/null +++ b/software/src/modules/meters_modbus_tcp/Solarmax Max Storage Virtual Meter ID.uint8.enum @@ -0,0 +1,4 @@ +None +Inverter +Grid +Battery diff --git a/software/src/modules/meters_modbus_tcp/Sungrow Hybrid Inverter Virtual Meter ID.uint8.enum b/software/src/modules/meters_modbus_tcp/Sungrow Hybrid Inverter Virtual Meter ID.uint8.enum new file mode 100644 index 000000000..7c927eb2e --- /dev/null +++ b/software/src/modules/meters_modbus_tcp/Sungrow Hybrid Inverter Virtual Meter ID.uint8.enum @@ -0,0 +1,5 @@ +None +Inverter +Grid +Battery +Load diff --git a/software/src/modules/meters_modbus_tcp/Sungrow String Inverter Virtual Meter ID.uint8.enum b/software/src/modules/meters_modbus_tcp/Sungrow String Inverter Virtual Meter ID.uint8.enum new file mode 100644 index 000000000..bc5941064 --- /dev/null +++ b/software/src/modules/meters_modbus_tcp/Sungrow String Inverter Virtual Meter ID.uint8.enum @@ -0,0 +1,4 @@ +None +Inverter +Grid +Load diff --git a/software/src/modules/meters_modbus_tcp/Victron Energy GX Virtual Meter ID.uint8.enum b/software/src/modules/meters_modbus_tcp/Victron Energy GX Virtual Meter ID.uint8.enum new file mode 100644 index 000000000..7c927eb2e --- /dev/null +++ b/software/src/modules/meters_modbus_tcp/Victron Energy GX Virtual Meter ID.uint8.enum @@ -0,0 +1,5 @@ +None +Inverter +Grid +Battery +Load diff --git a/software/src/modules/meters_modbus_tcp/generic_modbus_tcp_client.h b/software/src/modules/meters_modbus_tcp/generic_modbus_tcp_client.h index c62ec5245..a318ea0db 100644 --- a/software/src/modules/meters_modbus_tcp/generic_modbus_tcp_client.h +++ b/software/src/modules/meters_modbus_tcp/generic_modbus_tcp_client.h @@ -29,7 +29,7 @@ #include "ModbusTCP.h" #include "tools.h" -#include "meters_modbus_tcp_defs.h" +#include "modbus_register_type.enum.h" #if defined(__GNUC__) #pragma GCC diagnostic push diff --git a/software/src/modules/meters_modbus_tcp/meter_modbus_tcp.cpp b/software/src/modules/meters_modbus_tcp/meter_modbus_tcp.cpp index 3e893aa5b..505c73b65 100644 --- a/software/src/modules/meters_modbus_tcp/meter_modbus_tcp.cpp +++ b/software/src/modules/meters_modbus_tcp/meter_modbus_tcp.cpp @@ -29,6 +29,7 @@ #include "gcc_warnings.h" +#include "modbus_register_address_mode.enum.h" #include "meters_modbus_tcp_defs.inc" //#define DEBUG_LOG_ALL_VALUES @@ -406,7 +407,7 @@ void MeterModbusTCP::read_done_callback() { if (generic_read_request.result_code != Modbus::ResultCode::EX_SUCCESS) { logger.printfln("Error reading %s / %s (%zu): %s [%d]", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, get_modbus_result_code_name(generic_read_request.result_code), @@ -453,7 +454,7 @@ void MeterModbusTCP::read_done_callback() break; default: - logger.printfln("%s has unknown Output Type: %u", get_table_name(table_id), register_buffer[0]); + logger.printfln("%s has unknown Output Type: %u", get_meter_modbus_tcp_table_id_name(table_id), register_buffer[0]); return; } @@ -461,7 +462,7 @@ void MeterModbusTCP::read_done_callback() #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / Output Type (%u): %d", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), SUNGROW_INVERTER_OUTPUT_TYPE_ADDRESS, sungrow_inverter_output_type); #endif @@ -485,7 +486,7 @@ void MeterModbusTCP::read_done_callback() case 0x0002: case 0x0003: case 0x0004: - logger.printfln("%s has unsupported Device Type: 0x%04x", get_table_name(table_id), register_buffer[0]); + logger.printfln("%s has unsupported Device Type: 0x%04x", get_meter_modbus_tcp_table_id_name(table_id), register_buffer[0]); return; case 0x0005: @@ -498,7 +499,7 @@ void MeterModbusTCP::read_done_callback() break; default: - logger.printfln("%s has unknown Device Type: 0x%04x", get_table_name(table_id), register_buffer[0]); + logger.printfln("%s has unknown Device Type: 0x%04x", get_meter_modbus_tcp_table_id_name(table_id), register_buffer[0]); return; } @@ -506,7 +507,7 @@ void MeterModbusTCP::read_done_callback() #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / Device Type (%u): %d", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), DEYE_HYBRID_INVERTER_DEVICE_TYPE_ADDRESS, deye_hybrid_inverter_device_type); #endif @@ -572,7 +573,7 @@ void MeterModbusTCP::read_done_callback() break; default: - logger.printfln("%s / %s has unsupported register count: %u", get_table_name(table_id), table->specs[read_index].name, register_count); + logger.printfln("%s / %s has unsupported register count: %u", get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, register_count); return; } @@ -583,7 +584,7 @@ void MeterModbusTCP::read_done_callback() case ModbusValueType::U16: #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / %s (%zu): %u", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, register_buffer[register_buffer_index]); @@ -595,7 +596,7 @@ void MeterModbusTCP::read_done_callback() case ModbusValueType::S16: #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / %s (%zu): %d", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, static_cast(register_buffer[register_buffer_index])); @@ -608,7 +609,7 @@ void MeterModbusTCP::read_done_callback() case ModbusValueType::U32LE: #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / %s (%zu): %u (%u %u)", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, c32.u, @@ -623,7 +624,7 @@ void MeterModbusTCP::read_done_callback() case ModbusValueType::S32LE: #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / %s (%zu): %d (%u %u)", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, static_cast(c32.u), @@ -638,7 +639,7 @@ void MeterModbusTCP::read_done_callback() case ModbusValueType::F32LE: #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / %s (%zu): %f (%u %u)", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, static_cast(c32.f), @@ -653,7 +654,7 @@ void MeterModbusTCP::read_done_callback() case ModbusValueType::U64LE: #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / %s (%zu): %llu (%u %u %u %u)", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, c64.u, @@ -670,7 +671,7 @@ void MeterModbusTCP::read_done_callback() case ModbusValueType::S64LE: #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / %s (%zu): %lld (%u %u %u %u)", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, static_cast(c64.u), @@ -687,7 +688,7 @@ void MeterModbusTCP::read_done_callback() case ModbusValueType::F64LE: #ifdef DEBUG_LOG_ALL_VALUES logger.printfln("%s / %s (%zu): %f (%u %u %u %u)", - get_table_name(table_id), + get_meter_modbus_tcp_table_id_name(table_id), table->specs[read_index].name, table->specs[read_index].start_address, c64.f, diff --git a/software/src/modules/meters_modbus_tcp/meter_modbus_tcp.h b/software/src/modules/meters_modbus_tcp/meter_modbus_tcp.h index 5efb11321..965e50a9d 100644 --- a/software/src/modules/meters_modbus_tcp/meter_modbus_tcp.h +++ b/software/src/modules/meters_modbus_tcp/meter_modbus_tcp.h @@ -27,7 +27,14 @@ #include "config.h" #include "modules/meters/imeter.h" #include "meters_modbus_tcp.h" -#include "meters_modbus_tcp_defs.h" +#include "modbus_register_type.enum.h" +#include "modbus_value_type.enum.h" +#include "meter_modbus_tcp_table_id.enum.h" +#include "sungrow_hybrid_inverter_virtual_meter_id.enum.h" +#include "sungrow_string_inverter_virtual_meter_id.enum.h" +#include "solarmax_max_storage_virtual_meter_id.enum.h" +#include "victron_energy_gx_virtual_meter_id.enum.h" +#include "deye_hybrid_inverter_virtual_meter_id.enum.h" #if defined(__GNUC__) #pragma GCC diagnostic push diff --git a/software/src/modules/meters_modbus_tcp/meters_modbus_tcp.cpp b/software/src/modules/meters_modbus_tcp/meters_modbus_tcp.cpp index d4e6bbcb2..82d03b506 100644 --- a/software/src/modules/meters_modbus_tcp/meters_modbus_tcp.cpp +++ b/software/src/modules/meters_modbus_tcp/meters_modbus_tcp.cpp @@ -26,6 +26,7 @@ #include "event_log.h" #include "tools.h" +#include "modbus_register_address_mode.enum.h" #include "gcc_warnings.h" diff --git a/software/src/modules/meters_modbus_tcp/meters_modbus_tcp.h b/software/src/modules/meters_modbus_tcp/meters_modbus_tcp.h index 2e87073e9..9dd082631 100644 --- a/software/src/modules/meters_modbus_tcp/meters_modbus_tcp.h +++ b/software/src/modules/meters_modbus_tcp/meters_modbus_tcp.h @@ -27,7 +27,7 @@ #include "modules/meters/imeter.h" #include "modules/meters/meter_generator.h" #include "modules/meters/meter_value_id.h" -#include "meters_modbus_tcp_defs.h" +#include "meter_modbus_tcp_table_id.enum.h" #include "module.h" #if defined(__GNUC__) diff --git a/software/src/modules/meters_modbus_tcp/prepare.py b/software/src/modules/meters_modbus_tcp/prepare.py index 9c0084a93..ba1d0a68a 100644 --- a/software/src/modules/meters_modbus_tcp/prepare.py +++ b/software/src/modules/meters_modbus_tcp/prepare.py @@ -26,146 +26,30 @@ def make_modbus_value_type(register_count, is_signed, is_float, register_order_i return register_count | ((1 if is_signed else 0) << 3) | ((1 if is_float else 0) << 4) | ((1 if register_order_is_le else 0) << 5) -# NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! -tables = [ - ('None', 0), - ('Custom', 1), - ('Sungrow Hybrid Inverter', 2), - ('Sungrow String Inverter', 3), - ('Solarmax Max Storage', 4), - ('Victron Energy GX', 5), - ('Deye Hybrid Inverter', 6), +modbus_value_type = [ + ('None', 0), + ('U16', make_modbus_value_type(1, False, False, False)), + ('S16', make_modbus_value_type(1, True, False, False)), + ('U32BE', make_modbus_value_type(2, False, False, False)), + ('U32LE', make_modbus_value_type(2, False, False, True)), + ('S32BE', make_modbus_value_type(2, True, False, False)), + ('S32LE', make_modbus_value_type(2, True, False, True)), + ('F32BE', make_modbus_value_type(2, True, True, False)), + ('F32LE', make_modbus_value_type(2, True, True, True)), + ('U64BE', make_modbus_value_type(4, False, False, False)), + ('U64LE', make_modbus_value_type(4, False, False, True)), + ('S64BE', make_modbus_value_type(4, True, False, False)), + ('S64LE', make_modbus_value_type(4, True, False, True)), + ('F64BE', make_modbus_value_type(4, True, True, False)), + ('F64LE', make_modbus_value_type(4, True, True, True)), ] -enums = [ - { - 'name': 'Modbus Register Type', - # NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! - 'values': [ - ('Holding Register', 0), - ('Input Register', 1), - ], - }, - { - 'name': 'Modbus Register Address Mode', - # NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! - 'values': [ - ('Address', 0), - ('Number', 1), - ], - }, - { - 'name': 'Modbus Value Type', - # NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! - 'values': [ - ('None', 0), - ('U16', make_modbus_value_type(1, False, False, False)), - ('S16', make_modbus_value_type(1, True, False, False)), - ('U32BE', make_modbus_value_type(2, False, False, False)), - ('U32LE', make_modbus_value_type(2, False, False, True)), - ('S32BE', make_modbus_value_type(2, True, False, False)), - ('S32LE', make_modbus_value_type(2, True, False, True)), - ('F32BE', make_modbus_value_type(2, True, True, False)), - ('F32LE', make_modbus_value_type(2, True, True, True)), - ('U64BE', make_modbus_value_type(4, False, False, False)), - ('U64LE', make_modbus_value_type(4, False, False, True)), - ('S64BE', make_modbus_value_type(4, True, False, False)), - ('S64LE', make_modbus_value_type(4, True, False, True)), - ('F64BE', make_modbus_value_type(4, True, True, False)), - ('F64LE', make_modbus_value_type(4, True, True, True)), - ], - }, - { - 'name': 'Sungrow Hybrid Inverter Virtual Meter ID', - # NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! - 'values': [ - ('None', 0), - ('Inverter', 1), - ('Grid', 2), - ('Battery', 3), - ('Load', 4), - ], - }, - { - 'name': 'Sungrow String Inverter Virtual Meter ID', - # NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! - 'values': [ - ('None', 0), - ('Inverter', 1), - ('Grid', 2), - ('Load', 3), - ], - }, - { - 'name': 'Solarmax Max Storage Virtual Meter ID', - # NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! - 'values': [ - ('None', 0), - ('Inverter', 1), - ('Grid', 2), - ('Battery', 3), - ], - }, - { - 'name': 'Victron Energy GX Virtual Meter ID', - # NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! - 'values': [ - ('None', 0), - ('Inverter', 1), - ('Grid', 2), - ('Battery', 3), - ('Load', 4), - ], - }, - { - 'name': 'Deye Hybrid Inverter Virtual Meter ID', - # NEVER EVER EDIT OR REMOVE IDS. Only append new ones. Changing or removing IDs is a breaking API and config change! - 'values': [ - ('None', 0), - ('Inverter', 1), - ('Grid', 2), - ('Battery', 3), - ('Load', 4), - ], - }, -] - -table_values = [] -table_names = [] - -for table in tables: - table_values.append(' {0} = {1},\n'.format(util.FlavoredName(table[0]).get().camel, table[1])) - table_names.append(' case MeterModbusTCPTableID::{0}: return "{1}";\n'.format(util.FlavoredName(table[0]).get().camel, table[0])) - -with open('meters_modbus_tcp_defs.h', 'w', encoding='utf-8') as f: - f.write('// WARNING: This file is generated.\n\n') - f.write('#include \n\n') - f.write('#pragma once\n\n') - f.write('enum class MeterModbusTCPTableID : uint8_t {\n') - f.write(''.join(table_values)) - f.write('};\n') - - for enum in enums: - f.write(f'\nenum class {util.FlavoredName(enum["name"]).get().camel} : uint8_t {{\n') - - for value in enum['values']: - f.write(' {0} = {1},\n'.format(util.FlavoredName(value[0]).get().camel, value[1])) - - f.write('};\n') - -with open('../../../web/src/modules/meters_modbus_tcp/meters_modbus_tcp_defs.ts', 'w', encoding='utf-8') as f: - f.write('// WARNING: This file is generated.\n\n') - f.write('export const enum MeterModbusTCPTableID {\n') - f.write(''.join(table_values)) - f.write('}\n') - - for enum in enums: - f.write(f'\nexport const enum {util.FlavoredName(enum["name"]).get().camel} {{\n') +with open('Modbus Value Type.uint8.enum', 'w', encoding='utf-8') as f: + f.write('# WARNING: This file is generated\n') - for value in enum['values']: - f.write(' {0} = {1},\n'.format(util.FlavoredName(value[0]).get().camel, value[1])) + for name_and_value in modbus_value_type: + f.write(f'{name_and_value[0]} = {name_and_value[1]}\n') - f.write('}\n') VALUE_ID_META = 0xFFFFFFFF - 1 VALUE_ID_DEBUG = 0xFFFFFFFF - 2 @@ -1420,11 +1304,4 @@ def make_modbus_value_type(register_count, is_signed, is_float, register_order_i f.write(f'#define VALUE_INDEX_META {VALUE_ID_META}u\n') f.write(f'#define VALUE_INDEX_DEBUG {VALUE_ID_DEBUG}u\n\n') f.write(f'#define START_ADDRESS_VIRTUAL {START_ADDRESS_VIRTUAL}u\n\n') - f.write('\n\n'.join(spec_values).replace('\r\n', '') + '\n\n') - f.write('static const char *get_table_name(MeterModbusTCPTableID table)\n') - f.write('{\n') - f.write(' switch (table) {\n') - f.write(''.join(table_names)) - f.write(' default: return "Unknown table";\n') - f.write(' }\n') - f.write('}\n') + f.write('\n\n'.join(spec_values).replace('\r\n', '') + '\n') diff --git a/software/web/src/modules/automation/.gitignore b/software/web/src/modules/automation/.gitignore index 858a955ef..e3b8d6689 100644 --- a/software/web/src/modules/automation/.gitignore +++ b/software/web/src/modules/automation/.gitignore @@ -1,3 +1,2 @@ api.ts plugins.tsx -automation_defs.ts diff --git a/software/web/src/modules/automation/main.tsx b/software/web/src/modules/automation/main.tsx index 35ce0dc82..cd23dfab3 100644 --- a/software/web/src/modules/automation/main.tsx +++ b/software/web/src/modules/automation/main.tsx @@ -19,14 +19,15 @@ import * as util from "../../ts/util"; import * as API from "../../ts/api"; -import { h, Fragment, ComponentChild, toChildArray } from "preact"; +import { h, Fragment, ComponentChild } from "preact"; import { ConfigComponent } from "../../ts/components/config_component"; import { Table, TableRow } from "../../ts/components/table"; import { ConfigForm } from "../../ts/components/config_form"; import { InputSelect } from "../../ts/components/input_select"; import { FormRow } from "../../ts/components/form_row"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID, AutomationActionID } from "./automation_defs"; +import { AutomationTriggerID } from "./automation_trigger_id.enum"; +import { AutomationActionID } from "./automation_action_id.enum"; import { Task, AutomationTriggerComponents, AutomationActionComponents } from "./types"; import { plugins_init } from "./plugins"; import { SubPage } from "../../ts/components/sub_page"; diff --git a/software/web/src/modules/automation/plugin_automation_action.tsx b/software/web/src/modules/automation/plugin_automation_action.tsx index 305493eb7..d15260b37 100644 --- a/software/web/src/modules/automation/plugin_automation_action.tsx +++ b/software/web/src/modules/automation/plugin_automation_action.tsx @@ -20,7 +20,7 @@ import { h, Fragment } from "preact"; import { useState } from "preact/hooks"; import { __ } from "../../ts/translation"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { InputText } from "../../ts/components/input_text"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/automation/plugin_automation_trigger.tsx b/software/web/src/modules/automation/plugin_automation_trigger.tsx index c04b6d335..8692bad73 100644 --- a/software/web/src/modules/automation/plugin_automation_trigger.tsx +++ b/software/web/src/modules/automation/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; import { InputSelect } from "../../ts/components/input_select"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/charge_limits/plugin_automation_action.tsx b/software/web/src/modules/charge_limits/plugin_automation_action.tsx index 782b7aba4..a5347e1a5 100644 --- a/software/web/src/modules/charge_limits/plugin_automation_action.tsx +++ b/software/web/src/modules/charge_limits/plugin_automation_action.tsx @@ -21,7 +21,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; import * as util from "../../ts/util"; import * as API from "../../ts/api"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { InputSelect } from "../../ts/components/input_select"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/charge_limits/plugin_automation_trigger.tsx b/software/web/src/modules/charge_limits/plugin_automation_trigger.tsx index 3082284a3..dc2942467 100644 --- a/software/web/src/modules/charge_limits/plugin_automation_trigger.tsx +++ b/software/web/src/modules/charge_limits/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { __ } from "../../ts/translation"; import { AutomationTrigger, InitResult } from "../automation/types"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { ComponentChildren } from "preact"; export type ChargeLimitsAutomationTrigger = [ diff --git a/software/web/src/modules/charge_manager/plugin_automation_action.tsx b/software/web/src/modules/charge_manager/plugin_automation_action.tsx index 8b2b2e6d0..fc446806f 100644 --- a/software/web/src/modules/charge_manager/plugin_automation_action.tsx +++ b/software/web/src/modules/charge_manager/plugin_automation_action.tsx @@ -20,7 +20,7 @@ import { h } from "preact"; import * as util from "../../ts/util"; import { __ } from "../../ts/translation"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { InputFloat } from "../../ts/components/input_float"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/charge_manager/plugin_automation_trigger.tsx b/software/web/src/modules/charge_manager/plugin_automation_trigger.tsx index 99dfd9765..11c75dfb1 100644 --- a/software/web/src/modules/charge_manager/plugin_automation_trigger.tsx +++ b/software/web/src/modules/charge_manager/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { h, ComponentChildren } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; export type ChargeManagerWdAutomationTrigger = [ diff --git a/software/web/src/modules/charge_tracker/plugin_automation_action.tsx b/software/web/src/modules/charge_tracker/plugin_automation_action.tsx index 9418050da..85ef55cd0 100644 --- a/software/web/src/modules/charge_tracker/plugin_automation_action.tsx +++ b/software/web/src/modules/charge_tracker/plugin_automation_action.tsx @@ -20,8 +20,7 @@ import { h, ComponentChildren } from "preact"; import { __ } from "../../ts/translation"; import { AutomationAction, InitResult } from "../automation/types"; -import { AutomationActionID } from "../automation/automation_defs"; - +import { AutomationActionID } from "../automation/automation_action_id.enum"; export type ChargeTrackerResetAutomationAction = [ AutomationActionID.ChargeTrackerReset, diff --git a/software/web/src/modules/energy_manager/plugin_automation_action.tsx b/software/web/src/modules/energy_manager/plugin_automation_action.tsx index f965a4442..30596a860 100644 --- a/software/web/src/modules/energy_manager/plugin_automation_action.tsx +++ b/software/web/src/modules/energy_manager/plugin_automation_action.tsx @@ -19,7 +19,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { FormRow } from "../../ts/components/form_row"; import { InputSelect } from "../../ts/components/input_select"; diff --git a/software/web/src/modules/energy_manager/plugin_automation_trigger.tsx b/software/web/src/modules/energy_manager/plugin_automation_trigger.tsx index a254580b4..3a54796ac 100644 --- a/software/web/src/modules/energy_manager/plugin_automation_trigger.tsx +++ b/software/web/src/modules/energy_manager/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; import { FormRow } from "../../ts/components/form_row"; import { InputSelect } from "../../ts/components/input_select"; diff --git a/software/web/src/modules/evse_common/plugin_automation_action.tsx b/software/web/src/modules/evse_common/plugin_automation_action.tsx index e8fb4b1e1..ca542c293 100644 --- a/software/web/src/modules/evse_common/plugin_automation_action.tsx +++ b/software/web/src/modules/evse_common/plugin_automation_action.tsx @@ -19,7 +19,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { InputSelect } from "../../ts/components/input_select"; import { InputFloat } from "../../ts/components/input_float"; diff --git a/software/web/src/modules/evse_common/plugin_automation_trigger.tsx b/software/web/src/modules/evse_common/plugin_automation_trigger.tsx index 038c618ed..20dbc912f 100644 --- a/software/web/src/modules/evse_common/plugin_automation_trigger.tsx +++ b/software/web/src/modules/evse_common/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { h, ComponentChildren } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; import { InputSelect } from "../../ts/components/input_select"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/evse_v2/plugin_automation_action.tsx b/software/web/src/modules/evse_v2/plugin_automation_action.tsx index efa7b7b75..a0d1f65f0 100644 --- a/software/web/src/modules/evse_v2/plugin_automation_action.tsx +++ b/software/web/src/modules/evse_v2/plugin_automation_action.tsx @@ -19,7 +19,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { InputSelect } from "../../ts/components/input_select"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/evse_v2/plugin_automation_trigger.tsx b/software/web/src/modules/evse_v2/plugin_automation_trigger.tsx index 18c80db1c..21d704336 100644 --- a/software/web/src/modules/evse_v2/plugin_automation_trigger.tsx +++ b/software/web/src/modules/evse_v2/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { h, ComponentChildren } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; import { InputSelect } from "../../ts/components/input_select"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/meters/plugin_automation_action.tsx b/software/web/src/modules/meters/plugin_automation_action.tsx index b2c80447c..e2d1d5203 100644 --- a/software/web/src/modules/meters/plugin_automation_action.tsx +++ b/software/web/src/modules/meters/plugin_automation_action.tsx @@ -20,7 +20,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; import { AutomationAction, InitResult } from "../automation/types"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { ComponentChildren } from "preact"; import { FormRow } from "../../ts/components/form_row"; import { METERS_SLOTS } from "../../build"; diff --git a/software/web/src/modules/meters_modbus_tcp/.gitignore b/software/web/src/modules/meters_modbus_tcp/.gitignore deleted file mode 100644 index 632f6d455..000000000 --- a/software/web/src/modules/meters_modbus_tcp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -meters_modbus_tcp_defs.ts diff --git a/software/web/src/modules/meters_modbus_tcp/plugin_meters_config.tsx b/software/web/src/modules/meters_modbus_tcp/plugin_meters_config.tsx index 3eec52955..a068f72f0 100644 --- a/software/web/src/modules/meters_modbus_tcp/plugin_meters_config.tsx +++ b/software/web/src/modules/meters_modbus_tcp/plugin_meters_config.tsx @@ -23,15 +23,15 @@ import { __ } from "../../ts/translation"; import { MeterClassID } from "../meters/meters_defs"; import { MeterConfig } from "../meters/types"; import { MeterValueIDSelector, get_meter_value_id_name } from "../meters_api/plugin_meters_config"; -import { MeterModbusTCPTableID, - ModbusRegisterType, - ModbusRegisterAddressMode, - ModbusValueType, - SungrowHybridInverterVirtualMeterID, - SungrowStringInverterVirtualMeterID, - SolarmaxMaxStorageVirtualMeterID, - VictronEnergyGXVirtualMeterID, - DeyeHybridInverterVirtualMeterID } from "./meters_modbus_tcp_defs"; +import { MeterModbusTCPTableID } from "./meter_modbus_tcp_table_id.enum"; +import { ModbusRegisterType } from "./modbus_register_type.enum"; +import { ModbusRegisterAddressMode } from "./modbus_register_address_mode.enum"; +import { ModbusValueType } from "./modbus_value_type.enum"; +import { SungrowHybridInverterVirtualMeterID } from "./sungrow_hybrid_inverter_virtual_meter_id.enum"; +import { SungrowStringInverterVirtualMeterID } from "./sungrow_string_inverter_virtual_meter_id.enum"; +import { SolarmaxMaxStorageVirtualMeterID } from "./solarmax_max_storage_virtual_meter_id.enum"; +import { VictronEnergyGXVirtualMeterID } from "./victron_energy_gx_virtual_meter_id.enum"; +import { DeyeHybridInverterVirtualMeterID } from "./deye_hybrid_inverter_virtual_meter_id.enum"; import { InputText } from "../../ts/components/input_text"; import { InputNumber } from "../../ts/components/input_number"; import { InputAnyFloat } from "../../ts/components/input_any_float"; diff --git a/software/web/src/modules/mqtt/plugin_automation_action.tsx b/software/web/src/modules/mqtt/plugin_automation_action.tsx index 59d3da51d..3229f0cab 100644 --- a/software/web/src/modules/mqtt/plugin_automation_action.tsx +++ b/software/web/src/modules/mqtt/plugin_automation_action.tsx @@ -20,7 +20,7 @@ import { h, Fragment } from "preact"; import { useState } from "preact/hooks"; import { __ } from "../../ts/translation"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { InputText } from "../../ts/components/input_text"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/mqtt/plugin_automation_trigger.tsx b/software/web/src/modules/mqtt/plugin_automation_trigger.tsx index 3501c04c1..0706aa299 100644 --- a/software/web/src/modules/mqtt/plugin_automation_trigger.tsx +++ b/software/web/src/modules/mqtt/plugin_automation_trigger.tsx @@ -20,7 +20,7 @@ import { h, Fragment } from "preact"; import { useState } from "preact/hooks"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; import { InputText } from "../../ts/components/input_text"; import { FormRow } from "../../ts/components/form_row"; diff --git a/software/web/src/modules/nfc/plugin_automation_action.tsx b/software/web/src/modules/nfc/plugin_automation_action.tsx index b556072ce..27e094017 100644 --- a/software/web/src/modules/nfc/plugin_automation_action.tsx +++ b/software/web/src/modules/nfc/plugin_automation_action.tsx @@ -19,7 +19,7 @@ import { h, Fragment } from "preact"; import { __, translate_unchecked } from "../../ts/translation"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { InputText } from "../../ts/components/input_text"; import { InputSelect } from "../../ts/components/input_select"; diff --git a/software/web/src/modules/nfc/plugin_automation_trigger.tsx b/software/web/src/modules/nfc/plugin_automation_trigger.tsx index 720663a32..63e853911 100644 --- a/software/web/src/modules/nfc/plugin_automation_trigger.tsx +++ b/software/web/src/modules/nfc/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { h } from "preact"; import { __, translate_unchecked } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; import { InputText } from "../../ts/components/input_text"; import { InputSelect } from "../../ts/components/input_select"; diff --git a/software/web/src/modules/power_manager/plugin_automation_action.tsx b/software/web/src/modules/power_manager/plugin_automation_action.tsx index dab3dd42e..e0a234060 100644 --- a/software/web/src/modules/power_manager/plugin_automation_action.tsx +++ b/software/web/src/modules/power_manager/plugin_automation_action.tsx @@ -19,7 +19,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationActionID } from "../automation/automation_defs"; +import { AutomationActionID } from "../automation/automation_action_id.enum"; import { AutomationAction, InitResult } from "../automation/types"; import { FormRow } from "../../ts/components/form_row"; import { InputSelect } from "../../ts/components/input_select"; diff --git a/software/web/src/modules/power_manager/plugin_automation_trigger.tsx b/software/web/src/modules/power_manager/plugin_automation_trigger.tsx index 99f998ceb..53c1282f4 100644 --- a/software/web/src/modules/power_manager/plugin_automation_trigger.tsx +++ b/software/web/src/modules/power_manager/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { h } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; import { FormRow } from "../../ts/components/form_row"; import { InputSelect } from "../../ts/components/input_select"; diff --git a/software/web/src/modules/require_meter/plugin_automation_trigger.tsx b/software/web/src/modules/require_meter/plugin_automation_trigger.tsx index 30a727b5f..05d4a4b69 100644 --- a/software/web/src/modules/require_meter/plugin_automation_trigger.tsx +++ b/software/web/src/modules/require_meter/plugin_automation_trigger.tsx @@ -19,7 +19,7 @@ import { h, ComponentChildren } from "preact"; import { __ } from "../../ts/translation"; -import { AutomationTriggerID } from "../automation/automation_defs"; +import { AutomationTriggerID } from "../automation/automation_trigger_id.enum"; import { AutomationTrigger, InitResult } from "../automation/types"; export type RequireMeterAutomationTrigger = [