From cad5e4fc620f56743bac72cf2b047b8ff961bca3 Mon Sep 17 00:00:00 2001 From: jthomas462 Date: Wed, 13 Mar 2024 18:12:04 -0400 Subject: [PATCH 1/2] Health Command created; please check over --- .../pipeline/pipelines/terminal_output_pipeline.py | 2 +- postgresDB/dbApp/views.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/EosGround/database/pipeline/pipelines/terminal_output_pipeline.py b/EosGround/database/pipeline/pipelines/terminal_output_pipeline.py index 2cc4242..d68b692 100644 --- a/EosGround/database/pipeline/pipelines/terminal_output_pipeline.py +++ b/EosGround/database/pipeline/pipelines/terminal_output_pipeline.py @@ -28,7 +28,7 @@ def get_notify_channel() -> str | None: return None def extract(self, session: Session) -> Query: - commands = [Type.CUTDOWN, Type.PING, Type.VALVE] + commands = [Type.CUTDOWN, Type.PING, Type.VALVE, Type.HEALTH_QUERY_COMMAND] return session.query(ReceivedPackets).filter(ReceivedPackets.packet_type.in_(commands), ReceivedPackets.processed == False)\ .order_by(ReceivedPackets.id) diff --git a/postgresDB/dbApp/views.py b/postgresDB/dbApp/views.py index c41c055..aecde3e 100644 --- a/postgresDB/dbApp/views.py +++ b/postgresDB/dbApp/views.py @@ -17,6 +17,7 @@ from EosLib.format.definitions import Type from EosLib.format.formats.cutdown import CutDown from EosLib.format.formats.ping_format import Ping +from EosLib.format.formats.health.health_query import HealthQuery from EosLib.device import Device from EosLib.packet import Packet from EosLib.packet.data_header import DataHeader @@ -108,6 +109,16 @@ def transmitTableInsert(request): cursor.execute("NOTIFY update;") connection.commit() return Response({'message': 'Valve command sent ', 'ack': ack}, status=status.HTTP_200_OK) + elif command == "healthQuery": + healthQuery_body = HealthQuery(ack) + healthQuery_body_bytes = healthQuery_body.encode() + transmitTable.packet_type = Type.HEALTHQUERY + transmitTable.destination = Device.HEALTHQUERY + transmitTable.body = healthQuery_body_bytes + transmitTable.save() + cursor.execute("NOTIFY update;") + connection.commit() + return Response({'message': 'Health Query command sent ', 'ack': ack}, status=status.HTTP_200_OK) return Response({'message': 'Invalid input or method'}, status=status.HTTP_400_BAD_REQUEST) From 70fc08cc2578a298ec3c70b0d487aa3f64db5a94 Mon Sep 17 00:00:00 2001 From: jthomas462 Date: Wed, 24 Apr 2024 14:52:22 -0400 Subject: [PATCH 2/2] updates to command made --- postgresDB/dbApp/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postgresDB/dbApp/views.py b/postgresDB/dbApp/views.py index aecde3e..82e23c9 100644 --- a/postgresDB/dbApp/views.py +++ b/postgresDB/dbApp/views.py @@ -69,7 +69,7 @@ def transmitTableInsert(request): transmitTable.priority = Priority.DATA transmitTable.generate_time = datetime.now() - valid_commands = {"cutdown", "ping", "valve", "clear"} + valid_commands = {"cutdown", "ping", "valve", "clear", "healthQuery"} if command not in valid_commands: return Response({'message': 'Invalid command'}, status=status.HTTP_400_BAD_REQUEST) @@ -110,7 +110,7 @@ def transmitTableInsert(request): connection.commit() return Response({'message': 'Valve command sent ', 'ack': ack}, status=status.HTTP_200_OK) elif command == "healthQuery": - healthQuery_body = HealthQuery(ack) + healthQuery_body = HealthQuery(command_parts[1], command_parts[2]) healthQuery_body_bytes = healthQuery_body.encode() transmitTable.packet_type = Type.HEALTHQUERY transmitTable.destination = Device.HEALTHQUERY