version final de la Herramienta

parent 6f530cd8
/nbproject/private/
/build/
/dist/
\ No newline at end of file
annotation.processing.enabled=true annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list= annotation.processing.processors.list=
annotation.processing.run.all.processors=true annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=Reset_Cartucho
application.vendor=Usuario
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
build.classes.dir=${build.dir}/classes build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned: # This directory is removed when the project is cleaned:
...@@ -26,14 +28,17 @@ dist.archive.excludes= ...@@ -26,14 +28,17 @@ dist.archive.excludes=
dist.dir=dist dist.dir=dist
dist.jar=${dist.dir}/Reset_Cartucho.jar dist.jar=${dist.dir}/Reset_Cartucho.jar
dist.javadoc.dir=${dist.dir}/javadoc dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes= excludes=
file.reference.PanamaHitek_Arduino-3.0.3.jar=/home/alex/NetBeansProjects/PanamaHitek_Arduino-3.0.3.jar file.reference.PanamaHitek_Arduino-3.0.0.jar=C:\\Users\\Usuario\\Documents\\NetBeansProjects\\PanamaHitek_Arduino-3.0.0.jar
file.reference.rxtx-2.1.7.jar=/home/alex/NetBeansProjects/rxtx-2.1.7.jar file.reference.RXTXcomm.jar=C:\\Users\\Usuario\\Downloads\\RXTXcomm.jar
includes=** includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=false jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\ javac.classpath=\
${file.reference.PanamaHitek_Arduino-3.0.3.jar}:\ ${file.reference.RXTXcomm.jar}:\
${file.reference.rxtx-2.1.7.jar} ${file.reference.PanamaHitek_Arduino-3.0.0.jar}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false
...@@ -58,7 +63,24 @@ javadoc.splitindex=true ...@@ -58,7 +63,24 @@ javadoc.splitindex=true
javadoc.use=true javadoc.use=true
javadoc.version=false javadoc.version=false
javadoc.windowtitle= javadoc.windowtitle=
main.class=reset_cartucho.Reset_Cartucho jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
main.class=reset_cartucho.index
# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found.
manifest.custom.application.library.allowable.codebase=
# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts.
manifest.custom.caller.allowable.codebase=
# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed
manifest.custom.codebase=
# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions)
manifest.custom.permissions=
manifest.file=manifest.mf manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false mkdist.disabled=false
......
File added
...@@ -16,6 +16,8 @@ public class Reset_Cartucho { ...@@ -16,6 +16,8 @@ public class Reset_Cartucho {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
// TODO code application logic here // TODO code application logic here
index i = new index();
i.setVisible(true);
} }
} }
...@@ -45,29 +45,31 @@ ...@@ -45,29 +45,31 @@
<EmptySpace min="-2" pref="55" max="-2" attributes="0"/> <EmptySpace min="-2" pref="55" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="cbx_com" min="-2" pref="153" max="-2" attributes="0"/> <Component id="cbx_com" min="-2" pref="153" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
<Component id="txt_baudios" min="-2" pref="147" max="-2" attributes="0"/> <Component id="txt_baudios" min="-2" pref="147" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/> <EmptySpace min="-2" pref="200" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace pref="36" max="32767" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="43" max="-2" attributes="0"/> <EmptySpace min="-2" pref="43" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Component id="jScrollPane1" alignment="0" pref="400" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="btn_conectar" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chk_editar" min="-2" max="-2" attributes="0"/> <Component id="chk_editar" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/> <EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
</Group> </Group>
<Component id="scroll" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
...@@ -80,21 +82,27 @@ ...@@ -80,21 +82,27 @@
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="txt_baudios" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txt_baudios" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbx_com" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbx_com" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="chk_editar" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<EmptySpace type="unrelated" max="-2" attributes="0"/> <Component id="btn_conectar" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="126" max="32767" attributes="0"/> <Component id="chk_editar" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="scroll" min="-2" pref="144" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JTextField" name="txt_baudios"> <Component class="javax.swing.JTextField" name="txt_baudios">
<Events>
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txt_baudiosKeyPressed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabel1"> <Component class="javax.swing.JLabel" name="jLabel1">
<Properties> <Properties>
...@@ -114,14 +122,25 @@ ...@@ -114,14 +122,25 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btn_resetActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btn_resetActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="chk_editar"> <Component class="javax.swing.JComboBox" name="cbx_com">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Modificar"/> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties> </Properties>
<Events> <AuxValues>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chk_editarActionPerformed"/> <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</Events> </AuxValues>
</Component> </Component>
<Container class="javax.swing.JScrollPane" name="scroll">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1"> <Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues> <AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
...@@ -137,20 +156,23 @@ ...@@ -137,20 +156,23 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JComboBox" name="cbx_com"> </SubComponents>
</Container>
<Component class="javax.swing.JButton" name="btn_conectar">
<Properties> <Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <Property name="text" type="java.lang.String" value="Conectar"/>
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties> </Properties>
<AuxValues> <Events>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btn_conectarActionPerformed"/>
</AuxValues> </Events>
</Component>
<Component class="javax.swing.JButton" name="chk_editar">
<Properties>
<Property name="text" type="java.lang.String" value="Modificar"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chk_editarActionPerformed"/>
</Events>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
......
...@@ -9,6 +9,9 @@ import com.panamahitek.ArduinoException; ...@@ -9,6 +9,9 @@ import com.panamahitek.ArduinoException;
import com.panamahitek.PanamaHitek_Arduino; import com.panamahitek.PanamaHitek_Arduino;
import java.util.Enumeration; import java.util.Enumeration;
import gnu.io.CommPortIdentifier; import gnu.io.CommPortIdentifier;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
...@@ -29,14 +32,17 @@ public class index extends javax.swing.JFrame { ...@@ -29,14 +32,17 @@ public class index extends javax.swing.JFrame {
public void serialEvent(SerialPortEvent spe) { public void serialEvent(SerialPortEvent spe) {
try { try {
if (ino.isMessageAvailable()) { if (ino.isMessageAvailable()) {
txt_area.setText(ino.printMessage().toString()); txt_area.setText(txt_area.getText().toString() + ino.printMessage().toString() + "\n");
txt_area.setCaretPosition(txt_area.getDocument().getLength());
} }
} catch (SerialPortException ex) { } catch (SerialPortException ex) {
Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(par, "Ocurrió un error al establecer comunicación con el arduino", "ERROR", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(par, "Ocurrió un error al establecer comunicación con el arduino\nNo se puede obtener los datos del puerto Serial", "ERROR", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} catch (ArduinoException ex) { } catch (ArduinoException ex) {
Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(par, "Ocurrió un error al establecer comunicación con el arduino", "ERROR", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(par, "Ocurrió un error al establecer comunicación con el arduino\nNo se puede obtener los datos del puerto Serial", "ERROR", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} }
} }
}; };
...@@ -46,6 +52,16 @@ public class index extends javax.swing.JFrame { ...@@ -46,6 +52,16 @@ public class index extends javax.swing.JFrame {
*/ */
public index() { public index() {
initComponents(); initComponents();
btn_conectar.setAlignmentX(chk_editar.getAlignmentX());
btn_conectar.setAlignmentY(chk_editar.getAlignmentY());
btn_conectar.setVisible(false);
Dimension tamanhoTextArea = txt_area.getSize();
Point p = new Point(
0,
tamanhoTextArea.height);
scroll.getViewport().setViewPosition(p);
txt_area.setWrapStyleWord(true);
txt_area.setCaretPosition(txt_area.getDocument().getLength());
txt_baudios.setEnabled(false); txt_baudios.setEnabled(false);
txt_baudios.setText("115200"); txt_baudios.setText("115200");
cbx_com.removeAllItems(); cbx_com.removeAllItems();
...@@ -58,13 +74,17 @@ public class index extends javax.swing.JFrame { ...@@ -58,13 +74,17 @@ public class index extends javax.swing.JFrame {
} }
} }
if (!cbx_com.getSelectedItem().toString().isEmpty()) { if (cbx_com.getSelectedItem() != null && !cbx_com.getSelectedItem().toString().isEmpty()) {
try { try {
ino.arduinoRXTX(cbx_com.getSelectedItem().toString().toUpperCase().trim(), Integer.parseInt(txt_baudios.getText().trim()), listener); ino.arduinoRXTX(cbx_com.getSelectedItem().toString().toUpperCase().trim(), Integer.parseInt(txt_baudios.getText().trim()), listener);
} catch (ArduinoException ex) { } catch (ArduinoException ex) {
Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(par, "Ocurrió un error al establecer comunicación con el arduino", "ERROR", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(par, "Ocurrió un error al establecer comunicación con el arduino\nEl Puerto " + cbx_com.getSelectedItem().toString() + " puede estar en uso.", "ERROR", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} }
} else {
JOptionPane.showMessageDialog(par, "No hay Puertos para Listar", "ERROR", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} }
} }
...@@ -82,14 +102,22 @@ public class index extends javax.swing.JFrame { ...@@ -82,14 +102,22 @@ public class index extends javax.swing.JFrame {
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
btn_reset = new javax.swing.JButton(); btn_reset = new javax.swing.JButton();
chk_editar = new javax.swing.JCheckBox(); cbx_com = new javax.swing.JComboBox<>();
scroll = new javax.swing.JScrollPane();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
txt_area = new javax.swing.JTextArea(); txt_area = new javax.swing.JTextArea();
cbx_com = new javax.swing.JComboBox<>(); btn_conectar = new javax.swing.JButton();
chk_editar = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Resetear Cartucho"); setTitle("Resetear Cartucho");
txt_baudios.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txt_baudiosKeyPressed(evt);
}
});
jLabel1.setText("Puerto COM:"); jLabel1.setText("Puerto COM:");
jLabel2.setText("Baudios:"); jLabel2.setText("Baudios:");
...@@ -101,6 +129,21 @@ public class index extends javax.swing.JFrame { ...@@ -101,6 +129,21 @@ public class index extends javax.swing.JFrame {
} }
}); });
cbx_com.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
txt_area.setColumns(20);
txt_area.setRows(5);
jScrollPane1.setViewportView(txt_area);
scroll.setViewportView(jScrollPane1);
btn_conectar.setText("Conectar");
btn_conectar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_conectarActionPerformed(evt);
}
});
chk_editar.setText("Modificar"); chk_editar.setText("Modificar");
chk_editar.addActionListener(new java.awt.event.ActionListener() { chk_editar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
...@@ -108,12 +151,6 @@ public class index extends javax.swing.JFrame { ...@@ -108,12 +151,6 @@ public class index extends javax.swing.JFrame {
} }
}); });
txt_area.setColumns(20);
txt_area.setRows(5);
jScrollPane1.setViewportView(txt_area);
cbx_com.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.setHorizontalGroup(
...@@ -123,24 +160,26 @@ public class index extends javax.swing.JFrame { ...@@ -123,24 +160,26 @@ public class index extends javax.swing.JFrame {
.addComponent(btn_reset, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_reset, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(55, 55, 55)) .addGap(55, 55, 55))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(cbx_com, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbx_com, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txt_baudios, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txt_baudios, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(25, 25, 25) .addGap(200, 200, 200)
.addComponent(jLabel1) .addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
.addComponent(jLabel2) .addComponent(jLabel2)
.addGap(43, 43, 43))) .addGap(43, 43, 43)))
.addContainerGap()) .addContainerGap())
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(0, 0, Short.MAX_VALUE)
.addComponent(btn_conectar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chk_editar) .addComponent(chk_editar)
.addGap(42, 42, 42)) .addGap(40, 40, 40))
.addComponent(scroll)
); );
jPanel1Layout.setVerticalGroup( jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
...@@ -151,14 +190,16 @@ public class index extends javax.swing.JFrame { ...@@ -151,14 +190,16 @@ public class index extends javax.swing.JFrame {
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1) .addComponent(jLabel1)
.addComponent(jLabel2)) .addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txt_baudios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txt_baudios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbx_com, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(cbx_com, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chk_editar) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btn_conectar)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)) .addComponent(chk_editar))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(scroll, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
); );
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
...@@ -179,23 +220,40 @@ public class index extends javax.swing.JFrame { ...@@ -179,23 +220,40 @@ public class index extends javax.swing.JFrame {
private void btn_resetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_resetActionPerformed private void btn_resetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_resetActionPerformed
// TODO add your handling code here: // TODO add your handling code here:
try { try {
ino.sendData("10"); ino.sendByte(13);
} catch (ArduinoException e) { } catch (ArduinoException e) {
JOptionPane.showMessageDialog(par, "Ocurrió un error al enviar mensaje al arduino", "ERROR", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(par, "Ocurrió un error al enviar mensaje al arduino\nNo se puede enviar datos a través del puerto Serial", "ERROR", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} catch (SerialPortException ex) { } catch (SerialPortException ex) {
Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(par, "Ocurrió un error al enviar mensaje al arduino", "ERROR", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(par, "Ocurrió un error al enviar mensaje al arduino\nNo se puede enviar datos a través del puerto Serial", "ERROR", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} }
}//GEN-LAST:event_btn_resetActionPerformed }//GEN-LAST:event_btn_resetActionPerformed
private void btn_conectarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_conectarActionPerformed
// TODO add your handling code here:
reconnectPort();
}//GEN-LAST:event_btn_conectarActionPerformed
private void chk_editarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chk_editarActionPerformed private void chk_editarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chk_editarActionPerformed
// TODO add your handling code here: // TODO add your handling code here:
if (chk_editar.isSelected()) {
txt_baudios.setEnabled(true); txt_baudios.setEnabled(true);
} else { chk_editar.setVisible(false);
btn_conectar.setVisible(true);
}//GEN-LAST:event_chk_editarActionPerformed
private void txt_baudiosKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_baudiosKeyPressed
// TODO add your handling code here:
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
reconnectPort();
}
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
txt_baudios.setEnabled(false); txt_baudios.setEnabled(false);
chk_editar.setVisible(true);
btn_conectar.setVisible(false);
} }
}//GEN-LAST:event_chk_editarActionPerformed }//GEN-LAST:event_txt_baudiosKeyPressed
/** /**
* @param args the command line arguments * @param args the command line arguments
...@@ -233,14 +291,31 @@ public class index extends javax.swing.JFrame { ...@@ -233,14 +291,31 @@ public class index extends javax.swing.JFrame {
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btn_conectar;
private javax.swing.JButton btn_reset; private javax.swing.JButton btn_reset;
private javax.swing.JComboBox<String> cbx_com; private javax.swing.JComboBox<String> cbx_com;
private javax.swing.JCheckBox chk_editar; private javax.swing.JButton chk_editar;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane scroll;
private javax.swing.JTextArea txt_area; private javax.swing.JTextArea txt_area;
private javax.swing.JTextField txt_baudios; private javax.swing.JTextField txt_baudios;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
private void reconnectPort() {
chk_editar.setVisible(true);
btn_conectar.setVisible(false);
try {
ino.killArduinoConnection();
ino.arduinoRXTX(cbx_com.getSelectedItem().toString().toUpperCase().trim(), Integer.parseInt(txt_baudios.getText().trim()), listener);
JOptionPane.showMessageDialog(par, "Conexión reiniciada con el puerto " + cbx_com.getSelectedItem().toString().toUpperCase().trim() + " con " + Integer.parseInt(txt_baudios.getText().trim()) + " baudios", "INFORMACIÓN", JOptionPane.INFORMATION_MESSAGE);
} catch (ArduinoException ex) {
Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(par, "Ocurrió un error al establecer comunicación con el arduino\nEl Puerto " + cbx_com.getSelectedItem().toString() + " puede estar en uso.", "ERROR", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
txt_baudios.setEnabled(false);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment