package InterfaceKit;
import com.phidgets.InterfaceKitPhidget;
import com.phidgets.PhidgetException;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import listeners.*;
public class InterfaceKit extends javax.swing.JFrame {
private static String runArgs[];
private InterfaceKitPhidget ifk;
private JCheckBox digiInArray[];
private JCheckBox digiOutArray[];
private JTextField sensorInArray[];
private IFKitAttachListener attach_listener;
private IFKitDetachListener detach_listener;
private IFKitErrorListener error_listener;
private IFKitInputChangeListener input_listener;
private IFKitOutputChangeListener output_listener;
private IFKitSensorChangeListener sensor_listener;
/** Creates new form InterfaceKit */
public InterfaceKit() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
attachedTxt = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
nameTxt = new javax.swing.JTextArea();
jLabel2 = new javax.swing.JLabel();
serialTxt = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
versionTxt = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
numDigiInTxt = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
numDigiOutTxt = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
numSensorTxt = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jCheckBox1 = new javax.swing.JCheckBox();
jCheckBox2 = new javax.swing.JCheckBox();
jCheckBox3 = new javax.swing.JCheckBox();
jCheckBox4 = new javax.swing.JCheckBox();
jCheckBox5 = new javax.swing.JCheckBox();
jCheckBox6 = new javax.swing.JCheckBox();
jCheckBox7 = new javax.swing.JCheckBox();
jCheckBox8 = new javax.swing.JCheckBox();
jCheckBox9 = new javax.swing.JCheckBox();
jCheckBox10 = new javax.swing.JCheckBox();
jCheckBox11 = new javax.swing.JCheckBox();
jCheckBox12 = new javax.swing.JCheckBox();
jCheckBox13 = new javax.swing.JCheckBox();
jCheckBox14 = new javax.swing.JCheckBox();
jCheckBox15 = new javax.swing.JCheckBox();
jCheckBox16 = new javax.swing.JCheckBox();
jPanel3 = new javax.swing.JPanel();
jCheckBox17 = new javax.swing.JCheckBox();
jCheckBox18 = new javax.swing.JCheckBox();
jCheckBox19 = new javax.swing.JCheckBox();
jCheckBox20 = new javax.swing.JCheckBox();
jCheckBox21 = new javax.swing.JCheckBox();
jCheckBox22 = new javax.swing.JCheckBox();
jCheckBox23 = new javax.swing.JCheckBox();
jCheckBox24 = new javax.swing.JCheckBox();
jCheckBox25 = new javax.swing.JCheckBox();
jCheckBox26 = new javax.swing.JCheckBox();
jCheckBox27 = new javax.swing.JCheckBox();
jCheckBox28 = new javax.swing.JCheckBox();
jCheckBox29 = new javax.swing.JCheckBox();
jCheckBox30 = new javax.swing.JCheckBox();
jCheckBox31 = new javax.swing.JCheckBox();
jCheckBox32 = new javax.swing.JCheckBox();
jPanel4 = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jTextField7 = new javax.swing.JTextField();
jTextField8 = new javax.swing.JTextField();
ratioChk = new javax.swing.JCheckBox();
jLabel8 = new javax.swing.JLabel();
sensitivityTxt = new javax.swing.JTextField();
sensitivityScrl = new javax.swing.JSlider();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("InterfaceKit - full");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("InterfaceKit Info"));
attachedTxt.setEditable(false);
jLabel1.setText("Attached:");
nameTxt.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground"));
nameTxt.setColumns(20);
nameTxt.setEditable(false);
nameTxt.setFont(new java.awt.Font("Tahoma", 0, 11));
nameTxt.setLineWrap(true);
nameTxt.setRows(3);
nameTxt.setTabSize(2);
nameTxt.setWrapStyleWord(true);
jScrollPane1.setViewportView(nameTxt);
jLabel2.setText("Name:");
serialTxt.setEditable(false);
jLabel3.setText("Serial No.:");
versionTxt.setEditable(false);
jLabel4.setText("Version:");
numDigiInTxt.setEditable(false);
jLabel5.setText("Digital Inputs:");
numDigiOutTxt.setEditable(false);
jLabel6.setText("Digital Outputs:");
numSensorTxt.setEditable(false);
jLabel7.setText("Analog Inputs:");
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel6)
.add(jLabel1)
.add(jLabel2)
.add(jLabel3)
.add(jLabel4)
.add(jLabel5)
.add(jLabel7))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, numSensorTxt)
.add(org.jdesktop.layout.GroupLayout.LEADING, numDigiOutTxt)
.add(org.jdesktop.layout.GroupLayout.LEADING, numDigiInTxt)
.add(org.jdesktop.layout.GroupLayout.LEADING, versionTxt)
.add(org.jdesktop.layout.GroupLayout.LEADING, serialTxt)
.add(org.jdesktop.layout.GroupLayout.LEADING, attachedTxt)
.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(attachedTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel1))
.add(15, 15, 15)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))
.add(16, 16, 16)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(serialTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))
.add(16, 16, 16)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(versionTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel4))
.add(15, 15, 15)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(numDigiInTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel5))
.add(15, 15, 15)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(numDigiOutTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel6))
.add(16, 16, 16)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(numSensorTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel7))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Digital In"));
jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox2.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox3.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox4.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox5.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox6.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox7.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox7.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox8.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox8.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox9.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox9.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox10.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox10.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox11.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox11.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox12.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox12.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox13.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox13.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox14.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox14.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox15.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox15.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox16.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox16.setMargin(new java.awt.Insets(0, 0, 0, 0));
org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.add(jCheckBox1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox4)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox5)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox6)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox7)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox8)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox9)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox10)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox11)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox12)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox13)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox14)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox15)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox16)
.addContainerGap(42, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jCheckBox16)
.add(jCheckBox15)
.add(jCheckBox14)
.add(jCheckBox13)
.add(jCheckBox12)
.add(jCheckBox11)
.add(jCheckBox10)
.add(jCheckBox9)
.add(jCheckBox8)
.add(jCheckBox7)
.add(jCheckBox6)
.add(jCheckBox5)
.add(jCheckBox4)
.add(jCheckBox3)
.add(jCheckBox2)
.add(jCheckBox1))
.addContainerGap(28, Short.MAX_VALUE))
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Digital Out"));
jCheckBox17.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox17.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox18.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox18.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox18.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox19.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox19.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox20.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox20.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox21.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox21.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox22.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox22.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox23.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox23.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox23.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox24.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox24.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox25.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox25.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox26.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox26.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox27.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox27.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox27.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox28.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox28.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox28.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox29.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox29.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox29.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox30.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox30.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox30.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox31.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox31.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox31.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
jCheckBox32.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox32.setMargin(new java.awt.Insets(0, 0, 0, 0));
jCheckBox32.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DigiOutCheckActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.add(jCheckBox17)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox18)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox19)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox20)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox21)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox22)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox23)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox24)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox25)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox26)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox27)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox28)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox29)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox30)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox31)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox32)
.addContainerGap(42, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jCheckBox32)
.add(jCheckBox31)
.add(jCheckBox30)
.add(jCheckBox29)
.add(jCheckBox28)
.add(jCheckBox27)
.add(jCheckBox26)
.add(jCheckBox25)
.add(jCheckBox24)
.add(jCheckBox23)
.add(jCheckBox22)
.add(jCheckBox21)
.add(jCheckBox20)
.add(jCheckBox19)
.add(jCheckBox18)
.add(jCheckBox17))
.addContainerGap(25, Short.MAX_VALUE))
);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Analog In"));
jTextField1.setEditable(false);
jTextField2.setEditable(false);
jTextField3.setEditable(false);
jTextField4.setEditable(false);
jTextField5.setEditable(false);
jTextField6.setEditable(false);
jTextField7.setEditable(false);
jTextField8.setEditable(false);
ratioChk.setText("Ratiometric");
ratioChk.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
ratioChk.setMargin(new java.awt.Insets(0, 0, 0, 0));
ratioChk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ratioChkActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4Layout.createSequentialGroup()
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(ratioChk))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(31, 31, 31)
.add(ratioChk)
.addContainerGap(41, Short.MAX_VALUE))
);
jLabel8.setText("Input Sensitivity");
sensitivityTxt.setEditable(false);
sensitivityScrl.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sensitivityScrlStateChanged(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(10, 10, 10)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, sensitivityTxt)
.add(org.jdesktop.layout.GroupLayout.LEADING, jLabel8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(sensitivityScrl, 0, 0, Short.MAX_VALUE))
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel8)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(sensitivityTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(14, 14, 14)
.add(sensitivityScrl, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
/**
* initialize the interfacekit object and hook the event listeners
**/
private void formWindowOpened(java.awt.event.WindowEvent evt) {
makeDigiInArray();
makeDigiOutArray();
makeSensorInArray();
this.ratioChk.setEnabled(false);
this.ratioChk.setSelected(false);
this.jLabel8.setVisible(false);
this.sensitivityTxt.setText("");
this.sensitivityTxt.setVisible(false);
this.sensitivityScrl.setEnabled(false);
this.sensitivityScrl.setVisible(false);
try {
ifk = new InterfaceKitPhidget();
attach_listener = new IFKitAttachListener(this, this.attachedTxt, this.nameTxt,
this.serialTxt, this.versionTxt, this.numDigiInTxt, this.numDigiOutTxt,
this.numSensorTxt, this.digiInArray, this.digiOutArray, this.sensorInArray,
this.ratioChk, this.jLabel8, this.sensitivityTxt, this.sensitivityScrl);
detach_listener = new IFKitDetachListener(this, this.attachedTxt, this.nameTxt,
this.serialTxt, this.versionTxt, this.numDigiInTxt, this.numDigiOutTxt,
this.numSensorTxt, this.digiInArray, this.digiOutArray, this.sensorInArray,
this.ratioChk, this.jLabel8, this.sensitivityTxt, this.sensitivityScrl);
error_listener = new IFKitErrorListener(this);
input_listener = new IFKitInputChangeListener(this, this.digiInArray);
output_listener = new IFKitOutputChangeListener(this, this.digiOutArray);
sensor_listener = new IFKitSensorChangeListener(this, this.sensorInArray);
ifk.addAttachListener(attach_listener);
ifk.addDetachListener(detach_listener);
ifk.addErrorListener(error_listener);
ifk.addInputChangeListener(input_listener);
ifk.addOutputChangeListener(output_listener);
ifk.addSensorChangeListener(sensor_listener);
//This assumes that if there is a command line argument, it is a serial number
//and we try to open that specific device. Otherwise, open any device.
if((runArgs.length > 1) && (runArgs[1].equals("remote")))
{
ifk.open(Integer.parseInt(runArgs[0]), null);
}
else if(runArgs.length > 0)
{
ifk.open(Integer.parseInt(runArgs[0]));
}
else
{
ifk.openAny();
}
} catch (PhidgetException ex) {
JOptionPane.showMessageDialog(this, ex.getDescription(), "Phidget Error" + ex.getErrorNumber(), JOptionPane.ERROR_MESSAGE);
}
}
/**
* Modify the digital ouputs... Each of the output checkboxes ActionPerformed
* events point to this one event handler, I use the source object from the
* Event arguements (the checkbox triggering the event) to get the checkbox
* that is changing. I then loop through and check which index in our
* output array corresponds to this checkbox object to determine wich output
* on the board this index represents.
**/
private void DigiOutCheckActionPerformed(java.awt.event.ActionEvent evt) {
JCheckBox outputChk = (JCheckBox)evt.getSource();
if(outputChk.isEnabled())
{
try
{
for(int i = 0; i < 16; i++)
{
if(digiOutArray[i].equals(outputChk))
{
ifk.setOutputState(i, digiOutArray[i].isSelected());
}
}
}
catch (PhidgetException ex)
{
JOptionPane.showMessageDialog(this, ex.getDescription(), "Phidget Error" + ex.getErrorNumber(), JOptionPane.ERROR_MESSAGE);
}
}
}
/**
* Modify the sensitivity of the analog inputs. In other words, the amount
* that the inputs must change between sensorchange events.
**/
private void sensitivityScrlStateChanged(javax.swing.event.ChangeEvent evt) {
if(sensitivityScrl.isEnabled())
{
try
{
if(sensitivityScrl.isEnabled() && ifk.isAttached())
{
for(int i = 0; i < ifk.getSensorCount(); i++)
{
ifk.setSensorChangeTrigger(i, sensitivityScrl.getValue());
}
sensitivityTxt.setText(Integer.toString(sensitivityScrl.getValue()));
}
}
catch(PhidgetException ex)
{
JOptionPane.showMessageDialog(this, ex.getDescription(), "Phidget Error" + ex.getErrorNumber(), JOptionPane.ERROR_MESSAGE);
}
}
}
private void ratioChkActionPerformed(java.awt.event.ActionEvent evt) {
if(ratioChk.isEnabled())
{
try
{
ifk.setRatiometric(ratioChk.isSelected());
}
catch (PhidgetException ex)
{
JOptionPane.showMessageDialog(this, ex.getDescription(), "Phidget Error" + ex.getErrorNumber(), JOptionPane.ERROR_MESSAGE);
}
}
}
/**
* When the application is terminating, close the Phidget.
**/
private void formWindowClosed(java.awt.event.WindowEvent evt) {
try
{
//unhook the event listeners
ifk.removeSensorChangeListener(sensor_listener);
ifk.removeOutputChangeListener(output_listener);
ifk.removeInputChangeListener(input_listener);
ifk.removeErrorListener(error_listener);
ifk.removeDetachListener(detach_listener);
ifk.removeAttachListener(attach_listener);
//close the phidget
ifk.close();
ifk = null;
dispose();
System.exit(0);
}
catch(PhidgetException ex)
{
JOptionPane.showMessageDialog(this, ex.getDescription(), "Phidget Error" + ex.getErrorNumber(), JOptionPane.ERROR_MESSAGE);
dispose();
System.exit(0);
}
}
/**
* this method creates the digital input array that corresponds to the
* group of checkboxes we are suing to represent the state of the digital
* inputs on the interface kit.
**/
private void makeDigiInArray()
{
digiInArray = new JCheckBox[16];
digiInArray[0] = jCheckBox1;
digiInArray[1] = jCheckBox2;
digiInArray[2] = jCheckBox3;
digiInArray[3] = jCheckBox4;
digiInArray[4] = jCheckBox5;
digiInArray[5] = jCheckBox6;
digiInArray[6] = jCheckBox7;
digiInArray[7] = jCheckBox8;
digiInArray[8] = jCheckBox9;
digiInArray[9] = jCheckBox10;
digiInArray[10] = jCheckBox11;
digiInArray[11] = jCheckBox12;
digiInArray[12] = jCheckBox13;
digiInArray[13] = jCheckBox14;
digiInArray[14] = jCheckBox15;
digiInArray[15] = jCheckBox16;
for(int i = 0; i < 16; i++)
{
digiInArray[i].setVisible(false);
digiInArray[i].setEnabled(false);
}
}
/**
* This method creates the digital output array that corresponds to the
* group of checkboxes we are using to represent the state of the digital
* outputs on the interface kit.
**/
private void makeDigiOutArray()
{
digiOutArray = new JCheckBox[16];
digiOutArray[0] = jCheckBox17;
digiOutArray[1] = jCheckBox18;
digiOutArray[2] = jCheckBox19;
digiOutArray[3] = jCheckBox20;
digiOutArray[4] = jCheckBox21;
digiOutArray[5] = jCheckBox22;
digiOutArray[6] = jCheckBox23;
digiOutArray[7] = jCheckBox24;
digiOutArray[8] = jCheckBox25;
digiOutArray[9] = jCheckBox26;
digiOutArray[10] = jCheckBox27;
digiOutArray[11] = jCheckBox28;
digiOutArray[12] = jCheckBox29;
digiOutArray[13] = jCheckBox30;
digiOutArray[14] = jCheckBox31;
digiOutArray[15] = jCheckBox32;
for(int i = 0; i < 16; i++)
{
digiOutArray[i].setVisible(false);
}
}
/**
* this method creates the analog input array (mst likelely connected to
* analog sensors) that corresponds to the group of textboxes which will
* be holding the current values of the analog inputs that are being sent
* to the interface kit.
**/
private void makeSensorInArray()
{
sensorInArray = new JTextField[8];
sensorInArray[0] = jTextField1;
sensorInArray[1] = jTextField2;
sensorInArray[2] = jTextField3;
sensorInArray[3] = jTextField4;
sensorInArray[4] = jTextField5;
sensorInArray[5] = jTextField6;
sensorInArray[6] = jTextField7;
sensorInArray[7] = jTextField8;
for(int i = 0; i < 8; i++)
{
sensorInArray[i].setVisible(false);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
runArgs = args;
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new InterfaceKit().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField attachedTxt;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox10;
private javax.swing.JCheckBox jCheckBox11;
private javax.swing.JCheckBox jCheckBox12;
private javax.swing.JCheckBox jCheckBox13;
private javax.swing.JCheckBox jCheckBox14;
private javax.swing.JCheckBox jCheckBox15;
private javax.swing.JCheckBox jCheckBox16;
private javax.swing.JCheckBox jCheckBox17;
private javax.swing.JCheckBox jCheckBox18;
private javax.swing.JCheckBox jCheckBox19;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JCheckBox jCheckBox20;
private javax.swing.JCheckBox jCheckBox21;
private javax.swing.JCheckBox jCheckBox22;
private javax.swing.JCheckBox jCheckBox23;
private javax.swing.JCheckBox jCheckBox24;
private javax.swing.JCheckBox jCheckBox25;
private javax.swing.JCheckBox jCheckBox26;
private javax.swing.JCheckBox jCheckBox27;
private javax.swing.JCheckBox jCheckBox28;
private javax.swing.JCheckBox jCheckBox29;
private javax.swing.JCheckBox jCheckBox3;
private javax.swing.JCheckBox jCheckBox30;
private javax.swing.JCheckBox jCheckBox31;
private javax.swing.JCheckBox jCheckBox32;
private javax.swing.JCheckBox jCheckBox4;
private javax.swing.JCheckBox jCheckBox5;
private javax.swing.JCheckBox jCheckBox6;
private javax.swing.JCheckBox jCheckBox7;
private javax.swing.JCheckBox jCheckBox8;
private javax.swing.JCheckBox jCheckBox9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextArea nameTxt;
private javax.swing.JTextField numDigiInTxt;
private javax.swing.JTextField numDigiOutTxt;
private javax.swing.JTextField numSensorTxt;
private javax.swing.JCheckBox ratioChk;
private javax.swing.JSlider sensitivityScrl;
private javax.swing.JTextField sensitivityTxt;
private javax.swing.JTextField serialTxt;
private javax.swing.JTextField versionTxt;
// End of variables declaration
}