From bd63f2648ce291e1655fdb449c983b3e57a3e060 Mon Sep 17 00:00:00 2001 From: jens Date: Tue, 19 Oct 2021 06:32:45 +0100 Subject: [PATCH] - refactored hendi_ctrl - fixed hend_heater - added workaround for typedDict and Python < v3.8 --- components/actor/heater_hendi.py | 2 +- components/actor/hendiCtrl.py | 9 ++++-- config.json.sim | 55 ++++++++++++++++++++++++++++++++ tracer.py | 6 +++- 4 files changed, 67 insertions(+), 5 deletions(-) mode change 100644 => 100755 components/actor/heater_hendi.py mode change 100644 => 100755 components/actor/hendiCtrl.py create mode 100755 config.json.sim mode change 100644 => 100755 tracer.py diff --git a/components/actor/heater_hendi.py b/components/actor/heater_hendi.py old mode 100644 new mode 100755 index df96fa7..520021f --- a/components/actor/heater_hendi.py +++ b/components/actor/heater_hendi.py @@ -18,7 +18,7 @@ class HeaterHendi(AHeater): def get_powers(self): caps = self.hendi.getCapabilties() - return [0].extend(caps['pwr_list']) + return [0] + caps['pwr_list'] def activate(self, enable): if enable: diff --git a/components/actor/hendiCtrl.py b/components/actor/hendiCtrl.py old mode 100644 new mode 100755 index 0c2c194..aa3e39b --- a/components/actor/hendiCtrl.py +++ b/components/actor/hendiCtrl.py @@ -22,8 +22,6 @@ class HendiCtrl: powers = [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300,3400, 3500] digits = [4092, 3840, 3700, 3440, 3300, 3060, 3000, 2930, 2860, 2780, 2640, 2510, 2430, 2360, 2190, 2130, 2030, 1980, 1880, 1730, 1630, 1560, 1480, 1400, 1240, 1150, 1150, 1080, 920, 740, 670] self.caps = { - "sw_id" : self.getSoftwareIdentifier(), - "sw_ver" : self.getSoftwareVersion(), "pwr_watts_min" : powers[0], "pwr_watts_max" : powers[-1], "pwr_list" : powers, @@ -124,7 +122,8 @@ class HendiCtrl: def getInfo(self): result = { - 'caps' : self.caps, + "sw_id" : self.getSoftwareIdentifier(), + "sw_ver" : self.getSoftwareVersion(), 'state' : self.getState(), 'pwr_digits' : self.getPowerDigits(), 'Switch_state' : self.getSwitch() @@ -188,6 +187,10 @@ if __name__ == '__main__': hendi.getState() hendi.getSoftwareIdentifier() hendi.getSoftwareVersion() + caps = hendi.getCapabilties() + print("Caps: ", caps) + info = hendi.getInfo() + print("Info: ", info) print("Test converters") for pwr in range(500, 3600, 100): diff --git a/config.json.sim b/config.json.sim new file mode 100755 index 0000000..5b6389c --- /dev/null +++ b/config.json.sim @@ -0,0 +1,55 @@ +{ + "Controller" : { + "dt": 0.1, + "sim_warp_factor": 10.0, + "stirrer_name": "sim", + "heater_name": "sim", + "sensor_name": "sim", + "plant_name": "sim", + "pid_type": "Smith" + }, + "TempCtrl": { + "Model": { + "theta": 20, + "C": 4190, + "M": 25, + "L": 0.05, + "Td": 80, + "kn": 0.2 + }, + "Kalman": { + "var_P" : 1.0, + "var_Q" : 0.0001, + "var_R" : 1.0 + }, + "Hold": { + "kp": 0.25, + "ki": 0.0, + "kd": 0.0, + "kt": 0.0 + }, + "Heat": { + "kp": 0.05, + "ki": 0.01, + "kd": 0.0, + "kt": 1.5 + } + }, + "Plant": { + "theta": 20, + "C": 4190, + "M": 22, + "L": 0.05, + "Td": 80, + "kn": 0.2 + }, + "Heater": { + "port": "/dev/ttyUSB0", + "speed": "115200" + }, + "Stirrer": { + "port": "/dev/ttyACM0", + "speed": "115200" + } +} + diff --git a/tracer.py b/tracer.py old mode 100644 new mode 100755 index 58aad7a..920af16 --- a/tracer.py +++ b/tracer.py @@ -1,8 +1,12 @@ -from typing import TypedDict import numpy as np import scipy.io import os +import sys import time +if sys.version_info[0] == 3 and sys.version_info[1] >= 8: + from typing import TypedDict +else: + from typing_extensions import TypedDict class Entry(TypedDict):