1 |
786 |
skrzyp |
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####
|
2 |
|
|
// -------------------------------------------
|
3 |
|
|
// This file is part of the eCos host tools.
|
4 |
|
|
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
5 |
|
|
//
|
6 |
|
|
// This program is free software; you can redistribute it and/or modify
|
7 |
|
|
// it under the terms of the GNU General Public License as published by
|
8 |
|
|
// the Free Software Foundation; either version 2 or (at your option) any
|
9 |
|
|
// later version.
|
10 |
|
|
//
|
11 |
|
|
// This program is distributed in the hope that it will be useful, but
|
12 |
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
// 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, write to the
|
18 |
|
|
// Free Software Foundation, Inc., 51 Franklin Street,
|
19 |
|
|
// Fifth Floor, Boston, MA 02110-1301, USA.
|
20 |
|
|
// -------------------------------------------
|
21 |
|
|
// ####ECOSHOSTGPLCOPYRIGHTEND####
|
22 |
|
|
// ConnectionPage.cpp : implementation file
|
23 |
|
|
//
|
24 |
|
|
|
25 |
|
|
#include "stdafx.h"
|
26 |
|
|
#include "eCosTestPlatform.h"
|
27 |
|
|
#include "eCosSocket.h"
|
28 |
|
|
#include "PropertiesDialog.h"
|
29 |
|
|
#include "LocalPropertiesDialog.h"
|
30 |
|
|
#include "RemotePropertiesDialog.h"
|
31 |
|
|
|
32 |
|
|
#ifdef _DEBUG
|
33 |
|
|
#define new DEBUG_NEW
|
34 |
|
|
#undef THIS_FILE
|
35 |
|
|
static char THIS_FILE[] = __FILE__;
|
36 |
|
|
#endif
|
37 |
|
|
|
38 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
// CPropertiesDialog property page
|
40 |
|
|
|
41 |
|
|
//IMPLEMENT_DYNCREATE(CPropertiesDialog, CeCosDialog)
|
42 |
|
|
|
43 |
|
|
CPropertiesDialog::CPropertiesDialog(bool bHideTarget,bool bHideRemoteControls) :
|
44 |
|
|
CeCosDialog(IDD_TT_PROPERTIES),
|
45 |
|
|
m_bConnectionModified(false),
|
46 |
|
|
m_bHideRemoteControls(bHideRemoteControls),
|
47 |
|
|
m_bHideTarget(bHideTarget)
|
48 |
|
|
{
|
49 |
|
|
//{{AFX_DATA_INIT(CPropertiesDialog)
|
50 |
|
|
//}}AFX_DATA_INIT
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
CPropertiesDialog::~CPropertiesDialog()
|
54 |
|
|
{
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
void CPropertiesDialog::DoDataExchange(CDataExchange* pDX)
|
58 |
|
|
{
|
59 |
|
|
CeCosDialog::DoDataExchange(pDX);
|
60 |
|
|
CComboBox *pCombo=((CComboBox *)GetDlgItem(IDC_TT_PLATFORM));
|
61 |
|
|
if(pDX->m_bSaveAndValidate){
|
62 |
|
|
int i=pCombo->GetCurSel();
|
63 |
|
|
pCombo->GetLBText(i, m_strTarget.GetBuffer(pCombo->GetLBTextLen(i)));
|
64 |
|
|
m_strTarget.ReleaseBuffer();
|
65 |
|
|
m_bRemote=(TRUE==((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->GetCheck());
|
66 |
|
|
} else {
|
67 |
|
|
if(pCombo->GetCount()>0){
|
68 |
|
|
int nSel=0;
|
69 |
|
|
for(int i=0;i<pCombo->GetCount();i++){
|
70 |
|
|
CString str;
|
71 |
|
|
pCombo->GetLBText(i, str.GetBuffer(pCombo->GetLBTextLen(i)));
|
72 |
|
|
str.ReleaseBuffer();
|
73 |
|
|
if(0==str.Compare(m_strTarget)){
|
74 |
|
|
nSel=i;
|
75 |
|
|
break;
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
|
|
pCombo->SetCurSel(nSel);
|
79 |
|
|
}
|
80 |
|
|
GetDlgItem(IDC_TT_STATIC_PLATFORM)->SetWindowText(m_strTarget);
|
81 |
|
|
|
82 |
|
|
SetButtons();
|
83 |
|
|
((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->SetCheck(m_bRemote);
|
84 |
|
|
((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->SetCheck(!m_bRemote);
|
85 |
|
|
}
|
86 |
|
|
//{{AFX_DATA_MAP(CPropertiesDialog)
|
87 |
|
|
DDX_Text(pDX, IDC_TT_DOWNLOADTIMEOUT, m_nDownloadTimeout);
|
88 |
|
|
DDV_MinMaxUInt(pDX, m_nDownloadTimeout, 1, 3600);
|
89 |
|
|
DDX_Text(pDX, IDC_TT_TESTTIMEOUT, m_nTimeout);
|
90 |
|
|
DDV_MinMaxUInt(pDX, m_nTimeout, 1, 3600);
|
91 |
|
|
DDX_CBIndex(pDX, IDC_TT_DOWNLOADTIMEOUT_COMBO, m_nDownloadTimeoutType);
|
92 |
|
|
DDX_CBIndex(pDX, IDC_TT_TIMEOUT_COMBO, m_nTimeoutType);
|
93 |
|
|
//}}AFX_DATA_MAP
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
BEGIN_MESSAGE_MAP(CPropertiesDialog, CeCosDialog)
|
98 |
|
|
//{{AFX_MSG_MAP(CPropertiesDialog)
|
99 |
|
|
ON_BN_CLICKED(IDC_TT_RADIO_LOCAL, OnRadioLocal)
|
100 |
|
|
ON_BN_CLICKED(IDC_TT_RADIO_REMOTE, OnRadioRemote)
|
101 |
|
|
ON_CBN_SELCHANGE(IDC_TT_PLATFORM, OnSelchangePlatform)
|
102 |
|
|
ON_BN_CLICKED(IDC_TT_SETTINGS, OnSettings)
|
103 |
|
|
ON_CBN_SELCHANGE(IDC_TT_DOWNLOADTIMEOUT_COMBO, OnSelchangeDownloadtimeoutCombo)
|
104 |
|
|
ON_CBN_SELCHANGE(IDC_TT_TIMEOUT_COMBO, OnSelchangeTimeoutCombo)
|
105 |
|
|
//}}AFX_MSG_MAP
|
106 |
|
|
END_MESSAGE_MAP()
|
107 |
|
|
|
108 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
109 |
|
|
// CPropertiesDialog message handlers
|
110 |
|
|
|
111 |
|
|
void CPropertiesDialog::OnRadioLocal()
|
112 |
|
|
{
|
113 |
|
|
((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->SetCheck(FALSE);
|
114 |
|
|
SetButtons();
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
void CPropertiesDialog::OnRadioRemote()
|
118 |
|
|
{
|
119 |
|
|
((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->SetCheck(FALSE);
|
120 |
|
|
SetButtons();
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
BOOL CPropertiesDialog::OnInitDialog()
|
125 |
|
|
{
|
126 |
|
|
GetParent()->BringWindowToTop();
|
127 |
|
|
|
128 |
|
|
if(m_bHideRemoteControls){
|
129 |
|
|
|
130 |
|
|
m_bRemote=false;
|
131 |
|
|
|
132 |
|
|
// Hide these controls:
|
133 |
|
|
static const arIDs1[]={IDC_STATIC_EXECUTION, IDC_TT_RADIO_LOCAL, IDC_TT_RADIO_REMOTE};
|
134 |
|
|
for(int i=0;i<sizeof arIDs1/sizeof arIDs1[0];i++){
|
135 |
|
|
GetDlgItem(arIDs1[i])->ShowWindow(SW_HIDE);
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
// Move the bottom three buttons up
|
139 |
|
|
CRect rect;
|
140 |
|
|
GetDlgItem(IDC_STATIC_EXECUTION)->GetWindowRect(rect);
|
141 |
|
|
ScreenToClient(rect);
|
142 |
|
|
int nTop=rect.top;
|
143 |
|
|
static const arIDs2[]={IDC_TT_SETTINGS, IDOK, IDCANCEL};
|
144 |
|
|
int nDelta=0;
|
145 |
|
|
for(i=0;i<sizeof arIDs2/sizeof arIDs2[0];i++){
|
146 |
|
|
CWnd *pWnd=GetDlgItem(arIDs2[i]);
|
147 |
|
|
pWnd->GetWindowRect(rect);
|
148 |
|
|
ScreenToClient(rect);
|
149 |
|
|
int nHeight=rect.Height();
|
150 |
|
|
nDelta=rect.top-nTop;
|
151 |
|
|
rect.top=nTop;
|
152 |
|
|
rect.bottom=rect.top+nHeight;
|
153 |
|
|
pWnd->MoveWindow(rect);
|
154 |
|
|
}
|
155 |
|
|
GetWindowRect(rect);
|
156 |
|
|
rect.bottom-=nDelta;
|
157 |
|
|
MoveWindow(rect);
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
CeCosDialog::OnInitDialog();
|
161 |
|
|
|
162 |
|
|
CComboBox *pCombo=(CComboBox *)GetDlgItem(IDC_TT_PLATFORM);
|
163 |
|
|
for(unsigned int i=0;i<CeCosTestPlatform::Count();i++){
|
164 |
|
|
pCombo->AddString(CeCosTestPlatform::Get(i)->Name());
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
UpdateData(false);
|
168 |
|
|
|
169 |
|
|
((CSpinButtonCtrl *)GetDlgItem(IDC_TT_SPIN3))->SetRange(1,999);
|
170 |
|
|
((CSpinButtonCtrl *)GetDlgItem(IDC_TT_SPIN4))->SetRange(1,999);
|
171 |
|
|
|
172 |
|
|
if(m_bHideTarget){
|
173 |
|
|
GetDlgItem(IDC_TT_STATIC_PLATFORM)->ShowWindow(SW_SHOW);
|
174 |
|
|
GetDlgItem(IDC_TT_PLATFORM)->ShowWindow(SW_HIDE);
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
SetButtons();
|
178 |
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
179 |
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
void CPropertiesDialog::OnSelchangePlatform()
|
183 |
|
|
{
|
184 |
|
|
SetButtons();
|
185 |
|
|
}
|
186 |
|
|
|
187 |
|
|
void CPropertiesDialog::SetButtons()
|
188 |
|
|
{
|
189 |
|
|
CString strTarget;
|
190 |
|
|
GetDlgItemText(IDC_TT_PLATFORM,strTarget);
|
191 |
|
|
static const int arIDs[]={IDC_TT_DOWNLOADTIMEOUT,IDC_TT_SPIN4,IDC_TT_DOWNLOADTIMEOUT_COMBO};
|
192 |
|
|
for(int i=0;i<sizeof arIDs/sizeof arIDs[0];i++){
|
193 |
|
|
GetDlgItem(arIDs[i]) ->EnableWindow(true);
|
194 |
|
|
}
|
195 |
|
|
//GetDlgItem(IDC_TT_SETTINGS)->EnableWindow(!bSim || !((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->GetCheck());
|
196 |
|
|
|
197 |
|
|
bool b=(TIMEOUT_SPECIFIED==((CComboBox*)GetDlgItem(IDC_TT_TIMEOUT_COMBO))->GetCurSel());
|
198 |
|
|
GetDlgItem(IDC_TT_TESTTIMEOUT)->EnableWindow(b);
|
199 |
|
|
GetDlgItem(IDC_TT_SPIN3)->EnableWindow(b);
|
200 |
|
|
|
201 |
|
|
b=(TIMEOUT_SPECIFIED==((CComboBox*)GetDlgItem(IDC_TT_DOWNLOADTIMEOUT_COMBO))->GetCurSel());
|
202 |
|
|
GetDlgItem(IDC_TT_DOWNLOADTIMEOUT)->EnableWindow(b);
|
203 |
|
|
GetDlgItem(IDC_TT_SPIN4)->EnableWindow(b);
|
204 |
|
|
}
|
205 |
|
|
|
206 |
|
|
void CPropertiesDialog::OnSettings()
|
207 |
|
|
{
|
208 |
|
|
if(((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->GetCheck()){
|
209 |
|
|
CRemotePropertiesDialog dlg;
|
210 |
|
|
dlg.m_strResourceHost=m_strResourceHost;
|
211 |
|
|
dlg.m_nResourcePort=m_nResourcePort;
|
212 |
|
|
dlg.m_strRemoteHost=m_strRemoteHost;
|
213 |
|
|
dlg.m_nRemotePort=m_nRemotePort;
|
214 |
|
|
dlg.m_bFarmed=m_bFarmed;
|
215 |
|
|
if(IDOK==dlg.DoModal()){
|
216 |
|
|
m_bConnectionModified=true;
|
217 |
|
|
|
218 |
|
|
m_strResourceHost=dlg.m_strResourceHost;
|
219 |
|
|
m_nResourcePort=dlg.m_nResourcePort;
|
220 |
|
|
m_strRemoteHost=dlg.m_strRemoteHost;
|
221 |
|
|
m_nRemotePort=dlg.m_nRemotePort;
|
222 |
|
|
m_bFarmed=dlg.m_bFarmed;
|
223 |
|
|
}
|
224 |
|
|
} else {
|
225 |
|
|
CLocalPropertiesDialog dlg(m_bHideRemoteControls);
|
226 |
|
|
dlg.m_bSerial=m_bSerial;
|
227 |
|
|
dlg.m_strPort=m_strPort;
|
228 |
|
|
dlg.m_nBaud=m_nBaud;
|
229 |
|
|
dlg.m_strLocalTCPIPHost=m_strLocalTCPIPHost;
|
230 |
|
|
dlg.m_nLocalTCPIPPort=m_nLocalTCPIPPort;
|
231 |
|
|
dlg.m_nReset=m_nReset;
|
232 |
|
|
dlg.m_strPort=m_strPort;
|
233 |
|
|
if(IDOK==dlg.DoModal()){
|
234 |
|
|
m_bConnectionModified=true;
|
235 |
|
|
|
236 |
|
|
m_bSerial=dlg.m_bSerial;
|
237 |
|
|
m_strPort=dlg.m_strPort;
|
238 |
|
|
m_nBaud=dlg.m_nBaud;
|
239 |
|
|
m_strPort=dlg.m_strPort;
|
240 |
|
|
m_strLocalTCPIPHost=dlg.m_strLocalTCPIPHost;
|
241 |
|
|
m_nLocalTCPIPPort=dlg.m_nLocalTCPIPPort;
|
242 |
|
|
m_nReset=dlg.m_nReset;
|
243 |
|
|
m_strReset=dlg.m_strReset;
|
244 |
|
|
}
|
245 |
|
|
}
|
246 |
|
|
}
|
247 |
|
|
|
248 |
|
|
void CPropertiesDialog::OnCancel()
|
249 |
|
|
{
|
250 |
|
|
if(!m_bConnectionModified || IDYES==MessageBox(_T("This will discard any changes that may have been made to connection settings. Do you still wish to cancel?"),NULL,MB_YESNO|MB_DEFBUTTON2)){
|
251 |
|
|
CeCosDialog::OnCancel();
|
252 |
|
|
}
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
void CPropertiesDialog::OnSelchangeDownloadtimeoutCombo()
|
256 |
|
|
{
|
257 |
|
|
SetButtons();
|
258 |
|
|
}
|
259 |
|
|
|
260 |
|
|
void CPropertiesDialog::OnSelchangeTimeoutCombo()
|
261 |
|
|
{
|
262 |
|
|
SetButtons();
|
263 |
|
|
}
|
264 |
|
|
|