From 6d76979ea4b4c6ca25da664d17a176c59420f31f Mon Sep 17 00:00:00 2001 From: Brendan Date: Sun, 8 Mar 2015 23:02:45 -0600 Subject: [PATCH] adds 'arm motor' button --- GroundStation/v2/ConnectionPanel.java | 4 ---- GroundStation/v2/GroundStation.java | 23 +++++++++++++++++++++-- GroundStation/v2/MotorTestPanel.java | 11 ++++++----- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/GroundStation/v2/ConnectionPanel.java b/GroundStation/v2/ConnectionPanel.java index cfd55c9..01af49c 100644 --- a/GroundStation/v2/ConnectionPanel.java +++ b/GroundStation/v2/ConnectionPanel.java @@ -143,10 +143,6 @@ class ConnectionPanel extends JPanel implements ActionListener { if( contentOut.getMotorsEnabled() ) out.print( "E " ); // enable motors (redundant) } } - /*if( contentOut.orientation ) { - for( int i = 0; i < contentOut.orientValues.length; i++ ) - out.print( "O" + i + "_" + contentOut.orientValues[i] + " " ); - }*/ out.println(); } diff --git a/GroundStation/v2/GroundStation.java b/GroundStation/v2/GroundStation.java index a018894..1dafa85 100644 --- a/GroundStation/v2/GroundStation.java +++ b/GroundStation/v2/GroundStation.java @@ -16,6 +16,9 @@ class GroundStation implements ActionListener { /** connection options section of window */ private ConnectionPanel connectPanel; + /** flight controller arm/disarm button*/ + private ArmButton arm; + /** tabbed pane to hold stuff */ private JTabbedPane tabbedPane; /** motor testing panel */ @@ -40,8 +43,9 @@ class GroundStation implements ActionListener { connectPanel.setEnabled( true ); mainWindow.getContentPane().add( connectPanel ); - JButton fcButton = new JButton( "arm" ); - mainWindow.getContentPane().add( fcButton ); + arm = new ArmButton( sendContent ); + arm.setEnabled( false ); + mainWindow.getContentPane().add( arm ); tabbedPane = new JTabbedPane(); mainWindow.getContentPane().add( tabbedPane ); @@ -67,11 +71,23 @@ class GroundStation implements ActionListener { public void disableMotors() { connectPanel.setEnabled( true ); + + arm.setEnabled( true ); + motorTestPanel.setEnabled( true ); + eStopWindow.dispose(); } public void enableMotors() { connectPanel.setEnabled( false ); + + if( motorTestPanel.getTestStatus() ) { + arm.setEnabled( false ); + } + else { + motorTestPanel.setEnabled( false ); + } + eStopWindow = new EStopWindow(); eStopWindow.addActionListener( this ); } @@ -79,15 +95,18 @@ class GroundStation implements ActionListener { public void actionPerformed( ActionEvent evt ) { if( evt.getSource() == eStopWindow ) { sendContent.setMotorsEnabled( false ); + arm.setText( "Arm Flight Controller" ); } if( evt.getSource() == connectPanel ) { if( evt.getActionCommand().equals( "CONNECT" ) ) { mainWindow.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); motorTestPanel.setEnabled( true ); + arm.setEnabled( true ); } else if( evt.getActionCommand().equals( "DISCONNECT" ) ) { mainWindow.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); motorTestPanel.setEnabled( false ); + arm.setEnabled( false ); } } else if( evt.getActionCommand().equals( "ENABLE_MOTORS" ) ) { diff --git a/GroundStation/v2/MotorTestPanel.java b/GroundStation/v2/MotorTestPanel.java index 2b1af87..e47be2e 100644 --- a/GroundStation/v2/MotorTestPanel.java +++ b/GroundStation/v2/MotorTestPanel.java @@ -79,10 +79,10 @@ class MotorTestPanel extends JPanel implements ActionListener { * */ public void setEnabled( boolean state ) { + checkBox.setEnabled( state ); if( !state ) { setTestStatus( false ); } - checkBox.setEnabled( state ); } /** @@ -90,7 +90,7 @@ class MotorTestPanel extends JPanel implements ActionListener { */ public void setTestStatus( boolean enable ) { checkBox.setSelected( enable ); - controlOutput.setMotorsEnabled( enable ); + if( checkBox.isEnabled() ) controlOutput.setMotorsEnabled( enable ); controlOutput.motorTesting = enable; if( !enable ) { masterSlider.setValue( 0 ); @@ -132,17 +132,18 @@ class MotorTestPanel extends JPanel implements ActionListener { } return; } - if( evt.getSource() == checkBox ) { + else if( evt.getSource() == checkBox ) { setTestStatus( checkBox.isSelected() ); return; } - if( evt.getSource() == masterSlider ) { + else if( evt.getSource() == masterSlider ) { slider0.setValue( Integer.parseInt( evt.getActionCommand() ) ); slider1.setValue( Integer.parseInt( evt.getActionCommand() ) ); slider2.setValue( Integer.parseInt( evt.getActionCommand() ) ); slider3.setValue( Integer.parseInt( evt.getActionCommand() ) ); } - fireActionPerformed(); + + if( evt.getSource() != controlOutput ) fireActionPerformed(); } ////////////////////////////////////////////