brbrain
Class PoseGUI

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.Box
                  extended by brbrain.GUI
                      extended by brbrain.PoseGUI
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
PoseSequenceGUI

public class PoseGUI
extends GUI

Dynamixel GUI component for a Pose.

Displays a table of all of the registers of all of the dynamixels in Pose. The registers are either in columns or rows depending on whether registerAxis is BoxLayout.Y_AXIS or BoxLayout.X_AXIS, respectively.

Dynamixels names are displayed (passing null for any or all dynamixel names uses default names generated from the dynamixel IDs), and register names and units are optionally displayed. The data for each register can be configured to display in either raw or natural units.

Each register may be editable and if so accepts and validates typing from the user.

The GUI further supports synchronization of the data with an BRBrain, either read-only (data in GUI updated to reflect current state of hardware) or read/write, using the write span of the pose.

Copyright (C) 2007 Marsette A. Vona, III

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Author:
Marsette (Marty) A. Vona, III
See Also:
Serialized Form

Nested Class Summary
protected  class PoseGUI.DynamixelBox
          displays a dynamixel name and PoseGUI.ValueBoxes
protected  class PoseGUI.RegisterNameBox
          shows register names and units
protected  class PoseGUI.ValueBox
          A box containing the numeric value of a dynamixel register, either in raw or natural units according to useNaturalUnits.
 
Nested classes/interfaces inherited from class brbrain.GUI
GUI.RemoveTask
 
Nested classes/interfaces inherited from class javax.swing.Box
javax.swing.Box.AccessibleBox, javax.swing.Box.Filler
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  int[] adcValue
          most recently read CM-5 raw ADC values
static int AUTO_SYNC_THREAD_GRANULARITY_MS
          update granularity of autoSyncThread
protected static java.util.List<PoseGUI> autoSyncAddList
          global auto sync add list
protected  BRBrain autoSyncBRBrain
          the BRBrain to auto sync, if any
protected  javax.swing.JCheckBox autoSyncCheckBox
          auto sync box
protected  boolean autoSyncEnableWrite
          whether to enable write in auto sync
protected  javax.swing.JCheckBox autoSyncEnableWriteCheckBox
          auto sync enable write box
protected static java.util.List<PoseGUI> autoSyncList
          global auto sync list
protected  java.lang.Object autoSyncLock
          lock for changing auto sync params
protected  int autoSyncMinUpdatePeriodMS
          min period of auto sync
protected  javax.swing.JTextField autoSyncMinUpdatePeriodMSField
          auto min update period field box
protected  boolean autoSyncSaveAndRestoreFormat
          whether to save and restore format in auto sync
protected  javax.swing.JCheckBox autoSyncSaveAndRestoreFormatsCheckBox
          auto sync save/restore formats box
protected  boolean autoSyncSetFormats
          whether to set format in auto sync
protected  javax.swing.JCheckBox autoSyncSetFormatsCheckBox
          auto sync set formats box
protected static java.lang.Thread autoSyncThread
          the auto sync daemon thread, if any
 int[] axIDs
          the set of dynamixelIDs; do not mutate
private static java.lang.String cvsid
           
static boolean DEF_SYNC_ENABLE_WRITE
          default for sync
static int DEF_SYNC_MIN_UPDATE_PERIOD_MS
          default for sync
static boolean DEF_SYNC_SAVE_AND_RESTORE_FORMAT
          default for sync
static boolean DEF_SYNC_SET_FORMAT
          default for sync
protected  BRBrain defSyncBRBrain
          default sync BRBrain
protected  boolean defSyncEnableWrite
          default sync enable write
protected  int defSyncMinUpdatePeriodMS
          default sync min update period
protected  boolean defSyncSaveAndRestoreFormats
          default sync save and restore formats
protected  boolean defSyncSetFormats
          default sync set formats
protected  PoseGUI.DynamixelBox[] dynamixelBoxes
          the PoseGUI.DynamixelBoxes
protected  java.lang.String[] dynamixelNames
          the names to display for each dynamixel
protected  javax.swing.JCheckBox enableWriteCheckBox
          manual sync enable write box
protected  javax.swing.JButton estopButton
          the estop button, if any
protected  java.text.DecimalFormat floatFormat
          format a float with two decimal digits
protected  int lastSyncStartTimeMS
          start time of latest sync
protected  int lastSyncTimeMS
          latest sync transaction duration
protected  int lastUpdatePeriodMS
          latest time between syncs
protected  javax.swing.JLabel negVoltageLabel
          negative battery voltage label
 int numDynamixels
          the number of dynamixels in pose
 int numRegisters
          the number of registers in pose
protected  int numSyncs
          total number of syncs so far
protected  Pose pose
          the Pose reference, synchronized by poseLock
protected  java.lang.Object poseLock
          lock for changing the pose reference
protected  javax.swing.JLabel posVoltageLabel
          positive battery voltage label
protected  int[] readAXIDSave
          saved read format dynamixel IDs
protected  int[] readLengthSave
          saved read format lengths
 int readNum
          the number of regs in the BRBrain read format
 AXRegister readStart
          the first reg in the BRBrain read format
protected  AXRegister[] readStartSave
          saved read format starts
static int REFRESH_PERIOD_MS
          gui refresh period
protected static java.util.List<PoseGUI> refreshList
          global gui refresh list
protected  java.lang.Object refreshLock
          lock for GUI update from pose
protected  boolean refreshPending
          whether a refresh is still waiting to happen
protected static java.lang.Thread refreshThread
          global gui refresh thread
protected  int registerAxis
          the axis along which registers are arrayed
protected  PoseGUI.RegisterNameBox registerNameBox
          the PoseGUI.RegisterNameBox, if any
 AXRegister[] registers
          the set of registers; do not mutate
protected  javax.swing.JCheckBox saveAndRestoreFormatsCheckBox
          manual sync save/restore formats box
protected  javax.swing.JCheckBox setFormatsCheckBox
          manual sync set formats box
static int STRUT
          component spacing
protected  javax.swing.JButton syncButton
          manual sync button
protected  int[] syncReadData
          BRBrain read block
protected  java.lang.String syncText
          text to display in sync label
protected  int[] syncWriteData
          BRBrain write block
protected  boolean syncWritePending
          whether a write should be done if enabled on the next sync
protected  javax.swing.JLabel thermLabel
          thermistor label
protected  java.util.Map<AXRegister,java.lang.Boolean> useNaturalUnits
          whether to use natural units for each register
static int VALUE_FIELD_HEIGHT
          height of PoseGUI.ValueBox fields
static int VALUE_FIELD_WIDTH
          width of PoseGUI.ValueBox fields
protected  java.util.Map<AXRegister,PoseGUI.ValueBox[]> valueBoxes
          PoseGUI.ValueBoxes indexed first by register then by dynamixel index
protected  int[] writeAXIDSave
          saved write format dynamixel IDs
protected  int[] writeLengthSave
          saved write format lengths
 int writeNum
          the number of regs in the BRBrain write format, or 0 if none
 AXRegister writeStart
          the first reg in the BRBrain write format, or null if none
protected  AXRegister[] writeStartSave
          saved write format starts
 
Fields inherited from class brbrain.GUI
lastFrame, MAX_SPLIT_LABEL_CHARS
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PoseGUI(int[] axIDs, AXRegister[] registers, AXRegister writeStart, int writeNum, int registerAxis, java.lang.String[] dynamixelNames, boolean showRegisterNames, boolean[] registerEditable, boolean enableShowEstop, boolean showADCs, boolean showManualSync, boolean showAutoSync)
          make a gui with a new Pose
PoseGUI(int[] axIDs, AXRegister[] registers, AXRegister writeStart, int writeNum, int registerAxis, java.lang.String[] dynamixelNames, boolean showRegisterNames, boolean editable, boolean enableShowEstop, boolean showADCs, boolean showManualSync, boolean showAutoSync)
          make a gui where everything is either editable or not
PoseGUI(int axID, AXRegister[] registers, AXRegister writeStart, int writeNum, int registerAxis, java.lang.String dynamixelName, boolean showRegisterNames, boolean editable, boolean enableShowEstop, boolean showADCs, boolean showManualSync, boolean showAutoSync)
          make a GUI for one dynamixel
PoseGUI(Pose pose, int registerAxis, java.lang.String[] dynamixelNames, boolean showRegisterNames, boolean[] registerEditable, boolean enableShowEstop, boolean showADCs, boolean showManualSync, boolean showAutoSync)
          make a gui for an existing Pose
 
Method Summary
protected  void addGUI(GUI gui)
          hook for adding the main gui
protected static void addToRefreshList(PoseGUI gui)
          add a gui to the global refresh list
 void autoSync()
          Covers autoSync(BRBrain, int, boolean, boolean, boolean), uses sync defaults.
 void autoSync(BRBrain brBrain)
          Covers autoSync(BRBrain, int, boolean, boolean, boolean), uses sync defaults.
 void autoSync(BRBrain brBrain, int minUpdatePeriodMS, boolean enableWrite, boolean setFormats, boolean saveAndRestoreFormat)
          Initiate or change automatic periodic synchronization of this GUI with the hardware via an BRBrain.
 void autoSync(int minUpdatePeriodMS)
          Covers autoSync(BRBrain, int, boolean, boolean, boolean), uses sync defaults.
protected static boolean[] consEditable(AXRegister[] registers, boolean editable)
          make up an editable array
protected  void didSync(Pose pose, BRBrain brBrain, boolean didWrite, boolean didRead, boolean setFormats, boolean savedAndRestoredFormat, int syncNum, long startTime, long duration)
          Hook called after each sync, while synchronized on refreshLock and pose.
 void doEstop()
          Attempt to estop all dynamixels that we know about.
 Pose getPose()
          Get a reference to the current pose, internally synchronized with setPose(brbrain.Pose).
 java.lang.String getSyncStats()
          Get a stats report on all sync(BRBrain, boolean, boolean, boolean) till now.
protected  void handleEditAutoSync()
          handle edits to the auto sync GUI
protected  void refresh()
          do actual gui refresh from within the AWT event thread
 void refreshFromPose()
          Schedule a refresh of the GUI from the curent data in pose.
protected static void removeFromRefreshList(PoseGUI gui)
          remove a gui from the global refresh list
 Pose setPose(Pose pose)
          Set pose.
 void setSyncDefaults(BRBrain defSyncBRBrain, int defSyncMinUpdatePeriodMS, boolean defSyncEnableWrite, boolean defSyncSetFormats, boolean defSyncSaveAndRestoreFormats)
          set default sync params
 void setSyncFormats(BRBrain brBrain)
          covers setSyncFormats(BRBrain, boolean), sets write format
 void setSyncFormats(BRBrain brBrain, boolean setWriteFormat)
          Set the read and optionally the write formats of brBrain to those of pose.
 void setUseNaturalUnits(AXRegister register, boolean enable)
          use natural units for the specified register
 void setUseNaturalUnits(boolean enable)
          use natural units for all registers
 void sync()
          Covers sync(BRBrain, boolean, boolean, boolean), uses sync defaults.
 void sync(BRBrain brBrain)
          Covers sync(BRBrain, boolean, boolean, boolean), uses sync defaults.
 void sync(BRBrain brBrain, boolean enableWrite, boolean setFormats, boolean saveAndRestoreFormat)
          Synchronize this GUI to the hardware via an BRBrain.
 void useAllLabelledNaturalUnits()
          Use natural units for all regs which specify an AXRegister.naturalUnitsLabel.
 
Methods inherited from class brbrain.GUI
addRemoveTask, addTitledBorder, addTitledBorder, dbgLayout, dbgLayout, makeSplitLabel, otherAxis, wrapInFrame, wrapInFrame
 
Methods inherited from class javax.swing.Box
createGlue, createHorizontalBox, createHorizontalGlue, createHorizontalStrut, createRigidArea, createVerticalBox, createVerticalGlue, createVerticalStrut, getAccessibleContext, paintComponent, setLayout
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cvsid

private static final java.lang.String cvsid
See Also:
Constant Field Values

DEF_SYNC_ENABLE_WRITE

public static final boolean DEF_SYNC_ENABLE_WRITE
default for sync

See Also:
Constant Field Values

DEF_SYNC_MIN_UPDATE_PERIOD_MS

public static final int DEF_SYNC_MIN_UPDATE_PERIOD_MS
default for sync

See Also:
Constant Field Values

DEF_SYNC_SET_FORMAT

public static final boolean DEF_SYNC_SET_FORMAT
default for sync

See Also:
Constant Field Values

DEF_SYNC_SAVE_AND_RESTORE_FORMAT

public static final boolean DEF_SYNC_SAVE_AND_RESTORE_FORMAT
default for sync

See Also:
Constant Field Values

VALUE_FIELD_WIDTH

public static final int VALUE_FIELD_WIDTH
width of PoseGUI.ValueBox fields

See Also:
Constant Field Values

VALUE_FIELD_HEIGHT

public static final int VALUE_FIELD_HEIGHT
height of PoseGUI.ValueBox fields

See Also:
Constant Field Values

STRUT

public static final int STRUT
component spacing

See Also:
Constant Field Values

REFRESH_PERIOD_MS

public static final int REFRESH_PERIOD_MS
gui refresh period

See Also:
Constant Field Values

refreshList

protected static final java.util.List<PoseGUI> refreshList
global gui refresh list


refreshLock

protected final java.lang.Object refreshLock
lock for GUI update from pose


poseLock

protected final java.lang.Object poseLock
lock for changing the pose reference


autoSyncLock

protected final java.lang.Object autoSyncLock
lock for changing auto sync params


pose

protected Pose pose
the Pose reference, synchronized by poseLock


axIDs

public final int[] axIDs
the set of dynamixelIDs; do not mutate


registers

public final AXRegister[] registers
the set of registers; do not mutate


readStart

public final AXRegister readStart
the first reg in the BRBrain read format


writeStart

public final AXRegister writeStart
the first reg in the BRBrain write format, or null if none


readNum

public final int readNum
the number of regs in the BRBrain read format


writeNum

public final int writeNum
the number of regs in the BRBrain write format, or 0 if none


numDynamixels

public final int numDynamixels
the number of dynamixels in pose


numRegisters

public final int numRegisters
the number of registers in pose


dynamixelNames

protected final java.lang.String[] dynamixelNames
the names to display for each dynamixel


useNaturalUnits

protected final java.util.Map<AXRegister,java.lang.Boolean> useNaturalUnits
whether to use natural units for each register


registerAxis

protected final int registerAxis
the axis along which registers are arrayed


refreshPending

protected boolean refreshPending
whether a refresh is still waiting to happen


syncWritePending

protected boolean syncWritePending
whether a write should be done if enabled on the next sync


valueBoxes

protected final java.util.Map<AXRegister,PoseGUI.ValueBox[]> valueBoxes
PoseGUI.ValueBoxes indexed first by register then by dynamixel index


dynamixelBoxes

protected final PoseGUI.DynamixelBox[] dynamixelBoxes
the PoseGUI.DynamixelBoxes


registerNameBox

protected final PoseGUI.RegisterNameBox registerNameBox
the PoseGUI.RegisterNameBox, if any


lastSyncStartTimeMS

protected int lastSyncStartTimeMS
start time of latest sync


lastSyncTimeMS

protected int lastSyncTimeMS
latest sync transaction duration


lastUpdatePeriodMS

protected int lastUpdatePeriodMS
latest time between syncs


numSyncs

protected int numSyncs
total number of syncs so far


syncWriteData

protected final int[] syncWriteData
BRBrain write block


syncReadData

protected final int[] syncReadData
BRBrain read block


writeAXIDSave

protected int[] writeAXIDSave
saved write format dynamixel IDs


readAXIDSave

protected int[] readAXIDSave
saved read format dynamixel IDs


writeStartSave

protected AXRegister[] writeStartSave
saved write format starts


readStartSave

protected AXRegister[] readStartSave
saved read format starts


writeLengthSave

protected int[] writeLengthSave
saved write format lengths


readLengthSave

protected int[] readLengthSave
saved read format lengths


AUTO_SYNC_THREAD_GRANULARITY_MS

public static final int AUTO_SYNC_THREAD_GRANULARITY_MS
update granularity of autoSyncThread

See Also:
Constant Field Values

autoSyncList

protected static final java.util.List<PoseGUI> autoSyncList
global auto sync list


autoSyncAddList

protected static final java.util.List<PoseGUI> autoSyncAddList
global auto sync add list


autoSyncBRBrain

protected BRBrain autoSyncBRBrain
the BRBrain to auto sync, if any


autoSyncMinUpdatePeriodMS

protected int autoSyncMinUpdatePeriodMS
min period of auto sync


autoSyncEnableWrite

protected boolean autoSyncEnableWrite
whether to enable write in auto sync


autoSyncSetFormats

protected boolean autoSyncSetFormats
whether to set format in auto sync


autoSyncSaveAndRestoreFormat

protected boolean autoSyncSaveAndRestoreFormat
whether to save and restore format in auto sync


estopButton

protected javax.swing.JButton estopButton
the estop button, if any


posVoltageLabel

protected javax.swing.JLabel posVoltageLabel
positive battery voltage label


negVoltageLabel

protected javax.swing.JLabel negVoltageLabel
negative battery voltage label


thermLabel

protected javax.swing.JLabel thermLabel
thermistor label


syncButton

protected javax.swing.JButton syncButton
manual sync button


enableWriteCheckBox

protected javax.swing.JCheckBox enableWriteCheckBox
manual sync enable write box


setFormatsCheckBox

protected javax.swing.JCheckBox setFormatsCheckBox
manual sync set formats box


saveAndRestoreFormatsCheckBox

protected javax.swing.JCheckBox saveAndRestoreFormatsCheckBox
manual sync save/restore formats box


autoSyncCheckBox

protected javax.swing.JCheckBox autoSyncCheckBox
auto sync box


autoSyncMinUpdatePeriodMSField

protected javax.swing.JTextField autoSyncMinUpdatePeriodMSField
auto min update period field box


autoSyncEnableWriteCheckBox

protected javax.swing.JCheckBox autoSyncEnableWriteCheckBox
auto sync enable write box


autoSyncSaveAndRestoreFormatsCheckBox

protected javax.swing.JCheckBox autoSyncSaveAndRestoreFormatsCheckBox
auto sync save/restore formats box


autoSyncSetFormatsCheckBox

protected javax.swing.JCheckBox autoSyncSetFormatsCheckBox
auto sync set formats box


defSyncBRBrain

protected BRBrain defSyncBRBrain
default sync BRBrain


defSyncMinUpdatePeriodMS

protected int defSyncMinUpdatePeriodMS
default sync min update period


defSyncEnableWrite

protected boolean defSyncEnableWrite
default sync enable write


defSyncSetFormats

protected boolean defSyncSetFormats
default sync set formats


defSyncSaveAndRestoreFormats

protected boolean defSyncSaveAndRestoreFormats
default sync save and restore formats


syncText

protected java.lang.String syncText
text to display in sync label


floatFormat

protected java.text.DecimalFormat floatFormat
format a float with two decimal digits


adcValue

protected int[] adcValue
most recently read CM-5 raw ADC values


autoSyncThread

protected static final java.lang.Thread autoSyncThread
the auto sync daemon thread, if any


refreshThread

protected static final java.lang.Thread refreshThread
global gui refresh thread

Constructor Detail

PoseGUI

public PoseGUI(Pose pose,
               int registerAxis,
               java.lang.String[] dynamixelNames,
               boolean showRegisterNames,
               boolean[] registerEditable,
               boolean enableShowEstop,
               boolean showADCs,
               boolean showManualSync,
               boolean showAutoSync)
make a gui for an existing Pose


PoseGUI

public PoseGUI(int[] axIDs,
               AXRegister[] registers,
               AXRegister writeStart,
               int writeNum,
               int registerAxis,
               java.lang.String[] dynamixelNames,
               boolean showRegisterNames,
               boolean[] registerEditable,
               boolean enableShowEstop,
               boolean showADCs,
               boolean showManualSync,
               boolean showAutoSync)
make a gui with a new Pose


PoseGUI

public PoseGUI(int[] axIDs,
               AXRegister[] registers,
               AXRegister writeStart,
               int writeNum,
               int registerAxis,
               java.lang.String[] dynamixelNames,
               boolean showRegisterNames,
               boolean editable,
               boolean enableShowEstop,
               boolean showADCs,
               boolean showManualSync,
               boolean showAutoSync)
make a gui where everything is either editable or not


PoseGUI

public PoseGUI(int axID,
               AXRegister[] registers,
               AXRegister writeStart,
               int writeNum,
               int registerAxis,
               java.lang.String dynamixelName,
               boolean showRegisterNames,
               boolean editable,
               boolean enableShowEstop,
               boolean showADCs,
               boolean showManualSync,
               boolean showAutoSync)
make a GUI for one dynamixel

Method Detail

handleEditAutoSync

protected void handleEditAutoSync()
handle edits to the auto sync GUI


addGUI

protected void addGUI(GUI gui)
hook for adding the main gui


consEditable

protected static boolean[] consEditable(AXRegister[] registers,
                                        boolean editable)
make up an editable array


setUseNaturalUnits

public void setUseNaturalUnits(AXRegister register,
                               boolean enable)
use natural units for the specified register


setUseNaturalUnits

public void setUseNaturalUnits(boolean enable)
use natural units for all registers


useAllLabelledNaturalUnits

public void useAllLabelledNaturalUnits()

Use natural units for all regs which specify an AXRegister.naturalUnitsLabel.


getSyncStats

public java.lang.String getSyncStats()

Get a stats report on all sync(BRBrain, boolean, boolean, boolean) till now.


setSyncFormats

public void setSyncFormats(BRBrain brBrain,
                           boolean setWriteFormat)
                    throws java.io.IOException,
                           java.lang.InterruptedException

Set the read and optionally the write formats of brBrain to those of pose.

Throws:
java.io.IOException
java.lang.InterruptedException

setSyncFormats

public void setSyncFormats(BRBrain brBrain)
                    throws java.io.IOException,
                           java.lang.InterruptedException
covers setSyncFormats(BRBrain, boolean), sets write format

Throws:
java.io.IOException
java.lang.InterruptedException

sync

public void sync(BRBrain brBrain,
                 boolean enableWrite,
                 boolean setFormats,
                 boolean saveAndRestoreFormat)
          throws java.io.IOException,
                 java.lang.InterruptedException

Synchronize this GUI to the hardware via an BRBrain.

The synchronization always includes a read of all the registers in this GUI from the hardware, and may optionally include a write of the registers in the pose write span to the hardware. If a write is incurred, it is done before the readback.

Internally synchronized with respect to pose, the GUI, and brBrain.

Parameters:
enableWrite - whether to even consider doing the write. Write will only actually be incurred if this is true and syncWritePending, which is set only when pose is changed by setPose(brbrain.Pose) or when the user has validly edited a value which is both writeable and editable.
setFormats - whether to setSyncFormats(BRBrain, boolean) before doing the transaction
saveAndRestoreFormat - whether to save and restore the current read write (if necessary) formats on the brBrain before and after doing the transaction
Throws:
java.io.IOException
java.lang.InterruptedException

didSync

protected void didSync(Pose pose,
                       BRBrain brBrain,
                       boolean didWrite,
                       boolean didRead,
                       boolean setFormats,
                       boolean savedAndRestoredFormat,
                       int syncNum,
                       long startTime,
                       long duration)

Hook called after each sync, while synchronized on refreshLock and pose.


sync

public void sync(BRBrain brBrain)
          throws java.io.IOException,
                 java.lang.InterruptedException

Covers sync(BRBrain, boolean, boolean, boolean), uses sync defaults.

Throws:
java.io.IOException
java.lang.InterruptedException

sync

public void sync()
          throws java.io.IOException,
                 java.lang.InterruptedException

Covers sync(BRBrain, boolean, boolean, boolean), uses sync defaults.

Throws:
java.io.IOException
java.lang.InterruptedException

setSyncDefaults

public void setSyncDefaults(BRBrain defSyncBRBrain,
                            int defSyncMinUpdatePeriodMS,
                            boolean defSyncEnableWrite,
                            boolean defSyncSetFormats,
                            boolean defSyncSaveAndRestoreFormats)
set default sync params


autoSync

public void autoSync(BRBrain brBrain,
                     int minUpdatePeriodMS,
                     boolean enableWrite,
                     boolean setFormats,
                     boolean saveAndRestoreFormat)

Initiate or change automatic periodic synchronization of this GUI with the hardware via an BRBrain.

sync(BRBrain, boolean, boolean, boolean) will be called by a daemon thread at the specified rate with the specified arguments.

Parameters:
brBrain - the BRBrain to sync, or null to disable auto sync
minUpdatePeriodMS - the minimum time in milliseconds between syncs, negative to disable auto sync

autoSync

public void autoSync(BRBrain brBrain)

Covers autoSync(BRBrain, int, boolean, boolean, boolean), uses sync defaults.


autoSync

public void autoSync(int minUpdatePeriodMS)

Covers autoSync(BRBrain, int, boolean, boolean, boolean), uses sync defaults.


autoSync

public void autoSync()

Covers autoSync(BRBrain, int, boolean, boolean, boolean), uses sync defaults.


getPose

public Pose getPose()

Get a reference to the current pose, internally synchronized with setPose(brbrain.Pose).


setPose

public Pose setPose(Pose pose)

Set pose.

Iff the new pose differs from the current one syncWritePending is set and refreshFromPose() is called after setting the new pose.

Internally synchronized with getPose(), sync(brbrain.BRBrain, boolean, boolean, boolean), and refreshFromPose().

Parameters:
pose - the new pose, not null, and must be same format as the current pose
Returns:
the old pose

addToRefreshList

protected static void addToRefreshList(PoseGUI gui)
add a gui to the global refresh list


removeFromRefreshList

protected static void removeFromRefreshList(PoseGUI gui)
remove a gui from the global refresh list


refreshFromPose

public void refreshFromPose()

Schedule a refresh of the GUI from the curent data in pose.

The refresh will occur at some later time from within the AWT event thread. Multiple scheduled refreshes will be coalesced.


refresh

protected void refresh()
do actual gui refresh from within the AWT event thread


doEstop

public void doEstop()

Attempt to estop all dynamixels that we know about.

This can succeed only if a default syncable BRBrain has been established by calling sync(brbrain.BRBrain, boolean, boolean, boolean), autoSync(brbrain.BRBrain, int, boolean, boolean, boolean), or setSyncDefaults(brbrain.BRBrain, int, boolean, boolean, boolean) prior to this call. That BRBrain is taken as the one on which to estop the dynamixels.

Our pose must contain either AX12Register.AX12_TORQUE_ENABLE or both AX12Register.AX12_GOAL_POSITION and AX12Register.AX12_PRESENT_POSITION.