mirror of https://github.com/contiki-ng/mspsim
made duty window a service and fixed some minor bugs
git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@614 23d1a52b-0c3c-0410-b72d-8f29ab48fe35
This commit is contained in:
parent
707eb99c3e
commit
8087c1e21a
|
|
@ -8,8 +8,8 @@
|
|||
# install ContikiChecker
|
||||
# contikichecker
|
||||
|
||||
#start the nodegui serice
|
||||
#start the nodegui service
|
||||
service controlgui start
|
||||
service nodegui start
|
||||
service stackui start
|
||||
#service stackchart start
|
||||
start
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package se.sics.mspsim.extutil.jfreechart;
|
|||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
|
|
@ -14,16 +13,29 @@ import org.jfree.data.time.Millisecond;
|
|||
import org.jfree.data.time.TimeSeries;
|
||||
import org.jfree.data.time.TimeSeriesCollection;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.ui.WindowUtils;
|
||||
import se.sics.mspsim.ui.ManagedWindow;
|
||||
import se.sics.mspsim.ui.WindowManager;
|
||||
import se.sics.mspsim.util.ComponentRegistry;
|
||||
import se.sics.mspsim.util.DataSource;
|
||||
import se.sics.mspsim.util.ServiceComponent;
|
||||
import se.sics.mspsim.util.StackMonitor;
|
||||
import se.sics.mspsim.util.ServiceComponent.Status;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class DataChart extends JPanel {
|
||||
public class DataChart extends JPanel implements ServiceComponent {
|
||||
|
||||
private enum Mode {NONE, STACK, DUTY};
|
||||
private Mode mode = Mode.NONE;
|
||||
|
||||
private TimeSeriesCollection dataset;
|
||||
|
||||
public DataChart(String title, String yaxis) {
|
||||
private ComponentRegistry registry;
|
||||
private ManagedWindow jw;
|
||||
private MSP430 cpu;
|
||||
private DataSourceSampler dss;
|
||||
private Status status = Status.STOPPED;
|
||||
private String name = null;
|
||||
|
||||
public DataChart(ComponentRegistry registry, String title, String yaxis) {
|
||||
DateAxis domain = new DateAxis("Time");
|
||||
NumberAxis range = new NumberAxis(yaxis);
|
||||
XYPlot xyplot = new XYPlot();
|
||||
|
|
@ -64,36 +76,43 @@ public class DataChart extends JPanel {
|
|||
dataset.addSeries(ts);
|
||||
}
|
||||
|
||||
private JFrame openFrame(String name) {
|
||||
JFrame jw = new JFrame(name);
|
||||
private ManagedWindow openFrame(String name) {
|
||||
WindowManager wm = (WindowManager) registry.getComponent("windowManager");
|
||||
ManagedWindow jw = wm.createWindow(name);
|
||||
jw.add(this);
|
||||
WindowUtils.restoreWindowBounds(name, jw);
|
||||
WindowUtils.addSaveOnShutdown(name, jw);
|
||||
// jw.setBounds(100, 100, 400, 200);
|
||||
return jw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setupStackFrame(MSP430 cpu) {
|
||||
JFrame jw = openFrame("Stack Monitor");
|
||||
StackMonitor sm = new StackMonitor(cpu);
|
||||
DataSourceSampler dss = new DataSourceSampler(cpu);
|
||||
TimeSeries ts = new TimeSeries("Max Stack", Millisecond.class);
|
||||
ts.setMaximumItemCount(200);
|
||||
addTimeSeries(ts);
|
||||
dss.addDataSource(sm.getMaxSource(), ts);
|
||||
ts = new TimeSeries("Stack", Millisecond.class);
|
||||
ts.setMaximumItemCount(200);
|
||||
addTimeSeries(ts);
|
||||
dss.addDataSource(sm.getSource(), ts);
|
||||
jw.setVisible(true);
|
||||
mode = Mode.STACK;
|
||||
this.cpu = cpu;
|
||||
}
|
||||
|
||||
private void openStackFrame() {
|
||||
if (jw == null) {
|
||||
jw = openFrame("Stack Monitor");
|
||||
StackMonitor sm = new StackMonitor(cpu);
|
||||
DataSourceSampler dss = new DataSourceSampler(cpu);
|
||||
TimeSeries ts = new TimeSeries("Max Stack", Millisecond.class);
|
||||
ts.setMaximumItemCount(200);
|
||||
addTimeSeries(ts);
|
||||
dss.addDataSource(sm.getMaxSource(), ts);
|
||||
ts = new TimeSeries("Stack", Millisecond.class);
|
||||
ts.setMaximumItemCount(200);
|
||||
addTimeSeries(ts);
|
||||
dss.addDataSource(sm.getSource(), ts);
|
||||
}
|
||||
}
|
||||
|
||||
public DataSourceSampler setupChipFrame(MSP430 cpu) {
|
||||
JFrame jw = openFrame("Duty-Cycle Monitor");
|
||||
DataSourceSampler dss = new DataSourceSampler(cpu);
|
||||
dss.setInterval(50);
|
||||
jw.setVisible(true);
|
||||
return dss;
|
||||
mode = Mode.DUTY;
|
||||
this.cpu = cpu;
|
||||
jw = openFrame("Duty-Cycle Monitor");
|
||||
dss = new DataSourceSampler(cpu);
|
||||
dss.setInterval(50);
|
||||
return dss;
|
||||
}
|
||||
|
||||
public void addDataSource(DataSourceSampler dss, String name, DataSource src) {
|
||||
|
|
@ -102,4 +121,37 @@ public class DataChart extends JPanel {
|
|||
addTimeSeries(ts);
|
||||
dss.addDataSource(src, ts);
|
||||
}
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void init(String name, ComponentRegistry registry) {
|
||||
this.registry = registry;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (mode == Mode.STACK) {
|
||||
openStackFrame();
|
||||
} else {
|
||||
dss.start();
|
||||
}
|
||||
jw.setVisible(true);
|
||||
status = Status.STARTED;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
jw.setVisible(false);
|
||||
if (mode == Mode.STACK) {
|
||||
// ?
|
||||
} else {
|
||||
dss.stop();
|
||||
}
|
||||
status = Status.STOPPED;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,14 @@ public class DataSourceSampler implements ActionListener {
|
|||
timer = new Timer(interval, this);
|
||||
timer.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
timer.stop();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
timer.start();
|
||||
}
|
||||
|
||||
public TimeSource addDataSource(DataSource source, TimeSeries ts) {
|
||||
TimeSource times = new TimeSource(cpu, source, ts);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ public abstract class GenericNode extends Chip implements Runnable {
|
|||
// Setup control and other UI components
|
||||
ControlUI control = new ControlUI();
|
||||
registry.registerComponent("controlgui", control);
|
||||
registry.registerComponent("stackui", new StackUI(cpu));
|
||||
registry.registerComponent("stackchart", new StackUI(cpu));
|
||||
HighlightSourceViewer sourceViewer = new HighlightSourceViewer();
|
||||
if (firmwareFile != null) {
|
||||
// Add the firmware location to the search path
|
||||
|
|
|
|||
|
|
@ -194,7 +194,8 @@ public abstract class MoteIVNode extends GenericNode implements PortListener, US
|
|||
registry.registerComponent("nodegui", gui);
|
||||
|
||||
// A HACK for some "graphs"!!!
|
||||
DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle");
|
||||
DataChart dataChart = new DataChart(registry, "Duty Cycle", "Duty Cycle");
|
||||
registry.registerComponent("dutychart", dataChart);
|
||||
DataSourceSampler dss = dataChart.setupChipFrame(cpu);
|
||||
dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getName(), 0, OperatingModeStatistics.OP_INVERT));
|
||||
dataChart.addDataSource(dss, "Listen", stats.getDataSource("CC2420", CC2420.MODE_RX_ON));
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class ControlUI extends JPanel implements ActionListener, SimEventListene
|
|||
private Action stepAction;
|
||||
private ComponentRegistry registry;
|
||||
|
||||
private Status status;
|
||||
private Status status = Status.STOPPED;
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ public class StackUI extends JPanel implements CPUMonitor, ServiceComponent {
|
|||
|
||||
private boolean update = false;
|
||||
|
||||
private Status status;
|
||||
private Status status = Status.STOPPED;
|
||||
|
||||
private ComponentRegistry registry;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue