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:
parent
b30bd308a9
commit
e98f81a7c9
@ -419,6 +419,8 @@ class Module(HasAccessibles):
|
|||||||
def announceUpdate(self, pname, value=None, err=None, timestamp=None):
|
def announceUpdate(self, pname, value=None, err=None, timestamp=None):
|
||||||
"""announce a changed value or readerror"""
|
"""announce a changed value or readerror"""
|
||||||
pobj = self.parameters[pname]
|
pobj = self.parameters[pname]
|
||||||
|
timestamp = timestamp or time.time()
|
||||||
|
changed = pobj.value != value or timestamp > (pobj.timestamp or 0) + 1
|
||||||
if value is not None:
|
if value is not None:
|
||||||
pobj.value = value # store the value even in case of error
|
pobj.value = value # store the value even in case of error
|
||||||
if err:
|
if err:
|
||||||
@ -431,7 +433,9 @@ class Module(HasAccessibles):
|
|||||||
pobj.value = pobj.datatype(value)
|
pobj.value = pobj.datatype(value)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err = secop_error(e)
|
err = secop_error(e)
|
||||||
pobj.timestamp = timestamp or time.time()
|
if not changed:
|
||||||
|
return # experimental: do not update unchanged values within 1 sec
|
||||||
|
pobj.timestamp = timestamp
|
||||||
pobj.readerror = err
|
pobj.readerror = err
|
||||||
if pobj.export:
|
if pobj.export:
|
||||||
self.DISPATCHER.announce_update(self.name, pname, pobj)
|
self.DISPATCHER.announce_update(self.name, pname, pobj)
|
||||||
|
@ -116,28 +116,37 @@ class DPM3(HasIodev, Drivable):
|
|||||||
|
|
||||||
def read_value(self):
|
def read_value(self):
|
||||||
value = float(self._iodev.communicate('*1B1'))
|
value = float(self._iodev.communicate('*1B1'))
|
||||||
if self._target is not None:
|
mot = self._motor
|
||||||
mot = self._motor
|
if self._target is None:
|
||||||
if self._direction * (self._target - value) > 0:
|
if mot.isBusy():
|
||||||
if not mot.isBusy():
|
self.status = self.Status.IDLE, 'stopping'
|
||||||
step = self.step * self._direction
|
else:
|
||||||
mot.write_target(mot.value + step)
|
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:
|
else:
|
||||||
print(value)
|
|
||||||
self.stop()
|
self.stop()
|
||||||
self.status = self.Status.IDLE, 'target reached'
|
self.status = self.Status.IDLE, 'target reached'
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def write_target(self, target):
|
def write_target(self, target):
|
||||||
self._target = target
|
self._target = target
|
||||||
|
self._started = True
|
||||||
if target - self.value > 0:
|
if target - self.value > 0:
|
||||||
self._direction = 1
|
self._direction = 1
|
||||||
else:
|
else:
|
||||||
self._direction = -1
|
self._direction = -1
|
||||||
print('direction', self._direction)
|
|
||||||
self.status = self.Status.BUSY, 'moving motor'
|
self.status = self.Status.BUSY, 'moving motor'
|
||||||
if self._motor.status[0] == self.Status.ERROR:
|
if self._motor.status[0] == self.Status.ERROR:
|
||||||
self._motor.reset()
|
self._motor.reset()
|
||||||
|
self._mot_target = self._motor.target
|
||||||
return target
|
return target
|
||||||
|
|
||||||
@Command()
|
@Command()
|
||||||
|
@ -81,7 +81,7 @@ class Motor(PersistentMixin, HasIodev, Drivable):
|
|||||||
# TupleOf(IntRange(0, 15), IntRange(0, 15)),
|
# TupleOf(IntRange(0, 15), IntRange(0, 15)),
|
||||||
# default=(8, 0))
|
# default=(8, 0))
|
||||||
|
|
||||||
value = Parameter('motor position', FloatRange(unit='deg', fmtstr='%.3f'))
|
value = Parameter('motor position', FloatRange(unit='deg', fmtstr='%.3f'), poll=False, default=0) # polling by read_status
|
||||||
zero = PersistentParam('zero point', FloatRange(unit='$'), readonly=False, default=0)
|
zero = PersistentParam('zero point', FloatRange(unit='$'), readonly=False, default=0)
|
||||||
encoder = HwParam('encoder reading', FloatRange(unit='$', fmtstr='%.1f'),
|
encoder = HwParam('encoder reading', FloatRange(unit='$', fmtstr='%.1f'),
|
||||||
209, ANGLE_SCALE, readonly=True, initwrite=False, persistent=True)
|
209, ANGLE_SCALE, readonly=True, initwrite=False, persistent=True)
|
||||||
@ -124,7 +124,8 @@ class Motor(PersistentMixin, HasIodev, Drivable):
|
|||||||
|
|
||||||
|
|
||||||
iodevClass = BytesIO
|
iodevClass = BytesIO
|
||||||
fast_pollfactor = 0.001 # poll as fast as possible when busy
|
# fast_pollfactor = 0.001 # poll as fast as possible when busy
|
||||||
|
fast_pollfactor = 0.05
|
||||||
_started = 0
|
_started = 0
|
||||||
_calcTimeout = True
|
_calcTimeout = True
|
||||||
_need_reset = None
|
_need_reset = None
|
||||||
@ -400,6 +401,7 @@ class Motor(PersistentMixin, HasIodev, Drivable):
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
self.comm(MOTOR_STOP, 0)
|
self.comm(MOTOR_STOP, 0)
|
||||||
self.status = self.Status.IDLE, 'stopped'
|
self.status = self.Status.IDLE, 'stopped'
|
||||||
|
self.target = self.value # indicate to customers that this was stopped
|
||||||
self._started = 0
|
self._started = 0
|
||||||
|
|
||||||
#@Command()
|
#@Command()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user