Code cleanup
This commit is contained in:
parent
9e2485ea97
commit
e72b54a6e0
|
@ -44,81 +44,54 @@ bool NETLIST_EXPORTER_PSPICE::WriteNetlist( const wxString& aOutFileName, unsign
|
|||
|
||||
bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
||||
{
|
||||
bool aUsePrefix = aCtl & NET_USE_X_PREFIX;
|
||||
|
||||
int ret = 0;
|
||||
int nbitems;
|
||||
wxString text;
|
||||
wxArrayString spiceCommandAtBeginFile;
|
||||
wxArrayString spiceCommandAtEndFile;
|
||||
wxString msg;
|
||||
wxString netName;
|
||||
|
||||
#define BUFYPOS_LEN 4
|
||||
wxChar bufnum[BUFYPOS_LEN + 1];
|
||||
std::vector<int> pinSequence; // numeric indices into m_SortedComponentPinList
|
||||
wxArrayString stdPinNameArray; // Array containing Standard Pin Names
|
||||
wxString delimeters = wxT( "{:,; }" );
|
||||
wxString disableStr = wxT( "N" );
|
||||
|
||||
//std::map<wxString, int> netIndices;
|
||||
const wxString delimiters( "{:,; }" );
|
||||
const wxString disableStr( "N" );
|
||||
|
||||
// Prepare list of nets generation (not used here, but...
|
||||
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
|
||||
m_masterList->GetItem( ii )->m_Flag = 0;
|
||||
|
||||
// Create text list starting by [.-]pspice , or [.-]gnucap (simulator
|
||||
// commands) and create text list starting by [+]pspice , or [+]gnucap
|
||||
// (simulator commands)
|
||||
bufnum[BUFYPOS_LEN] = 0;
|
||||
SCH_SHEET_LIST sheetList( g_RootSheet );
|
||||
|
||||
std::vector<wxString> directives;
|
||||
|
||||
formatter->Print(0, "Kicad schematic\n");
|
||||
formatter->Print( 0, ".title KiCad schematic\n" );
|
||||
|
||||
m_probes.clear();
|
||||
m_netMap.clear();
|
||||
|
||||
// Ground net has to be always assigned to node 0
|
||||
m_netMap["GND"] = 0;
|
||||
|
||||
for( unsigned i = 0; i < sheetList.size(); i++ )
|
||||
{
|
||||
for( EDA_ITEM* item = sheetList[i].LastDrawList(); item; item = item->Next() )
|
||||
{
|
||||
size_t l1, l2;
|
||||
wxChar ident;
|
||||
|
||||
if( item->Type() != SCH_TEXT_T )
|
||||
continue;
|
||||
|
||||
SCH_TEXT* drawText = (SCH_TEXT*) item;
|
||||
|
||||
text = drawText->GetText();
|
||||
wxString text = static_cast<SCH_TEXT*>( item )->GetText();
|
||||
|
||||
if( text.IsEmpty() )
|
||||
continue;
|
||||
|
||||
ident = text.GetChar( 0 );
|
||||
|
||||
if( ident == '.' )
|
||||
if( text.GetChar( 0 ) == '.' )
|
||||
{
|
||||
printf("Directive found: '%s'\n", (const char *) text.c_str());
|
||||
directives.push_back(text);
|
||||
wxLogDebug( "Directive found: '%s'\n", (const char *) text.c_str() );
|
||||
directives.push_back( text );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_ReferencesAlreadyFound.Clear();
|
||||
|
||||
|
||||
int curNetIndex = 1;
|
||||
|
||||
for( unsigned sheet_idx = 0; sheet_idx < sheetList.size(); sheet_idx++ )
|
||||
{
|
||||
//printf( "* Sheet Name: %s\n",
|
||||
// TO_UTF8( sheetList[sheet_idx].PathHumanReadable() ) );
|
||||
|
||||
// Process component attributes to find Spice directives
|
||||
for( EDA_ITEM* item = sheetList[sheet_idx].LastDrawList(); item; item = item->Next() )
|
||||
{
|
||||
SCH_COMPONENT* comp = findNextComponentAndCreatePinList( item, &sheetList[sheet_idx] );
|
||||
|
@ -131,35 +104,35 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
// Reset NodeSeqIndex Count:
|
||||
pinSequence.clear();
|
||||
|
||||
SCH_FIELD* spicePrimitiveType = comp->FindField( wxT( "Spice_Primitive" ) );
|
||||
SCH_FIELD* spiceModel = comp->FindField( wxT( "Spice_Model" ) );
|
||||
SCH_FIELD* spicePrimitiveType = comp->FindField( wxT( "Spice_Primitive" ) );
|
||||
SCH_FIELD* spiceModel = comp->FindField( wxT( "Spice_Model" ) );
|
||||
|
||||
wxString RefName = comp->GetRef( &sheetList[sheet_idx] );
|
||||
wxString CompValue = comp->GetField( VALUE )->GetText();
|
||||
|
||||
wxString model("");
|
||||
wxString primType ("X");
|
||||
wxString model( "" );
|
||||
wxString primType( "X" );
|
||||
|
||||
if(spicePrimitiveType)
|
||||
primType = spicePrimitiveType->GetText();
|
||||
else {
|
||||
if (RefName.StartsWith(wxT("IC")) || RefName.StartsWith("U") )
|
||||
primType = wxT("X"); // subckt
|
||||
else
|
||||
primType = RefName.GetChar(0);
|
||||
}
|
||||
|
||||
if(spiceModel)
|
||||
if( spicePrimitiveType )
|
||||
{
|
||||
// printf("model specified\n");
|
||||
model = spiceModel->GetText();
|
||||
} else {
|
||||
// printf("no model\n");
|
||||
model = CompValue;
|
||||
primType = spicePrimitiveType->GetText();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert ceratin modules to subcircuits
|
||||
if( RefName.StartsWith( "IC" ) || RefName.StartsWith( "U" ) )
|
||||
primType = "X";
|
||||
else
|
||||
primType = RefName.GetChar( 0 );
|
||||
}
|
||||
|
||||
if( spiceModel )
|
||||
model = spiceModel->GetText();
|
||||
else
|
||||
model = CompValue;
|
||||
|
||||
// Check to see if component should be removed from Spice Netlist:
|
||||
SCH_FIELD* netlistEnabledField = comp->FindField( wxT( "Spice_Netlist_Enabled" ) );
|
||||
SCH_FIELD* netlistEnabledField = comp->FindField( wxT( "Spice_Netlist_Enabled" ) );
|
||||
|
||||
if( netlistEnabledField )
|
||||
{
|
||||
|
@ -170,7 +143,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
}
|
||||
|
||||
// Check if Alternative Pin Sequence is Available:
|
||||
SCH_FIELD* spiceSeqField = comp->FindField( wxT( "Spice_Node_Sequence" ) );
|
||||
SCH_FIELD* spiceSeqField = comp->FindField( wxT( "Spice_Node_Sequence" ) );
|
||||
|
||||
if( spiceSeqField )
|
||||
{
|
||||
|
@ -180,7 +153,6 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
// Verify Field Exists and is not empty:
|
||||
if( !nodeSeqIndexLineStr.IsEmpty() )
|
||||
{
|
||||
|
||||
// Create an Array of Standard Pin Names from part definition:
|
||||
stdPinNameArray.Clear();
|
||||
|
||||
|
@ -195,7 +167,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
}
|
||||
|
||||
// Get Alt Pin Name Array From User:
|
||||
wxStringTokenizer tkz( nodeSeqIndexLineStr, delimeters );
|
||||
wxStringTokenizer tkz( nodeSeqIndexLineStr, delimiters );
|
||||
|
||||
while( tkz.HasMoreTokens() )
|
||||
{
|
||||
|
@ -206,15 +178,13 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
seq = stdPinNameArray.Index(pinIndex);
|
||||
|
||||
if( seq != wxNOT_FOUND )
|
||||
{
|
||||
pinSequence.push_back( seq );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO remove?
|
||||
#if 0
|
||||
if(CompValue == wxT("SPICE_PROBE"))
|
||||
{
|
||||
NETLIST_OBJECT* pin = m_SortedComponentPinList[0];
|
||||
|
@ -231,12 +201,14 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
//if( RefName.StartsWith( wxT( "U" ) ) || RefName.StartsWith( wxT( "IC" ) ) )
|
||||
// RefName = wxT( "X" ) + RefName;
|
||||
}
|
||||
#endif
|
||||
|
||||
printf( "Ref %s primType %s model/value '%s'\n", TO_UTF8( RefName ), (const char*)primType.c_str(), (const char *)model.c_str() );
|
||||
wxLogDebug( "Ref %s primType %s model/value '%s'\n",
|
||||
TO_UTF8( RefName ), (const char*) primType.c_str(), (const char*) model.c_str() );
|
||||
|
||||
int activePinIndex = 0;
|
||||
|
||||
formatter->Print(0, "%s%s ", (const char *)primType.c_str(), (const char *)RefName.c_str());
|
||||
formatter->Print( 0, "%s%s ", (const char*) primType.c_str(), (const char*) RefName.c_str() );
|
||||
|
||||
for( unsigned ii = 0; ii < m_SortedComponentPinList.size(); ii++ )
|
||||
{
|
||||
|
@ -274,7 +246,8 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
wxString netName = pin->GetNetName();
|
||||
int netIdx;
|
||||
|
||||
if (m_netMap.find(netName) == m_netMap.end())
|
||||
// Assign a node number (associated with net)
|
||||
if( m_netMap.find( netName ) == m_netMap.end() )
|
||||
{
|
||||
netIdx = curNetIndex++;
|
||||
m_netMap[netName] = netIdx;
|
||||
|
@ -282,6 +255,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
netIdx = m_netMap[netName];
|
||||
}
|
||||
|
||||
// TODO remove?
|
||||
//printf("net %s index %d\n", (const char*)netName.c_str(), netIdx);
|
||||
// sprintPinNetName( netName , wxT( "N-%.6d" ), pin, aUseNetcodeAsNetName );
|
||||
|
||||
|
@ -294,25 +268,22 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
|
||||
// ret |= fprintf( f, " %s", TO_UTF8( netName ) );
|
||||
|
||||
formatter->Print(0, "%d ", netIdx );
|
||||
formatter->Print( 0, "%d ", netIdx );
|
||||
}
|
||||
|
||||
formatter->Print(0, "%s\n",(const char *) model.c_str());
|
||||
|
||||
|
||||
formatter->Print( 0, "%s\n", (const char*) model.c_str() );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
for( auto dir : directives )
|
||||
// Print out all directives found in the text fields on the schematics
|
||||
for( auto& dir : directives )
|
||||
{
|
||||
formatter->Print(0, "%s\n", (const char *)dir.c_str());
|
||||
|
||||
formatter->Print( 0, "%s\n", (const char*) dir.c_str() );
|
||||
}
|
||||
|
||||
formatter->Print(0, ".end\n");
|
||||
formatter->Print( -1, ".end\n" );
|
||||
|
||||
// TODO remove?
|
||||
#if 0
|
||||
m_SortedComponentPinList.clear();
|
||||
|
||||
|
@ -335,9 +306,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* formatter, int aCtl )
|
|||
|
||||
ret |= fprintf( f, "\n.end\n" );
|
||||
fclose( f );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
return ret >= 0;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "ngspice.h"
|
||||
|
||||
#include <wx/dynlib.h>
|
||||
#include <wx/log.h>
|
||||
#include <reporter.h>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -56,7 +57,7 @@ NGSPICE::~NGSPICE()
|
|||
|
||||
void NGSPICE::Init()
|
||||
{
|
||||
m_ngSpice_Init( &cbSendChar, &cbSendStat, NULL, NULL, NULL, NULL, this);
|
||||
m_ngSpice_Init( &cbSendChar, &cbSendStat, NULL, NULL, NULL, NULL, this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,11 +74,10 @@ const vector<double> NGSPICE::GetPlot( const string& aName, int aMaxLen )
|
|||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool NGSPICE::LoadNetlist(const string& aNetlist)
|
||||
bool NGSPICE::LoadNetlist( const string& aNetlist )
|
||||
{
|
||||
// TODO remove the hard limit
|
||||
char* lines[16384];
|
||||
|
@ -90,7 +90,7 @@ bool NGSPICE::LoadNetlist(const string& aNetlist)
|
|||
ss.getline( line, sizeof(line) );
|
||||
|
||||
lines[n++] = strdup(line);
|
||||
printf("l '%s'\n", line);
|
||||
wxLogDebug( "l '%s'\n", line );
|
||||
}
|
||||
|
||||
lines[n] = NULL;
|
||||
|
@ -119,18 +119,18 @@ void NGSPICE::dump()
|
|||
|
||||
for( int i = 0; plots[i]; ++i )
|
||||
{
|
||||
printf( "-> plot : %s\n", plots[i] );
|
||||
wxLogDebug( "-> plot : %s\n", plots[i] );
|
||||
char** vecs = m_ngSpice_AllVecs( plots[i] );
|
||||
|
||||
for( int j = 0; vecs[j]; j++ )
|
||||
{
|
||||
printf( " - vector %s\n", vecs[j] );
|
||||
wxLogDebug( " - vector %s\n", vecs[j] );
|
||||
|
||||
vector_info* vi = m_ngGet_Vec_Info( vecs[j] );
|
||||
|
||||
printf( " - v_type %x\n", vi->v_type );
|
||||
printf( " - v_flags %x\n", vi->v_flags );
|
||||
printf( " - v_length %d\n", vi->v_length );
|
||||
wxLogDebug( " - v_type %x\n", vi->v_type );
|
||||
wxLogDebug( " - v_flags %x\n", vi->v_flags );
|
||||
wxLogDebug( " - v_length %d\n", vi->v_length );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ main()
|
|||
plt::plot(t, v2,"r--");
|
||||
|
||||
for(int i=0;i<v1.size();i++)
|
||||
printf("%.10f\n",v2[i]);
|
||||
wxLogDebug("%.10f\n",v2[i]);
|
||||
|
||||
// Add graph title
|
||||
plt::title("Sample figure");
|
||||
|
@ -193,11 +193,11 @@ string NGSPICE::GetConsole() const {
|
|||
}
|
||||
|
||||
|
||||
int NGSPICE::cbSendChar( char* what, int id, void* user)
|
||||
int NGSPICE::cbSendChar( char* what, int id, void* user )
|
||||
{
|
||||
NGSPICE* sim = reinterpret_cast<NGSPICE*>( user );
|
||||
|
||||
printf("sim %p cr %p\n",sim, sim->m_consoleReporter );
|
||||
wxLogDebug( "sim %p cr %p\n", sim, sim->m_consoleReporter );
|
||||
|
||||
if( sim->m_consoleReporter )
|
||||
sim->m_consoleReporter->Report( what );
|
||||
|
@ -206,10 +206,10 @@ int NGSPICE::cbSendChar( char* what, int id, void* user)
|
|||
}
|
||||
|
||||
|
||||
int NGSPICE::cbSendStat( char* what, int id, void* user)
|
||||
int NGSPICE::cbSendStat( char* what, int id, void* user )
|
||||
{
|
||||
/* NGSPICE *sim = reinterpret_cast<NGSPICE*>(user);
|
||||
if(sim->m_consoleReporter)
|
||||
sim->m_consoleReporter->Report(what);*/
|
||||
/* NGSPICE* sim = reinterpret_cast<NGSPICE*>( user );
|
||||
if( sim->m_consoleReporter )
|
||||
sim->m_consoleReporter->Report( what );*/
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,41 +1,32 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <schframe.h>
|
||||
#include <fctsys.h>
|
||||
#include <kiface_i.h>
|
||||
#include <pgm_base.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <gestfich.h>
|
||||
#include <confirm.h>
|
||||
#include <base_units.h>
|
||||
#include <msgpanel.h>
|
||||
#include <html_messagebox.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <netlist.h>
|
||||
#include <lib_pin.h>
|
||||
#include <class_library.h>
|
||||
#include <schframe.h>
|
||||
#include <sch_component.h>
|
||||
|
||||
#include <dialog_helpers.h>
|
||||
#include <libeditframe.h>
|
||||
#include <viewlib_frame.h>
|
||||
#include <hotkeys.h>
|
||||
#include <eeschema_config.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
|
||||
#include <invoke_sch_dialog.h>
|
||||
#include <dialogs/dialog_schematic_find.h>
|
||||
|
||||
#include <wx/display.h>
|
||||
#include <build_version.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <netlist_exporter_kicad.h>
|
||||
#include <kiway.h>
|
||||
|
||||
#include <netlist_exporter_kicad.h>
|
||||
#include <netlist_exporters/netlist_exporter_pspice.h>
|
||||
|
||||
#include <reporter.h>
|
||||
|
@ -52,10 +43,9 @@
|
|||
class SIM_REPORTER : public REPORTER
|
||||
{
|
||||
public:
|
||||
SIM_REPORTER( wxRichTextCtrl* console )
|
||||
SIM_REPORTER( wxRichTextCtrl* aConsole )
|
||||
{
|
||||
m_console = console;
|
||||
|
||||
m_console = aConsole;
|
||||
}
|
||||
|
||||
~SIM_REPORTER()
|
||||
|
@ -64,7 +54,7 @@ public:
|
|||
|
||||
virtual REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED )
|
||||
{
|
||||
m_console->WriteText(aText);
|
||||
m_console->WriteText( aText );
|
||||
m_console->Newline();
|
||||
return *this;
|
||||
}
|
||||
|
@ -112,7 +102,7 @@ void SIM_PLOT_FRAME::StartSimulation()
|
|||
m_exporter->Format( &formatter, GNL_ALL );
|
||||
//m_plotPanel->DeleteTraces();
|
||||
|
||||
printf("*******************\n%s\n", (const char *)formatter.GetString().c_str());
|
||||
wxLogDebug( "*******************\n%s\n", (const char *)formatter.GetString().c_str() );
|
||||
|
||||
m_simulator->LoadNetlist( formatter.GetString() );
|
||||
m_simulator->Command("run\n");
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __sim_plot_frame__
|
||||
#define __sim_plot_frame__
|
||||
|
||||
|
@ -7,11 +32,8 @@ Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
|
|||
*/
|
||||
|
||||
#include "sim_plot_frame_base.h"
|
||||
|
||||
#include "kiway_player.h"
|
||||
|
||||
#include <netlist_exporters/netlist_exporter_pspice.h>
|
||||
//// end generated include
|
||||
|
||||
class SPICE_SIMULATOR;
|
||||
class NETLIST_EXPORTER_PSPICE;
|
||||
|
@ -25,9 +47,9 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
|
|||
SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent );
|
||||
~SIM_PLOT_FRAME();
|
||||
|
||||
void SetSchFrame( SCH_EDIT_FRAME* schFrame )
|
||||
void SetSchFrame( SCH_EDIT_FRAME* aSchFrame )
|
||||
{
|
||||
m_schematicFrame = schFrame;
|
||||
m_schematicFrame = aSchFrame;
|
||||
}
|
||||
|
||||
void StartSimulation();
|
||||
|
@ -37,7 +59,7 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
|
|||
void TogglePythonConsole();
|
||||
|
||||
private:
|
||||
virtual void onNewPlot( wxCommandEvent& event ) { NewPlot(); }
|
||||
virtual void onNewPlot( wxCommandEvent& aEvent ) { NewPlot(); }
|
||||
|
||||
SIM_PLOT_PANEL* m_currentPlot;
|
||||
SCH_EDIT_FRAME* m_schematicFrame;
|
||||
|
@ -45,7 +67,6 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
|
|||
SPICE_SIMULATOR* m_simulator;
|
||||
wxWindow* m_pyConsole;
|
||||
|
||||
//// end generated class members
|
||||
};
|
||||
|
||||
#endif // __sim_plot_frame__
|
||||
|
|
|
@ -1,32 +1,56 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "sim_plot_panel.h"
|
||||
|
||||
static SIM_PLOT_PANEL *panel = NULL;
|
||||
static SIM_PLOT_PANEL* panel = NULL;
|
||||
|
||||
static int drawPlotFunc( mglGraph *graph )
|
||||
static int drawPlotFunc( mglGraph* aGraph )
|
||||
{
|
||||
printf("DrawPlot [%d traces]!\n", panel->m_traces.size());
|
||||
printf( "DrawPlot [%lu traces]!\n", panel->m_traces.size() );
|
||||
|
||||
graph->Clf();
|
||||
//graph->SetRanges(-10e-3,10e-3,-2,2);
|
||||
graph->Axis("x");
|
||||
graph->Label('x',"Time",0);
|
||||
graph->SetRange('x', 0, 10e-3);
|
||||
aGraph->Clf();
|
||||
//aGraph->SetRanges(-10e-3,10e-3,-2,2);
|
||||
aGraph->Axis( "x" );
|
||||
aGraph->Label( 'x', "Time", 0 );
|
||||
aGraph->SetRange( 'x', 0, 10e-3 );
|
||||
|
||||
graph->Axis("y");
|
||||
graph->Label('y',"Voltage",0);
|
||||
graph->SetRange('y', -1.5, 1.5);
|
||||
aGraph->Axis( "y" );
|
||||
aGraph->Label( 'y', "Voltage", 0 );
|
||||
aGraph->SetRange( 'y', -1.5, 1.5 );
|
||||
|
||||
for( auto t : panel->m_traces )
|
||||
{
|
||||
graph->AddLegend( (const char*) t.name.c_str(), "" );
|
||||
graph->Plot( t.y );
|
||||
aGraph->AddLegend( (const char*) t.name.c_str(), "" );
|
||||
aGraph->Plot( t.y );
|
||||
}
|
||||
|
||||
graph->Box();
|
||||
graph->Grid();
|
||||
if ( panel->m_traces.size() )
|
||||
graph->Legend(1,"-#");
|
||||
aGraph->Box();
|
||||
aGraph->Grid();
|
||||
|
||||
if( panel->m_traces.size() )
|
||||
aGraph->Legend( 1, "-#" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -49,18 +73,20 @@ SIM_PLOT_PANEL::~SIM_PLOT_PANEL()
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_PANEL::AddTrace(const wxString& name, int n_points, double *t, double *x, int flags )
|
||||
void SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints,
|
||||
double* aT, double* aX, int aFlags )
|
||||
{
|
||||
Trace trace;
|
||||
TRACE trace;
|
||||
|
||||
trace.name = name;
|
||||
trace.x.Set(t, n_points);
|
||||
trace.y.Set(x, n_points);
|
||||
trace.name = aName;
|
||||
trace.x.Set( aT, aPoints );
|
||||
trace.y.Set( aX, aPoints );
|
||||
|
||||
m_traces.push_back(trace);
|
||||
m_traces.push_back( trace );
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_PANEL::DeleteTraces()
|
||||
{
|
||||
m_traces.clear();
|
||||
|
|
|
@ -1,33 +1,49 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __SIM_PLOT_PANEL_H
|
||||
#define __SIM_PLOT_PANEL_H
|
||||
|
||||
#include "mgl2/canvas_wnd.h"
|
||||
#include "mgl2/wx.h"
|
||||
|
||||
|
||||
class SIM_PLOT_PANEL : public wxMathGL
|
||||
{
|
||||
public:
|
||||
SIM_PLOT_PANEL( wxWindow * parent,
|
||||
wxWindowID id,
|
||||
const wxPoint & pos = wxDefaultPosition,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString & name = wxPanelNameStr );
|
||||
SIM_PLOT_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr );
|
||||
|
||||
~SIM_PLOT_PANEL();
|
||||
|
||||
|
||||
|
||||
|
||||
struct Trace {
|
||||
struct TRACE {
|
||||
wxString name;
|
||||
mglData x, y;
|
||||
};
|
||||
|
||||
std::vector<Trace> m_traces;
|
||||
std::vector<TRACE> m_traces;
|
||||
|
||||
void AddTrace(const wxString& name, int n_points, double *t, double *x, int flags = 0 );
|
||||
void AddTrace( const wxString& name, int n_points, double *t, double *x, int flags = 0 );
|
||||
void DeleteTraces();
|
||||
};
|
||||
|
||||
|
|
|
@ -1,58 +1,33 @@
|
|||
#include <schframe.h>
|
||||
#include <fctsys.h>
|
||||
#include <kiface_i.h>
|
||||
#include <pgm_base.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <gestfich.h>
|
||||
#include <confirm.h>
|
||||
#include <base_units.h>
|
||||
#include <msgpanel.h>
|
||||
#include <html_messagebox.h>
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <general.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <netlist.h>
|
||||
#include <lib_pin.h>
|
||||
#include <class_library.h>
|
||||
#include <schframe.h>
|
||||
#include <sch_component.h>
|
||||
|
||||
#include <dialog_helpers.h>
|
||||
#include <libeditframe.h>
|
||||
#include <viewlib_frame.h>
|
||||
#include <hotkeys.h>
|
||||
#include <eeschema_config.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
|
||||
#include <invoke_sch_dialog.h>
|
||||
#include <dialogs/dialog_schematic_find.h>
|
||||
|
||||
#include <wx/display.h>
|
||||
#include <build_version.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <netlist_exporter_kicad.h>
|
||||
#include <kiway.h>
|
||||
|
||||
#include <netlist_exporters/netlist_exporter_pspice.h>
|
||||
|
||||
#include <sim/sim_plot_frame.h>
|
||||
#include <schframe.h>
|
||||
#include "sim_plot_frame.h"
|
||||
|
||||
void SCH_EDIT_FRAME::OnSimulationRun( wxCommandEvent& event )
|
||||
{
|
||||
#if 0
|
||||
|
||||
NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
|
||||
NETLIST_EXPORTER_PSPICE exporter( net_atoms, Prj().SchLibs() );
|
||||
STRING_FORMATTER formatter;
|
||||
|
||||
exporter.Format( &formatter, GNL_ALL );
|
||||
|
||||
printf("*******************\n%s\n", (const char *)formatter.GetString().c_str());
|
||||
#endif
|
||||
|
||||
SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
|
||||
|
||||
if( !simFrame )
|
||||
|
@ -61,7 +36,6 @@ void SCH_EDIT_FRAME::OnSimulationRun( wxCommandEvent& event )
|
|||
simFrame->Show( true );
|
||||
}
|
||||
|
||||
|
||||
// On Windows, Raise() does not bring the window on screen, when iconized
|
||||
if( simFrame->IsIconized() )
|
||||
simFrame->Iconize( false );
|
||||
|
@ -72,8 +46,12 @@ void SCH_EDIT_FRAME::OnSimulationRun( wxCommandEvent& event )
|
|||
simFrame->StartSimulation();
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::OnSimulationStop( wxCommandEvent& event )
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::OnSimulationAddProbe( wxCommandEvent& event )
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
|
|
@ -47,8 +47,6 @@ public:
|
|||
|
||||
static SPICE_SIMULATOR* CreateInstance( const std::string& aName );
|
||||
|
||||
typedef void (*ConsoleCallback)( bool isError, const std::string& message, void* userData );
|
||||
|
||||
virtual void Init() = 0;
|
||||
virtual bool LoadNetlist( const std::string& aNetlist ) = 0;
|
||||
virtual bool Command( const std::string& aCmd ) = 0;
|
||||
|
@ -58,7 +56,7 @@ public:
|
|||
m_consoleReporter = aReporter;
|
||||
}
|
||||
|
||||
virtual const std::vector<double> GetPlot( const std::string& aName, int aMaxLen = -1) = 0;
|
||||
virtual const std::vector<double> GetPlot( const std::string& aName, int aMaxLen = -1 ) = 0;
|
||||
|
||||
protected:
|
||||
REPORTER* m_consoleReporter;
|
||||
|
|
Loading…
Reference in New Issue