Boa noite galera!
estou com um problema que nao consigo resolver.
package controle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.arduino.Comunicacao; AQUI TA MEU ERRO
public class Servico implements ActionListener {
Comunicacao com;
Controle controle;
public Servico(Controle controle, Comunicacao com) {
this.controle = controle;
this.com = com;
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(com.getDados());
String dados = com.getDados();
if (dados != null && dados.matches("\\d+ \\d+ \\d+ \\d+")) {
String[] valores = dados.split("\\s");
int s1 = Integer.parseInt(valores[0]);
int s2 = Integer.parseInt(valores[1]);
int s3 = Integer.parseInt(valores[2]);
int s4 = Integer.parseInt(valores[3]);
controle.processar(s1,s2, s3, s4);
}
}
}
MEU OUTRO PACOTE
package visao;
import controle.Controle;
import controle.Servico;
import javax.swing.ImageIcon;
import javax.swing.Timer;
import org.arduino.Comunicacao; // AQUI TA MEU ERRO
public class Tela extends javax.swing.JFrame implements Controle{
public Tela() {
initComponents();
timer.start();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setLayout(null);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/visao/vazio.png"))); // NOI18N
jPanel1.add(jLabel1);
jLabel1.setBounds(0, 0, 736, 680);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 738, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 679, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Tela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Tela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Tela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Tela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Tela().setVisible(true);
}
});
}
private Comunicacao com = new Comunicacao("COM33", 9600, 2000);
private Timer timer = new Timer(1000, new Servico(this, com));
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
// End of variables declaration
public void processar(int s1, int s2, int s3, int s4) {
System.out.println(s1 + " " + s2 + " " + s3 + " " + s4);
if (s1 == 1 & s2 == 0 & s3 == 0 & s4 ==0) {
System.out.println("BOMBA LIGADA");// cisterna recebendo agua da chuva
jLabel1.setIcon(new ImageIcon(getClass().getResource("/visao/gifativar.gif")));
com.escreverDados(1);
} else if (s1 == 1 & s2 == 1 & s3 == 0 & s4 ==0) {// s1==0 cisterna com agua e s2==0 caia dagua seca entao ligar bomba
com.escreverDados(1);
System.out.println("BOMBA LIGADA");
jLabel1.setIcon(new ImageIcon(getClass().getResource("/visao/gifativar.gif")));
} else if (s1 == 1 & s2 == 0 & s3 == 1 & s4 ==0) {// s1==0 cisterna com agua e s2==0 caia dagua seca entao ligar bomba
com.escreverDados(1);
System.out.println("BOMBA LIGADA");
jLabel1.setIcon(new ImageIcon(getClass().getResource("/visao/gifativar.gif")));
}
else if (s1 == 1 & s2 == 1 & s3 == 1 & s4 ==0) {// s1==0 cisterna com agua e s2==0 caia dagua seca entao ligar bomba
com.escreverDados(1);
System.out.println("BOMBA LIGADA");
jLabel1.setIcon(new ImageIcon(getClass().getResource("/visao/gifativar.gif")));
} else {
com.escreverDados(0);
jLabel1.setIcon(new ImageIcon(getClass().getResource("/visao/caixacheia.png")));
System.out.println("BOMBA DESLIGADA");
}
}
}