2015-05-05 16:05:22 +02:00
package org.hwo.pulscounter.ui ;
import java.awt.BorderLayout ;
2016-09-06 16:49:11 +02:00
import java.awt.Component ;
2015-05-05 16:05:22 +02:00
import java.awt.EventQueue ;
2016-09-06 16:49:11 +02:00
import javax.swing.JDialog ;
2015-05-05 16:05:22 +02:00
import javax.swing.JFrame ;
import javax.swing.JPanel ;
import javax.swing.border.EmptyBorder ;
import java.awt.Dialog.ModalExclusionType ;
import javax.swing.JTabbedPane ;
import java.awt.GridBagLayout ;
import java.awt.GridBagConstraints ;
import javax.swing.JLabel ;
import java.awt.Insets ;
import javax.swing.JTextField ;
import javax.swing.JButton ;
2016-09-06 16:49:11 +02:00
import org.hwo.csv.CSV ;
2015-05-05 16:05:22 +02:00
import org.hwo.io.SerialPort ;
2016-09-06 16:49:11 +02:00
import org.hwo.io.NewSerialPort.NewSerialPort ;
2016-09-08 18:47:31 +02:00
import org.hwo.pulscounter.PulsCounterApplication ;
2016-09-06 16:49:11 +02:00
import org.hwo.pulscounter.SnapShot ;
import org.hwo.servicelink.ServiceLink ;
import org.hwo.servicelink.ServiceLinkException ;
import org.hwo.servicelink.ServiceLinkRequestFailedException ;
import org.hwo.ui.dialog.SerialPortChooser ;
2015-05-05 16:05:22 +02:00
import java.awt.event.ActionListener ;
2016-09-06 16:49:11 +02:00
import java.io.ByteArrayOutputStream ;
import java.io.File ;
import java.io.FileOutputStream ;
import java.io.IOException ;
import java.io.PrintStream ;
import java.text.SimpleDateFormat ;
import java.util.Calendar ;
import java.util.Date ;
import java.util.Hashtable ;
import java.util.Timer ;
import java.util.TimerTask ;
2015-05-05 16:05:22 +02:00
import java.awt.event.ActionEvent ;
2016-09-06 16:49:11 +02:00
import java.awt.Dialog.ModalityType ;
import javax.swing.border.TitledBorder ;
import javax.swing.JSpinner ;
import javax.swing.JEditorPane ;
import javax.swing.JScrollPane ;
2016-09-13 10:53:46 +02:00
import java.awt.event.WindowAdapter ;
import java.awt.event.WindowEvent ;
2015-05-05 16:05:22 +02:00
2016-09-06 16:49:11 +02:00
public class AppSettingsFrame extends JDialog {
2015-05-05 16:05:22 +02:00
private JPanel contentPane ;
private JTextField tfInterface ;
2016-09-06 16:49:11 +02:00
private NewSerialPort selectedSerialPort , formerSerialPort ;
private JTextField timeComputer ;
private JTextField timeSynololog ;
private JSpinner spTrimm ;
2015-05-05 16:05:22 +02:00
2016-09-06 16:49:11 +02:00
private Timer timer ;
private Calendar calendar = Calendar . getInstance ( ) ;
private SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ;
private JTabbedPane tabbedPane ;
private JPanel debugPanel ;
private JLabel lHeapDec ;
private JLabel lHeapHex ;
private JLabel lSStackDec ;
private JLabel lSStackHex ;
private JEditorPane msgExc ;
2015-05-05 16:05:22 +02:00
/ * *
* Create the frame .
* /
public AppSettingsFrame ( ) {
2016-09-13 10:53:46 +02:00
addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosed ( WindowEvent e ) {
timer . cancel ( ) ;
}
} ) ;
2016-09-06 16:49:11 +02:00
setModalityType ( ModalityType . APPLICATION_MODAL ) ;
setModal ( true ) ;
2015-05-05 16:05:22 +02:00
setTitle ( "Einstellungen" ) ;
setDefaultCloseOperation ( JFrame . DISPOSE_ON_CLOSE ) ;
setBounds ( 100 , 100 , 603 , 447 ) ;
contentPane = new JPanel ( ) ;
contentPane . setBorder ( new EmptyBorder ( 5 , 5 , 5 , 5 ) ) ;
contentPane . setLayout ( new BorderLayout ( 0 , 0 ) ) ;
setContentPane ( contentPane ) ;
2016-09-06 16:49:11 +02:00
tabbedPane = new JTabbedPane ( JTabbedPane . TOP ) ;
2015-05-05 16:05:22 +02:00
contentPane . add ( tabbedPane , BorderLayout . CENTER ) ;
JPanel panel = new JPanel ( ) ;
tabbedPane . addTab ( "Kommunikation" , null , panel , null ) ;
tabbedPane . setEnabledAt ( 0 , true ) ;
GridBagLayout gbl_panel = new GridBagLayout ( ) ;
gbl_panel . columnWidths = new int [ ] { 0 , 0 , 0 , 0 } ;
gbl_panel . rowHeights = new int [ ] { 0 , 0 , 0 , 0 } ;
gbl_panel . columnWeights = new double [ ] { 0.0 , 1.0 , 0.0 , Double . MIN_VALUE } ;
gbl_panel . rowWeights = new double [ ] { 0.0 , 0.0 , 0.0 , Double . MIN_VALUE } ;
panel . setLayout ( gbl_panel ) ;
JLabel lblSchnittstelle = new JLabel ( "Schnittstelle:" ) ;
GridBagConstraints gbc_lblSchnittstelle = new GridBagConstraints ( ) ;
gbc_lblSchnittstelle . anchor = GridBagConstraints . EAST ;
gbc_lblSchnittstelle . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblSchnittstelle . gridx = 0 ;
gbc_lblSchnittstelle . gridy = 0 ;
panel . add ( lblSchnittstelle , gbc_lblSchnittstelle ) ;
tfInterface = new JTextField ( ) ;
2016-09-06 16:49:11 +02:00
tfInterface . setToolTipText ( "<html>\n<b>Aktuell eingstellte Schnittstelle</b><br/>\n<br/>\nDiese Schnittstelle wird wür die Kommunikation mit dem Synololog verwendet.\n</html>" ) ;
2015-05-05 16:05:22 +02:00
GridBagConstraints gbc_tfInterface = new GridBagConstraints ( ) ;
gbc_tfInterface . anchor = GridBagConstraints . NORTH ;
gbc_tfInterface . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_tfInterface . fill = GridBagConstraints . HORIZONTAL ;
gbc_tfInterface . gridx = 1 ;
gbc_tfInterface . gridy = 0 ;
panel . add ( tfInterface , gbc_tfInterface ) ;
tfInterface . setColumns ( 10 ) ;
JButton btnWhlen = new JButton ( "wählen..." ) ;
btnWhlen . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent arg0 ) {
2016-09-13 12:07:01 +02:00
2015-05-05 16:05:22 +02:00
}
} ) ;
GridBagConstraints gbc_btnWhlen = new GridBagConstraints ( ) ;
gbc_btnWhlen . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_btnWhlen . gridx = 2 ;
gbc_btnWhlen . gridy = 0 ;
panel . add ( btnWhlen , gbc_btnWhlen ) ;
2016-09-06 16:49:11 +02:00
JPanel panel_3 = new JPanel ( ) ;
tabbedPane . addTab ( "Inbetriebnahme" , null , panel_3 , null ) ;
GridBagLayout gbl_panel_3 = new GridBagLayout ( ) ;
gbl_panel_3 . columnWidths = new int [ ] { 0 , 0 } ;
gbl_panel_3 . rowHeights = new int [ ] { 0 , 0 } ;
gbl_panel_3 . columnWeights = new double [ ] { 1.0 , Double . MIN_VALUE } ;
gbl_panel_3 . rowWeights = new double [ ] { 1.0 , Double . MIN_VALUE } ;
panel_3 . setLayout ( gbl_panel_3 ) ;
JPanel panel_4 = new JPanel ( ) ;
panel_4 . setBorder ( new TitledBorder ( null , "Echtzeituhr" , TitledBorder . LEADING , TitledBorder . TOP , null , null ) ) ;
GridBagConstraints gbc_panel_4 = new GridBagConstraints ( ) ;
gbc_panel_4 . fill = GridBagConstraints . BOTH ;
gbc_panel_4 . gridx = 0 ;
gbc_panel_4 . gridy = 0 ;
panel_3 . add ( panel_4 , gbc_panel_4 ) ;
GridBagLayout gbl_panel_4 = new GridBagLayout ( ) ;
gbl_panel_4 . columnWidths = new int [ ] { 0 , 0 , 0 } ;
gbl_panel_4 . rowHeights = new int [ ] { 0 , 0 , 0 , 0 } ;
gbl_panel_4 . columnWeights = new double [ ] { 0.0 , 1.0 , Double . MIN_VALUE } ;
gbl_panel_4 . rowWeights = new double [ ] { 0.0 , 0.0 , 0.0 , Double . MIN_VALUE } ;
panel_4 . setLayout ( gbl_panel_4 ) ;
JLabel lblAktuelleUhrzeitcomputer = new JLabel ( "Aktuelle Uhrzeit (Computer):" ) ;
GridBagConstraints gbc_lblAktuelleUhrzeitcomputer = new GridBagConstraints ( ) ;
gbc_lblAktuelleUhrzeitcomputer . anchor = GridBagConstraints . EAST ;
gbc_lblAktuelleUhrzeitcomputer . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblAktuelleUhrzeitcomputer . gridx = 0 ;
gbc_lblAktuelleUhrzeitcomputer . gridy = 0 ;
panel_4 . add ( lblAktuelleUhrzeitcomputer , gbc_lblAktuelleUhrzeitcomputer ) ;
timeComputer = new JTextField ( ) ;
GridBagConstraints gbc_timeComputer = new GridBagConstraints ( ) ;
gbc_timeComputer . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_timeComputer . fill = GridBagConstraints . HORIZONTAL ;
gbc_timeComputer . gridx = 1 ;
gbc_timeComputer . gridy = 0 ;
panel_4 . add ( timeComputer , gbc_timeComputer ) ;
timeComputer . setColumns ( 10 ) ;
JLabel lblAktuelleUhrzeitsynololog = new JLabel ( "Aktuelle Uhrzeit (Synololog):" ) ;
GridBagConstraints gbc_lblAktuelleUhrzeitsynololog = new GridBagConstraints ( ) ;
gbc_lblAktuelleUhrzeitsynololog . anchor = GridBagConstraints . EAST ;
gbc_lblAktuelleUhrzeitsynololog . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblAktuelleUhrzeitsynololog . gridx = 0 ;
gbc_lblAktuelleUhrzeitsynololog . gridy = 1 ;
panel_4 . add ( lblAktuelleUhrzeitsynololog , gbc_lblAktuelleUhrzeitsynololog ) ;
timeSynololog = new JTextField ( ) ;
GridBagConstraints gbc_timeSynololog = new GridBagConstraints ( ) ;
gbc_timeSynololog . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_timeSynololog . fill = GridBagConstraints . HORIZONTAL ;
gbc_timeSynololog . gridx = 1 ;
gbc_timeSynololog . gridy = 1 ;
panel_4 . add ( timeSynololog , gbc_timeSynololog ) ;
timeSynololog . setColumns ( 10 ) ;
JLabel lblTrimmungsynololog = new JLabel ( "Trimmung (Synololog):" ) ;
GridBagConstraints gbc_lblTrimmungsynololog = new GridBagConstraints ( ) ;
gbc_lblTrimmungsynololog . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_lblTrimmungsynololog . anchor = GridBagConstraints . EAST ;
gbc_lblTrimmungsynololog . gridx = 0 ;
gbc_lblTrimmungsynololog . gridy = 2 ;
panel_4 . add ( lblTrimmungsynololog , gbc_lblTrimmungsynololog ) ;
spTrimm = new JSpinner ( ) ;
spTrimm . setToolTipText ( "<html>\n<b>Trimmung</b><br/>\n<br/>\nDieser Wert korrigiert die Echtzeituhr des Synololog.<br/>\nPositive Werte beschleunigen, negative Werte verlangsamen die Echtzeituhr des Synololog.<br/>\n<br/>\nEinheit: <b>us / 1004ms</b>\n</html>" ) ;
GridBagConstraints gbc_spTrimm = new GridBagConstraints ( ) ;
gbc_spTrimm . fill = GridBagConstraints . HORIZONTAL ;
gbc_spTrimm . gridx = 1 ;
gbc_spTrimm . gridy = 2 ;
panel_4 . add ( spTrimm , gbc_spTrimm ) ;
debugPanel = new JPanel ( ) ;
GridBagLayout gbl_debugPanel = new GridBagLayout ( ) ;
gbl_debugPanel . columnWidths = new int [ ] { 0 , 0 } ;
gbl_debugPanel . rowHeights = new int [ ] { 0 , 0 , 0 , 0 } ;
gbl_debugPanel . columnWeights = new double [ ] { 1.0 , Double . MIN_VALUE } ;
gbl_debugPanel . rowWeights = new double [ ] { 0.0 , 0.0 , 1.0 , Double . MIN_VALUE } ;
debugPanel . setLayout ( gbl_debugPanel ) ;
JPanel panel_5 = new JPanel ( ) ;
GridBagConstraints gbc_panel_5 = new GridBagConstraints ( ) ;
gbc_panel_5 . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_panel_5 . fill = GridBagConstraints . BOTH ;
gbc_panel_5 . gridx = 0 ;
gbc_panel_5 . gridy = 0 ;
debugPanel . add ( panel_5 , gbc_panel_5 ) ;
GridBagLayout gbl_panel_5 = new GridBagLayout ( ) ;
gbl_panel_5 . columnWidths = new int [ ] { 0 , 0 , 0 , 0 , 0 , 0 } ;
gbl_panel_5 . rowHeights = new int [ ] { 0 , 0 } ;
gbl_panel_5 . columnWeights = new double [ ] { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , Double . MIN_VALUE } ;
gbl_panel_5 . rowWeights = new double [ ] { 0.0 , Double . MIN_VALUE } ;
panel_5 . setLayout ( gbl_panel_5 ) ;
JButton btnUpdate = new JButton ( "Update..." ) ;
btnUpdate . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
2016-09-13 12:07:01 +02:00
// readDebug();
2016-09-06 16:49:11 +02:00
}
} ) ;
GridBagConstraints gbc_btnUpdate = new GridBagConstraints ( ) ;
gbc_btnUpdate . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_btnUpdate . gridx = 0 ;
gbc_btnUpdate . gridy = 0 ;
panel_5 . add ( btnUpdate , gbc_btnUpdate ) ;
JButton btnRamImage = new JButton ( "RAM Image..." ) ;
GridBagConstraints gbc_btnRamImage = new GridBagConstraints ( ) ;
gbc_btnRamImage . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_btnRamImage . gridx = 1 ;
gbc_btnRamImage . gridy = 0 ;
panel_5 . add ( btnRamImage , gbc_btnRamImage ) ;
JButton btnDumpSnapshots = new JButton ( "Dump Snapshots" ) ;
btnDumpSnapshots . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
2016-09-13 12:07:01 +02:00
// dumpSnapshots();
2016-09-06 16:49:11 +02:00
}
} ) ;
GridBagConstraints gbc_btnDumpSnapshots = new GridBagConstraints ( ) ;
gbc_btnDumpSnapshots . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_btnDumpSnapshots . gridx = 2 ;
gbc_btnDumpSnapshots . gridy = 0 ;
panel_5 . add ( btnDumpSnapshots , gbc_btnDumpSnapshots ) ;
JButton btnResetDevice = new JButton ( "Reset Device" ) ;
btnResetDevice . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
2016-09-13 12:07:01 +02:00
// doRESETDevice();
2016-09-06 16:49:11 +02:00
}
} ) ;
GridBagConstraints gbc_btnResetDevice = new GridBagConstraints ( ) ;
gbc_btnResetDevice . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_btnResetDevice . gridx = 3 ;
gbc_btnResetDevice . gridy = 0 ;
panel_5 . add ( btnResetDevice , gbc_btnResetDevice ) ;
JButton btnRckDump = new JButton ( "RCK Dump" ) ;
btnRckDump . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
2016-09-13 12:07:01 +02:00
// doRCKDump();
2016-09-06 16:49:11 +02:00
}
} ) ;
GridBagConstraints gbc_btnRckDump = new GridBagConstraints ( ) ;
gbc_btnRckDump . gridx = 4 ;
gbc_btnRckDump . gridy = 0 ;
panel_5 . add ( btnRckDump , gbc_btnRckDump ) ;
btnRamImage . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
2016-09-13 12:07:01 +02:00
// doRAMImage();
2016-09-06 16:49:11 +02:00
}
} ) ;
tabbedPane . addTab ( "DEBUG" , null , debugPanel , null ) ;
JPanel panel_2 = new JPanel ( ) ;
panel_2 . setBorder ( new TitledBorder ( null , "Live Stats" , TitledBorder . LEADING , TitledBorder . TOP , null , null ) ) ;
GridBagConstraints gbc_panel_2 = new GridBagConstraints ( ) ;
gbc_panel_2 . insets = new Insets ( 0 , 0 , 5 , 0 ) ;
gbc_panel_2 . fill = GridBagConstraints . BOTH ;
gbc_panel_2 . gridx = 0 ;
gbc_panel_2 . gridy = 1 ;
debugPanel . add ( panel_2 , gbc_panel_2 ) ;
GridBagLayout gbl_panel_2 = new GridBagLayout ( ) ;
gbl_panel_2 . columnWidths = new int [ ] { 0 , 0 , 0 , 0 , 0 , 0 } ;
gbl_panel_2 . rowHeights = new int [ ] { 0 , 0 , 0 } ;
gbl_panel_2 . columnWeights = new double [ ] { 0.0 , 1.0 , 1.0 , 0.0 , 0.0 , Double . MIN_VALUE } ;
gbl_panel_2 . rowWeights = new double [ ] { 0.0 , 0.0 , Double . MIN_VALUE } ;
panel_2 . setLayout ( gbl_panel_2 ) ;
JLabel lblHeapEnd = new JLabel ( "HEAP END:" ) ;
GridBagConstraints gbc_lblHeapEnd = new GridBagConstraints ( ) ;
gbc_lblHeapEnd . anchor = GridBagConstraints . EAST ;
gbc_lblHeapEnd . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lblHeapEnd . gridx = 0 ;
gbc_lblHeapEnd . gridy = 0 ;
panel_2 . add ( lblHeapEnd , gbc_lblHeapEnd ) ;
lHeapDec = new JLabel ( "Heap Dec" ) ;
GridBagConstraints gbc_lHeapDec = new GridBagConstraints ( ) ;
gbc_lHeapDec . anchor = GridBagConstraints . EAST ;
gbc_lHeapDec . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lHeapDec . gridx = 1 ;
gbc_lHeapDec . gridy = 0 ;
panel_2 . add ( lHeapDec , gbc_lHeapDec ) ;
lHeapHex = new JLabel ( "HeapHex" ) ;
GridBagConstraints gbc_lHeapHex = new GridBagConstraints ( ) ;
gbc_lHeapHex . anchor = GridBagConstraints . EAST ;
gbc_lHeapHex . insets = new Insets ( 0 , 0 , 5 , 5 ) ;
gbc_lHeapHex . gridx = 2 ;
gbc_lHeapHex . gridy = 0 ;
panel_2 . add ( lHeapHex , gbc_lHeapHex ) ;
JLabel lblSysStackBottom = new JLabel ( "SYS STACK BOTTOM:" ) ;
GridBagConstraints gbc_lblSysStackBottom = new GridBagConstraints ( ) ;
gbc_lblSysStackBottom . anchor = GridBagConstraints . EAST ;
gbc_lblSysStackBottom . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_lblSysStackBottom . gridx = 0 ;
gbc_lblSysStackBottom . gridy = 1 ;
panel_2 . add ( lblSysStackBottom , gbc_lblSysStackBottom ) ;
lSStackDec = new JLabel ( "Stack Dec" ) ;
GridBagConstraints gbc_lSStackDec = new GridBagConstraints ( ) ;
gbc_lSStackDec . anchor = GridBagConstraints . EAST ;
gbc_lSStackDec . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_lSStackDec . gridx = 1 ;
gbc_lSStackDec . gridy = 1 ;
panel_2 . add ( lSStackDec , gbc_lSStackDec ) ;
lSStackHex = new JLabel ( "StackHex" ) ;
GridBagConstraints gbc_lSStackHex = new GridBagConstraints ( ) ;
gbc_lSStackHex . anchor = GridBagConstraints . EAST ;
gbc_lSStackHex . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_lSStackHex . gridx = 2 ;
gbc_lSStackHex . gridy = 1 ;
panel_2 . add ( lSStackHex , gbc_lSStackHex ) ;
JScrollPane scrollPane = new JScrollPane ( ) ;
GridBagConstraints gbc_scrollPane = new GridBagConstraints ( ) ;
gbc_scrollPane . fill = GridBagConstraints . BOTH ;
gbc_scrollPane . gridx = 0 ;
gbc_scrollPane . gridy = 2 ;
debugPanel . add ( scrollPane , gbc_scrollPane ) ;
msgExc = new JEditorPane ( ) ;
scrollPane . setViewportView ( msgExc ) ;
2015-05-05 16:05:22 +02:00
JPanel panel_1 = new JPanel ( ) ;
contentPane . add ( panel_1 , BorderLayout . SOUTH ) ;
GridBagLayout gbl_panel_1 = new GridBagLayout ( ) ;
gbl_panel_1 . columnWidths = new int [ ] { 0 , 0 , 0 } ;
gbl_panel_1 . rowHeights = new int [ ] { 0 , 0 } ;
gbl_panel_1 . columnWeights = new double [ ] { 1.0 , 1.0 , Double . MIN_VALUE } ;
gbl_panel_1 . rowWeights = new double [ ] { 0.0 , Double . MIN_VALUE } ;
panel_1 . setLayout ( gbl_panel_1 ) ;
JButton bCANCEL = new JButton ( "cancel" ) ;
bCANCEL . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
setVisible ( false ) ;
}
} ) ;
GridBagConstraints gbc_bCANCEL = new GridBagConstraints ( ) ;
gbc_bCANCEL . fill = GridBagConstraints . HORIZONTAL ;
gbc_bCANCEL . insets = new Insets ( 0 , 0 , 0 , 5 ) ;
gbc_bCANCEL . gridx = 0 ;
gbc_bCANCEL . gridy = 0 ;
panel_1 . add ( bCANCEL , gbc_bCANCEL ) ;
JButton bOK = new JButton ( "OK" ) ;
bOK . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
setVisible ( false ) ;
}
} ) ;
GridBagConstraints gbc_bOK = new GridBagConstraints ( ) ;
gbc_bOK . fill = GridBagConstraints . HORIZONTAL ;
gbc_bOK . gridx = 1 ;
gbc_bOK . gridy = 0 ;
panel_1 . add ( bOK , gbc_bOK ) ;
2016-09-13 12:07:01 +02:00
//initialize();
2015-05-05 16:05:22 +02:00
}
2016-09-13 12:07:01 +02:00
/ *
2015-05-05 16:05:22 +02:00
private void initialize ( ) {
2016-09-08 18:47:31 +02:00
PulsCounterApplication pc2a = PulsCounterApplication . getApplication ( ) ;
2015-05-05 16:05:22 +02:00
selectedSerialPort = pc2a . getSerialPort ( ) ;
2016-09-06 16:49:11 +02:00
formerSerialPort = selectedSerialPort ;
2015-05-05 16:05:22 +02:00
if ( selectedSerialPort ! = null )
tfInterface . setText ( selectedSerialPort . getPortName ( ) ) ;
2016-09-06 16:49:11 +02:00
Integer trimmung = application ( ) . getServiceLink ( ) . getServiceRegisterCache ( ) . getCachedInteger ( 13 , 0 , 0x1002 ) ;
if ( trimmung = = null ) {
System . err . println ( "Trimmung konnte nicht gelesen werden!" ) ;
trimmung = 0 ;
spTrimm . setEnabled ( false ) ;
} else {
spTrimm . setValue ( trimmung ) ;
}
timer = new Timer ( ) ;
timer . scheduleAtFixedRate ( new TimerTask ( ) {
@Override
public void run ( ) {
Long deviceTimestamp ;
Integer i ;
i = application ( ) . getServiceLink ( ) . getServiceRegisterCache ( ) . getCachedInteger ( 13 , 0 , 0x001C ) ;
if ( i ! = null ) {
deviceTimestamp = new Long ( i ) ;
calendar . setTimeInMillis ( deviceTimestamp * 1000L ) ;
timeSynololog . setText ( sdf . format ( calendar . getTime ( ) ) ) ;
timeComputer . setText ( sdf . format ( new Date ( ) ) ) ;
}
}
} , 500 , 500 ) ;
for ( int i = 0 ; i < tabbedPane . getTabCount ( ) ; i + + ) {
Component c = tabbedPane . getComponentAt ( i ) ;
if ( debugPanel . equals ( c ) ) {
tabbedPane . removeTabAt ( i ) ;
break ;
}
}
}
public void debugging ( ) {
tabbedPane . addTab ( "DEBUG" , null , debugPanel , null ) ;
2015-05-05 16:05:22 +02:00
}
2016-09-08 18:47:31 +02:00
private PulsCounterApplication application ( ) {
return PulsCounterApplication . getApplication ( ) ;
2016-09-06 16:49:11 +02:00
}
private void accept ( ) {
try {
application ( ) . getServiceLink ( ) . writeInt ( 13 , 0 , 0x1002 , ( Integer ) spTrimm . getValue ( ) ) ;
} catch ( ServiceLinkRequestFailedException e ) {
e . printStackTrace ( ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
} catch ( ServiceLinkException e ) {
e . printStackTrace ( ) ;
}
if ( formerSerialPort ! = selectedSerialPort ) {
application ( ) . setSerialPort ( selectedSerialPort ) ;
}
2015-05-05 16:05:22 +02:00
}
private void chooseSerialPort ( ) {
2016-09-08 18:47:31 +02:00
PulsCounterApplication pc2a = PulsCounterApplication . getApplication ( ) ;
2015-05-05 16:05:22 +02:00
SerialPortChooser spc = new SerialPortChooser ( ) ;
String selectedPortName = null ;
if ( selectedSerialPort ! = null )
selectedPortName = selectedSerialPort . getPortName ( ) ;
2016-09-06 16:49:11 +02:00
NewSerialPort sp = spc . execute ( selectedPortName ) ;
2015-05-05 16:05:22 +02:00
if ( sp ! = null ) {
selectedSerialPort = sp ;
tfInterface . setText ( sp . getPortName ( ) ) ;
} ;
}
2016-09-06 16:49:11 +02:00
private void doRESETDevice ( ) {
2016-09-08 18:47:31 +02:00
PulsCounterApplication pc2a = PulsCounterApplication . getApplication ( ) ;
2016-09-06 16:49:11 +02:00
ServiceLink sl = pc2a . getServiceLink ( ) ;
try {
sl . open ( ) ;
sl . writeInt ( 13 , 0 , 0x1001 , 3 ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
}
private void doRAMImage ( ) {
2016-09-08 18:47:31 +02:00
PulsCounterApplication pc2a = PulsCounterApplication . getApplication ( ) ;
2016-09-06 16:49:11 +02:00
ServiceLink sl = pc2a . getServiceLink ( ) ;
try {
sl . open ( ) ;
sl . writeInt ( 13 , 0 , 0x0004 , 0xFF00A3 ) ;
Integer sp = sl . getServiceRegisterCache ( ) . getCachedInteger ( 13 , 0 , 0x0004 ) ;
System . err . println ( String . format ( "SP readback: 0x%08x" , sp ) ) ;
File dump = new File ( "ram.bin" ) ;
FileOutputStream o = new FileOutputStream ( dump ) ;
for ( int p = 0 ; p < 0x2100 ; p + + ) {
if ( p % 0x0010 = = 0 ) {
System . err . println ( String . format ( "P: 0x%04x" , p ) ) ;
}
try {
Thread . sleep ( 2 ) ;
} catch ( InterruptedException e ) {
// TODO Auto-generated catch block
e . printStackTrace ( ) ;
}
sl . writeInt ( 13 , 0 , 0x00eb , ( p ) ) ;
try {
Thread . sleep ( 2 ) ;
} catch ( InterruptedException e ) {
// TODO Auto-generated catch block
e . printStackTrace ( ) ;
}
Integer i32 = sl . readInt ( 13 , 0 , 0x00ee ) ;
o . write ( i32 & 0xff ) ;
}
o . close ( ) ;
} catch ( ServiceLinkRequestFailedException e ) {
e . printStackTrace ( ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
} catch ( ServiceLinkException e ) {
e . printStackTrace ( ) ;
}
}
void readDebug ( ) {
Integer v ;
2016-09-08 18:47:31 +02:00
PulsCounterApplication pc2a = PulsCounterApplication . getApplication ( ) ;
2016-09-06 16:49:11 +02:00
ServiceLink sl = pc2a . getServiceLink ( ) ;
try {
v = sl . getServiceRegisterCache ( ) . getCachedInteger ( 13 , 0 , 0x0020 ) ;
if ( v ! = null ) {
lHeapDec . setText ( v . toString ( ) ) ;
lHeapHex . setText ( Integer . toHexString ( v ) ) ;
}
v = sl . getServiceRegisterCache ( ) . getCachedInteger ( 13 , 0 , 0x0021 ) ;
if ( v ! = null ) {
lSStackDec . setText ( v . toString ( ) ) ;
lSStackHex . setText ( Integer . toHexString ( v ) ) ;
}
} catch ( Exception e ) {
StringBuilder sb = new StringBuilder ( ) ;
ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ;
sb . append ( e . toString ( ) ) ;
e . printStackTrace ( new PrintStream ( out ) ) ;
sb . append ( "\n" ) ;
sb . append ( out . toString ( ) ) ;
msgExc . setText ( sb . toString ( ) ) ;
}
}
void dumpSnapshots ( ) {
2016-09-08 18:47:31 +02:00
SnapshotManager ssm = PulsCounterApplication . getApplication ( ) . getSnapshotManager ( ) ;
2016-09-06 16:49:11 +02:00
for ( int n = 0 ; n < ssm . size ( ) ; n + + ) {
SnapShot ss = ssm . loadSnapShot ( n ) ;
System . err . println ( ss . toString ( ) ) ;
}
}
void doRCKDump ( ) {
StringBuilder sb = new StringBuilder ( ) ;
ServiceLink sl = application ( ) . getServiceLink ( ) ;
sb . append ( "Dumpink RCK EEPROM:\n" ) ;
for ( int i = 0x0004000 ; i < 0x0005000 ; i + = 4 ) {
try {
sl . writeInt ( 13 , 0 , 0x9010 , i ) ;
} catch ( Exception e ) {
sb . append ( String . format ( "0x%08x failed [index] (%s).\n" , i , e . toString ( ) ) ) ;
}
try {
Integer v = sl . readInt ( 13 , 0 , 0x9011 ) ;
sb . append ( String . format ( "0x%08x: 0x%08x\n" , i , v ) ) ;
} catch ( Exception e ) {
sb . append ( String . format ( "0x%08x failed [read] (%s).\n" , i , e . toString ( ) ) ) ;
}
}
msgExc . setText ( sb . toString ( ) ) ;
}
2016-09-13 12:07:01 +02:00
* /
2015-05-05 16:05:22 +02:00
}