Fix build error when spice simulator build option is disabled.

This commit is contained in:
Wayne Stambaugh 2021-03-19 09:04:28 -04:00
parent 90742bba9f
commit dbb0a125ac
8 changed files with 147 additions and 91 deletions

View File

@ -248,6 +248,9 @@ set( EESCHEMA_SRCS
netlist_exporters/netlist_exporter_pspice.cpp
netlist_exporters/netlist_generator.cpp
# Simulator settings must get built even when the simulator build option is disabled.
sim/spice_settings.cpp
tools/backannotate.cpp
tools/assign_footprints.cpp
tools/ee_actions.cpp

View File

@ -28,7 +28,7 @@
#include <kiface_i.h>
#include <schematic_settings.h>
#include <settings/parameters.h>
#include <sim/ngspice.h>
#include <sim/spice_settings.h>
const int schSettingsSchemaVersion = 0;

View File

@ -30,9 +30,7 @@
#include "ngspice.h"
#include "spice_reporter.h"
#include <schematic_settings.h>
#include <settings/parameters.h>
#include "spice_settings.h"
#include <common.h>
#include <locale_io.h>
@ -59,29 +57,6 @@ using namespace std;
static const wxChar* const traceNgspice = wxT( "KICAD_NGSPICE" );
NGSPICE_SIMULATOR_SETTINGS::NGSPICE_SIMULATOR_SETTINGS(
JSON_SETTINGS* aParent, const std::string& aPath ) :
SPICE_SIMULATOR_SETTINGS( aParent, aPath ),
m_modelMode( NGSPICE_MODEL_MODE::USER_CONFIG )
{
m_params.emplace_back( new PARAM_ENUM<NGSPICE_MODEL_MODE>( "model_mode", &m_modelMode,
NGSPICE_MODEL_MODE::USER_CONFIG,
NGSPICE_MODEL_MODE::USER_CONFIG,
NGSPICE_MODEL_MODE::HSPICE ) );
}
bool NGSPICE_SIMULATOR_SETTINGS::operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const
{
const NGSPICE_SIMULATOR_SETTINGS* settings =
dynamic_cast<const NGSPICE_SIMULATOR_SETTINGS*>( &aRhs );
wxCHECK( settings, false );
return m_modelMode == settings->m_modelMode;
}
NGSPICE::NGSPICE() :
m_ngSpice_Init( nullptr ),
m_ngSpice_Circ( nullptr ),

View File

@ -34,39 +34,6 @@
class wxDynamicLibrary;
/**
* Spice model compatibility modes.
*
* @note The ngspice model modes are mutually exclusive.
*/
enum class NGSPICE_MODEL_MODE {
USER_CONFIG,
NGSPICE,
PSPICE,
LTSPICE,
LT_PSPICE,
HSPICE
};
/**
* Container for Ngspice simulator settings.
*/
class NGSPICE_SIMULATOR_SETTINGS : public SPICE_SIMULATOR_SETTINGS
{
public:
NGSPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const override;
NGSPICE_MODEL_MODE GetModelMode() const { return m_modelMode; }
void SetModelMode( NGSPICE_MODEL_MODE aMode ) { m_modelMode = aMode; }
private:
NGSPICE_MODEL_MODE m_modelMode;
};
class NGSPICE : public SPICE_SIMULATOR
{
public:

View File

@ -0,0 +1,61 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2021 CERN
*
* @author Wayne Stambaugh <stambaughw@gmail.com>
*
* 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 3
* 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:
* https://www.gnu.org/licenses/gpl-3.0.html
* or you may search the http://www.gnu.org website for the version 3 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "spice_settings.h"
#include <settings/parameters.h>
const int spiceSettingsSchemaVersion = 0;
SPICE_SIMULATOR_SETTINGS::SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent,
const std::string& aPath ) :
NESTED_SETTINGS( "simulator", spiceSettingsSchemaVersion, aParent, aPath )
{
}
NGSPICE_SIMULATOR_SETTINGS::NGSPICE_SIMULATOR_SETTINGS(
JSON_SETTINGS* aParent, const std::string& aPath ) :
SPICE_SIMULATOR_SETTINGS( aParent, aPath ),
m_modelMode( NGSPICE_MODEL_MODE::USER_CONFIG )
{
m_params.emplace_back( new PARAM_ENUM<NGSPICE_MODEL_MODE>( "model_mode", &m_modelMode,
NGSPICE_MODEL_MODE::USER_CONFIG,
NGSPICE_MODEL_MODE::USER_CONFIG,
NGSPICE_MODEL_MODE::HSPICE ) );
}
bool NGSPICE_SIMULATOR_SETTINGS::operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const
{
const NGSPICE_SIMULATOR_SETTINGS* settings =
dynamic_cast<const NGSPICE_SIMULATOR_SETTINGS*>( &aRhs );
wxCHECK( settings, false );
return m_modelMode == settings->m_modelMode;
}

View File

@ -0,0 +1,80 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2021 CERN
*
* @author Wayne Stambaugh <stambaughw@gmail.com>
*
* 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 3
* 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:
* https://www.gnu.org/licenses/gpl-3.0.html
* or you may search the http://www.gnu.org website for the version 3 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __SPICE_SETTINGS_H__
#define __SPICE_SETTINGS_H__
#include <settings/nested_settings.h>
/**
* Storage for simulator specific settings.
*/
class SPICE_SIMULATOR_SETTINGS : public NESTED_SETTINGS
{
public:
SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
virtual ~SPICE_SIMULATOR_SETTINGS() {}
virtual bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const = 0;
bool operator!=( const SPICE_SIMULATOR_SETTINGS& aRhs ) const { return !( *this == aRhs ); }
};
/**
* Ngspice simulator model compatibility modes.
*
* @note The ngspice model modes are mutually exclusive.
*/
enum class NGSPICE_MODEL_MODE {
USER_CONFIG,
NGSPICE,
PSPICE,
LTSPICE,
LT_PSPICE,
HSPICE
};
/**
* Container for Ngspice simulator settings.
*/
class NGSPICE_SIMULATOR_SETTINGS : public SPICE_SIMULATOR_SETTINGS
{
public:
NGSPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const override;
NGSPICE_MODEL_MODE GetModelMode() const { return m_modelMode; }
void SetModelMode( NGSPICE_MODEL_MODE aMode ) { m_modelMode = aMode; }
private:
NGSPICE_MODEL_MODE m_modelMode;
};
#endif // __SPICE_SETTINGS_H__

View File

@ -27,19 +27,6 @@
#include <confirm.h>
#include <schematic_settings.h>
const int ngspiceSettingsSchemaVersion = 0;
SPICE_SIMULATOR_SETTINGS::SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent,
const std::string& aPath ) :
NESTED_SETTINGS( "simulator", ngspiceSettingsSchemaVersion, aParent, aPath )
{
}
std::shared_ptr<SPICE_SIMULATOR> SPICE_SIMULATOR::CreateInstance( const std::string& )
{
try

View File

@ -27,9 +27,8 @@
#ifndef SPICE_SIMULATOR_H
#define SPICE_SIMULATOR_H
#include <settings/nested_settings.h>
#include "sim_types.h"
#include "spice_settings.h"
#include <string>
#include <vector>
@ -43,22 +42,6 @@ class SPICE_REPORTER;
typedef std::complex<double> COMPLEX;
/**
* Storage for simulator specific settings.
*/
class SPICE_SIMULATOR_SETTINGS : public NESTED_SETTINGS
{
public:
SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
virtual ~SPICE_SIMULATOR_SETTINGS() {}
virtual bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const = 0;
bool operator!=( const SPICE_SIMULATOR_SETTINGS& aRhs ) const { return !( *this == aRhs ); }
};
class SPICE_SIMULATOR
{
public: