Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@DataChannel
def motion_mode(self, chan):
"""Current motion controller mode
1) Free
2) Coord
3) Teleop
To return the string in a status label::
status:motion_mode?string
:returns: current motion mode
:rtype: int, str
"""
return STAT.motion_mode
@DataChannel
def state(self, chan):
"""Current command execution status
1) Done
2) Exec
3) Error
To return the string in a status label::
status:state?string
:returns: current command execution state
:rtype: int, str
"""
return STAT.state
@DataChannel
def abs(self, chan, anum=-1):
"""The current absolute axis positions
To get a single axis pass string and the axis letter::
position:abs?string&axis=x
To get a tuple of all the axes pass only string::
position:abs?
:returns: current absolute axis positions
:rtype: tuple, str
"""
if anum == -1:
@DataChannel
def program_units(self, chan):
"""Program units
Available as an integer, or in short or long string formats.
1) in, Inches
2) mm, Millimeters
3) cm, Centimeters
To return the string in a status label::
status:program_units
status:program_units?string
status:program_units?string&format=long
:returns: current program units
@DataChannel
def error_message(self, chan):
return chan.value or ''
@DataChannel
def linear_units(self, chan):
"""Machine linear units
Available as float (units/mm), or in short or long string formats.
To return the string in a status label::
status:linear_units
status:linear_units?string
status:linear_units?string&format=long
:returns: machine linear units
:rtype: float, str
"""
return STAT.linear_units
@DataChannel
def gcodes(self, chan, fmt=None):
"""G-codes
active G-codes for each modal group
| syntax ``status:gcodes`` returns tuple of strings
| syntax ``status:gcodes?raw`` returns tuple of integers
| syntax ``status:gcodes?string`` returns str
"""
if fmt == 'raw':
return STAT.gcodes
return chan.value
try:
STAT.poll()
except:
pass
excluded_items = ['axis', 'joint', 'spindle', 'poll']
self.old = {}
# initialize data channels
for item in dir(STAT):
if item in self.channels:
self.old[item] = getattr(STAT, item)
self.channels[item].setValue(getattr(STAT, item))
elif item not in excluded_items and not item.startswith('_'):
self.old[item] = getattr(STAT, item)
chan = DataChannel(doc=item)
chan.setValue(getattr(STAT, item))
self.channels[item] = chan
setattr(self, item, chan)
# add joint status channels
self.joint = tuple(JointStatus(jnum) for jnum in range(9))
for joint in self.joint:
for chan, obj in joint.channels.items():
self.channels['joint.{}.{}'.format(joint.jnum, chan)] = obj
# add spindle status channels
self.spindle = tuple(SpindleStatus(snum) for snum in range(8))
for spindle in self.spindle:
for chan, obj in spindle.channels.items():
self.channels['spindle.{}.{}'.format(spindle.snum, chan)] = obj
@DataChannel
def task_state(self, chan, query=None):
"""Current status of task
1) E-Stop
2) Reset
3) Off
4) On
To return the string in a status label::
status:task_state?string
:returns: current task state
:rtype: int, str
"""
return STAT.task_state
@DataChannel
def exec_state(self, chan):
"""Current task execution state
1) Error
2) Done
3) Waiting for Motion
4) Waiting for Motion Queue
5) Waiting for Pause
6) --
7) Waiting for Motion and IO
8) Waiting for Delay
9) Waiting for system CMD
10) Waiting for spindle orient
To return the string in a status label::