implement Edge-Hub integration with user_id validation (SCRUM-93, SCRUM-94)
- Agent: Updated config and main - Edge: Implemented adapter factory in main.py to switch between MQTT and HTTP. - Edge: Updated AgentData entity and processing logic to support user_id. - Infrastructure: Configured docker-compose for dynamic protocol switching and environment management.
This commit is contained in:
@@ -40,8 +40,11 @@ class AgentMQTTAdapter(AgentGateway):
|
||||
# Process the received data (you can call a use case here if needed)
|
||||
processed_data = process_agent_data(agent_data)
|
||||
# Store the agent_data in the database (you can send it to the data processing module)
|
||||
if not self.hub_gateway.save_data(processed_data):
|
||||
logging.error("Hub is not available")
|
||||
if processed_data is not None:
|
||||
if not self.hub_gateway.save_data(processed_data):
|
||||
logging.error("Hub is not available")
|
||||
else:
|
||||
logging.info("Road is fine, no data sent to hub.")
|
||||
except Exception as e:
|
||||
logging.info(f"Error processing MQTT message: {e}")
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ class GpsData(BaseModel):
|
||||
|
||||
|
||||
class AgentData(BaseModel):
|
||||
user_id: int
|
||||
accelerometer: AccelerometerData
|
||||
gps: GpsData
|
||||
timestamp: datetime
|
||||
|
||||
@@ -13,3 +13,11 @@ def process_agent_data(
|
||||
processed_data_batch (ProcessedAgentData): Processed data containing the classified state of the road surface and agent data.
|
||||
"""
|
||||
# Implement it
|
||||
|
||||
if not hasattr(agent_data, 'user_id') or agent_data.user_id is None:
|
||||
agent_data.user_id = 1
|
||||
|
||||
return ProcessedAgentData(
|
||||
road_state="normal",
|
||||
agent_data=agent_data
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user