[go: up one dir, main page]

Menu

[r962]: / trunk / VTS3 / EPICSTreeView.cpp  Maximize  Restore  History

Download this file

625 lines (502 with data), 19.1 kB

  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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
// EPICSTreeView.cpp : implementation file
//
#include "stdafx.h"
#include <afxrich.h>
#include <process.h>
#include "stdafx.h"
#include "VTS.h"
#include "ChildFrm.h"
#include "DockingEPICSViewBar.h"
#include "EPICSTreeView.h"
#include "EPICSViewInfoPanel.h"
#include "EPICSViewNode.h"
///////////////////////////////
namespace PICS {
#include "db.h"
#include "service.h"
#include "vtsapi.h"
#include "props.h"
#include "bacprim.h"
#include "dudapi.h"
#include "propid.h"
}
extern PICS::PICSdb * gPICSdb;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//
// madanner 9/04 add setup for EPICS notification
// global hack avoids messing with bacfuncs too much
CEPICSTreeView * g_pEPICSTreeView = NULL;
// hack globals to build a list of obj/prop/values received from RP and RPM
void EPICS_AddRPValue(long obj_id, int prop_id, int prop_index, char * pbuffer, int nLen )
{
// TODO: someday, nice to use the index to allow array properties
if ( (g_pEPICSTreeView != NULL) && (prop_index < 0) )
{
g_pEPICSTreeView->AddRPValue(obj_id, prop_id, pbuffer, nLen );
}
}
/////////////////////////////////////////////////////////////////////////////
// CEPICSTreeView
IMPLEMENT_DYNCREATE(CEPICSTreeView, CFormView)
CEPICSTreeView::CEPICSTreeView() : m_summary(false, true), CFormView(CEPICSTreeView::IDD)
{
m_pwndSplit = NULL;
m_pnodeview = NULL;
//{{AFX_DATA_INIT(CEPICSTreeView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CEPICSTreeView::~CEPICSTreeView()
{
}
void CEPICSTreeView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEPICSTreeView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
void CEPICSTreeView::SetTreeImageList()
{
// As of 30 May 2011, epicstree.bmp consists of
// - 10 images for top-level items, of which 8 are currently used, followed by
// - an image for each defined object type
// If you use both of the spare top-level images, you must insert space, and
// re-define this equate for the index of the first object type's image
//
// See test code in Refresh() to view all available images
//
#define FIRST_OBJECT_IMAGE 10
#define PROPRIETARY_OBJECT_IMAGE 7
m_imagelist.Create( IDB_EPICSTREE, 18, 2, RGB(255,0,255) );
CTreeCtrl * ptree = (CTreeCtrl *) GetDlgItem(IDC_EPICSV_TREE);
ptree->SetImageList( &m_imagelist, TVSIL_NORMAL );
}
BEGIN_MESSAGE_MAP(CEPICSTreeView, CFormView)
//{{AFX_MSG_MAP(CEPICSTreeView)
ON_WM_SIZE()
ON_BN_CLICKED(IDC_EPICSV_RESET, OnEpicsReset)
ON_BN_CLICKED(IDC_EPICSV_LOAD, OnEpicsLoad)
ON_NOTIFY(TVN_SELCHANGED, IDC_EPICSV_TREE, OnSelchangedEpicsTree)
ON_BN_CLICKED(IDC_EPICSV_EDIT, OnEpicsEdit)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_EPICSV_GEN, OnEpicsReadSingleProps)
ON_BN_CLICKED(IDC_EPICSV_GENALL, OnEpicsReadAllProps)
ON_WM_CREATE()
ON_CBN_DROPDOWN(IDC_EPICSV_DA, OnDropdownEpicsDA)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEPICSTreeView diagnostics
#ifdef _DEBUG
void CEPICSTreeView::AssertValid() const
{
CFormView::AssertValid();
}
void CEPICSTreeView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
VTSDoc* CEPICSTreeView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(VTSDoc)));
return (VTSDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEPICSTreeView message handlers
/////////////////////////////////////////////////////////////////////////////
// CEPICSView drawing
void CEPICSTreeView::OnSize(UINT nType, int cx, int cy)
{
// Calculate minimum sizes
cx = cx < 120 ? 120 : cx;
cy = cy < 130 ? 130 : cy;
SetScrollSizes(MM_TEXT, CSize(cx,cy));
// Resize the tree control
ResizeControl(GetDlgItem(IDC_EPICSV_TREE), cx, cy);
ResizeControl(GetDlgItem(IDC_EPICSV_FILENAME), cx, -1);
CFormView::OnSize(nType, cx, cy);
}
int CEPICSTreeView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFormView::OnCreate(lpCreateStruct) == -1)
return -1;
SetContext( gNewFrameContext );
return 0;
}
// Called when a new packet is received...
// See if we should pay attention to it.
void CEPICSTreeView::ContextChange( CFrameContext::Signal s )
{
// If this notification isn't for a newly arrived packet, or we haven't loaded EPICS or
// there are no packet... get out.
if (s != CFrameContext::eNewPacketCount || gPICSdb == NULL || m_FrameContext->m_PacketCount <= 0)
// if (s != CFrameContext::eNewCurrentPacket || gPICSdb == NULL || m_FrameContext->m_PacketCount <= 0)
return;
// Get last added packet and get out if it's not a received packet
VTSPacketPtr ppkt = m_FrameContext->m_pDoc->GetPacket(m_FrameContext->m_PacketCount-1);
// VTSPacketPtr ppkt = m_FrameContext->m_pDoc->GetPacket(m_FrameContext->m_CurrentPacket);
if (ppkt->packetHdr.packetType != rxData)
return;
// Who's it from?
const char *name = m_FrameContext->m_pDoc->AddrToName( ppkt->packetHdr.packetSource, ppkt->packetHdr.m_szPortName );
if (name == NULL)
return;
// Is that our DA?
CComboBox *pcomboDA = (CComboBox*)GetDlgItem(IDC_EPICSV_DA);
CString strDA;
pcomboDA->GetWindowText(strDA);
if (strDA.Compare(name) != 0)
return;
// Clear out read arrays and prep for the sniffer to stuff the values
PrepRPCallback(this);
NetworkSniffer::SetLookupContext( ppkt->packetHdr.m_szPortName );
m_summary.Interpret( (BACnetPIInfo::ProtocolType) ppkt->packetHdr.packetProtocolID, (char*) ppkt->packetData, ppkt->packetLen );
PrepRPCallback(NULL);
}
void CEPICSTreeView::PrepRPCallback( CEPICSTreeView * pthis )
{
g_pEPICSTreeView = pthis; // setup global so sniffer populates these lists properly
// m_aRPCallback_ObjID.RemoveAll();
// m_aRPCallback_PropID.RemoveAll();
// for(int i = 0; i < m_aRPCallback_ValuePtr.GetSize(); i++ )
// delete (BACnetEncodeable *) m_aRPCallback_ValuePtr[i];
// m_aRPCallback_ValuePtr.RemoveAll();
}
void CEPICSTreeView::ResizeControl(CWnd * pwnd, int cx, int cy)
{
RECT rc;
if ( pwnd != NULL )
{
pwnd->GetWindowRect(&rc);
ScreenToClient(&rc);
pwnd->SetWindowPos(NULL, 0, 0, cx - 3 - rc.left, cy == -1 ? rc.bottom - rc.top : cy - 3 - rc.top, SWP_NOMOVE | SWP_NOZORDER);
}
}
void CEPICSTreeView::OnEpicsReset()
{
CString str;
GetDlgItem(IDC_EPICSV_FILENAME)->GetWindowText(str);
if ( str.GetLength() != 0 )
EPICSLoad(str);
}
// Open a file dialog and get an EPICS file
bool CEPICSTreeView::GetEpicsFilename( CString &theFilePath )
{
// Start with the current EPICS (if any)
// Will override the default directory set below.
CString lastEpics = gVTSPreferences.Setting_GetLastEPICS();
// Don't change the current directory: EPICS file shouldn't affect location of anything else
CFileDialog fd( TRUE, "tpi", lastEpics,
OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR,
"EPICS (*.tpi)|*.tpi||" );
// Default EPICS directory: there is a sample EPICS here
CString dir;
((VTSApp*)AfxGetApp())->GetRelativeToExe( dir, "Docs" );
fd.m_ofn.lpstrInitialDir = dir;
bool retval = (fd.DoModal() == IDOK);
if (retval)
{
theFilePath = fd.GetPathName();
}
return retval;
}
void CEPICSTreeView::OnEpicsLoad()
{
CString filePath;
if (GetEpicsFilename( filePath ))
{
EPICSLoad(filePath);
}
}
void CEPICSTreeView::OnEpicsEdit()
{
CString str;
GetDlgItem(IDC_EPICSV_FILENAME)->GetWindowText(str);
if (!str.IsEmpty())
{
const char *pEditor = gVTSPreferences.Setting_GetTextEditor();
str.Insert(0, '"' );
str += '"';
_spawnlp(_P_NOWAIT, pEditor, pEditor, (LPCTSTR)str, NULL);
}
}
void CEPICSTreeView::OnEpicsReadSingleProps()
{
CChildFrame * p = (CChildFrame *) GetParentFrame();
// Get selected Object node
CTreeCtrl * ptree = (CTreeCtrl *) GetDlgItem(IDC_EPICSV_TREE);
HTREEITEM htreeitem = ptree->GetSelectedItem();
CEPICSViewNodeObject * pnode = htreeitem != NULL ? (CEPICSViewNodeObject *) ptree->GetItemData(htreeitem) : NULL;
if ( pnode != NULL && pnode->IsKindOf(RUNTIME_CLASS(CEPICSViewNodeObject)) )
p->DoReadSingleProperties("ReadObjectProperties.vts", pnode->GetObjectID());
}
void CEPICSTreeView::OnEpicsReadAllProps()
{
CChildFrame * p = (CChildFrame *) GetParentFrame();
p->DoReadAllProperties();
}
void CEPICSTreeView::SetSplitter( CDockingEPICSViewBar * pbar, CSplitterWnd * pwndSplit, CCreateContext * pContext )
{
m_pwndSplit = pwndSplit;
m_pContext = pContext;
m_pbar = pbar;
CreateInfoView(RUNTIME_CLASS(CEPICSViewInfoPanel), FALSE);
SetTreeImageList();
Refresh();
}
CView * CEPICSTreeView::CreateInfoView( CRuntimeClass * pviewclass, BOOL fDeleteOldView )
{
if ( m_pwndSplit == NULL )
return NULL;
int nRow = 1;
int nCol = 0;
if ( m_pwndSplit->GetColumnCount() == 2 )
{
nRow = 0;
nCol = 1;
}
if ( fDeleteOldView )
m_pwndSplit->DeleteView(nRow, nCol);
if ( !m_pwndSplit->CreateView(nRow, nCol, pviewclass, CSize(0, 0), m_pContext) )
{
TRACE0("Failed to create edit pane on EPICS view\n");
return NULL;
}
m_pnodeview = (CView *) m_pwndSplit->GetPane(nRow, nCol);
m_pwndSplit->RecalcLayout();
return m_pnodeview;
}
void CEPICSTreeView::DeleteDB()
{
if ( gPICSdb )
{
PICS::MyDeletePICSObject( gPICSdb->Database );
delete gPICSdb;
gPICSdb = NULL;
// m_pbar->m_nSyntaxE = 0;
// m_pbar->m_nConE = 0;
}
}
// Return TRUE if load was successful
BOOL CEPICSTreeView::EPICSLoad( LPCSTR lpszFileName )
{
GetDlgItem(IDC_EPICSV_FILENAME)->SetWindowText( lpszFileName == NULL ? "" : lpszFileName );
if ( lpszFileName == NULL || lstrlen(lpszFileName) == 0 )
{
Refresh();
return TRUE;
}
DeleteDB();
// make a new database
gPICSdb = new PICS::PICSdb;
m_pbar->m_nSyntaxE = 0;
m_pbar->m_nConE = 0;
// read in the EPICS
// ReadTextPICS returns false if canceled by user
if ( PICS::ReadTextPICS( (char *) (LPCSTR) lpszFileName, gPICSdb, &m_pbar->m_nSyntaxE, &m_pbar->m_nConE ) )
{
// Formerly saved the name only if read without error.
// But then you can't use the Edit button to FIX the errors.
gVTSPreferences.Setting_SetLastEPICS(lpszFileName);
if ( m_pbar->m_nSyntaxE != 0 )
DeleteDB();
}
else
{
// Cancelled by user... clear DB, reset last load, etc.
gVTSPreferences.Setting_SetLastEPICS("");
DeleteDB();
GetDlgItem(IDC_EPICSV_FILENAME)->SetWindowText("");
}
Refresh();
return gPICSdb == 0 ? FALSE : TRUE;
}
// Reload all of the controls and such for new EPICS database
void CEPICSTreeView::Refresh()
{
CTreeCtrl * ptree = (CTreeCtrl *) GetDlgItem(IDC_EPICSV_TREE);
WipeOut(ptree, ptree->GetRootItem());
ptree->DeleteAllItems();
GetDlgItem(IDC_EPICSV_GEN)->EnableWindow(FALSE);
GetDlgItem(IDC_EPICSV_GENALL)->EnableWindow(gPICSdb != NULL);
// Build tree nodes...
HTREEITEM htreeitemLast = NULL;
// Main node title... EPICS name
LPCSTR lpsz = "No EPICS Data";
if ( gPICSdb == NULL )
{
CString str;
GetDlgItem(IDC_EPICSV_FILENAME)->GetWindowText(str);
if ( str.GetLength() != 0 )
lpsz = "EPICS Error";
}
else
{
lpsz = gPICSdb->ProductName;
GetDlgItem(IDC_EPICSV_FILENAME)->SetWindowText(gVTSPreferences.Setting_GetLastEPICS());
}
HTREEITEM htreeitemRoot = ptree->InsertItem(TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpsz, 0, 0, 0, 0, (LPARAM) new CEPICSViewNodeRoot(this, m_pbar->m_nSyntaxE, m_pbar->m_nConE), NULL, htreeitemLast );
// Create BIBB node
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, _T("BIBBs"), 1, 1, 0, 0, (LPARAM) new CEPICSViewNodeBIBB(this), htreeitemRoot, NULL );
// Create Application Services
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, _T("Application Services"), 2, 2, 0, 0, (LPARAM) new CEPICSViewNodeAppService(this), htreeitemRoot, htreeitemLast );
// Create Object Types
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, _T("Object List"), 3, 3, 0, 0, (LPARAM) new CEPICSViewNodeObjTypes(this), htreeitemRoot, htreeitemLast );
m_htreeitemObjectParent = htreeitemLast;
if ( gPICSdb != NULL )
LoadObjectNodes(htreeitemLast);
// Create Data Link Options
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, _T("Data Link Layer Options"), 4, 4, 0, 0, (LPARAM) new CEPICSViewNodeDataLink(this), htreeitemRoot, htreeitemLast );
// Create Character Sets
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, _T("Character Sets Supported"), 5, 5, 0, 0, (LPARAM) new CEPICSViewNodeCharsets(this), htreeitemRoot, htreeitemLast );
// Create Special Functionality
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, _T("Special Functionality"), 6, 6, 0, 0, (LPARAM) new CEPICSViewNodeSpecialFunctionality(this), htreeitemRoot, htreeitemLast );
#if 0
// Test code: Show ALL icons in the list, to verify image/type matches when
// new object types are added
for (int ix=0; ix < 130; ix++)
{
CString str;
if (ix >= FIRST_OBJECT_IMAGE)
{
str.Format( "%d) type=%d %s",
ix, ix - FIRST_OBJECT_IMAGE,
(LPCTSTR)NetworkSniffer::BAC_STRTAB_BACnetObjectType.EnumString( ix - FIRST_OBJECT_IMAGE ) );
}
else
{
str.Format( "%d ", ix );
}
if (ix >= m_imagelist.GetImageCount())
{
str += " no image";
}
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, str, ix, ix, 0, 0, (LPARAM) new CEPICSViewNodeDataLink(this), htreeitemRoot, htreeitemLast );
}
#endif
// select the first item in the tree
ptree->SelectItem(ptree->GetFirstVisibleItem());
}
// Find the object nodes in the tree and attempt to set the object/prop/value...
void CEPICSTreeView::AddRPValue( long obj_id, int prop_id, char * pbuffer, int nLen )
{
// g_aRPCallback_ObjID.Add((DWORD) obj_id);
// g_aRPCallback_PropID.Add( (UINT) prop_id);
// g_aRPCallback_ValuePtr.Add( BACnetEncodeable::Factory(datatype, &decoder) );
CTreeCtrl * ptree = (CTreeCtrl *) GetDlgItem(IDC_EPICSV_TREE);
if ( !ptree->ItemHasChildren(m_htreeitemObjectParent) )
return;
// Could be any number of things that go wrong here... don't blow the sniffer decoding
// just because we can't get our value stuffed into our list view
try
{
for ( HTREEITEM htreeitemLast = ptree->GetChildItem(m_htreeitemObjectParent); htreeitemLast != NULL; htreeitemLast = ptree->GetNextSiblingItem(htreeitemLast) )
{
CEPICSViewNodeObject * pnode = (CEPICSViewNodeObject *) ptree->GetItemData(htreeitemLast);
if ( pnode->IsKindOf(RUNTIME_CLASS(CEPICSViewNodeObject)) && pnode->GetObjectID() == (DWORD) obj_id )
{
unsigned short nParseType;
int x = pnode->GetPropertyIndex((DWORD) prop_id, &nParseType);
if ( x != -1 )
pnode->SetDeviceValue(x, BACnetAnyValue(BACnetAnyValue::Factory(nParseType, BACnetAPDUDecoder((const BACnetOctet *) pbuffer, nLen), prop_id)).ToString());
break;
}
}
}
catch(...){}
}
void CEPICSTreeView::LoadObjectNodes( HTREEITEM htreeitemParent )
{
HTREEITEM htreeitemLast = NULL;
PICS::generic_object * pObj = gPICSdb->Database;
CTreeCtrl * ptree = (CTreeCtrl *) GetDlgItem(IDC_EPICSV_TREE);
while ( pObj != NULL )
{
if(pObj->object_type < 128)
{
// Standard object
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, _T(pObj->object_name), FIRST_OBJECT_IMAGE+(pObj->object_type), FIRST_OBJECT_IMAGE+(pObj->object_type), 0, 0, (LPARAM) new CEPICSViewNodeObject(this, pObj), htreeitemParent, htreeitemLast );
}
else
{
// Proprietary object
htreeitemLast = ptree->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE, _T(pObj->object_name), PROPRIETARY_OBJECT_IMAGE, PROPRIETARY_OBJECT_IMAGE, 0, 0, (LPARAM) new CEPICSViewNodeObject(this, pObj), htreeitemParent, htreeitemLast );
}
pObj = (PICS::generic_object *) pObj->next;
}
}
void CEPICSTreeView::LoadDACombo()
{
CComboBox *pcombo = (CComboBox*)GetDlgItem(IDC_EPICSV_DA);
// Get the current Destination setting so that we can restore it later
CString strText;
pcombo->GetWindowText(strText);
// Fill the Destination combo
pcombo->ResetContent();
VTSDoc *pdoc = (VTSDoc*) ((VTSApp*) AfxGetApp())->GetWorkspace();
VTSNames *pnames = (pdoc == NULL) ? NULL : pdoc->GetNames();
for (int i = 0; pnames != NULL && i < pnames->GetSize(); i++)
{
pcombo->AddString((*pnames)[i]->GetName());
}
if (strText.IsEmpty())
{
// Default to the unit under test
strText = "IUT";
}
// If SelectString fails, selection will remain at 0
pcombo->SetCurSel(0);
pcombo->SelectString(0, strText);
}
void CEPICSTreeView::WipeOut( CTreeCtrl *ptree, HTREEITEM htreeitem )
{
while (htreeitem != NULL )
{
if ( ptree->GetItemData(htreeitem) != NULL )
delete (CEPICSViewNode *) ptree->GetItemData(htreeitem);
WipeOut(ptree, ptree->GetNextItem(htreeitem, TVGN_CHILD));
htreeitem = ptree->GetNextItem(htreeitem, TVGN_NEXT);
}
}
CView * CEPICSTreeView::GetInfoPanel()
{
return m_pnodeview;
}
void CEPICSTreeView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetDlgItem(IDC_EPICSV_GEN)->EnableWindow(FALSE);
GetDlgItem(IDC_EPICSV_GENALL)->EnableWindow(FALSE);
LoadDACombo();
}
void CEPICSTreeView::OnSelchangedEpicsTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
CTreeCtrl * ptree = (CTreeCtrl *) GetDlgItem(IDC_EPICSV_TREE);
HTREEITEM htreeitem = pNMTreeView == NULL ? NULL : ptree->GetSelectedItem();
CEPICSViewNode * pnode = htreeitem != NULL ? (CEPICSViewNode *) ptree->GetItemData(htreeitem) : NULL;
GetDlgItem(IDC_EPICSV_GEN)->EnableWindow(pnode->IsKindOf(RUNTIME_CLASS(CEPICSViewNodeObject)));
if ( pnode != NULL )
pnode->LoadInfoPanel();
*pResult = 0;
}
void CEPICSTreeView::OnDestroy()
{
CTreeCtrl * ptree = (CTreeCtrl *) GetDlgItem(IDC_EPICSV_TREE);
// Kill the frame context listner
RemoveContext();
WipeOut(ptree, ptree->GetRootItem());
ptree->DeleteAllItems();
CFormView::OnDestroy();
}
void CEPICSTreeView::OnDropdownEpicsDA()
{
LoadDACombo();
}