KiCad PCB EDA Suite
Loading...
Searching...
No Matches
class_regulator_data.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) 1992-2011 jean-pierre.charras
5 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
30#ifndef CLASS_REGULATOR_DATA_H
31#define CLASS_REGULATOR_DATA_H
32
33#include <string_utils.h>
34
35#include <vector>
36
37#include <wx/arrstr.h>
38
39// Helper class to store parameters for a regulator
41{
42public:
43 REGULATOR_DATA( const wxString& aName, double aVrefMin, double aVrefTyp, double aVrefMax,
44 int aType, double aIadjTyp = 0, double aIadjMax = 0 ) :
45 m_Name( aName ),
46 m_Type( aType ), m_VrefMin( aVrefMin ), m_VrefTyp( aVrefTyp ), m_VrefMax( aVrefMax ),
47 m_IadjTyp( aIadjTyp ), m_IadjMax( aIadjMax )
48 {
49 }
50
51public:
52 wxString m_Name; // Regulator name
53 int m_Type; // type: with separate sense pin (normal) (=0)
54 // or adjustable 3 pins reg (=1)
55 double m_VrefMin; // min Vreference in volt
56 double m_VrefTyp; // typ Vreference in volt
57 double m_VrefMax; // max Vreference in volt
58 double m_IadjTyp; // 3 pin type only: typ I adjust in micro amp
59 double m_IadjMax; // 3 pin type only: max I adjust in micro amp
60};
61
62// Helper class to store the list of known regulators
64{
65public:
68 {
69 for( REGULATOR_DATA* regulator : m_List )
70 delete regulator;
71 }
72
73 unsigned int GetCount()
74 {
75 return m_List.size();
76 }
77
78 void Add( REGULATOR_DATA* aItem )
79 {
80 // add new item an try to keep alphabetic order,
81 // and because name have numbers inside, use a KiCad compare function
82 // that handles number as numbers not ASCII chars
83 unsigned ii = 0;
84
85 for( ; ii < m_List.size(); ii++ )
86 {
87 if( StrNumCmp( aItem->m_Name, m_List[ii]->m_Name, true ) < 0 )
88 break;
89 }
90
91 m_List.insert( m_List.begin() + ii, aItem );
92 }
93
94 REGULATOR_DATA* GetReg( const wxString& aName )
95 {
96 for( REGULATOR_DATA* regulator : m_List )
97 {
98 if( aName.CmpNoCase( regulator->m_Name ) == 0 )
99 return regulator;
100 }
101 return nullptr;
102 }
103
104 void Remove( const wxString& aRegName )
105 {
106 for( unsigned ii = 0; ii < m_List.size(); ii++ )
107 {
108 if( aRegName.CmpNoCase( m_List[ii]->m_Name ) == 0 )
109 {
110 // Found! remove it
111 m_List.erase( m_List.begin() + ii );
112 break;
113 }
114 }
115 }
116
122 void Replace( REGULATOR_DATA* aItem )
123 {
124 // Search for the old regulator
125 for( unsigned ii = 0; ii < m_List.size(); ii++ )
126 {
127 if( aItem->m_Name.CmpNoCase( m_List[ii]->m_Name ) == 0 )
128 {
129 // Found! remove it
130 delete m_List[ii];
131 m_List[ii] = aItem;
132 break;
133 }
134 }
135 }
136
137 wxArrayString GetRegList() const
138 {
139 wxArrayString list;
140
141 for( REGULATOR_DATA* regulator : m_List )
142 list.Add( regulator->m_Name );
143
144 return list;
145 }
146
147 void Clear() { m_List.clear(); }
148
149 std::vector <REGULATOR_DATA*> m_List;
150};
151
152#endif // CLASS_REGULATOR_DATA_H
REGULATOR_DATA(const wxString &aName, double aVrefMin, double aVrefTyp, double aVrefMax, int aType, double aIadjTyp=0, double aIadjMax=0)
void Remove(const wxString &aRegName)
wxArrayString GetRegList() const
void Replace(REGULATOR_DATA *aItem)
Replace an old REGULATOR_DATA by a new one The old one is deleted the 2 items must have the same name...
void Add(REGULATOR_DATA *aItem)
REGULATOR_DATA * GetReg(const wxString &aName)
unsigned int GetCount()
std::vector< REGULATOR_DATA * > m_List
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.