Guten Morgen,
hier mal aktueller Stand:
[CODE lang="java" title="Gasübernahme"]/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Moka7Demo;
import java.awt.*;
import javax.swing.*;
import javax.imageio.*;
import java.io.*;
import java.net.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
*
*
*/
public class Gasübernahme extends javax.swing.JFrame {
public static Komponenten V_931AK01 = new Komponenten();
public static Komponenten V_931AK02 = new Komponenten();
public static Komponenten P_931I41= new Komponenten();
/**
* Creates new form Gasübernahme
*
*/
public Gasübernahme() {
initComponents();
try
{
BufferedImage image = ImageIO.read(new File("E:/VISU/Gasübernahme.png"));
}
catch (IOException e)
{
// log the exception
// re-throw if desired
}
init();
java.util.Timer timer = new java.util.Timer();
timer.scheduleAtFixedRate(new Aufgabe(this),10000,2000);
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel6 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jButton5 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel6.setText("931I42");
getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(940, 720, -1, -1));
jLabel5.setText("jLabel5");
getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 710, -1, -1));
jLabel4.setText("jLabel4");
getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 610, -1, -1));
jLabel3.setText("jLabel3");
getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 740, -1, -1));
jLabel1.setText("jLabel1");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 710, 100, -1));
jButton3.setText("931AK02");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(790, 560, -1, -1));
jButton4.setText("931AK01");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
getContentPane().add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 740, -1, -1));
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Moka7Demo/Gasübernahme.png"))); // NOI18N
jLabel2.setText("jLabel2");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, 1320, 770));
jButton5.setText("jButton3");
getContentPane().add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 500, -1, -1));
pack();
}// </editor-fold>
private void init()
{
// Ventile
V_931AK01.Kennung = "DB";
V_931AK01.db_nr= 111;
V_931AK01.adresse = 54;
V_931AK01.bit = 0;
V_931AK02.Kennung = "DB";
V_931AK02.db_nr= 111;
V_931AK02.adresse = 58;
V_931AK02.bit = 0;
// Drucksensor
// P_931I41
P_931I41.Kennung = "DB";
P_931I41.db_nr= 102;
P_931I41.adresse = 26;
}
public void Einlesen(){
// jLabel6.setText( String.valueOf(Read.Read_float( 102, 26)));
jLabel6.setText("dfgdfgga");
}
// 931AK01
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
if (V_931AK01.Anwahl){
V_931AK01.Anwahl = false;
Read.Write_Bit(V_931AK01.Anwahl, V_931AK01.db_nr, V_931AK01.adresse, V_931AK01.bit);
aktualisieren();
return;
}
if (!V_931AK01.Anwahl)
V_931AK01.Anwahl = true;
Read.Write_Bit(V_931AK01.Anwahl, V_931AK01.db_nr, V_931AK01.adresse, V_931AK01.bit);
aktualisieren();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
if (V_931AK02.Anwahl){
V_931AK02.Anwahl = false;
Read.Write_Bit(V_931AK02.Anwahl, V_931AK02.db_nr, V_931AK02.adresse, V_931AK02.bit);
aktualisieren();
return;
}
if (!V_931AK02.Anwahl)
V_931AK02.Anwahl = true;
Read.Write_Bit(V_931AK02.Anwahl, V_931AK02.db_nr, V_931AK02.adresse, V_931AK02.bit);
aktualisieren();
}
private void aktualisieren()
{
if (V_931AK02.Anwahl)
{
jButton3.setBackground(Color.green);
}
else
{
jButton3.setBackground(Color.LIGHT_GRAY);
}
if (V_931AK01.Anwahl)
{
jButton4.setBackground(Color.green);
}
else
{
jButton4.setBackground(Color.LIGHT_GRAY);
}
}
/**
* @param args the command line arguments
*/
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(Gasübernahme.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Gasübernahme.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Gasübernahme.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Gasübernahme.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 Gasübernahme().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
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;
// End of variables declaration
}
[/CODE]
[CODE lang="java" title="Aufgabe Klasse"]/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Moka7Demo;
import Moka7.S7;
import java.awt.Color;
import java.io.IOException;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.text.*;
import javax.swing.DefaultListModel;
/**
*
* @author
*/
public class Aufgabe extends TimerTask implements Runnable
{
private Gasübernahme gasübernahme;
private Gaszufuhr gaszufuhr;
public Aufgabe(Gasübernahme gasübernahme)
{
this.gasübernahme = gasübernahme;
}
public Aufgabe(Gaszufuhr gaszufuhr)
{
// this.gaszufuhr = gaszufuhr;
}
// hier die Daten lesen
public void Einlesen()
{
}
@Override
public void run() {
gasübernahme.Einlesen();
}
}[/CODE]