package org.netfpga.eventcap;
/*
* DelayInternalFrame.java
*
* Created on May 7, 2007, 9:35 PM
*/
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractButton;
import javax.swing.Timer;
import org.netfpga.router.ControlCheckBox;
import org.netfpga.router.ControlRegGroup;
import org.netfpga.router.RegSliderGroupControl;
import org.netfpga.router.ValueTransformer;
import org.netfpga.backend.NFDevice;
import org.netfpga.backend.NFDeviceConsts;
/**
*
* @author jnaous
*/
@SuppressWarnings("serial")
public class DelayInternalFrame extends javax.swing.JInternalFrame {
private RegSliderGroupControl sliderCtrl;
private ControlRegGroup ctrlRegGrp;
private Timer timer;
private ActionListener timerActionListener;
/**
* Creates new form DelayInternalFrame
*/
public DelayInternalFrame(NFDevice nf2, Timer timer) {
this.timer = timer;
initComponents();
sliderCtrl = new RegSliderGroupControl(nf2, this.delaySlider, this.delayValueLabel, NFDeviceConsts.DELAY_LENGTH_REG);
sliderCtrl.setVt(new ValueTransformer() {
public int toSliderValue(int val) {
return val/1000;
}
public int toRegisterValue(int val) {
return val*1000;
}
public String toLabelStringFromReg(int val) {
return ""+(val/125000)+" ms";
}
public String toLabelStringFromComponent(int val) {
return ""+(val/125)+" ms";
}
});
AbstractButton[] buttons = {this.enabledCheckbox};
boolean[] invert = {false};
ctrlRegGrp = new ControlRegGroup(nf2, NFDeviceConsts.DELAY_ENABLE_REG,
buttons, invert);
/* add listeners to the update the tables */
timerActionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
sliderCtrl.updateFromRegs();
ctrlRegGrp.updateFromRegs();
}
};
/* add action listener to the timer */
timer.addActionListener(timerActionListener);
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
DelayScrollPane = new javax.swing.JScrollPane();
DelayPanel = new javax.swing.JPanel();
pageTitleLabel = new javax.swing.JLabel();
enabledCheckbox = new ControlCheckBox();
titleConfigSeparator = new javax.swing.JSeparator();
maxDelayLabel = new javax.swing.JLabel();
delaySlider = new javax.swing.JSlider();
delayLabel = new javax.swing.JLabel();
maxRecommendedDelayLabel = new javax.swing.JLabel();
delayValueLabel = new javax.swing.JLabel();
maxRecommendedDelayValueLabel = new javax.swing.JLabel();
setClosable(true);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
setTitle("Delay");
setMinimumSize(new java.awt.Dimension(0, 0));
setPreferredSize(new java.awt.Dimension(363, 220));
setVisible(true);
addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
formInternalFrameClosed(evt);
}
public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
}
});
DelayScrollPane.setPreferredSize(new java.awt.Dimension(365, 190));
DelayPanel.setPreferredSize(new java.awt.Dimension(100, 100));
pageTitleLabel.setFont(new java.awt.Font("Dialog", 1, 18));
pageTitleLabel.setText("Delay");
enabledCheckbox.setText("Enabled");
enabledCheckbox.setToolTipText("Uncheck to disable receiving any packet on this port");
enabledCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
enabledCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
maxDelayLabel.setText("1s");
delaySlider.setMajorTickSpacing(125);
delaySlider.setMaximum(125000);
delaySlider.setSnapToTicks(true);
delaySlider.setValue(0);
delayLabel.setText("Current delay: ");
maxRecommendedDelayLabel.setText("Recommended maximum delay:");
delayValueLabel.setText("0 ms");
maxRecommendedDelayValueLabel.setText("0 ms");
maxRecommendedDelayValueLabel.setToolTipText("This value is based on the throughput that is set in the rate limiter. If this is exceeded, packet drops may occur.");
org.jdesktop.layout.GroupLayout DelayPanelLayout = new org.jdesktop.layout.GroupLayout(DelayPanel);
DelayPanel.setLayout(DelayPanelLayout);
DelayPanelLayout.setHorizontalGroup(
DelayPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, DelayPanelLayout.createSequentialGroup()
.addContainerGap()
.add(delaySlider, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE))
.add(titleConfigSeparator, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
.add(DelayPanelLayout.createSequentialGroup()
.addContainerGap()
.add(DelayPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(DelayPanelLayout.createSequentialGroup()
.add(delayLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(delayValueLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(DelayPanelLayout.createSequentialGroup()
.add(maxRecommendedDelayLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(maxRecommendedDelayValueLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(46, Short.MAX_VALUE))
.add(DelayPanelLayout.createSequentialGroup()
.addContainerGap()
.add(enabledCheckbox)
.addContainerGap(272, Short.MAX_VALUE))
.add(DelayPanelLayout.createSequentialGroup()
.addContainerGap()
.add(pageTitleLabel)
.addContainerGap(285, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, DelayPanelLayout.createSequentialGroup()
.addContainerGap(323, Short.MAX_VALUE)
.add(maxDelayLabel)
.addContainerGap())
);
DelayPanelLayout.setVerticalGroup(
DelayPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(DelayPanelLayout.createSequentialGroup()
.addContainerGap()
.add(pageTitleLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(titleConfigSeparator, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(enabledCheckbox)
.add(27, 27, 27)
.add(maxDelayLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(delaySlider, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(DelayPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(delayLabel)
.add(delayValueLabel))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(DelayPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(maxRecommendedDelayLabel)
.add(maxRecommendedDelayValueLabel))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
DelayScrollPane.setViewportView(DelayPanel);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(DelayScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(DelayScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosed
this.timer.removeActionListener(timerActionListener);
}//GEN-LAST:event_formInternalFrameClosed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel DelayPanel;
private javax.swing.JScrollPane DelayScrollPane;
private javax.swing.JLabel delayLabel;
private javax.swing.JSlider delaySlider;
private javax.swing.JLabel delayValueLabel;
private javax.swing.JCheckBox enabledCheckbox;
private javax.swing.JLabel maxDelayLabel;
private javax.swing.JLabel maxRecommendedDelayLabel;
private javax.swing.JLabel maxRecommendedDelayValueLabel;
private javax.swing.JLabel pageTitleLabel;
private javax.swing.JSeparator titleConfigSeparator;
// End of variables declaration//GEN-END:variables
}