Skip to content

Commit

Permalink
Improve simulator types (#2076)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 authored Mar 4, 2024
1 parent cba37e2 commit 23760b7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pymodbus/server/simulator/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ def __init__(
)
self.web_app.on_startup.append(self.start_modbus_server)
self.web_app.on_shutdown.append(self.stop_modbus_server)
self.generator_html = {
self.generator_html: dict[str, list] = {
"log": ["", self.build_html_log],
"registers": ["", self.build_html_registers],
"calls": ["", self.build_html_calls],
"server": ["", self.build_html_server],
}
self.generator_json = {
self.generator_json: dict[str, list] = {
"log_json": [None, self.build_json_log],
"registers_json": [None, self.build_json_registers],
"calls_json": [None, self.build_json_calls],
Expand Down Expand Up @@ -344,7 +344,7 @@ def build_html_registers(self, params, html):
)
return new_html

def build_html_calls(self, params, html):
def build_html_calls(self, params: dict, html: str) -> str:
"""Build html calls page."""
result_txt, foot = self.helper_build_html_submit(params)
if not foot:
Expand Down Expand Up @@ -380,10 +380,10 @@ def build_html_calls(self, params, html):
for function in self.request_lookup.values():
selected = (
"selected"
if function.function_code == self.call_monitor.function
if function.function_code == self.call_monitor.function #type: ignore[attr-defined]
else ""
)
function_codes += f"<option value={function.function_code} {selected}>{function.function_code_name}</option>"
function_codes += f"<option value={function.function_code} {selected}>{function.function_code_name}</option>" #type: ignore[attr-defined]
simulation_action = (
"ACTIVE" if self.call_response.active != RESPONSE_INACTIVE else ""
)
Expand All @@ -394,7 +394,7 @@ def build_html_calls(self, params, html):
call_rows = ""
for entry in reversed(self.call_list):
# req_obj = self.request_lookup[entry[1]]
call_rows += f"<tr><td>{entry.call} - {entry.fc}</td><td>{entry.address}</td><td>{entry.count}</td><td>{entry.data}</td></tr>"
call_rows += f"<tr><td>{entry.call} - {entry.fc}</td><td>{entry.address}</td><td>{entry.count}</td><td>{entry.data.decode()}</td></tr>"
# line += req_obj.funcion_code_name
new_html = (
html.replace("<!--SIMULATION_ACTIVE-->", simulation_action)
Expand Down

0 comments on commit 23760b7

Please sign in to comment.