Skip to content

Commit

Permalink
BUG: positions - fix report actual and commanded pos settings
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtJacobson committed Feb 18, 2019
1 parent 75ecf09 commit a4e2284
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions qtpyvcp/plugins/positions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,19 @@

class Position(DataPlugin):
"""Positions Plugin"""
def __init__(self, report_actual_pos=True, use_program_units=True,
def __init__(self, report_actual_pos=False, use_program_units=True,
metric_format='%9.3f', imperial_format='%8.4f'):
super(Position, self).__init__()

self._report_actual_pos = report_actual_pos
self._report_actual_pos = False
self._use_program_units = use_program_units
self._metric_format = metric_format
self._imperial_format = imperial_format

self._current_format = self._imperial_format

self.report_actual_pos = report_actual_pos

self._update()

# all these should cause the positions to update
Expand Down Expand Up @@ -189,30 +191,30 @@ def dtg(self, chan, anum):
return self._current_format % chan.value[anum]

@property
def report_actual(self):
def report_actual_pos(self):
"""Whether to report the actual position. Default True."""
return self._report_actual_pos

@report_actual.setter
def report_actual(self, report_actual_pos):
@report_actual_pos.setter
def report_actual_pos(self, report_actual_pos):
if report_actual_pos == self._report_actual_pos:
return
self._report_actual_pos = report_actual_pos

if self._report_actual_pos:
# disconnect commanded pos update signals
STATUS.position.valueChanged.disconect(self.axis._update)
STATUS.joint_position.valueChanged.disconnect(self.joint._update)
# STATUS.joint_position.valueChanged.disconnect(self.joint._update)
# connect actual pos update signals
STATUS.actual_position.valueChanged.connect(self.axis._update)
STATUS.joint_actual_position.valueChanged.connect(self.joint._update)
# STATUS.joint_actual_position.valueChanged.connect(self.joint._update)
else:
# disconnect actual pos update signals
STATUS.actual_position.valueChanged.disconnect(self.axis._update)
STATUS.joint_actual_position.valueChanged.disconnect(self.joint._update)
# STATUS.joint_actual_position.valueChanged.disconnect(self.joint._update)
# connect commanded pos update signals
STATUS.position.valueChanged.connect(self.axis._update)
STATUS.joint_position.valueChanged.connect(self.joint._update)
# STATUS.joint_position.valueChanged.connect(self.joint._update)

def _update(self):

Expand Down Expand Up @@ -240,14 +242,11 @@ def _update(self):
for axis in INFO.AXIS_NUMBER_LIST:
rel[axis] -= g92_offset[axis]

if STAT.program_units != MACHINE_UNITS:
if STAT.program_units != MACHINE_UNITS and self._use_program_units:
pos = [pos[anum] * CONVERSION_FACTORS[anum] for anum in range(9)]
rel = [rel[anum] * CONVERSION_FACTORS[anum] for anum in range(9)]
dtg = [dtg[anum] * CONVERSION_FACTORS[anum] for anum in range(9)]

# self._positions = tuple([tuple(pos), tuple(rel), tuple(dtg)])
# self.valueChanged.emit(self._positions)

self.rel.setValue(tuple(rel))
self.abs.setValue(tuple(pos))
self.dtg.setValue(tuple(dtg))

0 comments on commit a4e2284

Please # to comment.