Skip to content

Commit

Permalink
changes to server
Browse files Browse the repository at this point in the history
  • Loading branch information
adenjonah committed May 16, 2024
1 parent 32e0917 commit 3052703
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 9 deletions.
Binary file not shown.
163 changes: 162 additions & 1 deletion server/initdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2136,9 +2136,170 @@
}

DEFAULT_EQUIPMENT_PROCEDURES_DATA = {

"procedures": [
{
"id": 1,
"title": "Structural Damage Repair",
"steps": [
{
"step": "Comm Tower Base 1",
"role": "EV1",
"description": "Collect structural repair materials including metal patches, welding tools, and adhesives."
},
{
"step": "Comm Tower Base 2",
"role": "EV2",
"description": "Assemble safety gear for climbing and securing both crew members."
},
{
"step": "Comm Tower 3",
"role": "EV1",
"description": "Assess tower for visible structural damage."
},
{
"step": "Comm Tower 4",
"role": "EV2",
"description": "Assist in removing debris and damaged components."
},
{
"step": "Comm Tower 5",
"role": "EV1",
"description": "Apply metal patches over holes or tears using welding tools."
},
{
"step": "Comm Tower 6",
"role": "EV2",
"description": "Provide support in applying patches or adhesives."
},
{
"step": "Comm Tower 7",
"role": "EV1",
"description": "Secure larger structural issues with adhesives and temporary supports."
},
{
"step": "Comm Tower 8",
"role": "EV2",
"description": "Ensure safety protocols are followed during high or difficult access points."
}
]
},
{
"id": 2,
"title": "Power System Troubleshooting and Repair",
"steps": [
{
"step": "Tower Base PSU 1",
"role": "EV1",
"description": "Assemble diagnostic kit, spare batteries, solar cells, and electrical repair tools."
},
{
"step": "Tower Base PSU 2",
"role": "EV2",
"description": "Carry additional spare parts and protective equipment."
},
{
"step": "Tower Base PSU 3",
"role": "EV1",
"description": "Perform diagnostics to identify power supply issues."
},
{
"step": "Tower Base PSU 4",
"role": "EV2",
"description": "Assist in identifying damaged components."
},
{
"step": "Tower Base PSU 5",
"role": "EV1",
"description": "Replace faulty batteries or solar cells."
},
{
"step": "Tower Base PSU 6",
"role": "EV2",
"description": "Help in repairing or replacing wiring, ensuring secure connections."
},
{
"step": "Tower Base PSU 7",
"role": "EV1",
"description": "Verify power system functionality post-repair."
}
]
},
{
"id": 3,
"title": "Antenna Alignment and Calibration",
"steps": [
{
"step": "Comm Tower Antenna 1",
"role": "EV1",
"description": "Prepare alignment tools and calibration software on a portable device."
},
{
"step": "Comm Tower Antenna 2",
"role": "EV2",
"description": "Assemble securing gear and safety equipment for both crew members."
},
{
"step": "Comm Tower Antenna 3",
"role": "EV1",
"description": "Adjust the antenna to correct orientation using tools."
},
{
"step": "Comm Tower Antenna 4",
"role": "EV2",
"description": "Assist in antenna inspection for misalignment or damage."
},
{
"step": "Comm Tower Antenna 5",
"role": "EV1",
"description": "Secure antenna position; perform calibration test."
},
{
"step": "Comm Tower Antenna 6",
"role": "EV2",
"description": "Support in adjustment and calibration process; maintain communication with mission control."
}
]
},
{
"id": 4,
"title": "Transceiver Module Replacement",
"steps": [
{
"step": "Comm Tower Transceiver 1",
"role": "EV1",
"description": "Collect replacement transceiver module and non-conductive tools."
},
{
"step": "Comm Tower Transceiver 2",
"role": "EV2",
"description": "Prepare electrostatic discharge safety equipment."
},
{
"step": "Comm Tower Transceiver 3",
"role": "EV1",
"description": "Remove the faulty module."
},
{
"step": "Comm Tower Transceiver 4",
"role": "EV2",
"description": "Assist in isolating power supply."
},
{
"step": "Comm Tower Transceiver 5",
"role": "EV1",
"description": "Install the new module ensuring all connections are secure."
},
{
"step": "Comm Tower Transceiver 6",
"role": "EV2",
"description": "Ensure module installation is correctly performed; conduct systems check to verify functionality."
}
]
}
]
}


DEFAULT_ALERTS_DATA = {
"alerts": []
}
Expand Down
2 changes: 1 addition & 1 deletion server/json_databases/equipment_repair.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{"procedures": [{"id": 1, "title": "Structural Damage Repair", "steps": [{"step": "Comm Tower Base 1", "role": "EV1", "description": "Collect structural repair materials including metal patches, welding tools, and adhesives."}, {"step": "Comm Tower Base 2", "role": "EV2", "description": "Assemble safety gear for climbing and securing both crew members."}, {"step": "Comm Tower 3", "role": "EV1", "description": "Assess tower for visible structural damage."}, {"step": "Comm Tower 4", "role": "EV2", "description": "Assist in removing debris and damaged components."}, {"step": "Comm Tower 5", "role": "EV1", "description": "Apply metal patches over holes or tears using welding tools."}, {"step": "Comm Tower 6", "role": "EV2", "description": "Provide support in applying patches or adhesives."}, {"step": "Comm Tower 7", "role": "EV1", "description": "Secure larger structural issues with adhesives and temporary supports."}, {"step": "Comm Tower 8", "role": "EV2", "description": "Ensure safety protocols are followed during high or difficult access points."}]}, {"id": 2, "title": "Power System Troubleshooting and Repair", "steps": [{"step": "Tower Base PSU 1", "role": "EV1", "description": "Assemble diagnostic kit, spare batteries, solar cells, and electrical repair tools."}, {"step": "Tower Base PSU 2", "role": "EV2", "description": "Carry additional spare parts and protective equipment."}, {"step": "Tower Base PSU 3", "role": "EV1", "description": "Perform diagnostics to identify power supply issues."}, {"step": "Tower Base PSU 4", "role": "EV2", "description": "Assist in identifying damaged components."}, {"step": "Tower Base PSU 5", "role": "EV1", "description": "Replace faulty batteries or solar cells."}, {"step": "Tower Base PSU 6", "role": "EV2", "description": "Help in repairing or replacing wiring, ensuring secure connections."}, {"step": "Tower Base PSU 7", "role": "EV1", "description": "Verify power system functionality post-repair."}]}, {"id": 3, "title": "Antenna Alignment and Calibration", "steps": [{"step": "Comm Tower Antenna 1", "role": "EV1", "description": "Prepare alignment tools and calibration software on a portable device."}, {"step": "Comm Tower Antenna 2", "role": "EV2", "description": "Assemble securing gear and safety equipment for both crew members."}, {"step": "Comm Tower Antenna 3", "role": "EV1", "description": "Adjust the antenna to correct orientation using tools."}, {"step": "Comm Tower Antenna 4", "role": "EV2", "description": "Assist in antenna inspection for misalignment or damage."}, {"step": "Comm Tower Antenna 5", "role": "EV1", "description": "Secure antenna position; perform calibration test."}, {"step": "Comm Tower Antenna 6", "role": "EV2", "description": "Support in adjustment and calibration process; maintain communication with mission control."}]}, {"id": 4, "title": "Transceiver Module Replacement", "steps": [{"step": "Comm Tower Transceiver 1", "role": "EV1", "description": "Collect replacement transceiver module and non-conductive tools."}, {"step": "Comm Tower Transceiver 2", "role": "EV2", "description": "Prepare electrostatic discharge safety equipment."}, {"step": "Comm Tower Transceiver 3", "role": "EV1", "description": "Remove the faulty module."}, {"step": "Comm Tower Transceiver 4", "role": "EV2", "description": "Assist in isolating power supply."}, {"step": "Comm Tower Transceiver 5", "role": "EV1", "description": "Install the new module ensuring all connections are secure."}, {"step": "Comm Tower Transceiver 6", "role": "EV2", "description": "Ensure module installation is correctly performed; conduct systems check to verify functionality."}]}]}
38 changes: 32 additions & 6 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
app = FastAPI()

DATA_FILE = './server/json_databases/tss_data.json'
GEOJSON_FILE = './server/json_databases/created_pins.json'
PINS_FILE = './server/json_databases/created_pins.json'
BOUNDARY_LINES_FILE = './server/json_databases/boundary_lines.json'
CONFIG_FILE = './server/json_databases/config_keys.json'
INGRESS_FILE = './server/json_databases/ingress_procedures.json'
EGRESS_FILE = './server/json_databases/egress_procedures.json'
EQUIPMENT_REPAIR_FILE = './server/json_databases/equipment_repair.json'
ALERTS_FILE = './server/json_databases/alerts.json'
MESSAGES_FILE = './server/json_databases/messages.json'

# Load config to get TSS_IP
if os.path.exists(CONFIG_FILE):
Expand Down Expand Up @@ -157,8 +162,8 @@ async def get_geojson():
geojson_data["features"].extend(boundary_lines_data["features"])

# Read existing geojson data
if os.path.exists(GEOJSON_FILE):
with open(GEOJSON_FILE, "r") as file:
if os.path.exists(BOUNDARY_LINES_FILE):
with open(BOUNDARY_LINES_FILE, "r") as file:
existing_geojson_data = json.load(file)
if "features" in existing_geojson_data:
geojson_data["features"].extend(existing_geojson_data["features"])
Expand All @@ -167,10 +172,10 @@ async def get_geojson():

@app.post("/add_marker")
async def add_marker(marker: Marker):
if not os.path.exists(GEOJSON_FILE):
if not os.path.exists(BOUNDARY_LINES_FILE):
data = {"type": "FeatureCollection", "features": []}
else:
with open(GEOJSON_FILE, "r") as file:
with open(BOUNDARY_LINES_FILE, "r") as file:
data = json.load(file)

new_feature = {
Expand All @@ -189,7 +194,7 @@ async def add_marker(marker: Marker):

data["features"].append(new_feature)

with open(GEOJSON_FILE, "w") as file:
with open(BOUNDARY_LINES_FILE, "w") as file:
json.dump(data, file)

return {"message": "Marker added successfully"}
Expand All @@ -210,3 +215,24 @@ async def get_team_data(team_number: int, filename: str):
raise HTTPException(status_code=400, detail="Team number must be between 0 and 10")
url = f"http://{tss_ip}/json_data/teams/{team_number}/{filename}"
return await fetch_json(url)

def load_procedures():
if os.path.exists(EQUIPMENT_REPAIR_FILE):
with open(EQUIPMENT_REPAIR_FILE, 'r') as file:
return json.load(file)
else:
raise FileNotFoundError(f"{EQUIPMENT_REPAIR_FILE} not found")

@app.get("/procedure")
async def get_procedure(id: int):
try:
data = load_procedures()
procedures = data.get("procedures", [])
except FileNotFoundError as e:
raise HTTPException(status_code=404, detail=str(e))

procedure = next((proc for proc in procedures if proc["id"] == id), None)
if procedure:
return procedure
else:
raise HTTPException(status_code=404, detail="Procedure not found")
1 change: 0 additions & 1 deletion src/pages/constant/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function Constant() {
<div className="pagecontainer" id="constantpage">
<div id="topbar"></div>
<div id="centerbar">
<div className='centerButton' id='Message' onClick={showMessageModal}>Message</div>
<div className='centerButton' id='Alert' onClick={showAlertModal}>Alert</div>
<div className='centerButton' id='MapButton' onClick={showMapModal}>Map</div>
</div>
Expand Down

0 comments on commit 3052703

Please sign in to comment.