Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpdx committed Nov 5, 2023
1 parent 51a51f0 commit e6f99bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions oresat_cfc/services/tec_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, pirt1280: Pirt1280, rc6_25: Rc625):
self._cooldown_temp_obj: canopen.objectdictionary.Variable = None
self._mv_avg_samples_obj: canopen.objectdictionary.Variable = None

self._start_time: int = None
self._start_time: int = 0
self._target_temperatures: list = []
self._current_temperatures: list = []
self._pid_outputs: list = []
Expand Down Expand Up @@ -103,17 +103,8 @@ def _get_moving_average(self, temp: float) -> float:
# return the average
return sum(self._samples) / len(self._samples)

def on_loop(self):
self.sleep(self._pid_delay_obj.value / 1000)

# only run tec controller alg when the camera and TEC controller are both enabled
if not self._camera.is_enabled or not self._controller_enabled:
self._tec.disable()
return

current_temp = self._camera.temperature
diff = self._pid(current_temp)
mv_avg = self._get_moving_average(current_temp)
def _update_graph_data(self, current_temp: float, diff: float, mv_avg: float):
"""Update the local data for the graph."""

self._current_temperatures.append(current_temp)
self._pid_outputs.append(0 if diff < 0 else (100 if diff > 100 else diff))
Expand All @@ -131,6 +122,20 @@ def on_loop(self):
if len(self._graph_unix_times) > self._maximum_graph_size:
self._graph_unix_times.pop(0)

def on_loop(self):
self.sleep(self._pid_delay_obj.value / 1000)

# only run tec controller alg when the camera and TEC controller are both enabled
if not self._camera.is_enabled or not self._controller_enabled:
self._tec.disable()
return

current_temp = self._camera.temperature
diff = self._pid(current_temp)
mv_avg = self._get_moving_average(current_temp)

self._update_graph_data(current_temp, diff, mv_avg)

# update the lowest temperature
if current_temp < self._lowest_temp:
self._lowest_temp = current_temp
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ignore = "C0103,E203,W0613,R0902,R901,R0913,R0914"
max_line_length = 100

[[tool.mypy.overrides]]
module = "canopen,olaf,tifffile,spidev,oresat_configs"
module = "canopen,olaf,tifffile,spidev,oresat_configs,cv2"
ignore_missing_imports = true

[tool.isort]
Expand Down

0 comments on commit e6f99bb

Please sign in to comment.