package org.netfpga.eventcap;
/*
* EventCaptureQueuePanel.java
*
* Created on May 23, 2007, 2:15 AM
*/
import org.netfpga.router.AreaGraphPanel;
import org.netfpga.router.GraphPanel;
/**
*
* @author jnaous
*/
@SuppressWarnings("serial")
public class EventCaptureQueuePanel extends javax.swing.JPanel {
/** Creates new form EventCaptureQueuePanel */
public EventCaptureQueuePanel() {
initComponents();
}
/** 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() {
totalNumWritesLabel = new javax.swing.JLabel();
totalNumReadsLabel = new javax.swing.JLabel();
totalNumDropsLabel = new javax.swing.JLabel();
totalNumWritesValueLabel = new javax.swing.JLabel();
totalNumReadsValueLabel = new javax.swing.JLabel();
totalNumDropsValueLabel = new javax.swing.JLabel();
queueOccupancyPkts = new AreaGraphPanel("Queue Occupancy (pkts)", "Num Packets in Queue", "time (ms)", "Queue Occupancy", 5000);
queueOccupancyBytes = new AreaGraphPanel("Queue Occupancy (bytes)", "Num Bytes in Queue", "time (ms)", "Queue Occupancy", 5000);
totalNumWritesLabel.setText("Total number of packet write events:");
totalNumReadsLabel.setText("Total number of packet read events:");
totalNumDropsLabel.setText("Total number of packet drop events:");
totalNumWritesValueLabel.setText("0");
totalNumReadsValueLabel.setText("0");
totalNumDropsValueLabel.setText("0");
javax.swing.GroupLayout queueOccupancyPktsLayout = new javax.swing.GroupLayout(queueOccupancyPkts);
queueOccupancyPkts.setLayout(queueOccupancyPktsLayout);
queueOccupancyPktsLayout.setHorizontalGroup(
queueOccupancyPktsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 380, Short.MAX_VALUE)
);
queueOccupancyPktsLayout.setVerticalGroup(
queueOccupancyPktsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 287, Short.MAX_VALUE)
);
javax.swing.GroupLayout queueOccupancyBytesLayout = new javax.swing.GroupLayout(queueOccupancyBytes);
queueOccupancyBytes.setLayout(queueOccupancyBytesLayout);
queueOccupancyBytesLayout.setHorizontalGroup(
queueOccupancyBytesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 380, Short.MAX_VALUE)
);
queueOccupancyBytesLayout.setVerticalGroup(
queueOccupancyBytesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 287, Short.MAX_VALUE)
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(queueOccupancyPkts, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(totalNumWritesLabel)
.addComponent(totalNumReadsLabel)
.addComponent(totalNumDropsLabel))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(totalNumDropsValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(totalNumReadsValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(totalNumWritesValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(queueOccupancyBytes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(totalNumWritesLabel)
.addComponent(totalNumWritesValueLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(totalNumReadsLabel)
.addComponent(totalNumReadsValueLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(totalNumDropsLabel)
.addComponent(totalNumDropsValueLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(queueOccupancyPkts, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(queueOccupancyBytes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel queueOccupancyBytes;
private javax.swing.JPanel queueOccupancyPkts;
private javax.swing.JLabel totalNumDropsLabel;
private javax.swing.JLabel totalNumDropsValueLabel;
private javax.swing.JLabel totalNumReadsLabel;
private javax.swing.JLabel totalNumReadsValueLabel;
private javax.swing.JLabel totalNumWritesLabel;
private javax.swing.JLabel totalNumWritesValueLabel;
// End of variables declaration//GEN-END:variables
private int currentOQBytes = 0;
private int currentOQPkts = 0;
private int numDropEvents = 0;
private int numRemoveEvents = 0;
private int numStoreEvents = 0;
private double lastTime = 0;
private int tickLength = 8;
/**
* Changes the number of points in the graph
* @param graphSize the maximum number of points to be stored in the dataset
*/
public void setGraphSize(int graphSize) {
((GraphPanel)queueOccupancyBytes).setGraphSize(graphSize);
}
/**
* sets the length of a single clock tick in nanoseconds
* @param tickLength
*/
public void setTickLength(int tickLength) {
this.tickLength = tickLength;
}
/**
* Processes a single event's data by updating the graphs and counters
* @param evt
*/
public void processEvent(NFEvent evt){
int type = evt.getType();
if(type==NFEvent.STORE_TYPE){
currentOQBytes += evt.getPktLength();
currentOQPkts += 1;
numStoreEvents += 1;
totalNumWritesValueLabel.setText(""+numStoreEvents);
} else if(type==NFEvent.REMOVE_TYPE){
currentOQBytes -= evt.getPktLength();
currentOQPkts -= 1;
numRemoveEvents += 1;
totalNumReadsValueLabel.setText(""+numRemoveEvents);
} else if (type == NFEvent.DROP_TYPE){
numDropEvents += 1;
totalNumDropsValueLabel.setText(""+numDropEvents);
return;
} else {
return;
}
/* wrap around the time:when a new packet's time is smaller
* then clear the graphs and restart plotting.
*/
// int time = (int)((evt.getAbsoluteTime())%Integer.MAX_VALUE);
// if(lastTime>time){
// ((GraphPanel)queueOccupancyBytes).clearAll();
// ((GraphPanel)queueOccupancyPkts).clearAll();
// }
/* get time in milliseconds */
double time = (evt.getAbsoluteTime()*tickLength)/1000000.0;
((GraphPanel)queueOccupancyBytes).addPoint(time, currentOQBytes, false);
((GraphPanel)queueOccupancyPkts).addPoint(time, currentOQPkts, false);
lastTime = time;
}
/**
* Sets the size of the queue.
* @param oqSizeBytes
* @param oqSizePkts
*/
public void setOQSize(int oqSizeBytes, int oqSizePkts){
this.currentOQBytes = oqSizeBytes;
this.currentOQPkts = oqSizePkts;
}
/**
* notifies the graphs to update
*/
public void notifyGraphs(){
((GraphPanel)queueOccupancyBytes).notifyGraph();
((GraphPanel)queueOccupancyPkts).notifyGraph();
}
public String toString() {
return ("currentOQBytes = " + currentOQBytes + "\n" +
"currentOQPkts = " + currentOQPkts + "\n" +
"numDropEvents = " + numDropEvents + "\n" +
"numRemoveEvents = " + numRemoveEvents + "\n" +
"numStoreEvents = " + numStoreEvents + "\n" +
"lastTime = " + lastTime);
}
}