Merge branch 'main' of https://git.nehemis.fr/aniketSaha/NorthStar-HMI
This commit is contained in:
commit
ef91ff4426
|
|
@ -127,7 +127,6 @@ class CANBackend:
|
|||
"MV06": data[4],
|
||||
"MV07": data[5],
|
||||
"MV08": data[6],
|
||||
"MV09": data[7],
|
||||
})
|
||||
|
||||
elif cob_id == 0x2AB and len(data) >= 1:
|
||||
|
|
|
|||
16
main.py
16
main.py
|
|
@ -51,6 +51,8 @@ latest_data: Dict[str, Any] = {
|
|||
"PatientSkid": {"QSkid": 0.0},
|
||||
}
|
||||
|
||||
active_PUs : list[int] = []
|
||||
|
||||
DEFAULT_FEED_VALVE = 0.0
|
||||
|
||||
# RECORDER
|
||||
|
|
@ -77,7 +79,9 @@ def format_data(data):
|
|||
"Pro": np.round(data.get("PS2", 0.0), 2),
|
||||
"Pdilute": np.round(data.get("PS3", 0.0), 2),
|
||||
"Pretentate": np.round(data.get("PS1", 0.0), 2),
|
||||
"Conductivity": np.round(data.get("Cond", 0.0), 1),
|
||||
"Cfeed": np.round(data.get("Conductivity_Feed", 0.0), 1),
|
||||
"Cperm": np.round(data.get("Conductivity_Permeate", 0.0), 1),
|
||||
"Cdilute": np.round(data.get("Conductivity_Product", 0.0), 1),
|
||||
"MV02": np.round(data.get("MV02", 0.0), 1),
|
||||
"MV02_sp": np.round(data.get("MV02_sp", 0.0), 1),
|
||||
"MV03": np.round(data.get("MV03", 0.0), 1),
|
||||
|
|
@ -213,6 +217,7 @@ def send_command(state: str, pu_number: int, ploop_setpoint: float = Query(...))
|
|||
|
||||
@app.get("/api/pu_status")
|
||||
def get_pu_status():
|
||||
global active_PUs
|
||||
states = {
|
||||
"PU1": can_backend.read_current_state(1),
|
||||
"PU2": can_backend.read_current_state(2),
|
||||
|
|
@ -220,15 +225,16 @@ def get_pu_status():
|
|||
}
|
||||
logging.info(f"[PU STATUS] {states}")
|
||||
|
||||
active_PUs = [pu for pu, status in states.items() if status != 'OFF']
|
||||
logging.info(f"[ACTIVE PU] {active_PUs}")
|
||||
|
||||
return JSONResponse(content=states)
|
||||
|
||||
|
||||
async def update_latest_data():
|
||||
global active_PUs
|
||||
while True:
|
||||
for pu in [
|
||||
1,
|
||||
2,
|
||||
]: # TODO: REPLACE THIS WITH CONNECTED PUs, IS GET PU STATUS SLOW?
|
||||
for pu in active_PUs: # TODO: test
|
||||
data = can_backend.get_latest_data(pu_number=pu)
|
||||
latest_data[f"PU_{pu}"] = format_data(data)
|
||||
current_data = latest_data[f"PU_{pu}"]
|
||||
|
|
|
|||
|
|
@ -320,8 +320,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-bolt"></i> Conductivity</h2>
|
||||
<div class="monitor-values" id="Conductivity">
|
||||
<h2><i class="fas fa-bolt"></i> Cdilute</h2>
|
||||
<div class="monitor-values" id="Cdilute">
|
||||
<div class="monitor-value">#1<br>0.0 µS/cm</div>
|
||||
<div class="monitor-value">#2<br>0.0 µS/cm</div>
|
||||
<div class="monitor-value">#3<br>0.0 µS/cm</div>
|
||||
|
|
@ -479,7 +479,7 @@
|
|||
<div class="monitor-value">P_ro<br>${puData.Pro.toFixed(1)} bar</div>
|
||||
<div class="monitor-value">P_dilute<br>${puData.Pdilute.toFixed(1)} bar</div>
|
||||
<div class="monitor-value">P_retentate<br>${puData.Pretentate.toFixed(1)} bar</div>
|
||||
<div class="monitor-value">Conductivity<br>${puData.Conductivity.toFixed(1)} µS/cm</div>
|
||||
<div class="monitor-value">Cdilute<br>${puData.Cdilute.toFixed(1)} µS/cm</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
|
@ -500,7 +500,7 @@ async function fetchMonitorData() {
|
|||
const fields = {
|
||||
"Qperm": "L/h",
|
||||
"Pdilute": "bar",
|
||||
"Conductivity": "µS/cm",
|
||||
"Cdilute": "µS/cm",
|
||||
"Pro": "bar"
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user