KiCad PCB EDA Suite
Loading...
Searching...
No Matches
simulator.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 Sylwester Kocjan <[email protected]>
5 * Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <mutex>
24#include <memory>
25
26class SPICE_SIMULATOR;
27class REPORTER;
28
30{
31public:
32 virtual ~SIMULATION_MODEL() {};
33};
34
35
37{
38public:
40 m_simModel( nullptr )
41 {}
42
43 virtual ~SIMULATOR() {}
44
46 static std::shared_ptr<SPICE_SIMULATOR> CreateInstance( const std::string& aName );
47
48 /*
49 * @return mutex for exclusive access to the simulator.
50 */
51 std::mutex& GetMutex()
52 {
53 return m_mutex;
54 }
55
61 virtual bool Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel,
62 const wxString& aSimCommand, unsigned aSimOptions, REPORTER& aReporter )
63 {
64 m_simModel = aModel;
65 return true;
66 }
67
73 virtual bool Run() = 0;
74
80 virtual bool Stop() = 0;
81
87 virtual bool IsRunning() = 0;
88
93 virtual void Clean() = 0;
94
95protected:
97 std::shared_ptr<SIMULATION_MODEL> m_simModel;
98
99private:
101 std::mutex m_mutex;
102};
103
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
virtual ~SIMULATION_MODEL()
Definition: simulator.h:32
std::mutex & GetMutex()
Definition: simulator.h:51
virtual ~SIMULATOR()
Create a simulator instance of particular type (currently only ngspice is handled)
Definition: simulator.h:43
virtual bool Run()=0
Execute the simulation with currently loaded netlist.
std::mutex m_mutex
< For interprocess synchronisation.
Definition: simulator.h:101
virtual bool IsRunning()=0
Check if simulation is running at the moment.
static std::shared_ptr< SPICE_SIMULATOR > CreateInstance(const std::string &aName)
std::shared_ptr< SIMULATION_MODEL > m_simModel
< Model that should be simulated.
Definition: simulator.h:97
virtual bool Stop()=0
Halt the simulation.
SIMULATOR()
Definition: simulator.h:39
virtual void Clean()=0
Cleans simulation data (i.e.
virtual bool Attach(const std::shared_ptr< SIMULATION_MODEL > &aModel, const wxString &aSimCommand, unsigned aSimOptions, REPORTER &aReporter)
Point out the model that will be used in future simulations.
Definition: simulator.h:61