2016-09-06 16:49:11 +02:00
package org.hwo.pulscounter.ui ;
import java.awt.BorderLayout ;
import java.awt.EventQueue ;
import javax.swing.JFrame ;
import javax.swing.JPanel ;
import javax.swing.border.EmptyBorder ;
import javax.swing.event.ChangeEvent ;
import javax.swing.event.ChangeListener ;
2016-09-08 18:47:31 +02:00
import org.hwo.pulscounter.PulsCounterApplication ;
2016-09-15 16:52:11 +02:00
import org.hwo.pulscounter.device.IDeviceConnector ;
2016-09-06 16:49:11 +02:00
import org.hwo.servicelink.ServiceLink ;
2017-03-10 15:11:01 +01:00
import org.hwo.servicelink.exceptions.* ;
2016-09-06 16:49:11 +02:00
import java.awt.GridLayout ;
import javax.swing.JTabbedPane ;
import java.awt.GridBagLayout ;
import java.awt.GridBagConstraints ;
import javax.swing.JLabel ;
2016-11-17 16:37:45 +01:00
import javax.swing.JOptionPane ;
2016-09-06 16:49:11 +02:00
import java.awt.Insets ;
2016-11-17 16:37:45 +01:00
import java.awt.Dialog.ModalityType ;
2016-09-06 16:49:11 +02:00
import java.awt.Dimension ;
import javax.swing.JComboBox ;
2016-11-17 16:37:45 +01:00
import javax.swing.JDialog ;
2016-09-06 16:49:11 +02:00
import java.awt.event.ActionListener ;
import java.io.IOException ;
import java.math.BigInteger ;
2016-09-15 16:52:11 +02:00
import java.util.Arrays ;
2016-09-06 16:49:11 +02:00
import java.awt.event.ActionEvent ;
import javax.swing.JCheckBox ;
import javax.swing.JSpinner ;
import javax.swing.SpinnerNumberModel ;
import javax.swing.JButton ;
import org.hwo.bitfields.BitField ;
import org.hwo.bitfields.Field ;
import org.hwo.bitfields.ui.BitFieldEditor ;
2017-03-10 15:11:01 +01:00
import org.hwo.i18n.Messages ;
2016-09-06 16:49:11 +02:00
import org.hwo.models.TableMapper.TableColumn ;
import org.hwo.models.TableMapper.TableMapper ;
import org.hwo.ui.JTimeSpanEditor ;
import java.awt.event.FocusAdapter ;
import java.awt.event.FocusEvent ;
import javax.swing.JScrollPane ;
import javax.swing.JTable ;
2016-11-17 16:37:45 +01:00
public class DeviceConfiguration extends JDialog {
2016-09-06 16:49:11 +02:00
2016-09-15 16:52:11 +02:00
private JPanel contentPane ;
int currentChannel ;
private BitFieldEditor bfeIntervall ;
private JTimeSpanEditor tseI3 ;
private JTimeSpanEditor tseI2 ;
private JTimeSpanEditor tseI1 ;
private JTimeSpanEditor tseI0 ;
2016-09-06 16:49:11 +02:00
2016-09-15 16:52:11 +02:00
private TableMapper tmSettings ;
int outputs ,
pullups ,
inverts ,
trigger ;
int [ ] filter ,
2016-11-17 16:37:45 +01:00
windows ,
increments ;
2016-09-15 16:52:11 +02:00
private JTable tSettings ;
private IDeviceConnector deviceConnector ;
2016-11-17 16:37:45 +01:00
private JPanel pManagement ;
private JButton btnSnapshotSpeicherZurcksetzen ;
private JButton btnSnapshotSpeicherAuf ;
private JButton btnAlleZhlerLschen ;
2016-09-15 16:52:11 +02:00
/ * *
* Create the frame .
* /
public DeviceConfiguration ( IDeviceConnector deviceConnector ) {
this . deviceConnector = deviceConnector ;
2016-11-17 16:37:45 +01:00
setModalityType ( ModalityType . APPLICATION_MODAL ) ;
2016-09-15 16:52:11 +02:00
setDefaultCloseOperation ( JFrame . DISPOSE_ON_CLOSE ) ;
setBounds ( 100 , 100 , 860 , 498 ) ;
contentPane = new JPanel ( ) ;
contentPane . setBorder ( new EmptyBorder ( 5 , 5 , 5 , 5 ) ) ;
setContentPane ( contentPane ) ;
GridBagLayout gbl_contentPane = new GridBagLayout ( ) ;
gbl_contentPane . columnWidths = new int [ ] { 30 , 0 , 0 } ;
gbl_contentPane . rowHeights = new int [ ] { 183 , 0 } ;
gbl_contentPane . columnWeights = new double [ ] { 1.0 , 0.0 , 0.0 } ;
gbl_contentPane . rowWeights = new double [ ] { 1.0 , 0.0 } ;
contentPane . setLayout ( gbl_contentPane ) ;
JTabbedPane tabbedPane = new JTabbedPane ( JTabbedPane . TOP ) ;
GridBagConstraints gbc_tabbedPane = new GridBagConstraints ( ) ;
gbc_tabbedPane . gridwidth = 3 ;
gbc_tabbedPane . fill = GridBagConstraints . BOTH ;
gbc_tabbedPane . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_tabbedPane . gridx = 0 ;
gbc_tabbedPane . gridy = 0 ;
contentPane . add ( tabbedPane , gbc_tabbedPane ) ;
JPanel panel_2 = new JPanel ( ) ;
tabbedPane . addTab ( "Intervalle" , null , panel_2 , null ) ;
GridBagLayout gbl_panel_2 = new GridBagLayout ( ) ;
gbl_panel_2 . columnWidths = new int [ ] { 0 , 0 , 0 } ;
2016-10-06 10:57:31 +02:00
gbl_panel_2 . rowHeights = new int [ ] { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ;
2016-09-15 16:52:11 +02:00
gbl_panel_2 . columnWeights = new double [ ] { 0.0 , 1.0 , Double . MIN_VALUE } ;
2016-10-06 10:57:31 +02:00
gbl_panel_2 . rowWeights = new double [ ] { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , Double . MIN_VALUE } ;
2016-09-15 16:52:11 +02:00
panel_2 . setLayout ( gbl_panel_2 ) ;
bfeIntervall = new BitFieldEditor ( ) ;
2017-03-10 15:11:01 +01:00
bfeIntervall . setToolTipText ( Messages . getString ( "tooltip.tagesbasierte.intervalle" ) ) ; //"<html>\n<b>Tagesbasierte Intervalle</b><br/>\n<br/>\nTagesbasierte Intervalle werden immer auf 0:00:00 Uhr des aktuellen Tages bezogen ausgeführt.<br/>\nDies ermöglicht nicht nur eine Regelmäßige Aufzeichnung, sondern erzwingt auch eine Aufzeichnung<br/>\nin einem festgelegten immer gleichen Raster.<br/>\n<br/>\nNicht tageszeitbasierte Intervalle werden mit Bezug auf den 1.1.1970 0:00:00 Uhr ausgeführt.<br/>\nDiese ermöglichen eine stete regelmäßige Aufzeichnung bei der die tageszeit ignoriert wird.\n</html>");
2016-09-15 16:52:11 +02:00
bfeIntervall . addChangeListener ( new ChangeListener ( ) {
public void stateChanged ( ChangeEvent e ) {
int v = bfeIntervall . getIntValue ( ) ;
tseI0 . setDaysEnabled ( ( ( v & 0x01 ) = = 0 ) ) ;
tseI1 . setDaysEnabled ( ( ( v & 0x02 ) = = 0 ) ) ;
tseI2 . setDaysEnabled ( ( ( v & 0x04 ) = = 0 ) ) ;
tseI3 . setDaysEnabled ( ( ( v & 0x08 ) = = 0 ) ) ;
}
} ) ;
2017-03-10 15:11:01 +01:00
JLabel lblTageszeitabhngigkeit = new JLabel ( Messages . getString ( "Tageszeitabhängigkeit:" ) ) ;
2016-09-15 16:52:11 +02:00
GridBagConstraints gbc_lblTageszeitabhngigkeit = new GridBagConstraints ( ) ;
gbc_lblTageszeitabhngigkeit . fill = GridBagConstraints . HORIZONTAL ;
gbc_lblTageszeitabhngigkeit . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblTageszeitabhngigkeit . gridx = 0 ;
gbc_lblTageszeitabhngigkeit . gridy = 0 ;
panel_2 . add ( lblTageszeitabhngigkeit , gbc_lblTageszeitabhngigkeit ) ;
GridBagConstraints gbc_bfeIntervall = new GridBagConstraints ( ) ;
gbc_bfeIntervall . anchor = GridBagConstraints . NORTH ;
gbc_bfeIntervall . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_bfeIntervall . fill = GridBagConstraints . HORIZONTAL ;
gbc_bfeIntervall . gridx = 1 ;
gbc_bfeIntervall . gridy = 0 ;
panel_2 . add ( bfeIntervall , gbc_bfeIntervall ) ;
2017-03-10 15:11:01 +01:00
JLabel lblIntervall = new JLabel ( Messages . getString ( "Intervall 0:" ) ) ;
lblIntervall . setToolTipText ( Messages . getString ( "tooltip.intervall" ) ) ; // "<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
2016-09-15 16:52:11 +02:00
GridBagConstraints gbc_lblIntervall = new GridBagConstraints ( ) ;
gbc_lblIntervall . fill = GridBagConstraints . HORIZONTAL ;
gbc_lblIntervall . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblIntervall . gridx = 0 ;
gbc_lblIntervall . gridy = 1 ;
panel_2 . add ( lblIntervall , gbc_lblIntervall ) ;
tseI0 = new JTimeSpanEditor ( ) ;
2017-03-10 15:11:01 +01:00
tseI0 . setToolTipText ( Messages . getString ( "tooltip.intervall" ) ) ;
2016-09-15 16:52:11 +02:00
tseI0 . addFocusListener ( new FocusAdapter ( ) {
@Override
public void focusLost ( FocusEvent e ) {
}
} ) ;
GridBagConstraints gbc_tseI0 = new GridBagConstraints ( ) ;
gbc_tseI0 . anchor = GridBagConstraints . WEST ;
gbc_tseI0 . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_tseI0 . gridx = 1 ;
gbc_tseI0 . gridy = 1 ;
panel_2 . add ( tseI0 , gbc_tseI0 ) ;
2017-03-10 15:11:01 +01:00
JLabel lblIntervall_1 = new JLabel ( Messages . getString ( "Intervall 1:" ) ) ;
lblIntervall_1 . setToolTipText ( Messages . getString ( "tooltip.intervall" ) ) ;
2016-09-15 16:52:11 +02:00
GridBagConstraints gbc_lblIntervall_1 = new GridBagConstraints ( ) ;
gbc_lblIntervall_1 . fill = GridBagConstraints . HORIZONTAL ;
gbc_lblIntervall_1 . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblIntervall_1 . gridx = 0 ;
gbc_lblIntervall_1 . gridy = 2 ;
panel_2 . add ( lblIntervall_1 , gbc_lblIntervall_1 ) ;
tseI1 = new JTimeSpanEditor ( ) ;
2017-03-10 15:11:01 +01:00
tseI1 . setToolTipText ( Messages . getString ( "tooltip.intervall" ) ) ;
2016-09-15 16:52:11 +02:00
tseI1 . addFocusListener ( new FocusAdapter ( ) {
@Override
public void focusLost ( FocusEvent e ) {
}
} ) ;
GridBagConstraints gbc_tseI1 = new GridBagConstraints ( ) ;
gbc_tseI1 . anchor = GridBagConstraints . WEST ;
gbc_tseI1 . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_tseI1 . gridx = 1 ;
gbc_tseI1 . gridy = 2 ;
panel_2 . add ( tseI1 , gbc_tseI1 ) ;
2017-03-10 15:11:01 +01:00
JLabel lblIntervall_2 = new JLabel ( Messages . getString ( "Intervall 2:" ) ) ;
lblIntervall_2 . setToolTipText ( Messages . getString ( "tooltip.intervall" ) ) ;
2016-09-15 16:52:11 +02:00
GridBagConstraints gbc_lblIntervall_2 = new GridBagConstraints ( ) ;
gbc_lblIntervall_2 . fill = GridBagConstraints . HORIZONTAL ;
gbc_lblIntervall_2 . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblIntervall_2 . gridx = 0 ;
gbc_lblIntervall_2 . gridy = 3 ;
panel_2 . add ( lblIntervall_2 , gbc_lblIntervall_2 ) ;
tseI2 = new JTimeSpanEditor ( ) ;
2017-03-10 15:11:01 +01:00
tseI2 . setToolTipText ( Messages . getString ( "tooltip.intervall" ) ) ;
2016-09-15 16:52:11 +02:00
tseI2 . addFocusListener ( new FocusAdapter ( ) {
@Override
public void focusLost ( FocusEvent e ) {
}
} ) ;
GridBagConstraints gbc_tseI2 = new GridBagConstraints ( ) ;
gbc_tseI2 . anchor = GridBagConstraints . WEST ;
gbc_tseI2 . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_tseI2 . gridx = 1 ;
gbc_tseI2 . gridy = 3 ;
panel_2 . add ( tseI2 , gbc_tseI2 ) ;
2017-03-10 15:11:01 +01:00
JLabel lblIntervall_3 = new JLabel ( Messages . getString ( "Intervall 3:" ) ) ;
lblIntervall_3 . setToolTipText ( Messages . getString ( "tooltip.intervall" ) ) ;
2016-09-15 16:52:11 +02:00
GridBagConstraints gbc_lblIntervall_3 = new GridBagConstraints ( ) ;
gbc_lblIntervall_3 . fill = GridBagConstraints . HORIZONTAL ;
gbc_lblIntervall_3 . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblIntervall_3 . gridx = 0 ;
gbc_lblIntervall_3 . gridy = 4 ;
panel_2 . add ( lblIntervall_3 , gbc_lblIntervall_3 ) ;
tseI3 = new JTimeSpanEditor ( ) ;
2017-03-10 15:11:01 +01:00
tseI3 . setToolTipText ( Messages . getString ( "tooltip.intervall" ) ) ;
2016-09-15 16:52:11 +02:00
tseI3 . addFocusListener ( new FocusAdapter ( ) {
@Override
public void focusLost ( FocusEvent e ) {
}
} ) ;
GridBagConstraints gbc_tseI3 = new GridBagConstraints ( ) ;
gbc_tseI3 . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_tseI3 . anchor = GridBagConstraints . WEST ;
gbc_tseI3 . gridx = 1 ;
gbc_tseI3 . gridy = 4 ;
panel_2 . add ( tseI3 , gbc_tseI3 ) ;
JPanel panel_1 = new JPanel ( ) ;
tabbedPane . addTab ( "Kanäle" , null , panel_1 , null ) ;
GridBagLayout gbl_panel_1 = new GridBagLayout ( ) ;
gbl_panel_1 . columnWidths = new int [ ] { 100 } ;
gbl_panel_1 . rowHeights = new int [ ] { 30 } ;
gbl_panel_1 . columnWeights = new double [ ] { 1.0 } ;
gbl_panel_1 . rowWeights = new double [ ] { 1.0 } ;
panel_1 . setLayout ( gbl_panel_1 ) ;
JScrollPane scrollPane = new JScrollPane ( ) ;
GridBagConstraints gbc_scrollPane = new GridBagConstraints ( ) ;
gbc_scrollPane . fill = GridBagConstraints . BOTH ;
gbc_scrollPane . gridx = 0 ;
gbc_scrollPane . gridy = 0 ;
panel_1 . add ( scrollPane , gbc_scrollPane ) ;
tSettings = new JTable ( ) ;
tSettings . setRowHeight ( 32 ) ;
tSettings . setFillsViewportHeight ( true ) ;
tSettings . setCellSelectionEnabled ( true ) ;
scrollPane . setViewportView ( tSettings ) ;
2016-11-17 16:37:45 +01:00
pManagement = new JPanel ( ) ;
tabbedPane . addTab ( "Speicherverwaltung" , null , pManagement , null ) ;
GridBagLayout gbl_pManagement = new GridBagLayout ( ) ;
gbl_pManagement . columnWidths = new int [ ] { 100 } ;
gbl_pManagement . rowHeights = new int [ ] { 25 , 0 , 0 , 0 , 0 } ;
gbl_pManagement . columnWeights = new double [ ] { 1.0 } ;
gbl_pManagement . rowWeights = new double [ ] { 0.0 , 0.0 , 0.0 , 0.0 , Double . MIN_VALUE } ;
pManagement . setLayout ( gbl_pManagement ) ;
2017-03-10 15:11:01 +01:00
btnAlleZhlerLschen = new JButton ( Messages . getString ( "Alle Zähler zurücksetzen" ) ) ;
2016-11-17 16:37:45 +01:00
btnAlleZhlerLschen . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
resetCounters ( ) ;
}
} ) ;
GridBagConstraints gbc_btnAlleZhlerLschen_1_1 = new GridBagConstraints ( ) ;
gbc_btnAlleZhlerLschen_1_1 . fill = GridBagConstraints . HORIZONTAL ;
gbc_btnAlleZhlerLschen_1_1 . gridx = 0 ;
gbc_btnAlleZhlerLschen_1_1 . gridy = 0 ;
gbc_btnAlleZhlerLschen_1_1 . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
pManagement . add ( btnAlleZhlerLschen , gbc_btnAlleZhlerLschen_1_1 ) ;
2017-03-10 15:11:01 +01:00
JLabel lblNurNachRcksprache = new JLabel ( Messages . getString ( "Nur nach Rücksprache mit Support:" ) ) ;
2016-11-17 16:37:45 +01:00
GridBagConstraints gbc_lblNurNachRcksprache = new GridBagConstraints ( ) ;
gbc_lblNurNachRcksprache . fill = GridBagConstraints . HORIZONTAL ;
gbc_lblNurNachRcksprache . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_lblNurNachRcksprache . gridx = 0 ;
gbc_lblNurNachRcksprache . gridy = 1 ;
pManagement . add ( lblNurNachRcksprache , gbc_lblNurNachRcksprache ) ;
2017-03-10 15:11:01 +01:00
btnSnapshotSpeicherZurcksetzen = new JButton ( Messages . getString ( "SnapShot Speicher zurücksetzen" ) ) ;
2016-11-17 16:37:45 +01:00
btnSnapshotSpeicherZurcksetzen . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
resetSnapShots ( ) ;
}
} ) ;
2017-03-10 15:11:01 +01:00
btnSnapshotSpeicherAuf = new JButton ( Messages . getString ( "SnapShot Speicher auf letzten bekannten SnapShot setzen" ) ) ;
2016-11-17 16:37:45 +01:00
btnSnapshotSpeicherAuf . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
resetSnapShots ( true ) ;
}
} ) ;
GridBagConstraints gbc_btnSnapshotSpeicherAuf_1_1 = new GridBagConstraints ( ) ;
gbc_btnSnapshotSpeicherAuf_1_1 . fill = GridBagConstraints . HORIZONTAL ;
gbc_btnSnapshotSpeicherAuf_1_1 . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_btnSnapshotSpeicherAuf_1_1 . gridx = 0 ;
gbc_btnSnapshotSpeicherAuf_1_1 . gridy = 2 ;
pManagement . add ( btnSnapshotSpeicherAuf , gbc_btnSnapshotSpeicherAuf_1_1 ) ;
GridBagConstraints gbc_btnSnapshotSpeicherZurcksetzen_1_1 = new GridBagConstraints ( ) ;
gbc_btnSnapshotSpeicherZurcksetzen_1_1 . fill = GridBagConstraints . HORIZONTAL ;
gbc_btnSnapshotSpeicherZurcksetzen_1_1 . gridx = 0 ;
gbc_btnSnapshotSpeicherZurcksetzen_1_1 . gridy = 3 ;
pManagement . add ( btnSnapshotSpeicherZurcksetzen , gbc_btnSnapshotSpeicherZurcksetzen_1_1 ) ;
2017-03-10 15:11:01 +01:00
JButton btnSchliessen = new JButton ( Messages . getString ( "Cancel" ) ) ;
2016-09-15 16:52:11 +02:00
btnSchliessen . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
setVisible ( false ) ;
}
} ) ;
2017-03-10 15:11:01 +01:00
JButton btnOk = new JButton ( Messages . getString ( "OK" ) ) ;
2016-09-15 16:52:11 +02:00
btnOk . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
writeDevice ( ) ;
setVisible ( false ) ;
}
} ) ;
GridBagConstraints gbc_btnOk = new GridBagConstraints ( ) ;
gbc_btnOk . fill = GridBagConstraints . BOTH ;
gbc_btnOk . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_btnOk . gridx = 1 ;
gbc_btnOk . gridy = 1 ;
contentPane . add ( btnOk , gbc_btnOk ) ;
GridBagConstraints gbc_btnSchliessen = new GridBagConstraints ( ) ;
gbc_btnSchliessen . fill = GridBagConstraints . BOTH ;
gbc_btnSchliessen . gridx = 2 ;
gbc_btnSchliessen . gridy = 1 ;
contentPane . add ( btnSchliessen , gbc_btnSchliessen ) ;
this . initialize ( ) ;
}
private Integer intOr0 ( Integer i ) {
if ( i = = null )
return 0 ;
return i ;
}
private void initialize ( ) {
currentChannel = - 1 ;
filter = new int [ 32 ] ;
windows = new int [ 32 ] ;
2016-11-17 16:37:45 +01:00
increments = new int [ 32 ] ;
2016-09-15 16:52:11 +02:00
tmSettings = new TableMapper ( ChannelConfiguration . class , tSettings ) ;
BitField bf = new BitField ( ) ;
bf . clear ( ) ;
2017-03-10 15:11:01 +01:00
bf . addField ( new Field ( bf , 0 , 1 , Messages . getString ( "Intervall 0 basiert auf Tageszeit" ) ) ) ;
bf . addField ( new Field ( bf , 1 , 1 , Messages . getString ( "Intervall 1 basiert auf Tageszeit" ) ) ) ;
bf . addField ( new Field ( bf , 2 , 1 , Messages . getString ( "Intervall 2 basiert auf Tageszeit" ) ) ) ;
bf . addField ( new Field ( bf , 3 , 1 , Messages . getString ( "Intervall 3 basiert auf Tageszeit" ) ) ) ;
2016-09-15 16:52:11 +02:00
bfeIntervall . setBitField ( bf ) ;
for ( int i = 0 ; i < 32 ; i + + ) {
tmSettings . addRow ( new ChannelConfiguration ( i ) ) ;
}
readDevice ( ) ;
}
private void resetSnapShots ( ) {
2016-11-17 16:37:45 +01:00
resetSnapShots ( false ) ;
2016-10-06 10:57:31 +02:00
}
private void resetSnapShots ( boolean toLastKnown ) {
2017-03-10 15:11:01 +01:00
if ( JOptionPane . showConfirmDialog ( null ,
Messages . getString ( "<html>Diese Funktion sollte nur auf Aufforderung durch den Support ausgeführt werden.<br/>Soll der Snapshot Index auf dem Gerät wirklich zurückgesetzt werden?</html>" ) ,
Messages . getString ( "Snapshot Index zurücksetzen" ) ,
JOptionPane . YES_NO_OPTION ) = = JOptionPane . YES_OPTION ) {
2016-11-17 16:37:45 +01:00
deviceConnector . reset ( toLastKnown ? PulsCounterApplication . getApplication ( ) . getDatabase ( ) . highestSnapShot ( deviceConnector . getDeviceSerial ( ) ) : - 1 ) ;
}
2016-09-15 16:52:11 +02:00
}
private void resetCounters ( ) {
2016-11-17 16:37:45 +01:00
2017-03-10 15:11:01 +01:00
if ( JOptionPane . showConfirmDialog ( null ,
Messages . getString ( "Wollen Sie wirklich alle Zählerstände auf 0 zurücksetzen?" ) ,
Messages . getString ( "Alle Zählerstände zurücksetzen" ) ,
JOptionPane . YES_NO_OPTION ) = = JOptionPane . YES_OPTION ) {
2016-11-17 16:37:45 +01:00
int [ ] zero = new int [ 32 ] ;
Arrays . fill ( zero , 0 ) ;
deviceConnector . setCounters ( zero ) ;
}
2016-09-15 16:52:11 +02:00
}
private void readDevice ( ) {
Integer v ;
outputs = intOr0 ( deviceConnector . getConfigOutputs ( ) ) ;
pullups = intOr0 ( deviceConnector . getConfigPullups ( ) ) ;
inverts = intOr0 ( deviceConnector . getConfigInverts ( ) ) ;
2016-11-17 16:37:45 +01:00
trigger = intOr0 ( deviceConnector . getConfigTriggers ( ) ) ;
2016-09-15 16:52:11 +02:00
bfeIntervall . setIntValue ( deviceConnector . getDailyBaseMask ( ) ) ;
filter = deviceConnector . getDebounce ( ) ;
windows = deviceConnector . getWindows ( ) ;
2016-11-17 16:37:45 +01:00
increments = deviceConnector . getIncrements ( ) ;
2016-09-15 16:52:11 +02:00
2017-08-24 18:01:41 +02:00
Integer iv0 = deviceConnector . getInterval ( 0 ) ;
tseI0 . setValue ( iv0 = = 0 ? null : iv0 ) ;
Integer iv1 = deviceConnector . getInterval ( 0 ) ;
tseI1 . setValue ( iv1 = = 0 ? null : iv1 ) ;
Integer iv2 = deviceConnector . getInterval ( 0 ) ;
tseI2 . setValue ( iv2 = = 0 ? null : iv2 ) ;
Integer iv3 = deviceConnector . getInterval ( 0 ) ;
tseI3 . setValue ( iv3 = = 0 ? null : iv3 ) ;
2016-09-15 16:52:11 +02:00
}
private void writeDevice ( ) {
deviceConnector . setInterval ( 0 , tseI0 . getValue ( ) , ( ( bfeIntervall . getIntValue ( ) & ( 1 < < 0 ) ) ! = 0 ) ? true : false ) ;
deviceConnector . setInterval ( 1 , tseI1 . getValue ( ) , ( ( bfeIntervall . getIntValue ( ) & ( 1 < < 1 ) ) ! = 0 ) ? true : false ) ;
deviceConnector . setInterval ( 2 , tseI2 . getValue ( ) , ( ( bfeIntervall . getIntValue ( ) & ( 1 < < 2 ) ) ! = 0 ) ? true : false ) ;
deviceConnector . setInterval ( 3 , tseI3 . getValue ( ) , ( ( bfeIntervall . getIntValue ( ) & ( 1 < < 3 ) ) ! = 0 ) ? true : false ) ;
deviceConnector . setConfigOutputs ( outputs ) ;
deviceConnector . setConfigPullups ( pullups ) ;
deviceConnector . setConfigInverts ( inverts ) ;
deviceConnector . setConfigTriggers ( trigger ) ;
deviceConnector . setDebounce ( filter ) ;
deviceConnector . setWindows ( windows ) ;
2016-11-17 16:37:45 +01:00
deviceConnector . setIncrements ( increments ) ;
2016-09-15 16:52:11 +02:00
deviceConnector . syncConfigToLive ( ) ;
}
class ChannelConfiguration {
int channel ;
public ChannelConfiguration ( int channel ) {
this . channel = channel ;
}
2016-11-17 16:37:45 +01:00
@TableColumn ( label = "Kanal" , width = 60 , order = 0 , format = "%02d" )
2016-09-15 16:52:11 +02:00
public int getChannel ( ) {
return channel ;
}
@TableColumn ( label = "Ausgang" , width = 80 , order = 10 )
public Boolean getOutput ( ) {
return ( outputs & 1 < < channel ) = = 0 ? false : true ;
}
public void setOutput ( Boolean value ) {
outputs & = ~ ( 1 < < channel ) ;
if ( value ) {
outputs | = ( 1 < < channel ) ;
}
}
@TableColumn ( label = "Passiver Schalter" , width = 80 , order = 20 )
public Boolean getPullup ( ) {
return ( pullups & 1 < < channel ) = = 0 ? false : true ;
}
public void setPullup ( Boolean value ) {
pullups & = ~ ( 1 < < channel ) ;
if ( value ) {
pullups | = ( 1 < < channel ) ;
}
}
@TableColumn ( label = "Invertiert" , width = 80 , order = 30 )
public Boolean getInvert ( ) {
return ( inverts & 1 < < channel ) = = 0 ? false : true ;
}
public void setInvert ( Boolean value ) {
inverts & = ~ ( 1 < < channel ) ;
if ( value ) {
inverts | = ( 1 < < channel ) ;
}
}
@TableColumn ( label = "Löst Snapshot aus" , width = 80 , order = 40 )
public Boolean getTrigger ( ) {
return ( trigger & 1 < < channel ) = = 0 ? false : true ;
}
public void setTrigger ( Boolean value ) {
trigger & = ~ ( 1 < < channel ) ;
if ( value ) {
trigger | = ( 1 < < channel ) ;
}
}
@TableColumn ( label = "Signalfenster" , width = 80 , order = 200 )
public Integer getWindow ( ) {
return windows [ channel ] ;
}
public void setWindow ( Integer value ) {
windows [ channel ] = value ;
}
@TableColumn ( label = "Signalfilter" , width = 80 , order = 210 )
public Integer getFilter ( ) {
return filter [ channel ] ;
}
public void setFilter ( Integer value ) {
filter [ channel ] = value ;
}
2016-11-17 16:37:45 +01:00
@TableColumn ( label = "Inkrement" , width = 80 , order = 190 )
public Integer getIncrement ( ) {
return increments [ channel ] ;
}
public void setIncrement ( Integer increment ) {
increments [ channel ] = increment ;
}
2016-09-15 16:52:11 +02:00
}
}