reduce communication traffic

- expermental change: no updates of unchanged values within 1 sec
- reduce fast_pollfactor in trinamic
- improve stop behaviour of dpm.DPM
This commit is contained in:
2021-09-21 16:40:54 +02:00
parent b30bd308a9
commit e98f81a7c9
3 changed files with 26 additions and 11 deletions

View File

@ -116,28 +116,37 @@ class DPM3(HasIodev, Drivable):
def read_value(self):
value = float(self._iodev.communicate('*1B1'))
if self._target is not None:
mot = self._motor
if self._direction * (self._target - value) > 0:
if not mot.isBusy():
step = self.step * self._direction
mot.write_target(mot.value + step)
mot = self._motor
if self._target is None:
if mot.isBusy():
self.status = self.Status.IDLE, 'stopping'
else:
self.status = self.Status.IDLE, ''
else:
if self._direction * (self._target - value) > 0:
if self._mot_target != mot.target:
self.stop()
self.status = self.Status.IDLE, 'motor was stopped'
elif not mot.isBusy():
step = self.step * self._direction
mot_target = mot.value + step
self._mot_target = mot.write_target(mot_target)
else:
print(value)
self.stop()
self.status = self.Status.IDLE, 'target reached'
return value
def write_target(self, target):
self._target = target
self._started = True
if target - self.value > 0:
self._direction = 1
else:
self._direction = -1
print('direction', self._direction)
self.status = self.Status.BUSY, 'moving motor'
if self._motor.status[0] == self.Status.ERROR:
self._motor.reset()
self._mot_target = self._motor.target
return target
@Command()