Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
e39002b8e7
|
|
@ -63,7 +63,6 @@ class CANBackend:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def send_state_command(self, state: str, pu_number: int, ploop_setpoint:float):
|
def send_state_command(self, state: str, pu_number: int, ploop_setpoint:float):
|
||||||
#TODO : link ploop_setpoint
|
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
raise RuntimeError("CAN not connected")
|
raise RuntimeError("CAN not connected")
|
||||||
|
|
||||||
|
|
@ -81,6 +80,11 @@ class CANBackend:
|
||||||
try:
|
try:
|
||||||
print(f"[DEBUG] Writing state {state_map[state]} to index 0x2024, subindex {pu_number}")
|
print(f"[DEBUG] Writing state {state_map[state]} to index 0x2024, subindex {pu_number}")
|
||||||
self.node.sdo[0x2024][0x01].raw = state_map[state]
|
self.node.sdo[0x2024][0x01].raw = state_map[state]
|
||||||
|
|
||||||
|
# Write the ploop setpoint to its own index/subindex
|
||||||
|
print(f"[DEBUG] Writing ploop_setpoint {ploop_setpoint} to index 0x2007, subindex {0x00}")
|
||||||
|
self.node.sdo[2007][0x00].raw = int(ploop_setpoint * 100)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[SDO WRITE ERROR] Failed to write to 0x2024:{pu_number} - {e}")
|
print(f"[SDO WRITE ERROR] Failed to write to 0x2024:{pu_number} - {e}")
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ FileVersion=1.0
|
||||||
FileRevision=1.0
|
FileRevision=1.0
|
||||||
EDSVersion=4.0
|
EDSVersion=4.0
|
||||||
Description=EDS
|
Description=EDS
|
||||||
CreationTime=09:54PM
|
CreationTime=14:47PM
|
||||||
CreationDate=07-07-25
|
CreationDate=07-07-25
|
||||||
ModificationTime=09:54PM
|
ModificationTime=14:47PM
|
||||||
ModificationDate=07-07-25
|
ModificationDate=07-07-25
|
||||||
CreatedBy=Aniket Saha
|
CreatedBy=Aniket Saha
|
||||||
ModifiedBy=Aniket Saha
|
ModifiedBy=Aniket Saha
|
||||||
|
|
@ -56,7 +56,7 @@ SupportedObjects=3
|
||||||
3=0x1018
|
3=0x1018
|
||||||
|
|
||||||
[ManufacturerObjects]
|
[ManufacturerObjects]
|
||||||
SupportedObjects=23
|
SupportedObjects=24
|
||||||
1=0x2000
|
1=0x2000
|
||||||
2=0x2001
|
2=0x2001
|
||||||
3=0x2002
|
3=0x2002
|
||||||
|
|
@ -79,7 +79,8 @@ SupportedObjects=23
|
||||||
20=0x2022
|
20=0x2022
|
||||||
21=0x2023
|
21=0x2023
|
||||||
22=0x2024
|
22=0x2024
|
||||||
23=0x3000
|
23=0x2025
|
||||||
|
24=0x3000
|
||||||
|
|
||||||
[OptionalObjects]
|
[OptionalObjects]
|
||||||
SupportedObjects=45
|
SupportedObjects=45
|
||||||
|
|
@ -2386,6 +2387,43 @@ DataType=5
|
||||||
AccessType=rw
|
AccessType=rw
|
||||||
PDOMapping=0
|
PDOMapping=0
|
||||||
|
|
||||||
|
[2025]
|
||||||
|
ParameterName=Mode Duration
|
||||||
|
ObjectType=8
|
||||||
|
SubNumber=4
|
||||||
|
|
||||||
|
[2025sub0]
|
||||||
|
ParameterName=Highest sub-index supported
|
||||||
|
ObjectType=7
|
||||||
|
DataType=5
|
||||||
|
AccessType=ro
|
||||||
|
PDOMapping=0
|
||||||
|
DefaultValue=3
|
||||||
|
|
||||||
|
[2025sub1]
|
||||||
|
ParameterName=Ro Flush Time
|
||||||
|
ObjectType=7
|
||||||
|
DataType=6
|
||||||
|
AccessType=rw
|
||||||
|
PDOMapping=0
|
||||||
|
DefaultValue=65535
|
||||||
|
|
||||||
|
[2025sub2]
|
||||||
|
ParameterName=Ro Rinse Time
|
||||||
|
ObjectType=7
|
||||||
|
DataType=6
|
||||||
|
AccessType=rw
|
||||||
|
PDOMapping=0
|
||||||
|
DefaultValue=65535
|
||||||
|
|
||||||
|
[2025sub3]
|
||||||
|
ParameterName=Edi Rinse Time
|
||||||
|
ObjectType=7
|
||||||
|
DataType=6
|
||||||
|
AccessType=rw
|
||||||
|
PDOMapping=0
|
||||||
|
DefaultValue=65535
|
||||||
|
|
||||||
[3000]
|
[3000]
|
||||||
ParameterName=Motor position
|
ParameterName=Motor position
|
||||||
ObjectType=8
|
ObjectType=8
|
||||||
|
|
|
||||||
36
main.py
36
main.py
|
|
@ -18,28 +18,26 @@ logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
can_backend = CANBackend()
|
can_backend = CANBackend()
|
||||||
|
|
||||||
|
|
||||||
# Serve static files (HTML, JS, CSS)
|
# Serve static files (HTML, JS, CSS)
|
||||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||||
|
|
||||||
@router.post("/webhook")
|
# @router.post("/webhook")
|
||||||
async def github_webhook(request: Request):
|
# async def github_webhook(request: Request):
|
||||||
payload = await request.json()
|
# payload = await request.json()
|
||||||
print("[WEBHOOK] Received webhook:", payload.get("head_commit", {}).get("message"))
|
# print("[WEBHOOK] Received webhook:", payload.get("head_commit", {}).get("message"))
|
||||||
|
|
||||||
try:
|
|
||||||
# Call the update script on the HOST using host bash
|
|
||||||
subprocess.run(
|
|
||||||
["/usr/bin/bash", "-c", "bash /home/hmi/Desktop/HMI/update_hmi.sh"],
|
|
||||||
check=True,
|
|
||||||
capture_output=True,
|
|
||||||
text=True
|
|
||||||
)
|
|
||||||
return {"status": "Update triggered"}
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
print(f"[WEBHOOK] Update failed:\n{e.stderr}")
|
|
||||||
return {"status": "Update failed", "error": str(e)}
|
|
||||||
|
|
||||||
|
# try:
|
||||||
|
# # Call the update script on the HOST using host bash
|
||||||
|
# subprocess.run(
|
||||||
|
# ["/usr/bin/bash", "-c", "bash /home/hmi/Desktop/HMI/update_hmi.sh"],
|
||||||
|
# check=True,
|
||||||
|
# capture_output=True,
|
||||||
|
# text=True
|
||||||
|
# )
|
||||||
|
# return {"status": "Update triggered"}
|
||||||
|
# except subprocess.CalledProcessError as e:
|
||||||
|
# print(f"[WEBHOOK] Update failed:\n{e.stderr}")
|
||||||
|
# return {"status": "Update failed", "error": str(e)}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/connect_toggle")
|
@app.post("/connect_toggle")
|
||||||
|
|
@ -167,7 +165,7 @@ if __name__ == "__main__":
|
||||||
import uvicorn
|
import uvicorn
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
"main:app",
|
"main:app",
|
||||||
host="0.0.0.0",
|
host="127.0.0.1",
|
||||||
port=8000,
|
port=8000,
|
||||||
reload=True,
|
reload=True,
|
||||||
reload_dirs=["."],
|
reload_dirs=["."],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user