You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(12) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(25) |
Feb
(54) |
Mar
(63) |
Apr
(52) |
May
(17) |
Jun
(3) |
Jul
(3) |
Aug
(5) |
Sep
(49) |
Oct
(50) |
Nov
(34) |
Dec
(14) |
2009 |
Jan
(9) |
Feb
(15) |
Mar
(38) |
Apr
(12) |
May
(35) |
Jun
(20) |
Jul
(2) |
Aug
(7) |
Sep
(36) |
Oct
(24) |
Nov
(2) |
Dec
(2) |
2010 |
Jan
(14) |
Feb
(1) |
Mar
(36) |
Apr
(2) |
May
(4) |
Jun
(6) |
Jul
(35) |
Aug
(11) |
Sep
(8) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(11) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(12) |
Jun
(8) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
(2) |
Dec
(4) |
2012 |
Jan
(2) |
Feb
(1) |
Mar
(14) |
Apr
(5) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ni...@us...> - 2008-04-24 15:14:03
|
Revision: 261 http://mspsim.svn.sourceforge.net/mspsim/?rev=261&view=rev Author: nifi Date: 2008-04-24 08:13:20 -0700 (Thu, 24 Apr 2008) Log Message: ----------- fixed to update memory when changing pin Modified Paths: -------------- mspsim/se/sics/mspsim/core/IOPort.java Modified: mspsim/se/sics/mspsim/core/IOPort.java =================================================================== --- mspsim/se/sics/mspsim/core/IOPort.java 2008-04-24 12:17:39 UTC (rev 260) +++ mspsim/se/sics/mspsim/core/IOPort.java 2008-04-24 15:13:20 UTC (rev 261) @@ -168,35 +168,39 @@ // for HW to set hi/low on the pins... public void setPinState(int pin, int state) { - if (interrupt > 0) { - if (pinState[pin] != state) { - pinState[pin] = state; - int bit = 1 << pin; - if ((memory[offset + IES] & bit) == 0) { - // LO/HI transition - if (state == PIN_HI) { - interruptFlag |= bit; - if (DEBUG) { - System.out.println(getName() + - " Flagging interrupt (HI): " + bit); - } - } - } else { - // HI/LO transition - if (state == PIN_LOW) { - interruptFlag |= bit; - if (DEBUG) { - System.out.println(getName() + - " Flagging interrupt (LOW): " + bit); - } - } - } + if (pinState[pin] != state) { + pinState[pin] = state; + int bit = 1 << pin; + if (state == PIN_HI) { + memory[IN + offset] |= bit; + } else { + memory[IN + offset] &= ~bit; } + if (interrupt > 0) { + if ((memory[offset + IES] & bit) == 0) { + // LO/HI transition + if (state == PIN_HI) { + interruptFlag |= bit; + if (DEBUG) { + System.out.println(getName() + + " Flagging interrupt (HI): " + bit); + } + } + } else { + // HI/LO transition + if (state == PIN_LOW) { + interruptFlag |= bit; + if (DEBUG) { + System.out.println(getName() + + " Flagging interrupt (LOW): " + bit); + } + } + } + memory[offset + IFG] = interruptFlag; + // Maybe this is not the only place where we should flag int? + cpu.flagInterrupt(interrupt, this, (interruptFlag & interruptEnable) > 0); + } } - memory[offset + IFG] = interruptFlag; - - // Maybe this is not the only place where we should flag int? - cpu.flagInterrupt(interrupt, this, (interruptFlag & interruptEnable) > 0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-24 12:18:16
|
Revision: 260 http://mspsim.svn.sourceforge.net/mspsim/?rev=260&view=rev Author: nifi Date: 2008-04-24 05:17:39 -0700 (Thu, 24 Apr 2008) Log Message: ----------- removed debug output Modified Paths: -------------- mspsim/se/sics/mspsim/core/Watchdog.java Modified: mspsim/se/sics/mspsim/core/Watchdog.java =================================================================== --- mspsim/se/sics/mspsim/core/Watchdog.java 2008-04-23 20:42:06 UTC (rev 259) +++ mspsim/se/sics/mspsim/core/Watchdog.java 2008-04-24 12:17:39 UTC (rev 260) @@ -40,8 +40,6 @@ */ package se.sics.mspsim.core; -import se.sics.mspsim.util.Utils; - /** * @author joakim * @@ -68,8 +66,6 @@ } }; - - public Watchdog(MSP430Core cpu) { super(cpu.memory, 0x120); this.cpu = cpu; @@ -77,19 +73,17 @@ @Override public String getName() { - // TODO Auto-generated method stub return "Watchdog"; } @Override public void interruptServiced(int vector) { - // TODO Auto-generated method stub cpu.flagInterrupt(RESET_VECTOR, this, false); } private void triggerWDT(long time) { - // Here the WDT triggered!!! - System.out.println("WDT trigger - should reset?!?!"); + // Here the WDT triggered!!! +// System.out.println("WDT trigger - should reset?!?!"); } public int read(int address, boolean word, long cycles) { @@ -101,7 +95,7 @@ public void write(int address, int value, boolean word, long cycles) { if (address == WDTCTL) { if ((value >> 8) == 0x5a) { - System.out.println("Wrote to WDTCTL: " + Utils.hex8(wdtctl)); +// System.out.println("Wrote to WDTCTL: " + Utils.hex8(wdtctl)); wdtctl = value & 0xff; // Is it on? wdtOn = (value & 0x80) == 0; @@ -110,7 +104,7 @@ } } else { // Trigger reset!! - System.out.println("WDTCTL: illegal write - should reset!!!! " + value); +// System.out.println("WDTCTL: illegal write - should reset!!!! " + value); cpu.flagInterrupt(RESET_VECTOR, this, true); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-23 20:42:19
|
Revision: 259 http://mspsim.svn.sourceforge.net/mspsim/?rev=259&view=rev Author: joxe Date: 2008-04-23 13:42:06 -0700 (Wed, 23 Apr 2008) Log Message: ----------- reimplemented reset to trigger the resetvector and added HW reset before executing reset vector. Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-04-23 19:06:13 UTC (rev 258) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-04-23 20:42:06 UTC (rev 259) @@ -514,10 +514,9 @@ } public void reset() { -// flagInterrupt(15, null, true); - reg[PC] = memory[0xfffe] + (memory[0xffff] << 8); - System.out.println("Reset the CPU: " + reg[PC]); - internalReset(); +// reg[PC] = memory[0xfffe] + (memory[0xffff] << 8); +// System.out.println("Reset the CPU: " + reg[PC]); + flagInterrupt(15, null, true); } // Indicate that we have an interrupt now! @@ -535,6 +534,8 @@ interruptMax = interrupt; if (interruptMax == 15) { System.out.println("Triggering reset IRQ!!!!!"); + // This can not be masked at all! + interruptsEnabled = true; } } } else { @@ -629,18 +630,22 @@ int spBefore = readRegister(SP); int sp = spBefore; int sr = readRegister(SR); - // Push PC and SR to stack - // store on stack - always move 2 steps (W) even if B. - writeRegister(SP, sp = spBefore - 2); - // Put lo & hi on stack! - memory[sp] = pc & 0xff; - memory[sp + 1] = (pc >> 8) & 0xff; - writeRegister(SP, sp = sp - 2); - // Put lo & hi on stack! - memory[sp] = sr & 0xff; - memory[sp + 1] = (sr >> 8) & 0xff; + // Only store stuff on irq except reset... - not sure if this is correct... + // TODO: Check what to do if reset is called! + if (interruptMax < 15) { + // Push PC and SR to stack + // store on stack - always move 2 steps (W) even if B. + writeRegister(SP, sp = spBefore - 2); + // Put lo & hi on stack! + memory[sp] = pc & 0xff; + memory[sp + 1] = (pc >> 8) & 0xff; + writeRegister(SP, sp = sp - 2); + // Put lo & hi on stack! + memory[sp] = sr & 0xff; + memory[sp + 1] = (sr >> 8) & 0xff; + } // Clear SR - except ... // Jump to the address specified in the interrupt vector writeRegister(PC, pc = @@ -656,7 +661,7 @@ interruptMax = -1; if (servicedInterrupt == 15) { - System.out.println("Servicing RESET! => " + Utils.hex16(pc)); + System.out.println("**** Servicing RESET! => " + Utils.hex16(pc)); internalReset(); } @@ -678,7 +683,7 @@ servicedInterruptUnit.getName()); } servicedInterruptUnit.interruptServiced(servicedInterrupt); - } + } return pc; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-23 19:06:45
|
Revision: 258 http://mspsim.svn.sourceforge.net/mspsim/?rev=258&view=rev Author: joxe Date: 2008-04-23 12:06:13 -0700 (Wed, 23 Apr 2008) Log Message: ----------- fixed so that illegal write to WDTCTL resets MSPSim + fixed argument to reset method. Modified Paths: -------------- mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/core/IOPort.java mspsim/se/sics/mspsim/core/IOUnit.java mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/Timer.java mspsim/se/sics/mspsim/core/USART.java mspsim/se/sics/mspsim/core/Watchdog.java Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-04-23 19:06:13 UTC (rev 258) @@ -280,6 +280,17 @@ return 0; } }); + + ch.registerCommand("set", new BasicCommand("set memory", "<address> <value> [type]") { + public int executeCommand(final CommandContext context) { + int adr = context.getArgumentAsAddress(0); + int val = context.getArgumentAsInt(1); + boolean word = val > 0xff; + cpu.write(adr, val, word); + return 0; + }}); + + } Modified: mspsim/se/sics/mspsim/core/IOPort.java =================================================================== --- mspsim/se/sics/mspsim/core/IOPort.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/core/IOPort.java 2008-04-23 19:06:13 UTC (rev 258) @@ -200,7 +200,7 @@ } - public void reset() { + public void reset(int type) { for (int i = 0, n = 8; i < n; i++) { pinState[i] = PIN_LOW; } Modified: mspsim/se/sics/mspsim/core/IOUnit.java =================================================================== --- mspsim/se/sics/mspsim/core/IOUnit.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/core/IOUnit.java 2008-04-23 19:06:13 UTC (rev 258) @@ -51,7 +51,7 @@ this.offset = offset; } - public void reset() { + public void reset(int type) { } public boolean needsTick() { Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-04-23 19:06:13 UTC (rev 258) @@ -45,6 +45,9 @@ public static final String VERSION = "0.90"; + public static final int RESET_PUC = 0; + public static final int RESET_POR = 1; + // MODES public static final int MODE_ACTIVE = 0; public static final int MODE_LPM0 = 1; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-04-23 19:06:13 UTC (rev 258) @@ -492,18 +492,15 @@ private void resetIOUnits() { for (int i = 0, n = lastIOUnitPos; i < n; i++) { - ioUnits[i].reset(); + ioUnits[i].reset(RESET_POR); } for (int i = 0, n = passiveIOUnits.length; i < n; i++) { - passiveIOUnits[i].reset(); + passiveIOUnits[i].reset(RESET_POR); } } - public void reset() { + private void internalReset() { resetIOUnits(); - reg[PC] = memory[0xfffe] + (memory[0xffff] << 8); - System.out.println("Reset the CPU: " + reg[PC]); - for (int i = 0, n = 16; i < n; i++) { interruptSource[i] = null; } @@ -514,8 +511,14 @@ cycleEventQueue.removeAll(); vTimeEventQueue.removeAll(); - } + + public void reset() { +// flagInterrupt(15, null, true); + reg[PC] = memory[0xfffe] + (memory[0xffff] << 8); + System.out.println("Reset the CPU: " + reg[PC]); + internalReset(); + } // Indicate that we have an interrupt now! // We should only get same IOUnit for same interrupt level @@ -527,8 +530,12 @@ System.out.println("### Interrupt flagged ON by " + source.getName()); } + // MAX priority is executed first - update max if this is higher! if (interrupt > interruptMax) { interruptMax = interrupt; + if (interruptMax == 15) { + System.out.println("Triggering reset IRQ!!!!!"); + } } } else { if (interruptSource[interrupt] == source) { @@ -648,6 +655,12 @@ // executed things might change! interruptMax = -1; + if (servicedInterrupt == 15) { + System.out.println("Servicing RESET! => " + Utils.hex16(pc)); + internalReset(); + } + + // Interrupts take 6 cycles! cycles += 6; Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/core/SFR.java 2008-04-23 19:06:13 UTC (rev 258) @@ -71,7 +71,7 @@ this.memory = memory; } - public void reset() { + public void reset(int type) { } public boolean needsTick() { Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-04-23 19:06:13 UTC (rev 258) @@ -72,7 +72,6 @@ public class Timer extends IOUnit { public static final boolean DEBUG = false; - public static final int TIMER_A = 0; public static final int TIMER_B = 1; private String[] name = new String[] {"A", "B"}; @@ -235,10 +234,10 @@ ccr0Vector = type == TIMER_A ? TACCR0_VECTOR : TBCCR0_VECTOR; ccr1Vector = type == TIMER_A ? TACCR1_VECTOR : TBCCR1_VECTOR; - reset(); + reset(0); } - public void reset() { + public void reset(int type) { for (int i = 0, n = expCompare.length; i < n; i++) { expCompare[i] = -1; expCaptureTime[i] = -1; @@ -320,12 +319,15 @@ case TCCR6: i = (index - TCCR0) / 2; val = tccr[i]; + if (i == 2) { + System.out.println("Read CCR2: " + val); + } break; default: System.out.println("Not supported read, returning zero!!!"); } - if (DEBUG) { + if (DEBUG && false) { System.out.println(getName() + ": Read " + getName(address) + "(" + Utils.hex16(address) + ") => " + Utils.hex16(val) + " (" + val + ")"); } @@ -385,6 +387,7 @@ counter = 0; counterStart = cycles; // inputDivider = 1; ???? + updateCaptures(-1, cycles); } int newMode = (data >> 4) & 3; @@ -438,9 +441,9 @@ triggerInterrupts(); - if (DEBUG) { + if (DEBUG || index == 2) { System.out.println(getName() + " Write: CCTL" + - index + " => " + Utils.hex16(data) + + index + ": => " + Utils.hex16(data) + " CM: " + capNames[capMode[index]] + " CCIS:" + inputSel[index] + " name: " + getSourceName(inputSrc[index]) + @@ -521,7 +524,7 @@ if (DEBUG) { System.out.println(getName() + " expCapInterval[" + i + "] frq = " + - frqClk + " div = " + divisor); + frqClk + " div = " + divisor + " SMCLK_FRQ: " + core.smclkFrq); } // This is used to calculate expected time before next capture of @@ -611,6 +614,10 @@ // Write the expected capture time to the register (counter could // differ slightly) tccr[i] = expCompare[i]; + if (i == 2) { + updateCounter(cycles); + System.out.println("CCR2 set to: " + tccr[i] + " should be " + counter); + } // Update capture times... for next capture expCompare[i] = (expCompare[i] + expCapInterval[i]) & 0xffff; expCaptureTime[i] += expCapInterval[i] * cyclesMultiplicator; Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/core/USART.java 2008-04-23 19:06:13 UTC (rev 258) @@ -132,7 +132,7 @@ nextTXReady = cpu.cycles + 1000; } - public void reset() { + public void reset(int type) { nextTXReady = cpu.cycles + 1000; } Modified: mspsim/se/sics/mspsim/core/Watchdog.java =================================================================== --- mspsim/se/sics/mspsim/core/Watchdog.java 2008-04-22 19:04:23 UTC (rev 257) +++ mspsim/se/sics/mspsim/core/Watchdog.java 2008-04-23 19:06:13 UTC (rev 258) @@ -55,6 +55,7 @@ private static final int WDTSSEL = 0x04; private static final int WDTISx = 0x03; + private static final int RESET_VECTOR = 15; private int wdtctl; private boolean wdtOn = true; @@ -83,7 +84,7 @@ @Override public void interruptServiced(int vector) { // TODO Auto-generated method stub - + cpu.flagInterrupt(RESET_VECTOR, this, false); } private void triggerWDT(long time) { @@ -110,6 +111,7 @@ } else { // Trigger reset!! System.out.println("WDTCTL: illegal write - should reset!!!! " + value); + cpu.flagInterrupt(RESET_VECTOR, this, true); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-22 19:05:14
|
Revision: 257 http://mspsim.svn.sourceforge.net/mspsim/?rev=257&view=rev Author: nifi Date: 2008-04-22 12:04:23 -0700 (Tue, 22 Apr 2008) Log Message: ----------- added color command Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/jfreechart/JFreeWindowDataHandler.java mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java Modified: mspsim/se/sics/mspsim/extutil/jfreechart/JFreeWindowDataHandler.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/JFreeWindowDataHandler.java 2008-04-22 18:57:49 UTC (rev 256) +++ mspsim/se/sics/mspsim/extutil/jfreechart/JFreeWindowDataHandler.java 2008-04-22 19:04:23 UTC (rev 257) @@ -40,10 +40,7 @@ */ package se.sics.mspsim.extutil.jfreechart; -import javax.swing.JComponent; - import org.jfree.data.general.Series; - import se.sics.mspsim.cli.AbstractWindowDataHandler; /** @@ -61,15 +58,14 @@ */ @Override public void setProperty(int index, String param, String[] args) { - System.out.println("setProperty called!!! " + param); if (index > getDataSeriesCount()) { throw new IndexOutOfBoundsException("Illegal index: " + index); } if ("label".equals(param)) { - System.out.println("setting label to: " + args[0]); getDataSeries(index).setKey(args[0]); + getComponent().revalidate(); + getComponent().repaint(); } - getComponent().revalidate(); } } Modified: mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java 2008-04-22 18:57:49 UTC (rev 256) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java 2008-04-22 19:04:23 UTC (rev 257) @@ -43,36 +43,28 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; - import javax.swing.JComponent; import javax.swing.JPanel; - import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; import org.jfree.data.general.Series; -import org.jfree.data.time.Millisecond; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import se.sics.mspsim.cli.AbstractWindowDataHandler; - /** * @author joakim * */ public class LineChart extends JFreeWindowDataHandler { - JPanel panel; + private JPanel panel; private JFreeChart chart; private XYSeriesCollection dataset; private DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); - + public LineChart() { NumberAxis domain = new NumberAxis("Time"); NumberAxis range = new NumberAxis("Value"); @@ -94,9 +86,8 @@ panel.setLayout(new BorderLayout()); panel.setPreferredSize(new Dimension(400, 200)); panel.add(chartPanel, BorderLayout.CENTER); - } - + @Override public JComponent getComponent() { return panel; @@ -105,7 +96,7 @@ public int getDataSeriesCount() { return dataset.getSeriesCount(); } - + public Series getDataSeries(int index) { while (index >= dataset.getSeriesCount()) { addSeries(); @@ -144,5 +135,9 @@ @Override public void setProperty(int index, String param, String[] args) { super.setProperty(index, param, args); + if ("color".equals(param)) { + renderer.setSeriesPaint(index, Color.decode(args[0])); + panel.repaint(); + } } } Modified: mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-22 18:57:49 UTC (rev 256) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-22 19:04:23 UTC (rev 257) @@ -13,16 +13,15 @@ import org.jfree.data.general.Series; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import se.sics.mspsim.cli.AbstractWindowDataHandler; - public class LineSampleChart extends JFreeWindowDataHandler { - JPanel panel; + private JPanel panel; private XYSeriesCollection dataset; private XYSeries dataSeries; private JFreeChart chart; - + private DefaultXYItemRenderer renderer; + public LineSampleChart() { NumberAxis domain = new NumberAxis("Index"); NumberAxis range = new NumberAxis("Value"); @@ -32,7 +31,7 @@ // xyplot.setBackgroundPaint(Color.black); xyplot.setDataset(dataset = new XYSeriesCollection()); - DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); + renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesShapesVisible(0, false); xyplot.setRenderer(renderer); @@ -75,18 +74,22 @@ chart.setTitle(args[0]); } } - + public int getDataSeriesCount() { return 1; } - + public Series getDataSeries(int index) { return dataSeries; } - + @Override public void setProperty(int index, String param, String[] args) { super.setProperty(index, param, args); + if ("color".equals(param)) { + renderer.setSeriesPaint(index, Color.decode(args[0])); + panel.repaint(); + } } - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-22 18:58:48
|
Revision: 256 http://mspsim.svn.sourceforge.net/mspsim/?rev=256&view=rev Author: nifi Date: 2008-04-22 11:57:49 -0700 (Tue, 22 Apr 2008) Log Message: ----------- use AWT thread to update Window targets Modified Paths: -------------- mspsim/se/sics/mspsim/cli/WindowTarget.java Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-22 18:55:59 UTC (rev 255) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-22 18:57:49 UTC (rev 256) @@ -2,6 +2,7 @@ import javax.swing.JFrame; import javax.swing.JTextArea; +import javax.swing.SwingUtilities; import se.sics.mspsim.extutil.jfreechart.LineChart; import se.sics.mspsim.extutil.jfreechart.LineSampleChart; @@ -23,8 +24,17 @@ } @Override - public void lineRead(String line) { - if (line == null) return; + public void lineRead(final String line) { + if (line != null && window != null) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + handleLine(line); + } + }); + } + } + + private void handleLine(String line) { if (line.startsWith("#!")) { line = line.substring(2); String[] parts = CommandParser.parseLine(line); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-22 18:56:50
|
Revision: 255 http://mspsim.svn.sourceforge.net/mspsim/?rev=255&view=rev Author: nifi Date: 2008-04-22 11:55:59 -0700 (Tue, 22 Apr 2008) Log Message: ----------- handle special characters (#,>,|) as arguments when not using redirect and pipes Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandParser.java Modified: mspsim/se/sics/mspsim/cli/CommandParser.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandParser.java 2008-04-22 12:43:55 UTC (rev 254) +++ mspsim/se/sics/mspsim/cli/CommandParser.java 2008-04-22 18:55:59 UTC (rev 255) @@ -133,6 +133,10 @@ case '#': if (!handleRedirect) { // No redirect handling. Process as normal character. + if (state == TEXT) { + index = i; + state = ARG; + } } else if (state == TEXT && redirectCommand != null && redirectFile == args.size()) { redirectCommand += '#'; } else if (state != QUOTE) { @@ -142,6 +146,10 @@ case '>': if (!handleRedirect) { // No redirect handling. Process as normal character. + if (state == TEXT) { + index = i; + state = ARG; + } } else if (state != QUOTE) { // Redirection if (state == ARG) { @@ -168,6 +176,10 @@ case '|': if (!handlePipes) { // No pipe handling. Process as normal character. + if (state == TEXT) { + index = i; + state = ARG; + } } else if (state != QUOTE) { // PIPE if (state == ARG) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-22 12:44:42
|
Revision: 254 http://mspsim.svn.sourceforge.net/mspsim/?rev=254&view=rev Author: nifi Date: 2008-04-22 05:43:55 -0700 (Tue, 22 Apr 2008) Log Message: ----------- fixed to set title in new data handler Modified Paths: -------------- mspsim/se/sics/mspsim/cli/WindowTarget.java Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-22 12:30:44 UTC (rev 253) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-22 12:43:55 UTC (rev 254) @@ -47,11 +47,19 @@ dataHandler = new LineSampleChart(); } else if ("line".equals(parts[1])) { dataHandler = new LineChart(); + } else { + System.err.println("Unknown window data handler type: " + parts[1]); } if (dataHandler != null) { System.out.println("Replacing window data handler! " + parts[1] + " " + dataHandler); window.getContentPane().removeAll(); window.getContentPane().add(dataHandler.getComponent()); + String title = window.getTitle(); + if (title != null) { + // Set title for the new data handler + dataHandler.setProperty("title", new String[] { title }); + } + window.repaint(); } } else if (dataHandler != null) { dataHandler.handleCommand(parts); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-22 12:31:37
|
Revision: 253 http://mspsim.svn.sourceforge.net/mspsim/?rev=253&view=rev Author: nifi Date: 2008-04-22 05:30:44 -0700 (Tue, 22 Apr 2008) Log Message: ----------- merge arguments to title Modified Paths: -------------- mspsim/se/sics/mspsim/cli/WindowTarget.java Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-22 12:29:41 UTC (rev 252) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-22 12:30:44 UTC (rev 253) @@ -37,9 +37,10 @@ System.err.println("Could not set bounds: " + line); } } else if ("title".equals(cmd)) { - window.setTitle(parts[1]); + String args = CommandParser.toString(parts, 1, parts.length); + window.setTitle(args); if (dataHandler != null) { - dataHandler.setProperty("title", new String[] {parts[1]}); + dataHandler.setProperty("title", new String[] {args}); } } else if ("type".equals(cmd)) { if ("line-sample".equals(parts[1])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-22 12:30:01
|
Revision: 252 http://mspsim.svn.sourceforge.net/mspsim/?rev=252&view=rev Author: nifi Date: 2008-04-22 05:29:41 -0700 (Tue, 22 Apr 2008) Log Message: ----------- added toString() for merging argument array Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandParser.java Modified: mspsim/se/sics/mspsim/cli/CommandParser.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandParser.java 2008-04-22 12:00:28 UTC (rev 251) +++ mspsim/se/sics/mspsim/cli/CommandParser.java 2008-04-22 12:29:41 UTC (rev 252) @@ -224,6 +224,17 @@ return list.toArray(new String[list.size()][]); } + public static String toString(String[] parts, int start, int end) { + StringBuilder sb = new StringBuilder(); + for (int i = start; i < end; i++) { + if (i > start) { + sb.append(' '); + } + sb.append(parts[i]); + } + return sb.toString(); + } + // public static void main(String[] args) { // StringBuilder sb = new StringBuilder(); // for (int i = 0, n = args.length; i < n; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-22 12:02:03
|
Revision: 251 http://mspsim.svn.sourceforge.net/mspsim/?rev=251&view=rev Author: nifi Date: 2008-04-22 05:00:28 -0700 (Tue, 22 Apr 2008) Log Message: ----------- removed default script ext + renamed script directory to scripts Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-22 08:57:47 UTC (rev 250) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-22 12:00:28 UTC (rev 251) @@ -16,8 +16,7 @@ public class CommandHandler implements ActiveComponent, Runnable { - private static final String SCRIPT_EXT = ".sc"; - private String scriptDirectory = "script"; + private String scriptDirectory = "scripts"; private Hashtable<String, Command> commands = new Hashtable<String, Command>(); private boolean exit; @@ -172,7 +171,7 @@ return null; } } - File scriptFile = new File(scriptDirectory, cmd + SCRIPT_EXT); + File scriptFile = new File(scriptDirectory, cmd); if (scriptFile.isFile() && scriptFile.canRead()) { return new ScriptCommand(scriptFile); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-22 08:57:54
|
Revision: 250 http://mspsim.svn.sourceforge.net/mspsim/?rev=250&view=rev Author: joxe Date: 2008-04-22 01:57:47 -0700 (Tue, 22 Apr 2008) Log Message: ----------- Added watchdog in Core. Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-04-22 08:55:02 UTC (rev 249) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-04-22 08:57:47 UTC (rev 250) @@ -141,6 +141,10 @@ memIn[0x180 + i] = tb; } + Watchdog wdt = new Watchdog(this); + memOut[0x120] = wdt; + memIn[0x120] = wdt; + sfr = new SFR(this, memory); for (int i = 0, n = 0x10; i < n; i++) { memOut[i] = sfr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-22 08:55:23
|
Revision: 249 http://mspsim.svn.sourceforge.net/mspsim/?rev=249&view=rev Author: joxe Date: 2008-04-22 01:55:02 -0700 (Tue, 22 Apr 2008) Log Message: ----------- added initial watchdog component. - not yet working. Added Paths: ----------- mspsim/se/sics/mspsim/core/Watchdog.java Added: mspsim/se/sics/mspsim/core/Watchdog.java =================================================================== --- mspsim/se/sics/mspsim/core/Watchdog.java (rev 0) +++ mspsim/se/sics/mspsim/core/Watchdog.java 2008-04-22 08:55:02 UTC (rev 249) @@ -0,0 +1,117 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: $ + * + * ----------------------------------------------------------------- + * + * Watchdog + * + * Author : Joakim Eriksson + * Created : 22 apr 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.core; + +import se.sics.mspsim.util.Utils; + +/** + * @author joakim + * + */ +public class Watchdog extends IOUnit { + + private static final int WDTCTL = 0x120; + + private static final int WDTHOLD = 0x80; + private static final int WDTCNTCL = 0x08; + private static final int WDTSSEL = 0x04; + private static final int WDTISx = 0x03; + + + private int wdtctl; + private boolean wdtOn = true; + private MSP430Core cpu; + + private TimeEvent wdtTrigger = new TimeEvent(0) { + public void execute(long t) { +// System.out.println(getName() + " **** executing update timers at " + t + " cycles=" + core.cycles); + triggerWDT(t); + } + }; + + + + public Watchdog(MSP430Core cpu) { + super(cpu.memory, 0x120); + this.cpu = cpu; + } + + @Override + public String getName() { + // TODO Auto-generated method stub + return "Watchdog"; + } + + @Override + public void interruptServiced(int vector) { + // TODO Auto-generated method stub + + } + + private void triggerWDT(long time) { + // Here the WDT triggered!!! + System.out.println("WDT trigger - should reset?!?!"); + } + + public int read(int address, boolean word, long cycles) { + if (address == WDTCTL) return wdtctl | 0x6900; + return 0; + } + + @Override + public void write(int address, int value, boolean word, long cycles) { + if (address == WDTCTL) { + if ((value >> 8) == 0x5a) { + System.out.println("Wrote to WDTCTL: " + Utils.hex8(wdtctl)); + wdtctl = value & 0xff; + // Is it on? + wdtOn = (value & 0x80) == 0; + if ((value & WDTCNTCL) != 0) { + // Clear timer - reschedule the event! + } + } else { + // Trigger reset!! + System.out.println("WDTCTL: illegal write - should reset!!!! " + value); + } + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-22 07:24:11
|
Revision: 248 http://mspsim.svn.sourceforge.net/mspsim/?rev=248&view=rev Author: joxe Date: 2008-04-22 00:23:45 -0700 (Tue, 22 Apr 2008) Log Message: ----------- Added Paths: ----------- mspsim/scripts/ mspsim/scripts/duty.sc Added: mspsim/scripts/duty.sc =================================================================== --- mspsim/scripts/duty.sc (rev 0) +++ mspsim/scripts/duty.sc 2008-04-22 07:23:45 UTC (rev 248) @@ -0,0 +1,8 @@ +echo "#!type line" >#duty +duty 10 "MSP430 Core.active" CC2420.listen CC2420.transmit "Tmote Sky.0" >#duty +echo "#!" +echo "#!set 0 label CPU" >#duty +echo "#!set 1 label Listen" >#duty +echo "#!set 2 label Transmit" >#duty +echo "#!set 3 label LEDS" >#duty +echo "#!title Duty Cycle" >#duty \ No newline at end of file Property changes on: mspsim/scripts/duty.sc ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-21 21:47:10
|
Revision: 247 http://mspsim.svn.sourceforge.net/mspsim/?rev=247&view=rev Author: nifi Date: 2008-04-21 14:46:36 -0700 (Mon, 21 Apr 2008) Log Message: ----------- added support for using scripts as commands Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java Added Paths: ----------- mspsim/se/sics/mspsim/cli/ScriptCommand.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-18 22:39:21 UTC (rev 246) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-21 21:46:36 UTC (rev 247) @@ -1,6 +1,7 @@ package se.sics.mspsim.cli; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.InterruptedIOException; @@ -15,6 +16,9 @@ public class CommandHandler implements ActiveComponent, Runnable { + private static final String SCRIPT_EXT = ".sc"; + private String scriptDirectory = "script"; + private Hashtable<String, Command> commands = new Hashtable<String, Command>(); private boolean exit; private boolean workaround = false; @@ -26,7 +30,7 @@ private MapTable mapTable; private ComponentRegistry registry; private int pidCounter = 0; - + public CommandHandler() { exit = false; inReader = new BufferedReader(new InputStreamReader(System.in)); @@ -94,7 +98,7 @@ String[][] parts; PrintStream out = context == null ? this.out : context.out; PrintStream err = context == null ? this.err : context.err; - + try { parts = CommandParser.parseCommandLine(commandLine); } catch (Exception e) { @@ -102,13 +106,18 @@ e.printStackTrace(err); return -1; } - if(parts != null && parts.length > 0 && checkCommands(parts) == 0) { + if (parts == null || parts.length == 0) { + // Nothing to execute + return 0; + } + Command[] cmds = createCommands(parts); + if(cmds != null && cmds.length > 0) { CommandContext[] commands = new CommandContext[parts.length]; boolean error = false; int pid = -1; for (int i = 0; i < parts.length; i++) { String[] args = parts[i]; - Command cmd = getCommand(args[0]); + Command cmd = cmds[i]; if (i == 0 && cmd instanceof AsyncCommand) { pid = ++pidCounter; } @@ -146,8 +155,9 @@ currentAsyncCommands.add(commands); } } + return 0; } - return 0; + return -1; } // This will return an instance that can be configured - @@ -159,21 +169,27 @@ return (Command) command.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(err); + return null; } } + File scriptFile = new File(scriptDirectory, cmd + SCRIPT_EXT); + if (scriptFile.isFile() && scriptFile.canRead()) { + return new ScriptCommand(scriptFile); + } return null; } - private int checkCommands(String[][] cmds) { - for (int i = 0; i < cmds.length; i++) { - Command command = commands.get(cmds[i][0]); + private Command[] createCommands(String[][] commandList) { + Command[] cmds = new Command[commandList.length]; + for (int i = 0; i < commandList.length; i++) { + Command command = getCommand(commandList[i][0]); if (command == null) { - err.println("CLI: Command not found: \"" + cmds[i][0] + "\". Try \"help\"."); - return -1; + err.println("CLI: Command not found: \"" + commandList[i][0] + "\". Try \"help\"."); + return null; } if (i > 0 && !(command instanceof LineListener)) { - err.println("CLI: Error, command \"" + cmds[i][0] + "\" does not take input."); - return -1; + err.println("CLI: Error, command \"" + commandList[i][0] + "\" does not take input."); + return null; } // TODO replace with command name String argHelp = command.getArgumentHelp(null); @@ -184,15 +200,16 @@ requiredCount++; } } - if (requiredCount > cmds[i].length - 1) { + if (requiredCount > commandList[i].length - 1) { // Too few arguments - err.println("Too few arguments for " + cmds[i][0]); - err.println("Usage: " + cmds[i][0] + ' ' + argHelp); - return -1; + err.println("Too few arguments for " + commandList[i][0]); + err.println("Usage: " + commandList[i][0] + ' ' + argHelp); + return null; } } + cmds[i] = command; } - return 0; + return cmds; } public void setComponentRegistry(ComponentRegistry registry) { @@ -246,7 +263,7 @@ } String cmd = context.getArgument(0); - Command command = commands.get(cmd); + Command command = getCommand(cmd); if (command != null) { String helpText = command.getCommandHelp(cmd); String argHelp = command.getArgumentHelp(cmd); @@ -270,7 +287,7 @@ return 0; } }); - + registerCommand("ps", new BasicCommand("list current executing commands", "") { public int executeCommand(CommandContext context) { for (int i = 0; i < currentAsyncCommands.size(); i++) { @@ -280,7 +297,7 @@ return 0; } }); - + registerCommand("kill", new BasicCommand("kill a currently executing command", "<process>") { public int executeCommand(CommandContext context) { int pid = context.getArgumentAsInt(0); Added: mspsim/se/sics/mspsim/cli/ScriptCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/ScriptCommand.java (rev 0) +++ mspsim/se/sics/mspsim/cli/ScriptCommand.java 2008-04-21 21:46:36 UTC (rev 247) @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * ScriptCommand + * + * Authors : Joakim Eriksson, Niclas Finne + * Created : 21 apr 2008 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.cli; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; + +/** + * + */ +public class ScriptCommand extends Command { + + private final File scriptFile; + + public ScriptCommand(File scriptFile) { + this.scriptFile = scriptFile; + } + + @Override + public String getArgumentHelp(String commandName) { + return null; + } + + @Override + public String getCommandHelp(String commandName) { + return "(implemented as " + scriptFile.getAbsolutePath() + ')'; + } + + @Override + public int executeCommand(CommandContext context) { + try { + BufferedReader in = new BufferedReader(new FileReader(scriptFile)); + try { + String line; + while ((line = in.readLine()) != null) { + line = line.trim(); + if (line.length() > 0 && (line.charAt(0) != '#' || line.startsWith("#!"))) { + if (context.executeCommand(line) != 0) { + break; + } + } + } + } finally { + in.close(); + } + return 0; + } catch (FileNotFoundException e) { + context.err.println("could not read the script '" + scriptFile + '\''); + return 1; + } catch (IOException e) { + context.err.println("could not read the script '" + scriptFile + '\''); + e.printStackTrace(context.err); + return 1; + } + } +} Property changes on: mspsim/se/sics/mspsim/cli/ScriptCommand.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-18 22:39:36
|
Revision: 246 http://mspsim.svn.sourceforge.net/mspsim/?rev=246&view=rev Author: joxe Date: 2008-04-18 15:39:21 -0700 (Fri, 18 Apr 2008) Log Message: ----------- fixed another type of window for showing multiple line-graphs. Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/cli/WindowDataHandler.java mspsim/se/sics/mspsim/cli/WindowTarget.java mspsim/se/sics/mspsim/core/ADC12.java mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java mspsim/se/sics/mspsim/util/OperatingModeStatistics.java mspsim/se/sics/mspsim/util/StatCommands.java Added Paths: ----------- mspsim/se/sics/mspsim/extutil/jfreechart/JFreeWindowDataHandler.java mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-04-18 22:39:21 UTC (rev 246) @@ -119,11 +119,15 @@ public static final int RAM_PANID = 0x168; public static final int RAM_SHORTADDR = 0x16A; + // The Operation modes of the CC2420 public static final int MODE_TXRX_OFF = 0x00; public static final int MODE_RX_ON = 0x01; public static final int MODE_TXRX_ON = 0x02; public static final int MODE_MAX = MODE_TXRX_ON; - + public static final String[] MODE_NAMES = new String[] { + "off", "listen", "transmit" + }; + // when reading registers this flag is set! public static final int FLAG_READ = 0x40; @@ -198,6 +202,7 @@ registers[REG_SNOP] = 0; registers[REG_TXCTRL] = 0xa0ff; this.cpu = cpu; + setModeNames(MODE_NAMES); } public void dataReceived(USART source, int data) { Modified: mspsim/se/sics/mspsim/cli/WindowDataHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowDataHandler.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/cli/WindowDataHandler.java 2008-04-18 22:39:21 UTC (rev 246) @@ -49,4 +49,5 @@ public interface WindowDataHandler extends LineListener { public JComponent getComponent(); public void handleCommand(String[] parts); + public void setProperty(String name, String[] args); } Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-18 22:39:21 UTC (rev 246) @@ -3,6 +3,7 @@ import javax.swing.JFrame; import javax.swing.JTextArea; +import se.sics.mspsim.extutil.jfreechart.LineChart; import se.sics.mspsim.extutil.jfreechart.LineSampleChart; public class WindowTarget implements LineListener { @@ -37,9 +38,14 @@ } } else if ("title".equals(cmd)) { window.setTitle(parts[1]); + if (dataHandler != null) { + dataHandler.setProperty("title", new String[] {parts[1]}); + } } else if ("type".equals(cmd)) { if ("line-sample".equals(parts[1])) { dataHandler = new LineSampleChart(); + } else if ("line".equals(parts[1])) { + dataHandler = new LineChart(); } if (dataHandler != null) { System.out.println("Replacing window data handler! " + parts[1] + " " + dataHandler); Modified: mspsim/se/sics/mspsim/core/ADC12.java =================================================================== --- mspsim/se/sics/mspsim/core/ADC12.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/core/ADC12.java 2008-04-18 22:39:21 UTC (rev 246) @@ -47,8 +47,6 @@ package se.sics.mspsim.core; -import com.sun.org.apache.xpath.internal.operations.Div; - public class ADC12 extends IOUnit { private static final boolean DEBUG = true; //false; Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/core/Chip.java 2008-04-18 22:39:21 UTC (rev 246) @@ -49,7 +49,8 @@ public abstract class Chip { private ArrayList<OperatingModeListener> omListeners; - + private String[] modeNames = null; + public void addOperatingModeListener(OperatingModeListener listener) { if (omListeners == null) omListeners = new ArrayList<OperatingModeListener>(); @@ -70,6 +71,33 @@ } } + protected void setModeNames(String[] names) { + modeNames = names; + } + + public String getModeName(int index) { + if (modeNames == null) { + return null; + } + return modeNames[index]; + } + + public int getModeByName(String mode) { + if (modeNames != null) { + for (int i = 0; i < modeNames.length; i++) { + if (mode.equals(modeNames[i])) return i; + } + } + try { + // If it is just an int it can be parsed! + System.out.println("Parsing as int: " + mode); + int modei = Integer.parseInt(mode); + return modei; + } catch (Exception e) { + } + return -1; + } + public abstract String getName(); public abstract int getModeMax(); } Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-04-18 22:39:21 UTC (rev 246) @@ -44,6 +44,19 @@ public interface MSP430Constants { public static final String VERSION = "0.90"; + + // MODES + public static final int MODE_ACTIVE = 0; + public static final int MODE_LPM0 = 1; + public static final int MODE_LPM1 = 2; + public static final int MODE_LPM2 = 3; + public static final int MODE_LPM3 = 4; + public static final int MODE_LPM4 = 5; + public static final int MODE_MAX = MODE_LPM4; + + public static String[] MODE_NAMES = { + "active", "lpm0", "lpm1", "lpm2", "lpm3", "lpm4" + }; public static final int CLK_ACLK = 1; public static final int CLK_SMCLK = 2; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-04-18 22:39:21 UTC (rev 246) @@ -55,14 +55,6 @@ public static final int INTERNAL_IO_SIZE = 3; public static final int PORTS = 6; - public static final int MODE_ACTIVE = 0; - public static final int MODE_LPM0 = 1; - public static final int MODE_LPM1 = 2; - public static final int MODE_LPM2 = 3; - public static final int MODE_LPM3 = 4; - public static final int MODE_LPM4 = 5; - private static final int MODE_MAX = MODE_LPM4; - // 16 registers of which some are "special" - PC, SP, etc. public int[] reg = new int[16]; @@ -129,7 +121,7 @@ public MSP430Core(int type) { // Ignore type for now... - + setModeNames(MODE_NAMES); // Internal Active IOUnits int passIO = 0; int actIO = 0; Added: mspsim/se/sics/mspsim/extutil/jfreechart/JFreeWindowDataHandler.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/JFreeWindowDataHandler.java (rev 0) +++ mspsim/se/sics/mspsim/extutil/jfreechart/JFreeWindowDataHandler.java 2008-04-18 22:39:21 UTC (rev 246) @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: $ + * + * ----------------------------------------------------------------- + * + * JFreeWindowDataHandler + * + * Author : Joakim Eriksson + * Created : 18 apr 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.extutil.jfreechart; + +import javax.swing.JComponent; + +import org.jfree.data.general.Series; + +import se.sics.mspsim.cli.AbstractWindowDataHandler; + +/** + * @author joakim + * + */ +public abstract class JFreeWindowDataHandler extends AbstractWindowDataHandler { + + + public abstract int getDataSeriesCount(); + public abstract Series getDataSeries(int index); + + /* (non-Javadoc) + * @see se.sics.mspsim.cli.AbstractWindowDataHandler#setProperty(int, java.lang.String, java.lang.String[]) + */ + @Override + public void setProperty(int index, String param, String[] args) { + System.out.println("setProperty called!!! " + param); + if (index > getDataSeriesCount()) { + throw new IndexOutOfBoundsException("Illegal index: " + index); + } + if ("label".equals(param)) { + System.out.println("setting label to: " + args[0]); + getDataSeries(index).setKey(args[0]); + } + getComponent().revalidate(); + } + +} Added: mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java (rev 0) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java 2008-04-18 22:39:21 UTC (rev 246) @@ -0,0 +1,148 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: $ + * + * ----------------------------------------------------------------- + * + * LineChart + * + * Author : Joakim Eriksson + * Created : 17 apr 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.extutil.jfreechart; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; + +import javax.swing.JComponent; +import javax.swing.JPanel; + +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; +import org.jfree.data.general.Series; +import org.jfree.data.time.Millisecond; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; + +import se.sics.mspsim.cli.AbstractWindowDataHandler; + +/** + * @author joakim + * + */ +public class LineChart extends JFreeWindowDataHandler { + + JPanel panel; + private JFreeChart chart; + private XYSeriesCollection dataset; + private DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); + + public LineChart() { + NumberAxis domain = new NumberAxis("Time"); + NumberAxis range = new NumberAxis("Value"); + XYPlot xyplot = new XYPlot(); + xyplot.setDomainAxis(domain); + xyplot.setRangeAxis(range); + xyplot.setDataset(dataset = new XYSeriesCollection()); + xyplot.setRenderer(renderer); + + domain.setAutoRange(true); + domain.setAutoRangeIncludesZero(false); + domain.setLowerMargin(0.0); + domain.setUpperMargin(0.0); + domain.setTickLabelsVisible(true); + range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + chart = new JFreeChart("Data", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); + ChartPanel chartPanel = new ChartPanel(chart); + panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.setPreferredSize(new Dimension(400, 200)); + panel.add(chartPanel, BorderLayout.CENTER); + + } + + @Override + public JComponent getComponent() { + return panel; + } + + public int getDataSeriesCount() { + return dataset.getSeriesCount(); + } + + public Series getDataSeries(int index) { + while (index >= dataset.getSeriesCount()) { + addSeries(); + } + return dataset.getSeries(index); + } + + public void setProperty(String param, String[] args) { + if ("title".equals(param)) { + chart.setTitle(args[0]); + } + } + + private void addSeries() { + XYSeries dataSeries = new XYSeries("series " + (getDataSeriesCount() + 1)); + dataSeries.setMaximumItemCount(200); +// renderer.setSeriesPaint(0, Color.black); + renderer.setSeriesShapesVisible(getDataSeriesCount(), false); + dataset.addSeries(dataSeries); + } + + int point = 0; + @Override + public void lineRead(String line) { + String parts[] = line.trim().split(" "); + while (parts.length > getDataSeriesCount()) { + addSeries(); + } + for (int i = 0; i < parts.length; i++) { + dataset.getSeries(i).add(point, atoi(parts[i], 0)); + } + point++; + panel.repaint(); + } + + @Override + public void setProperty(int index, String param, String[] args) { + super.setProperty(index, param, args); + } +} Modified: mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-18 22:39:21 UTC (rev 246) @@ -10,17 +10,19 @@ import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; +import org.jfree.data.general.Series; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import se.sics.mspsim.cli.AbstractWindowDataHandler; -public class LineSampleChart extends AbstractWindowDataHandler { +public class LineSampleChart extends JFreeWindowDataHandler { JPanel panel; private XYSeriesCollection dataset; private XYSeries dataSeries; - + private JFreeChart chart; + public LineSampleChart() { NumberAxis domain = new NumberAxis("Index"); NumberAxis range = new NumberAxis("Value"); @@ -41,7 +43,7 @@ domain.setTickLabelsVisible(true); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); - JFreeChart chart = new JFreeChart("Test", + chart = new JFreeChart("Test", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); ChartPanel chartPanel = new ChartPanel(chart); panel = new JPanel(); @@ -68,16 +70,23 @@ panel.repaint(); } + public void setProperty(String param, String[] args) { + if ("title".equals(param)) { + chart.setTitle(args[0]); + } + } + + public int getDataSeriesCount() { + return 1; + } + + public Series getDataSeries(int index) { + return dataSeries; + } + @Override public void setProperty(int index, String param, String[] args) { - if (index != 0) { - throw new IndexOutOfBoundsException("Illegal index: " + index); - } - if ("label".equals(param)) { - System.out.println("setting label to: " + args[0]); - dataSeries.setKey(args[0]); - } - panel.repaint(); - } + super.setProperty(index, param, args); + } } Modified: mspsim/se/sics/mspsim/util/OperatingModeStatistics.java =================================================================== --- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-04-18 22:39:21 UTC (rev 246) @@ -93,6 +93,18 @@ return getDataSource(chip, mode, OP_NORMAL); } + public DataSource getDataSource(String chip, String modeStr) { + StatEntry se = statistics.get(chip); + if (se != null) { + int mode = se.chip.getModeByName(modeStr); + if (mode != -1) { + return new StatDataSource(se, mode, OP_NORMAL); + } + } + return null; + } + + public DataSource getDataSource(String chip, int mode, int operation) { StatEntry se = statistics.get(chip); if (se != null) { Modified: mspsim/se/sics/mspsim/util/StatCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/StatCommands.java 2008-04-17 08:40:24 UTC (rev 245) +++ mspsim/se/sics/mspsim/util/StatCommands.java 2008-04-18 22:39:21 UTC (rev 246) @@ -96,7 +96,7 @@ "<frequency> <chip> [chips...]") { private PrintStream out; - private MultiDataSource[] sources; + private Object[] sources; private double frequency; private boolean isRunning = true; @@ -106,12 +106,22 @@ context.err.println("illegal frequency: " + context.getArgument(0)); return 1; } - sources = new MultiDataSource[context.getArgumentCount() - 1]; + sources = new Object[context.getArgumentCount() - 1]; for (int i = 0, n = sources.length; i < n; i++) { - sources[i] = statistics.getMultiDataSource(context.getArgument(i + 1)); - if (sources[i] == null) { - context.err.println("could not find chip " + context.getArgument(i + 1)); - return 1; + String sName = context.getArgument(i + 1); + if (sName.indexOf('.') >= 0) { + String[] parts = sName.split("\\."); + sources[i] = statistics.getDataSource(parts[0], parts[1]); + if (sources[i] == null) { + context.err.println("could not find chip / mode combination " + context.getArgument(i + 1)); + return 1; + } + } else { + sources[i] = statistics.getMultiDataSource(context.getArgument(i + 1)); + if (sources[i] == null) { + context.err.println("could not find chip " + context.getArgument(i + 1)); + return 1; + } } } this.out = context.out; @@ -123,11 +133,16 @@ if (isRunning) { cpu.scheduleTimeEventMillis(this, 1000.0 / frequency); for (int j = 0, n = sources.length; j < n; j++) { - MultiDataSource ds = sources[j]; + Object s = sources[j]; if (j > 0) out.print(' '); - for (int k = 0, m = ds.getModeMax(); k <= m; k++) { - if (k > 0) out.print(' '); - out.print(ds.getValue(k)); + if (s instanceof MultiDataSource) { + MultiDataSource ds = (MultiDataSource) s; + for (int k = 0, m = ds.getModeMax(); k <= m; k++) { + if (k > 0) out.print(' '); + out.print(ds.getValue(k)); + } + } else { + out.print(((DataSource)s).getValue()); } } out.println(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-17 08:40:39
|
Revision: 245 http://mspsim.svn.sourceforge.net/mspsim/?rev=245&view=rev Author: joxe Date: 2008-04-17 01:40:24 -0700 (Thu, 17 Apr 2008) Log Message: ----------- minor fix. Modified Paths: -------------- mspsim/se/sics/mspsim/core/ADC12.java mspsim/se/sics/mspsim/platform/esb/ESBGui.java Modified: mspsim/se/sics/mspsim/core/ADC12.java =================================================================== --- mspsim/se/sics/mspsim/core/ADC12.java 2008-04-17 00:23:19 UTC (rev 244) +++ mspsim/se/sics/mspsim/core/ADC12.java 2008-04-17 08:40:24 UTC (rev 245) @@ -206,9 +206,11 @@ int reg = address - ADC12MEM0; // Clear ifg! adc12ifg &= ~(1 << reg); - if (adc12iv == reg) { +// System.out.println("Read ADCMEM" + (reg / 2)); + if (adc12iv == reg + 6) { core.flagInterrupt(adc12Vector, this, false); adc12iv = 0; +// System.out.println("** de-Trigger ADC12 IRQ for ADCMEM" + adc12Pos); } return adc12mem[reg]; } @@ -228,6 +230,7 @@ adc12ifg |= (1 << adc12Pos); // This should check if there already is an hihger iv! adc12iv = adc12Pos * 2 + 6; +// System.out.println("** Trigger ADC12 IRQ for ADCMEM" + adc12Pos); core.flagInterrupt(adc12Vector, this, true); } // Increase Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2008-04-17 00:23:19 UTC (rev 244) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2008-04-17 08:40:24 UTC (rev 245) @@ -158,11 +158,11 @@ } } - byte[] data = new byte[2]; + byte[] data = new byte[4]; public int nextData() { - inDataLine.read(data, 0, 2); + inDataLine.read(data, 0, 4); //System.out.println("sampled: " + ((data[1] << 8) + data[0])); - return data[0]; + return (((data[1] & 0xff) << 8) | data[0] & 0xff) >> 4; } public void mouseMoved(MouseEvent e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-17 00:23:41
|
Revision: 244 http://mspsim.svn.sourceforge.net/mspsim/?rev=244&view=rev Author: joxe Date: 2008-04-16 17:23:19 -0700 (Wed, 16 Apr 2008) Log Message: ----------- added source command for the cli and ADC12 subsystem including sound-sampler for the ESB (demo purpose). Modified Paths: -------------- mspsim/se/sics/mspsim/cli/MiscCommands.java mspsim/se/sics/mspsim/core/ADC12.java mspsim/se/sics/mspsim/platform/esb/ESBGui.java Added Paths: ----------- mspsim/se/sics/mspsim/core/ADCInput.java Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-16 18:26:57 UTC (rev 243) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-17 00:23:19 UTC (rev 244) @@ -39,7 +39,12 @@ * $Revision$ */ package se.sics.mspsim.cli; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Hashtable; import java.util.Iterator; @@ -170,6 +175,30 @@ } }); + handler.registerCommand("source", new BasicCommand("run script", "<filename>") { + public int executeCommand(CommandContext context) { + FileInputStream infs = null; + try { + infs = new FileInputStream(context.getArgument(0)); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + BufferedReader input = new BufferedReader(new InputStreamReader(infs)); + String line = null; + try { + while ((line = input.readLine()) != null) { + context.executeCommand(line); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return 0; + } + }); + + handler.registerCommand("repeat", new BasicAsyncCommand("repeat the specified command line", "[-t delay] [-c count] <command line>") { private MSP430 cpu; Modified: mspsim/se/sics/mspsim/core/ADC12.java =================================================================== --- mspsim/se/sics/mspsim/core/ADC12.java 2008-04-16 18:26:57 UTC (rev 243) +++ mspsim/se/sics/mspsim/core/ADC12.java 2008-04-17 00:23:19 UTC (rev 244) @@ -35,7 +35,8 @@ * * Each time a sample is converted the ADC12 system will check for EOS flag * and if not set it just continues with the next conversion (x + 1). - * If EOS next conv is startMem. + * If EOS next conv is startMem. + * Interrupt is triggered when the IE flag are set! * * * Author : Joakim Eriksson @@ -46,6 +47,8 @@ package se.sics.mspsim.core; +import com.sun.org.apache.xpath.internal.operations.Div; + public class ADC12 extends IOUnit { private static final boolean DEBUG = true; //false; @@ -93,32 +96,52 @@ 256, 384, 512, 768, 1024, 1024, 1024, 1024 }; + public static final int EOS_MASK = 0x80; private int adc12ctl0 = 0; private int adc12ctl1 = 0; private int[] adc12mctl = new int[16]; private int[] adc12mem = new int[16]; + private int adc12Pos = 0; private int shTime0 = 4; private int shTime1 = 4; private boolean adc12On = false; private boolean enableConversion; private boolean startConversion; - + private int shSource = 0; private int startMem = 0; private int adcDiv = 1; + private ADCInput adcInput[] = new ADCInput[8]; + private int conSeq; private int adc12ie; private int adc12ifg; + private int adc12iv; + + private int adcSSel; + private MSP430Core core; + private int adc12Vector = 7; - private int adcSSel; + private TimeEvent adcTrigger = new TimeEvent(0) { + public void execute(long t) { +// System.out.println(getName() + " **** executing update timers at " + t + " cycles=" + core.cycles); + convert(); + } + }; + public ADC12(MSP430Core cpu) { super(cpu.memory, 0); + core = cpu; } + + public void setADCInput(int adindex, ADCInput input) { + adcInput[adindex] = input; + } // write a value to the IO unit public void write(int address, int value, boolean word, @@ -134,8 +157,12 @@ if (DEBUG) System.out.println(getName() + ": Set SHTime0: " + shTime0 + " SHTime1: " + shTime1 + " ENC:" + enableConversion + " Start: " + startConversion + " ADC12ON: " + adc12On); + if (adc12On && enableConversion && startConversion) { + convert(); + } break; case ADC12CTL1: + adc12ctl1 = value; startMem = (value >> 12) & 0xf; shSource = (value >> 10) & 0x3; adcDiv = ((value >> 5) & 0x7) + 1; @@ -143,7 +170,6 @@ adcSSel = (value >> 3) & 0x03; if (DEBUG) System.out.println(getName() + ": Set startMem: " + startMem + " SHSource: " + shSource + " ConSeq-mode:" + conSeq + " Div: " + adcDiv + " ADCSSEL: " + adcSSel); - break; case ADC12IE: adc12ie = value; @@ -154,6 +180,7 @@ default: if (address >= ADC12MCTL0 && address <= ADC12MCTL15) { adc12mctl[address - ADC12MCTL0] = value & 0xff; + System.out.println("ADC12MCTL" + (address - ADC12MCTL0) + " source = " + (value & 0xf)); if ((value & 0x80) != 0) { System.out.println("ADC12MCTL" + (address - ADC12MCTL0) + " EOS bit set"); } @@ -176,7 +203,14 @@ if (address >= ADC12MCTL0 && address <= ADC12MCTL15) { return adc12mctl[address - ADC12MCTL0]; } else if (address >= ADC12MEM0) { - return adc12mem[address - ADC12MEM0]; + int reg = address - ADC12MEM0; + // Clear ifg! + adc12ifg &= ~(1 << reg); + if (adc12iv == reg) { + core.flagInterrupt(adc12Vector, this, false); + adc12iv = 0; + } + return adc12mem[reg]; } } return 0; @@ -186,6 +220,27 @@ return "ADC12"; } + private void convert() { + // Some noice... + ADCInput input = adcInput[adc12mctl[adc12Pos] & 0x7]; + adc12mem[adc12Pos] = input != null ? input.nextData() : 2048 + 100 - (int) Math.random() * 200; + if ((adc12ie & (1 << adc12Pos)) > 0) { + adc12ifg |= (1 << adc12Pos); + // This should check if there already is an hihger iv! + adc12iv = adc12Pos * 2 + 6; + core.flagInterrupt(adc12Vector, this, true); + } + // Increase + if ((adc12mctl[adc12Pos] & EOS_MASK) == EOS_MASK) { + adc12Pos = startMem; + } else { + adc12Pos = (adc12Pos + 1) & 0x0f; + } + int delay = adcDiv * (shTime0 + 13); + //System.out.println("Sampling again after: " + delay + " => " + adc12Pos); + core.scheduleTimeEvent(adcTrigger, adcTrigger.time + delay); + } + public void interruptServiced(int vector) { } } Added: mspsim/se/sics/mspsim/core/ADCInput.java =================================================================== --- mspsim/se/sics/mspsim/core/ADCInput.java (rev 0) +++ mspsim/se/sics/mspsim/core/ADCInput.java 2008-04-17 00:23:19 UTC (rev 244) @@ -0,0 +1,5 @@ +package se.sics.mspsim.core; + +public interface ADCInput { + public int nextData(); +} Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2008-04-16 18:26:57 UTC (rev 243) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2008-04-17 00:23:19 UTC (rev 244) @@ -48,6 +48,11 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.event.MouseListener; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.TargetDataLine; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; @@ -59,7 +64,7 @@ public class ESBGui extends JComponent implements KeyListener, MouseMotionListener, - MouseListener { + MouseListener, ADCInput { private static final long serialVersionUID = -139331418649524704L; @@ -76,6 +81,9 @@ public static final Color YELLOW_C = new Color(0xffffff00); public static final Color GREEN_C = new Color(0xff40ff40); + private static final float SAMPLE_RATE = 22050; + private static final int DL_BUFFER_SIZE = 2200; + private SerialMon serial; Beeper beeper; @@ -85,6 +93,8 @@ private boolean buttonDown = false; private boolean resetDown = false; + private TargetDataLine inDataLine; + public ESBGui(ESBNode node) { this.node = node; @@ -118,10 +128,43 @@ ((USART) usart).setUSARTListener(serial); } + IOUnit adc = cpu.getIOUnit("ADC12"); + if (adc instanceof ADC12) { + ((ADC12) adc).setADCInput(0, this); + } + beeper = new Beeper(); cpu.addIOUnit(-1,0,-1,0,beeper, true); + + + // Just a test... TODO: remove!!! + AudioFormat af = new AudioFormat(SAMPLE_RATE, 16, 1, true, false); + DataLine.Info dlin = + new DataLine.Info(TargetDataLine.class, af, DL_BUFFER_SIZE); + + try { + inDataLine = (TargetDataLine) AudioSystem.getLine(dlin); + + if (inDataLine == null) { + System.out.println("No in dataline"); + } else { + System.out.println("Format: " + inDataLine.getFormat()); + inDataLine.open(inDataLine.getFormat(), DL_BUFFER_SIZE); + inDataLine.start(); + } + } catch (Exception e) { + System.out.println("Problem while getting data line "); + e.printStackTrace(); + } } + byte[] data = new byte[2]; + public int nextData() { + inDataLine.read(data, 0, 2); + //System.out.println("sampled: " + ((data[1] << 8) + data[0])); + return data[0]; + } + public void mouseMoved(MouseEvent e) { // System.out.println("Mouse moved: " + e.getX() + "," + e.getY()); int x = e.getX(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-16 18:27:05
|
Revision: 243 http://mspsim.svn.sourceforge.net/mspsim/?rev=243&view=rev Author: joxe Date: 2008-04-16 11:26:57 -0700 (Wed, 16 Apr 2008) Log Message: ----------- added window commands. Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandContext.java mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/ExecCommand.java mspsim/se/sics/mspsim/cli/MiscCommands.java mspsim/se/sics/mspsim/cli/WindowTarget.java Modified: mspsim/se/sics/mspsim/cli/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandContext.java 2008-04-16 16:42:52 UTC (rev 242) +++ mspsim/se/sics/mspsim/cli/CommandContext.java 2008-04-16 18:26:57 UTC (rev 243) @@ -164,7 +164,7 @@ } public int executeCommand(String command) { - return commandHandler.executeCommand(command); + return commandHandler.executeCommand(command, this); } public String toString() { Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-16 16:42:52 UTC (rev 242) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-16 18:26:57 UTC (rev 243) @@ -80,7 +80,7 @@ } if (line != null && line.length() > 0) { lastLine = line; - executeCommand(line); + executeCommand(line, null); } } catch (IOException e) { e.printStackTrace(err); @@ -90,8 +90,11 @@ } } - public int executeCommand(String commandLine) { + public int executeCommand(String commandLine, CommandContext context) { String[][] parts; + PrintStream out = context == null ? this.out : context.out; + PrintStream err = context == null ? this.err : context.err; + try { parts = CommandParser.parseCommandLine(commandLine); } catch (Exception e) { Modified: mspsim/se/sics/mspsim/cli/ExecCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/ExecCommand.java 2008-04-16 16:42:52 UTC (rev 242) +++ mspsim/se/sics/mspsim/cli/ExecCommand.java 2008-04-16 18:26:57 UTC (rev 243) @@ -85,7 +85,9 @@ } public void lineRead(String line) { + System.out.println("Exec: sending a line: " + line); output.println(line); + output.flush(); } public void stopCommand(CommandContext context) { Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-16 16:42:52 UTC (rev 242) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-16 18:26:57 UTC (rev 243) @@ -232,7 +232,7 @@ @Override public void stopCommand(CommandContext context) { isRunning = false; - context.out.println("[repeat exit: " + commandLine + ']'); + context.err.println("[repeat exit: " + commandLine + ']'); context.exit(0); } }); Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-16 16:42:52 UTC (rev 242) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-16 18:26:57 UTC (rev 243) @@ -22,8 +22,9 @@ } @Override - public void lineRead(String line) { - if (line != null && line.startsWith("#!")) { + public void lineRead(String line) { + if (line == null) return; + if (line.startsWith("#!")) { line = line.substring(2); String[] parts = CommandParser.parseLine(line); String cmd = parts[0]; @@ -48,7 +49,7 @@ } else if (dataHandler != null) { dataHandler.handleCommand(parts); } - } else { + } else if (!line.startsWith("#")){ if (dataHandler != null) { dataHandler.lineRead(line); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-16 16:44:14
|
Revision: 242 http://mspsim.svn.sourceforge.net/mspsim/?rev=242&view=rev Author: nifi Date: 2008-04-16 09:42:52 -0700 (Wed, 16 Apr 2008) Log Message: ----------- added defaultValue to atoi() instead of throwing exception for non-number arguments Modified Paths: -------------- mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java Modified: mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java 2008-04-16 13:42:34 UTC (rev 241) +++ mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java 2008-04-16 16:42:52 UTC (rev 242) @@ -39,8 +39,6 @@ */ package se.sics.mspsim.cli; -import javax.swing.JComponent; - /** * @author joakime * @@ -51,17 +49,23 @@ public void handleCommand(String[] parts) { String cmd = parts[0]; if ("set".equals(cmd)) { - int index = atoi(parts[1]); + int index = atoi(parts[1], 0); String[] args = new String[parts.length - 3]; System.arraycopy(parts, 3, args, 0, args.length); setProperty(index, parts[2], args); + } else { + System.err.println("unknown command: " + cmd); } } - + public abstract void setProperty(int index, String param, String[] args); - - public int atoi(String data) { - return Integer.parseInt(data); + + public int atoi(String data, int defaultValue) { + try { + return Integer.parseInt(data); + } catch (NumberFormatException e) { + return defaultValue; + } } - + } Modified: mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-16 13:42:34 UTC (rev 241) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-16 16:42:52 UTC (rev 242) @@ -63,7 +63,7 @@ String parts[] = line.trim().split(" "); dataSeries.clear(); for (int i = 0; i < parts.length; i++) { - dataSeries.add(i, atoi(parts[i])); + dataSeries.add(i, atoi(parts[i], 0)); } panel.repaint(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-16 13:42:44
|
Revision: 241 http://mspsim.svn.sourceforge.net/mspsim/?rev=241&view=rev Author: nifi Date: 2008-04-16 06:42:34 -0700 (Wed, 16 Apr 2008) Log Message: ----------- changed to use command parser Modified Paths: -------------- mspsim/se/sics/mspsim/cli/WindowTarget.java Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-16 13:32:10 UTC (rev 240) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-16 13:42:34 UTC (rev 241) @@ -12,7 +12,7 @@ // Default in the current version - TODO: replace with better private JTextArea jta = new JTextArea(40,40); private WindowDataHandler dataHandler = null; - + public WindowTarget(String name) { window = new JFrame(name); window.getContentPane().add(jta); @@ -20,21 +20,19 @@ window.setVisible(true); targetName = name; } - + @Override public void lineRead(String line) { - // TODO Auto-generated method stub if (line != null && line.startsWith("#!")) { line = line.substring(2); - // TODO: replace with command parser - String[] parts = line.split(" "); + String[] parts = CommandParser.parseLine(line); String cmd = parts[0]; if ("bounds".equals(cmd)) { try { window.setBounds(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]), Integer.parseInt(parts[4])); } catch (Exception e) { - System.err.println("Cound not set bounds: " + line); + System.err.println("Could not set bounds: " + line); } } else if ("title".equals(cmd)) { window.setTitle(parts[1]); @@ -57,19 +55,17 @@ jta.append(line + '\n'); } } - // jta.set } public void close() { - // Notify all the currently active "streams" of lines to this windows - // data-handlers + // TODO Notify all the currently active "streams" of lines to this windows data-handlers window.setVisible(false); + window.dispose(); window.removeAll(); window = null; } public String getName() { - // TODO Auto-generated method stub return targetName; - } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-16 13:32:20
|
Revision: 240 http://mspsim.svn.sourceforge.net/mspsim/?rev=240&view=rev Author: nifi Date: 2008-04-16 06:32:10 -0700 (Wed, 16 Apr 2008) Log Message: ----------- added repeat command Modified Paths: -------------- mspsim/se/sics/mspsim/cli/MiscCommands.java Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-16 13:31:27 UTC (rev 239) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-16 13:32:10 UTC (rev 240) @@ -45,6 +45,7 @@ import java.util.Iterator; import java.util.regex.Pattern; import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.core.TimeEvent; import se.sics.mspsim.util.ComponentRegistry; /** @@ -157,7 +158,7 @@ } }); - handler.registerCommand("echo", new BasicCommand("echoes argument", "") { + handler.registerCommand("echo", new BasicCommand("echo arguments", "") { public int executeCommand(CommandContext context) { StringBuilder sb = new StringBuilder(); for (int i = 0, n = context.getArgumentCount(); i < n; i++) { @@ -168,7 +169,74 @@ return 0; } }); - + + handler.registerCommand("repeat", new BasicAsyncCommand("repeat the specified command line", "[-t delay] [-c count] <command line>") { + + private MSP430 cpu; + private int period = 1; + private int count = 0; + private int maxCount = -1; + private String commandLine; + private boolean isRunning = true; + + public int executeCommand(final CommandContext context) { + int index = 0; + do { + String a = context.getArgument(index); + if (a.startsWith("-")) { + if (a.equals("-t")) { + period = context.getArgumentAsInt(index + 1); + index += 2; + } else if (a.equals("-c")) { + maxCount = context.getArgumentAsInt(index + 1); + index += 2; + } else { + context.err.println("illegal option: " + a); + return 1; + } + } else { + break; + } + } while (true); + if (index + 1 < context.getArgumentCount()) { + context.err.println("too many arguments"); + return 1; + } + commandLine = context.getArgument(index); + + cpu = (MSP430) registry.getComponent(MSP430.class); + if (cpu == null) { + context.err.println("could not access the CPU."); + return 1; + } + + cpu.scheduleTimeEventMillis(new TimeEvent(0) { + + @Override + public void execute(long t) { + if (isRunning) { + count++; + context.executeCommand(commandLine); + if ((maxCount <= 0) || (count < maxCount)) { + cpu.scheduleTimeEventMillis(this, period * 1000d); + } else { + stopCommand(context); + } + } + } + + }, period * 1000d); + return 0; + } + + @Override + public void stopCommand(CommandContext context) { + isRunning = false; + context.out.println("[repeat exit: " + commandLine + ']'); + context.exit(0); + } + }); + handler.registerCommand("exec", new ExecCommand()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-16 13:31:28
|
Revision: 239 http://mspsim.svn.sourceforge.net/mspsim/?rev=239&view=rev Author: joxe Date: 2008-04-16 06:31:27 -0700 (Wed, 16 Apr 2008) Log Message: ----------- fixed the line sample chart to be an XYSeries chart. Modified Paths: -------------- mspsim/se/sics/mspsim/cli/WindowDataHandler.java mspsim/se/sics/mspsim/cli/WindowTarget.java mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java mspsim/se/sics/mspsim/util/NetworkConnection.java Added Paths: ----------- mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java Added: mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java (rev 0) +++ mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java 2008-04-16 13:31:27 UTC (rev 239) @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: AsyncCommand.java 187 2008-03-17 19:34:12Z joxe $ + * + * ----------------------------------------------------------------- + * + * + * Author : Joakim Eriksson + * Created : 9 april 2008 + * Updated : $Date: 2008-03-17 20:34:12 +0100 (Mon, 17 Mar 2008) $ + * $Revision: 187 $ + */ +package se.sics.mspsim.cli; + +import javax.swing.JComponent; + +/** + * @author joakime + * + */ +public abstract class AbstractWindowDataHandler implements WindowDataHandler { + + @Override + public void handleCommand(String[] parts) { + String cmd = parts[0]; + if ("set".equals(cmd)) { + int index = atoi(parts[1]); + String[] args = new String[parts.length - 3]; + System.arraycopy(parts, 3, args, 0, args.length); + setProperty(index, parts[2], args); + } + } + + public abstract void setProperty(int index, String param, String[] args); + + public int atoi(String data) { + return Integer.parseInt(data); + } + +} Modified: mspsim/se/sics/mspsim/cli/WindowDataHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowDataHandler.java 2008-04-16 13:26:40 UTC (rev 238) +++ mspsim/se/sics/mspsim/cli/WindowDataHandler.java 2008-04-16 13:31:27 UTC (rev 239) @@ -47,5 +47,6 @@ * */ public interface WindowDataHandler extends LineListener { - public JComponent getJComponent(); + public JComponent getComponent(); + public void handleCommand(String[] parts); } Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-16 13:26:40 UTC (rev 238) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-16 13:31:27 UTC (rev 239) @@ -9,13 +9,15 @@ private JFrame window; private String targetName; - private JTextArea jta = new JTextArea(20,20); + // Default in the current version - TODO: replace with better + private JTextArea jta = new JTextArea(40,40); private WindowDataHandler dataHandler = null; public WindowTarget(String name) { window = new JFrame(name); + window.getContentPane().add(jta); + window.pack(); window.setVisible(true); - window.getContentPane().add(jta); targetName = name; } @@ -24,6 +26,7 @@ // TODO Auto-generated method stub if (line != null && line.startsWith("#!")) { line = line.substring(2); + // TODO: replace with command parser String[] parts = line.split(" "); String cmd = parts[0]; if ("bounds".equals(cmd)) { @@ -42,8 +45,10 @@ if (dataHandler != null) { System.out.println("Replacing window data handler! " + parts[1] + " " + dataHandler); window.getContentPane().removeAll(); - window.getContentPane().add(dataHandler.getJComponent()); + window.getContentPane().add(dataHandler.getComponent()); } + } else if (dataHandler != null) { + dataHandler.handleCommand(parts); } } else { if (dataHandler != null) { Modified: mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-16 13:26:40 UTC (rev 238) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-16 13:31:27 UTC (rev 239) @@ -3,37 +3,32 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; -import java.util.Date; - import javax.swing.JComponent; import javax.swing.JPanel; - import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; -import org.jfree.data.time.Millisecond; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import se.sics.mspsim.cli.AbstractWindowDataHandler; -import se.sics.mspsim.cli.WindowDataHandler; -public class LineSampleChart implements WindowDataHandler { +public class LineSampleChart extends AbstractWindowDataHandler { JPanel panel; - private TimeSeriesCollection dataset; - private TimeSeries timeSeries; + private XYSeriesCollection dataset; + private XYSeries dataSeries; public LineSampleChart() { - DateAxis domain = new DateAxis("Time"); + NumberAxis domain = new NumberAxis("Index"); NumberAxis range = new NumberAxis("Value"); XYPlot xyplot = new XYPlot(); xyplot.setDomainAxis(domain); xyplot.setRangeAxis(range); // xyplot.setBackgroundPaint(Color.black); - xyplot.setDataset(dataset = new TimeSeriesCollection()); + xyplot.setDataset(dataset = new XYSeriesCollection()); DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.black); @@ -54,23 +49,35 @@ panel.setPreferredSize(new Dimension(400, 200)); panel.add(chartPanel, BorderLayout.CENTER); - timeSeries = new TimeSeries("-", Millisecond.class); - timeSeries.setMaximumItemCount(200); - dataset.addSeries(timeSeries); + dataSeries = new XYSeries("-"); + dataSeries.setMaximumItemCount(200); + dataset.addSeries(dataSeries); } - public JComponent getJComponent() { + public JComponent getComponent() { return panel; } @Override public void lineRead(String line) { - System.out.println("Got line to: " + line); String parts[] = line.trim().split(" "); - timeSeries.clear(); + dataSeries.clear(); for (int i = 0; i < parts.length; i++) { - timeSeries.add(new Millisecond(new Date(i)), Integer.parseInt(parts[i])); + dataSeries.add(i, atoi(parts[i])); } panel.repaint(); } + + @Override + public void setProperty(int index, String param, String[] args) { + if (index != 0) { + throw new IndexOutOfBoundsException("Illegal index: " + index); + } + if ("label".equals(param)) { + System.out.println("setting label to: " + args[0]); + dataSeries.setKey(args[0]); + } + panel.repaint(); + } + } Modified: mspsim/se/sics/mspsim/util/NetworkConnection.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-16 13:26:40 UTC (rev 238) +++ mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-16 13:31:27 UTC (rev 239) @@ -103,7 +103,8 @@ } } - // Data incoming from the network!!! + // Data incoming from the network!!! - forward to radio and if server, to + // all other nodes private void dataReceived(byte[] data, int len, ConnectionThread source) { int[] buf = new int[len]; if (listener != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-16 13:27:00
|
Revision: 238 http://mspsim.svn.sourceforge.net/mspsim/?rev=238&view=rev Author: nifi Date: 2008-04-16 06:26:40 -0700 (Wed, 16 Apr 2008) Log Message: ----------- added executeCommand(commandLine) + fixed bug in removePid Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandContext.java mspsim/se/sics/mspsim/cli/CommandHandler.java Modified: mspsim/se/sics/mspsim/cli/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandContext.java 2008-04-16 13:23:18 UTC (rev 237) +++ mspsim/se/sics/mspsim/cli/CommandContext.java 2008-04-16 13:26:40 UTC (rev 238) @@ -163,6 +163,10 @@ return 0.0; } + public int executeCommand(String command) { + return commandHandler.executeCommand(command); + } + public String toString() { return (pid >= 0 ? ("" + pid) : "?") + '\t' + (commandLine == null ? getCommandName() : commandLine); } Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-16 13:23:18 UTC (rev 237) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-16 13:26:40 UTC (rev 238) @@ -80,57 +80,7 @@ } if (line != null && line.length() > 0) { lastLine = line; - String[][] parts; - try { - parts = CommandParser.parseCommandLine(line); - } catch (Exception e) { - err.println("Error: failed to parse command:"); - e.printStackTrace(err); - parts = null; - } - if(parts != null && parts.length > 0 && checkCommands(parts) == 0) { - CommandContext[] commands = new CommandContext[parts.length]; - boolean error = false; - int pid = -1; - for (int i = 0; i < parts.length; i++) { - String[] args = parts[i]; - Command cmd = getCommand(args[0]); - if (i == 0 && cmd instanceof AsyncCommand) { - pid = ++pidCounter; - } - commands[i] = new CommandContext(this, mapTable, line, args, pid, cmd); - if (i > 0) { - PrintStream po = new PrintStream(new LineOutputStream((LineListener) commands[i].getCommand())); - commands[i - 1].setOutput(po, err); - } - // Last element also needs output! - if (i == parts.length - 1) { - commands[i].setOutput(out, err); - } - // TODO: Check if first command is also LineListener and set it up for input!! - } - // Execute when all is set-up in opposite order... - // TODO if error the command chain should be stopped - for (int i = parts.length - 1; i >= 0; i--) { - try { - int code = commands[i].getCommand().executeCommand(commands[i]); - if (code != 0) { - err.println("command '" + commands[i].getCommandName() - + "' failed with error code " + code); - error = true; - } - } catch (Exception e) { - err.println("Error: Command failed: " + e.getMessage()); - e.printStackTrace(err); - error = true; - } - } - if (error) { - // TODO close any started commands - } else if (pid >= 0) { - currentAsyncCommands.add(commands); - } - } + executeCommand(line); } } catch (IOException e) { e.printStackTrace(err); @@ -140,20 +90,77 @@ } } + public int executeCommand(String commandLine) { + String[][] parts; + try { + parts = CommandParser.parseCommandLine(commandLine); + } catch (Exception e) { + err.println("Error: failed to parse command:"); + e.printStackTrace(err); + return -1; + } + if(parts != null && parts.length > 0 && checkCommands(parts) == 0) { + CommandContext[] commands = new CommandContext[parts.length]; + boolean error = false; + int pid = -1; + for (int i = 0; i < parts.length; i++) { + String[] args = parts[i]; + Command cmd = getCommand(args[0]); + if (i == 0 && cmd instanceof AsyncCommand) { + pid = ++pidCounter; + } + commands[i] = new CommandContext(this, mapTable, commandLine, args, pid, cmd); + if (i > 0) { + PrintStream po = new PrintStream(new LineOutputStream((LineListener) commands[i].getCommand())); + commands[i - 1].setOutput(po, err); + } + // Last element also needs output! + if (i == parts.length - 1) { + commands[i].setOutput(out, err); + } + // TODO: Check if first command is also LineListener and set it up for input!! + } + // Execute when all is set-up in opposite order... + // TODO if error the command chain should be stopped + for (int i = parts.length - 1; i >= 0; i--) { + try { + int code = commands[i].getCommand().executeCommand(commands[i]); + if (code != 0) { + err.println("command '" + commands[i].getCommandName() + "' failed with error code " + code); + error = true; + } + } catch (Exception e) { + err.println("Error: Command failed: " + e.getMessage()); + e.printStackTrace(err); + error = true; + } + } + if (error) { + // TODO close any started commands + return 1; + } else if (pid >= 0) { + synchronized (currentAsyncCommands) { + currentAsyncCommands.add(commands); + } + } + } + return 0; + } + // This will return an instance that can be configured - // which is basically not OK... TODO - fix this!!! private Command getCommand(String cmd) { Command command = commands.get(cmd); if (command != null) { try { - return (Command) command.clone(); + return (Command) command.clone(); } catch (CloneNotSupportedException e) { - e.printStackTrace(err); + e.printStackTrace(err); } } return null; } - + private int checkCommands(String[][] cmds) { for (int i = 0; i < cmds.length; i++) { Command command = commands.get(cmds[i][0]); @@ -168,23 +175,23 @@ // TODO replace with command name String argHelp = command.getArgumentHelp(null); if (argHelp != null) { - int requiredCount = 0; - for (int j = 0, m = argHelp.length(); j < m; j++) { - if (argHelp.charAt(j) == '<') { - requiredCount++; - } - } - if (requiredCount > cmds[i].length - 1) { - // Too few arguments - err.println("Too few arguments for " + cmds[i][0]); - err.println("Usage: " + cmds[i][0] + ' ' + argHelp); - return -1; - } + int requiredCount = 0; + for (int j = 0, m = argHelp.length(); j < m; j++) { + if (argHelp.charAt(j) == '<') { + requiredCount++; + } + } + if (requiredCount > cmds[i].length - 1) { + // Too few arguments + err.println("Too few arguments for " + cmds[i][0]); + err.println("Usage: " + cmds[i][0] + ' ' + argHelp); + return -1; + } } } return 0; } - + public void setComponentRegistry(ComponentRegistry registry) { this.registry = registry; } @@ -290,22 +297,28 @@ } private boolean removePid(int pid) { - for (int i = 0; i < currentAsyncCommands.size(); i++) { - CommandContext[] contexts = currentAsyncCommands.get(i); - CommandContext cmd = contexts[0]; - if (pid == cmd.getPID()) { - for (int j = 0; j < contexts.length; j++) { - Command command = contexts[i].getCommand(); - // Stop any commands that have not yet been stopped... - if (command instanceof AsyncCommand && !contexts[i].hasExited()) { - AsyncCommand ac = (AsyncCommand) command; - ac.stopCommand(contexts[i]); - } + CommandContext[] contexts = null; + synchronized (currentAsyncCommands) { + for (int i = 0, n = currentAsyncCommands.size(); i < n; i++) { + CommandContext[] cntx = currentAsyncCommands.get(i); + if (pid == cntx[0].getPID()) { + contexts = cntx; + currentAsyncCommands.remove(cntx); + break; } - currentAsyncCommands.remove(contexts); - return true; } } + if (contexts != null) { + for (int i = 0; i < contexts.length; i++) { + Command command = contexts[i].getCommand(); + // Stop any commands that have not yet been stopped... + if (command instanceof AsyncCommand && !contexts[i].hasExited()) { + AsyncCommand ac = (AsyncCommand) command; + ac.stopCommand(contexts[i]); + } + } + return true; + } return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-16 13:23:53
|
Revision: 237 http://mspsim.svn.sourceforge.net/mspsim/?rev=237&view=rev Author: nifi Date: 2008-04-16 06:23:18 -0700 (Wed, 16 Apr 2008) Log Message: ----------- added flag to stop the duty command Modified Paths: -------------- mspsim/se/sics/mspsim/util/StatCommands.java Modified: mspsim/se/sics/mspsim/util/StatCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/StatCommands.java 2008-04-16 11:56:14 UTC (rev 236) +++ mspsim/se/sics/mspsim/util/StatCommands.java 2008-04-16 13:23:18 UTC (rev 237) @@ -98,6 +98,7 @@ private PrintStream out; private MultiDataSource[] sources; private double frequency; + private boolean isRunning = true; public int executeCommand(CommandContext context) { frequency = context.getArgumentAsDouble(0); @@ -119,22 +120,25 @@ @Override public void execute(long t) { - cpu.scheduleTimeEventMillis(this, 1000.0 / frequency); - for (int j = 0, n = sources.length; j < n; j++) { - MultiDataSource ds = sources[j]; - if (j > 0) out.print(' '); - for (int k = 0, m = ds.getModeMax(); k <= m; k++) { - if (k > 0) out.print(' '); - out.print(ds.getValue(k)); + if (isRunning) { + cpu.scheduleTimeEventMillis(this, 1000.0 / frequency); + for (int j = 0, n = sources.length; j < n; j++) { + MultiDataSource ds = sources[j]; + if (j > 0) out.print(' '); + for (int k = 0, m = ds.getModeMax(); k <= m; k++) { + if (k > 0) out.print(' '); + out.print(ds.getValue(k)); + } } + out.println(); } - out.println(); } }, 1000.0 / frequency); return 0; } public void stopCommand(CommandContext context) { + isRunning = false; context.exit(0); } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |