Commit Graph

72 Commits

Author SHA1 Message Date
Seth Hillbrand 35ac39844f Clean up some auto usage
Don't make new copies of shared_ptr if we can use references.  Keep auto
usage down to hard-to-type-out sequences
2022-08-15 11:29:45 -07:00
Mikolaj Wielgus a1a99b1ec2 Sim QA: Check NGSPICE's LoadNetlist() and Run() status code 2022-08-10 17:54:28 +02:00
Mikolaj Wielgus 739b9255d9 Sim Model Editor improvements
- Tab-switching,
- Automatic expansion of categories on tab-switch,
- Various minor simulation improvements,
- Various new simulation-related bugfixes.
2022-07-30 02:25:34 +00:00
Mikolaj Wielgus 978f01553b Sim Model Editor: Serialize models in fields
Implemented serialization and deserialization of models in symbol fields
through the SIM_VALUE class. We don't carry the Spice legacy of
case-insensitive suffixes, instead we conform to the SI standard (i.e. M
is Mega, not milli, P is peta, p is pico).

Parameter grid value validation is implemented by simply not allowing
any characters that will make the value invalid (instead of highlighting
the field in a red color). This will likely be changed at some point in
the future.
2022-07-30 02:25:34 +00:00
Eduardo Behr f246646d7a Fix severe simulation memory leaks 2022-05-28 20:40:24 +00:00
Sylwester Kocjan a9c61d21ca eeschema: fix crash when closing simulation frame
Destructor of SIM_PLOT_FRAME calls sim->Attach( nullptr ) in order to destroy
circuit model (former netlist exporter). If this is skipped, eeschema crashes
when program is closed. nullptr is a valid parameter for Attach()
2022-04-05 19:28:05 +00:00
Sylwester Kocjan f5dedd77c6 eeschema,sim: add SIMULATOR and SIM_MODEL interface
SIMULATOR has now an Attach() method, which should be called
with proper SIMULATION_MODEL that should be simulated, before calling Run()

Concrete class of SIMULATION_MODEL for ngspice is NGSPICE_CIRCUIT_MODEL,
renamed from NETLIST_EXPORTER_PSPICE_SIM. DIALOG_SIM_SETTINGS relies
on above mentioned object, so it was added as an argument of the constructor.
2022-04-01 19:28:31 +00:00
Seth Hillbrand 098e8f7d9b Revert "cmake: adding KICAD_MACOSX_APP_BUNDLE option"
This reverts commit ea9f960cc1.

Reverted for updates as this currently breaks kicad-mac-builder
2022-01-31 15:57:56 -08:00
Davide Gerhard ea9f960cc1 cmake: adding KICAD_MACOSX_APP_BUNDLE option
ADDED: with cmake KICAD_MACOSX_APP_BUNDLE option the user can disable
the macOS app bundle creation when compiling on macOS. This permit to
use/install KiCad like any other *nix platform (/usr/bin, /usr/share,
ecc.). By default, cmake build the app bundle.
2022-01-28 15:49:37 -08:00
jean-pierre charras d4e5861c62 Fix a few issue in simulation (noticeable only when the calculation time is high):
- Wait for end of simulation before return from "C" locale to current locale
(to avoid data files created by ngspice using curr locale instead of "C" locale)
- Do not allow changing signal list to plot during simulation calculation
(avoid crashes)
2021-05-05 20:28:46 +02:00
Seth Hillbrand 61289ab39a Cleanup ngspice calling signatures 2021-05-05 10:49:40 -07:00
Seth Hillbrand 36975c9cd0 Conditionally handle the SPICE signatures
ngspice updated their function signatures, requiring us to test.  They
also don't provide an indicator that the signature is changed, so we
need to test based on the existence of a new version define.

Fixes https://gitlab.com/kicad/code/kicad/issues/8358
2021-05-05 10:19:01 -07:00
jean-pierre charras e5dd54e05a Eeschema, spice sim: fix a crash when no value is available.
onSimFinished() try to analyse the list of plots, but did not test
if there is available data before using it.
Fixes #8169
https://gitlab.com/kicad/code/kicad/issues/8169
2021-04-14 21:01:39 +02:00
Wayne Stambaugh dbb0a125ac Fix build error when spice simulator build option is disabled. 2021-03-19 09:04:28 -04:00
Wayne Stambaugh acec6ad7fc Spice simulator: add Ngspce model behavior mode settings.
ADDED: Ngspice simulator model behavior mode settings for PSpice, LTSpice,
       PSpice and LTSpice, and HSpice.

Fixes https://gitlab.com/kicad/code/kicad/issues/5810
2021-03-18 15:31:02 -04:00
jean-pierre charras 14b1d36b38 Simulator: Fix a ugly bug that happens is some simulations
TRhe initial code was broken.
2021-03-08 20:01:36 +01:00
Marek Roszko b609c7dcd6 Kick the osx specific path helpers into PATHS 2021-02-16 23:29:26 -05:00
Marek Roszko f9c7eae63a Avoid null access in NGSPICE::AllPlots 2021-02-16 18:37:57 -05:00
Marek Roszko 1608282a57 Remove msys2 search paths for ngspice under msvc 2021-02-13 20:08:31 -05:00
Sylwester Kocjan 6a48e21eb2 simulator: update dialog to handle R, I & TEMP DC sweeps
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2370
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6195
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2386
2021-01-25 21:29:13 +00:00
Marek Roszko 1d559108c8 Move LOCALE_IO out of common.h 2020-10-23 21:49:42 -04:00
jean-pierre charras f6b4b66a86 Avoid include wx/wx.h in many files that do not actually use this include.
Including wx.h includes the full set of wxWidgets include files, that is not good,
and can create some conflicts with some Windows headers on msys2.
2020-10-18 18:21:34 +02:00
Jeff Young 741481591e NetClass settings for Eeschema.
ADDED Eeschema-specific netclass settings including wire and bus
thickness, color, and line style.

Netclasses override individual wire & bus colors and line styles.
If that proves an issue we might look at something more sophisticated
with inheritance.

Fixes https://gitlab.com/kicad/code/kicad/issues/4581
2020-07-08 21:23:25 +01:00
Simon Richter 632494cba7 Add missing includes
A few more instances of missing <algorithm> for std::max
2020-05-10 00:24:11 +02:00
Sylwester Kocjan fdccdd5cb9 Eeschema: adding .op SPICE simulation support
ADDED new tab on simulation settings dialog, which allows to run .op analysis.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/2368
2020-04-15 01:51:58 +00:00
Ian McInerney 0d017e262c Update documentation and comment 2020-01-22 08:47:14 +00:00
Simon Richter f87dc08801 Readd <config.h> to ngspice.cpp
This file should really be included first from any source file, because it
contains platform specific workarounds.

This also groups includes a bit by source.
2020-01-22 08:38:45 +00:00
Jeff Young 384ff2539a Fix uninitialized variables. 2020-01-21 09:29:33 +00:00
Seth Hillbrand b5f021ff9f Cleanup: Replace push_back with emplace_back
In cases where we create a new item and immediately push into a
container, the emplace idiom is faster and more efficient.
2019-12-05 13:41:21 -08:00
Adam Wolf c7c49cee5a Add additional ngspice codemodel path for launching from standalone eeschema on macOS. 2019-10-04 13:41:50 -04:00
Simon Richter 05353049b5 Pull in macro definition for strncasecmp on MSVC 2019-07-17 08:10:47 -04:00
jean-pierre charras 6cdde97e6f ngspice dll search: add auxiliary search paths on Linux, like on other platforms 2019-04-15 11:04:59 +02:00
Maciej Suminski b445b0fab2 Link eeschema with ngspice DLL
Adds a link-time dependency for libngspice, so that other tools may
detect ngspice as a KiCad dependency.

The library is still loaded with dlopen() as it gives a way to reload it
in case of problems. The DLL name is recognized during CMake
configuration and used to load the library at runtime.
2018-10-30 08:32:38 +01:00
Stefan Brüns d1db2c7621 Use fixed version for libngspice.so.0
CanonicalizeName only adds the lib prefix and .so suffix, so loading
libngspice.so fails until the development package is installed.
MAC/Windows code paths lookup soversion 0 of ngspice as well, as this
is the only compatible version.
2018-10-27 10:20:09 +02:00
Wayne Stambaugh 7343e78347 Fix some Coverity uninitialized field warnings.
Fixes Coverity CIDs:

- 175824
- 169337
- 163191
- 175827
- 175440
- 175438
- 157136
2018-06-04 13:48:57 -04:00
Maciej Suminski e3a06dca70 Fallback to system ngspice library when libngspice is not found in other paths on macOS 2018-04-19 14:48:31 +02:00
Maciej Suminski 4526f40fe1 ngspice: add extra paths to search for libngspice
The main purpose of the patch is to load libngspice from macOS bundle.
There are also some additional paths that could make Windows developers
easier.

Fixes: lp:1630675
* https://bugs.launchpad.net/kicad/+bug/1630675
2018-04-19 11:43:29 +02:00
Maciej Suminski a8ef222517 ngspice: keep the ngspice DLL handle as an automatic variable 2018-04-19 11:44:48 +02:00
Maciej Suminski 058f2bffd0 Spice simulator: safety check 2018-03-22 18:20:02 +01:00
Maciej Suminski bad462a228 Spice simulator: reload ngSpice dll on error
ngSpice frequently ends up a simulation with an error:
"Error: ngspice.dll cannot recover and awaits to be detached"
The only way forward is to reload the shared library and
reinitialize ngSpice.

Fixes: lp:1753101
* https://bugs.launchpad.net/kicad/+bug/1753101
2018-03-21 18:01:38 +01:00
Maciej Suminski 33620ecc85 Revert "libngspice is linked at compile time"
This reverts commit 75f8b20493.
In case of problems, ngspice demands to be detached which is not
possible when it is linked at compile time.
2018-03-21 18:01:38 +01:00
Tomasz Włostowski 919b449595 Added 'show spice netlist' menu option in the simulator
Fixes: lp:1745887
* https://bugs.launchpad.net/kicad/+bug/1745887
2018-03-03 17:38:28 +01:00
Maciej Suminski d7e1152aa3 Correct way of freeing memory in NGSPICE class
Strings created with strdup() should be deleted using free(), not
delete.
2017-03-01 13:56:24 +01:00
Maciej Suminski af3d5befa7 Solve codemodel libraries loading problem in ngspice
Fixes: lp:1630675
* https://bugs.launchpad.net/kicad/+bug/1630675
2016-10-17 10:11:27 +02:00
Maciej Suminski 2a6b8f153b NGSPICE as a singleton
One cannot call ngSpice_Init() twice without unloading the dll. When calling
ngSpice_Init, we pass a pointer to a NGSPICE instance and thus it cannot be changed.
When any of the callback function is called with a stale pointer everything crashes.
2016-08-19 15:51:19 +02:00
Maciej Suminski cac571c056 Initialize ngspice only once 2016-08-18 18:10:00 +02:00
Maciej Suminski 43d93682a2 Fix locale in NGSPICE methods using LOCALE_IO instead of setlocale.
More information: https://lists.launchpad.net/kicad-developers/msg25763.html
2016-08-15 15:52:07 +02:00
Maciej Suminski 75f8b20493 libngspice is linked at compile time 2016-08-15 13:52:13 +02:00
Maciej Suminski 18e99fa30f Fixed a crash with certain shared library versions 2016-08-11 14:42:21 +02:00
Maciej Suminski 0667b7ba63 Fixed ngspice freeze when there is an error in the simulated netlist Does not work with current ngspice head, it has to be compiled from the official master branch. 2016-08-11 14:42:18 +02:00