-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrameModbusFunctions.cpp
184 lines (151 loc) · 6.06 KB
/
FrameModbusFunctions.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <algorithm>
#include "Utils.h"
#include "FrameModbusFunctions.h"
using std::min;
using std::max;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
//TfrmeModbusFunctions *frmeModbusFunctions;
//---------------------------------------------------------------------------
__fastcall TfrmeModbusFunctions::TfrmeModbusFunctions(TComponent* Owner)
: TFrame(Owner)
{
}
//---------------------------------------------------------------------------
int TfrmeModbusFunctions::GetFnIdx() const
{
return pgctrlFunctions->TabIndex;
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetFnIdx( int Val )
{
pgctrlFunctions->TabIndex =
max( 0, min( pgctrlFunctions->PageCount - 1, Val ) );
}
//---------------------------------------------------------------------------
Modbus::RegAddrType TfrmeModbusFunctions::GetReadHoldingRegistersAddr() const
{
return ParseWord( edtReadHoldingRegistersAddr->Text );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetReadHoldingRegistersAddr( Modbus::RegAddrType Val )
{
edtReadHoldingRegistersAddr->Text = Val;
}
//---------------------------------------------------------------------------
Modbus::RegCountType TfrmeModbusFunctions::GetReadHoldingRegistersPtCnt() const
{
return ParseWord( edtReadHoldingRegistersPtCnt->Text );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetReadHoldingRegistersPtCnt( Modbus::RegCountType Val )
{
edtReadHoldingRegistersPtCnt->Text = Val;
}
//---------------------------------------------------------------------------
Modbus::RegAddrType TfrmeModbusFunctions::GetReadInputRegistersAddr() const
{
return ParseWord( edtReadInputRegistersAddr->Text );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetReadInputRegistersAddr( Modbus::RegAddrType Val )
{
edtReadInputRegistersAddr->Text = Val;
}
//---------------------------------------------------------------------------
Modbus::RegCountType TfrmeModbusFunctions::GetReadInputRegistersPtCnt() const
{
return ParseWord( edtReadInputRegistersPtCnt->Text );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetReadInputRegistersPtCnt( Modbus::RegCountType Val )
{
edtReadInputRegistersPtCnt->Text = Val;
}
//---------------------------------------------------------------------------
Modbus::RegAddrType TfrmeModbusFunctions::GetPresetSingleRegisterAddr() const
{
return ParseWord( edtPresetSingleRegisterAddr->Text );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetPresetSingleRegisterAddr( Modbus::RegAddrType Val )
{
edtPresetSingleRegisterAddr->Text = Val;
}
//---------------------------------------------------------------------------
Modbus::RegDataType TfrmeModbusFunctions::GetPresetSingleRegisterValue() const
{
return ParseWord( edtPresetSingleRegisterValue->Text );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetPresetSingleRegisterValue( Modbus::RegDataType Val )
{
edtPresetSingleRegisterValue->Text = Val;
}
//---------------------------------------------------------------------------
Modbus::RegAddrType TfrmeModbusFunctions::GetPresetMultipleRegistersAddr() const
{
return ParseWord( edtPresetMultipleRegistersAddr->Text );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetPresetMultipleRegistersAddr( Modbus::RegAddrType Val )
{
edtPresetMultipleRegistersAddr->Text = Val;
}
//---------------------------------------------------------------------------
String TfrmeModbusFunctions::GetPresetMultipleRegistersData() const
{
return Trim( edtPresetMultipleRegistersData->Text );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetPresetMultipleRegistersData( String Val )
{
edtPresetMultipleRegistersData->Text = Trim( Val );
}
//---------------------------------------------------------------------------
bool TfrmeModbusFunctions::GetPresetSingleRegisterPulsed() const
{
return cboxPresetSingleRegisterPulsed->Checked;
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetPresetSingleRegisterPulsed( bool Val )
{
cboxPresetSingleRegisterPulsed->Checked = Val;
}
//---------------------------------------------------------------------------
uint32_t TfrmeModbusFunctions::GetPresetSingleRegisterPulseTime() const
{
return
max( edtPresetSingleRegisterPulseTime->Text.ToIntDef( 1000 ), 0 );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetPresetSingleRegisterPulseTime( uint32_t Val )
{
edtPresetSingleRegisterPulseTime->Text = Val;
}
//---------------------------------------------------------------------------
bool TfrmeModbusFunctions::GetPresetMultipleRegisterPulsed() const
{
return cboxPresetMultipleRegisterPulsed->Checked;
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetPresetMultipleRegisterPulsed( bool Val )
{
cboxPresetMultipleRegisterPulsed->Checked = Val;
}
//---------------------------------------------------------------------------
uint32_t TfrmeModbusFunctions::GetPresetMultipleRegisterPulseTime() const
{
return
max( edtPresetMultipleRegisterPulseTime->Text.ToIntDef( 1000 ), 0 );
}
//---------------------------------------------------------------------------
void TfrmeModbusFunctions::SetPresetMultipleRegisterPulseTime( uint32_t Val )
{
edtPresetMultipleRegisterPulseTime->Text = Val;
}
//---------------------------------------------------------------------------