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-2024 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,
63 const wxString& aInputPath, REPORTER& aReporter )
64 {
65 m_simModel = aModel;
66 return true;
67 }
68
74 virtual bool Run() = 0;
75
81 virtual bool Stop() = 0;
82
88 virtual bool IsRunning() = 0;
89
94 virtual void Clean() = 0;
95
96protected:
98 std::shared_ptr<SIMULATION_MODEL> m_simModel;
99
100private:
102 std::mutex m_mutex;
103};
104
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
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:102
virtual bool Attach(const std::shared_ptr< SIMULATION_MODEL > &aModel, const wxString &aSimCommand, unsigned aSimOptions, const wxString &aInputPath, REPORTER &aReporter)
Point out the model that will be used in future simulations.
Definition: simulator.h:61
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:98
virtual bool Stop()=0
Halt the simulation.
SIMULATOR()
Definition: simulator.h:39
virtual void Clean()=0
Cleans simulation data (i.e.