Class Reference plotData

This class provides functions to handel simulation results and convert it into different formats. More...

Member

void setSource(string filename,string type)
string source()
string sourceType()
void setPlotTool(string plotTool)
string plotTool()
void setPortMapping(string netlistType)
string mappedPort(string port)
string nodeName()
string deviceName()
string portName()
void readSource()
bool dataRead()
void writeData(string filename, string format, intList items)
int items()
doubleList itemData(int)
string itemTitle(int)
string itemNativeTitle(int)
string itemUnit(int)
int findItem()
int findItemTitle(string title)
void setError(string error)

Detailed Description

graph LR sd(schematicDisplay)--setProbeMode-->pd(plotData) cb(callbacks)--iPlot-->pd pd--itemData-->dl(doubleList) click sd "/layoutscript/api/schematicdisplay" click cb "/layoutscript/api/callbacks" click pd "/layoutscript/api/plotdata" click dl "/layoutscript/api/doublelist" classDef thisClas fill:#eaf5fc,stroke:#3c7faa,stroke-width:4px; classDef clas fill:#eaf5fc,stroke:#3c7faa,stroke-width:1px; class pd thisClas class sd,cb,dl clas

plotData holds simulation waveforms so the Schematic Editor can probe a net after a run. LayoutEditor does not simulate here; a macro loads a result file with setSource and readSource, then calls schematicDisplay setProbeMode with this object. When the user clicks a node, a device or a port, the plot macro runs and iPlot() from callbacks returns the same data. nodeName, deviceName and portName tell you what was clicked. findItem picks the matching data row; itemData returns that row as a doubleList. Call readSource before writeData, items or itemTitle. Supported source types are ngspice, ltspice and qucs (ASCII). If a row cannot be found, findItem returns -1; setError shows a message after the plot macro finishes.

Example:

plotData *pd = iPlot();
if (pd == NULL)
 return 1;
if (!pd->dataRead())
 pd->readSource();
int row = pd->findItem();
if (row < 0)
 row = pd->findItemTitle(pd->nodeName());
if (row < 0) {
 pd->setError("no waveform for this node");
 return 1;
}
doubleList y = pd->itemData(row);
string unit = pd->itemUnit(row);

Member Function Documentation


void plotData::setSource(string filename,string type)

Sets the result file filename and its type. Supported types are ngspice, ltspice and qucs, all ASCII encoded.

Parameter:
filename path of the file
type mode selector

string plotData::source()

Returns: the file name of the simulation results.


string plotData::sourceType()

Returns: the type of the simulation result file.


void plotData::setPlotTool(string plotTool)

Sets the plot macro that displays the results. If nothing is set, the last used plot macro is used. In probe mode the user can also change the plot macro.


string plotData::plotTool()

Returns: the file name of the chosen plot macro.


void plotData::setPortMapping(string netlistType)

Sets the netlist format used to map device port names onto names in the result file.


string plotData::mappedPort(string port)

Returns: the mapped name of port. For a SPICE transistor, devicename:port for the collector becomes Ic(short_devicename).


string plotData::nodeName()

Returns: the name of the clicked node in probe mode, or an empty string if a node was not selected.


string plotData::deviceName()

Returns: the name of the clicked device in probe mode, or an empty string if a device was not selected.


string plotData::portName()

Returns: the name of the clicked device port in probe mode, or an empty string if a port was not selected.


void plotData::readSource()

Loads the simulation file into memory. Call this before writeData, items, itemData or findItem.


bool plotData::dataRead()

Returns: true if readSource has already loaded the file, otherwise false.


void plotData::writeData(string filename, string format, intList items)

Writes previously loaded data to filename. format is array (tab-separated), csv (comma-separated, as in the setup dialog) or cvseurope (semicolon-separated, comma as decimal sign). If items is empty, every row is written; otherwise only the listed row numbers are written.

Parameter:
filename output file name
format array, csv or cvseurope
items row numbers to write, or empty for all rows

int plotData::items()

Returns: the number of loaded data rows.


doubleList plotData::itemData(int)

Returns: one data row as a doubleList. The argument is the row index from 0 to items()-1.


string plotData::itemTitle(int)

Returns: the display title of that data row.


string plotData::itemNativeTitle(int)

Returns: the title as stored in the simulation file. It matches itemTitle when no separate native name exists.


string plotData::itemUnit(int)

Returns: the unit of that data row, or an empty string if the file has no unit.


int plotData::findItem()

Returns: the row index of the clicked node, device or port, or -1 if no matching row is found.


int plotData::findItemTitle(string title)

Returns: the row index whose title is title.


void plotData::setError(string error)

Sets an error message that is shown after the plot macro finishes.