forked from M-Labs/thermostat
Sync
This commit is contained in:
parent
2e8b26eb60
commit
83c14fb2de
@ -72,8 +72,9 @@ registerParameterType('mutex', MutexParameter)
|
|||||||
class WrappedClient(QObject, Client):
|
class WrappedClient(QObject, Client):
|
||||||
connection_error = pyqtSignal()
|
connection_error = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent):
|
async def start_session(self, *args, **kwargs):
|
||||||
super().__init__(parent)
|
await super().start_session(*args, **kwargs)
|
||||||
|
await self._sync_pwm_pid_limits()
|
||||||
|
|
||||||
async def _read_line(self):
|
async def _read_line(self):
|
||||||
try:
|
try:
|
||||||
@ -82,10 +83,24 @@ class WrappedClient(QObject, Client):
|
|||||||
logging.error("Client connection error, disconnecting", exc_info=True)
|
logging.error("Client connection error, disconnecting", exc_info=True)
|
||||||
self.connection_error.emit()
|
self.connection_error.emit()
|
||||||
|
|
||||||
async def _check_zero_limits(self):
|
async def _sync_pwm_pid_limits(self):
|
||||||
pwm_report = await self.get_pwm()
|
pwm_report = await self.get_pwm()
|
||||||
pid_report = await self.get_pid()
|
pid_report = await self.get_pid()
|
||||||
# TODO: Get pid output_max and max_i_pos synced. Same for min and neg.
|
for pwm_channel, pid_channel in zip(pwm_report, pid_report):
|
||||||
|
ch = pwm_channel['channel']
|
||||||
|
if (pwm_limit := pwm_channel['max_i_pos']['value']) != (pid_limit := pid_channel['parameters']['output_max']):
|
||||||
|
# Set the minimum of the 2
|
||||||
|
if pwm_limit < pid_limit:
|
||||||
|
await self.set_param('pid', ch, 'output_max', pwm_limit)
|
||||||
|
else:
|
||||||
|
await self.set_param('pwm', ch, 'max_i_pos', pid_limit)
|
||||||
|
|
||||||
|
if (pwm_limit := -pwm_channel['max_i_neg']['value']) != (pid_limit := pid_channel['parameters']['output_min']):
|
||||||
|
# Set the minimum of the 2
|
||||||
|
if pwm_limit < pid_limit:
|
||||||
|
await self.set_param('pid', ch, 'output_min', pwm_limit)
|
||||||
|
else:
|
||||||
|
await self.set_param('pwm', ch, 'max_i_neg', -pid_limit)
|
||||||
|
|
||||||
|
|
||||||
class ClientWatcher(QObject):
|
class ClientWatcher(QObject):
|
||||||
|
Loading…
Reference in New Issue
Block a user