-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
60 lines (44 loc) · 1.43 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "gui.h"
struct Material {
const char* name;
float res300, res1300;
};
wxVector<Material> material;
bool MyApp::OnInit()
{
MainFrame *frame = new MainFrame("Resistance");
frame->InitMaterials();
return true;
}
IMPLEMENT_APP(MyApp)
void MainFrame::InitMaterials() {
material.push_back( {"Wolfram", 5.44e-8, 33e-8} );
material.push_back( {"Tantal", 13.48e-8, 55e-8} );
material.push_back( {"Nihrom", 1.1e-6, 1.18e-6} );
material.push_back( {"Molibden", 5.78e-8, 35.2e-8} );
material.push_back( {"Titan", 4.2e-7, 17e-7} );
material.push_back( {"Graphite", 8e-6, 8e-6} );
for (int i = 0; i < material.size(); i++)
cbb1->Append(material[i].name);
cbb1->SetSelection(0);
}
void MainFrame::OnPressBTN1(wxCommandEvent& WXUNUSED(event))
{
MainFrame::Calculate();
}
void MainFrame::Calculate() {
int pos_cbb1 = cbb1->GetSelection();
int pos_cbb2 = cbb2->GetSelection();
int L = wxAtoi(inpL->GetValue());
int H = wxAtoi(inpH->GetValue());
int Th = wxAtoi(inpTh->GetValue());
if (H ==0 || Th ==0) return;
float p;
(pos_cbb2 == 0) ? p = material[pos_cbb1].res300 : p = material[pos_cbb1].res1300;
if (H == 0 || Th == 0) {
*log << "Please enter valid dimensions\n\n";
return;
}
float R = 1e9 * p * L / (H * Th);
*log << "Object resistance equals: " << R << " mOhm \n\n";
}