Skip to content

Commit

Permalink
confirm DCM communication changes
Browse files Browse the repository at this point in the history
  • Loading branch information
plebbbb committed Nov 30, 2023
1 parent 01d6851 commit 04ac506
Show file tree
Hide file tree
Showing 146 changed files with 13,863 additions and 6,956 deletions.
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
helpsearch*/

# Simulink code generation folders
slprj/
sccprj/
simulink_group9_FIX/slprj/
simulink_group9_FIX/sccprj/
simulink_group9_FIX/sccprj/

# Matlab code generation folders
codegen/
codegen/Assignment1_V4_ert_rtw

*.bin
*.elf
*.hex

# Simulink autosave extension
*.autosave
Expand Down
12 changes: 7 additions & 5 deletions DCM_group9/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, port: str = None, device_id: str = None):
self.port = port
self.device_id = device_id
self.previous_device_ids = []
self.egram_data = [(0,0)]*6000
self.egram_data = [(0,0)]*600
self.transmit_params = True
self.banned_ports = []
self.ser = serial.Serial()
Expand Down Expand Up @@ -73,9 +73,11 @@ def open_port(self, current_screen):
self.transmit_params = True
print("Attemping to connect to: ", port.device)
try:
time.sleep(0.1)
self.ser = serial.Serial(port.device, 115200, timeout=1, write_timeout=1)
data = bytearray()
self.ser.write(packed_serial_data)
# time.sleep(0.3)
self.__flush()
time.sleep(0.1)
for _ in range(4):
Expand Down Expand Up @@ -148,8 +150,8 @@ def get_egram_data(self, current_screen):
while current_screen[0]:
if self.is_connected:
try:
time.sleep(1)
continue
# time.sleep(1)
# continue
while not self.transmit_params:
# Read data from serial port
data = self.ser.read(4)
Expand All @@ -159,7 +161,7 @@ def get_egram_data(self, current_screen):

# Data for time and voltage TODO: change in a2 to match expected transfer
v_vector = struct.unpack('<2h', data)
if i != 5999:
if i != 599:
i = i + 1
self.egram_data[i] = (float(v_vector[0]/1000), float(v_vector[1]/1000))
else:
Expand Down Expand Up @@ -195,7 +197,7 @@ def transmit_parameters(self, pacing_mode: str, params: dict) -> None:
count = 0

for param in params:
if count == 3 or count == 6:
if count == 3 or count == 6 or count == 5 or count == 8:
serial_data_start.append(np.uint8(params[param]*10))
else:
serial_data_start.append(np.uint8(params[param]))
Expand Down
16 changes: 8 additions & 8 deletions DCM_group9/backend/database.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@
"Recovery Time": 0
},
"AOOR": {
"Lower Rate Limit": 60,
"Upper Rate Limit": 120,
"Maximum Sensor Rate": 120,
"Atrial Amplitude Regulated": 5,
"Atrial Pulse Width": 1,
"Lower Rate Limit": 60.0,
"Upper Rate Limit": 120.0,
"Maximum Sensor Rate": 120.0,
"Atrial Amplitude Regulated": 5.0,
"Atrial Pulse Width": 1.0,
"Atrial Sensitivity": 5,
"Ventricular Amplitude Regulated": 0,
"Ventricular Pulse Width": 0,
"Ventricular Sensitivity": 5,
"ARP": 0,
"VRP": 0,
"Reaction Time": 30,
"Response Factor": 8,
"Recovery Time": 5
"Reaction Time": 30.0,
"Response Factor": 12.0,
"Recovery Time": 2.0
},
"AAIR": {
"Lower Rate Limit": 60,
Expand Down
2 changes: 1 addition & 1 deletion DCM_group9/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ def run_screen(self):

# Placeholder x and y data (This is to be replaced with the data received from the board)

x = np.arange(0, 6000)
x = np.arange(0, 600)
y_a = np.array([vector[0] for vector in self.backend.egram_data])
y_v = np.array([vector[1] for vector in self.backend.egram_data])

Expand Down
Binary file modified simulink_group9_FIX/Assignment1_V5.slx
Binary file not shown.
Loading

0 comments on commit 04ac506

Please sign in to comment.