-
Notifications
You must be signed in to change notification settings - Fork 0
/
enter_data.cpp
110 lines (91 loc) · 3.47 KB
/
enter_data.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* DAC - Dish Antenna Calculator
* Copyright (C) 2005 Georgi D. Sotirov, Boayn D. Sotirov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/* Title: Enter data frame
* Description: The implementation of the window for entering input parameters
* File: enter_data.cpp
* ---
* Written by Georgi D. Sotirov <[email protected]>
*/
#include <vcl.h>
#include <stdlib.h>
#include <cmath>
#pragma hdrstop
#include "enter_data.h"
#include "mainform.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TEnterData * EnterData;
__fastcall TEnterData::TEnterData(TComponent * Owner) : TForm(Owner) {
}
void __fastcall TEnterData::BtnCancelClick(TObject *) {
Close();
}
void __fastcall TEnterData::BtnApplyClick(TObject *) {
double f1_min = this->f1_min->Text.ToDouble();
double f1_max = this->f1_max->Text.ToDouble();
double gmax = this->gmax->Text.ToDouble();
double bi = this->bi->Text.ToDouble();
double v = this->v->Text.ToDouble();
if ( f1_max <= f1_min ) {
MessageDlg("Frequency range maximum is bellow the minimum! Plese, correct the values.", mtError, TMsgDlgButtons() << mbOK, 0);
this->f1_max->SetFocus();
return;
}
if ( f1_min < 3.9 || f1_min > 18.0 ) {
MessageDlg("The frequency range minimum is not in the allowed interval from 3.9 GHz to 18 GHz!", mtError, TMsgDlgButtons() << mbOK, 0);
this->f1_min->SetFocus();
return;
}
if ( f1_max < 3.9 || f1_max > 18.0 ) {
MessageDlg("The frequency range maximum is not in the allowed interval from 3.9 GHz to 18 GHz!", mtError, TMsgDlgButtons() << mbOK, 0);
this->f1_max->SetFocus();
return;
}
if ( gmax < 10.0 || gmax > 70.0 ) {
MessageDlg("The Gmax value is not in the allowed interval from 10 dB to 70 db!", mtError, TMsgDlgButtons() << mbOK, 0);
this->gmax->SetFocus();
return;
}
if ( bi >= b_tbl[0] ) {
String msg;
msg.sprintf("The value of bi must be lower than %f dB!", b_tbl[0]);
MessageDlg(msg, mtError, TMsgDlgButtons() << mbOK, 0);
this->bi->SetFocus();
return;
}
if ( v < 0 || v > 1 ) {
MessageDlg("The value of v is not in the allowed interval from 0 to 1!", mtError, TMsgDlgButtons() << mbOK, 0);
this->v->SetFocus();
return;
}
MainForm->set_freqency_range(f1_min * 1e9, f1_max * 1e9);
MainForm->set_gdb(gmax);
MainForm->set_bi(bi);
MainForm->set_v(v);
Hide();
Close();
SendMessage(MainForm->Handle, MSG_DATACHANGE, 0, (int)(this));
}
void __fastcall TEnterData::FormShow(TObject *) {
f1_min->Text = AnsiString(MainForm->get_f1_min()/1e9);
f1_max->Text = AnsiString(MainForm->get_f1_max()/1e9);
gmax->Text = AnsiString(MainForm->get_gdb());
bi->Text = AnsiString(MainForm->get_bi());
v->Text = AnsiString(MainForm->get_v());
f1_min->SetFocus();
}