KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_signal_utils.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef SIM_SIGNAL_UTILS_H
21#define SIM_SIGNAL_UTILS_H
22
23#include <map>
24#include <string>
25#include <vector>
26#include <wx/arrstr.h> // wxbase exports std::vector<wxString>, so MSVC needs this to avoid LNK2005
27#include <wx/string.h>
28
34namespace SIM_SIGNAL
35{
36
38enum class PART
39{
44};
45
47inline const wxString DEVICE_VECTOR_PREFIX = wxS( "kicad_vdev" );
48
50bool IsDerivedSignalVector( const wxString& aVectorName );
51
53bool IsSingleVoltageRef( const wxString& aExpression );
54
56bool IsMeasVector( const wxString& aSignal );
57
63bool MeasurableSignal( const wxString& aBase, PART aPart, wxString& aResult );
64
71void SplitMeasurement( const wxString& aCmd, wxString& aFunc, wxString& aSignal, wxString& aParams );
72
79wxString ExpandDeviceVoltages( const wxString& aExpression, const std::map<wxString, wxString>& aDeviceExprs );
80
87wxString QuoteNetNames( const wxString& aExpression, const std::vector<wxString>& aNetnames );
88
90bool ParensBalanced( const wxString& aExpression );
91
98std::vector<wxString> ExtractSignalRefs( const wxString& aExpression );
99
108wxString DeviceVoltageExpression( const std::vector<std::string>& aModelPins,
109 const std::vector<std::string>& aPinNumbers,
110 const std::vector<std::string>& aPinNetNames );
111
112} // namespace SIM_SIGNAL
113
114#endif // SIM_SIGNAL_UTILS_H
Text handling for simulator signal expressions and measurement commands.
bool ParensBalanced(const wxString &aExpression)
bool MeasurableSignal(const wxString &aBase, PART aPart, wxString &aResult)
Build the signal a measurement should read so it matches what is plotted.
wxString QuoteNetNames(const wxString &aExpression, const std::vector< wxString > &aNetnames)
Quote every whole occurrence of a net name that ngspice would otherwise parse as an expression.
void SplitMeasurement(const wxString &aCmd, wxString &aFunc, wxString &aSignal, wxString &aParams)
Split "MAX V(out) from=1m to=2m" into its function, signal and trailing parameters.
wxString DeviceVoltageExpression(const std::vector< std::string > &aModelPins, const std::vector< std::string > &aPinNumbers, const std::vector< std::string > &aPinNetNames)
Build the voltage across a two-terminal part in its model's pin order, matching the sign of I() and P...
const wxString DEVICE_VECTOR_PREFIX
Vector name prefix for the voltage across a component, "kicad_vdev3".
bool IsDerivedSignalVector(const wxString &aVectorName)
std::vector< wxString > ExtractSignalRefs(const wxString &aExpression)
Extract the V() and I() and P() node or device references from an expression, unquoted.
PART
Which part of a complex signal a plotted row shows.
@ GAIN
AC magnitude, plotted in dB.
@ AMPLITUDE
S-parameter magnitude, plotted linear.
bool IsSingleVoltageRef(const wxString &aExpression)
bool IsMeasVector(const wxString &aSignal)
wxString ExpandDeviceVoltages(const wxString &aExpression, const std::map< wxString, wxString > &aDeviceExprs)
Replace V(R1), VDB(R1), VM(R1), ... with the terminal voltage expression of the part.