[go: up one dir, main page]

Menu

[r993]: / trunk / VTS3 / SummaryView.cpp  Maximize  Restore  History

Download this file

391 lines (310 with data), 9.5 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
// SummaryView.cpp : implementation file
This file is obsolete - replaced by CListSummaryView
#include "stdafx.h"
#include "VTS.h"
#include "VTSDoc.h"
#include "ChildFrm.h"
#include "SummaryView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSummaryView
IMPLEMENT_DYNCREATE(CSummaryView, CScrollView)
CSummaryView::CSummaryView()
{
}
CSummaryView::~CSummaryView()
{
}
BEGIN_MESSAGE_MAP(CSummaryView, CScrollView)
//{{AFX_MSG_MAP(CSummaryView)
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_WM_CHAR()
ON_WM_KEYDOWN()
ON_WM_CANCELMODE()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_LBUTTONDBLCLK()
ON_WM_CAPTURECHANGED()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSummaryView drawing
void CSummaryView::OnInitialUpdate()
{
// let everything initialize correctly
CScrollLineView::OnInitialUpdate();
// set the line count according to what is in the document
// VTSDoc* pDoc = GetDocument();
// ASSERT_VALID(pDoc);
// SetLineCount( pDoc->m_nPacketCount );
SetLineCount(m_FrameContext->m_PacketCount);
// set the scroll position at the top
ScrollToPosition( CPoint( 0, 0 ) );
}
void CSummaryView::OnDraw(CDC* pDC)
{
CScrollLineView::OnDraw( pDC );
}
/////////////////////////////////////////////////////////////////////////////
// CSummaryView diagnostics
#ifdef _DEBUG
void CSummaryView::AssertValid() const
{
CScrollLineView::AssertValid();
}
void CSummaryView::Dump(CDumpContext& dc) const
{
CScrollLineView::Dump(dc);
}
VTSDoc* CSummaryView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(VTSDoc)));
return (VTSDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSummaryView message handlers
int CSummaryView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CScrollLineView::OnCreate(lpCreateStruct) == -1)
return -1;
SetContext( gNewFrameContext );
return 0;
}
//
// CSummaryView::OnUpdate
//
// This function passes the update message along to the scroll view. Note
// that CScrollLineView doesn't have an OnUpdate() function to call, so
// this hops over the class.
//
void CSummaryView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// pass update message to the view which invalidates the visible area
CScrollView::OnUpdate( pSender, lHint, pHint );
}
void CSummaryView::OnLButtonDown(UINT nFlags, CPoint point)
{
int lineNo = GetLineAtPoint( point );
m_FrameContext->SetCurrentPacket( lineNo );
}
void CSummaryView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
TRACE1( "CSummaryView::OnChar( %d, ...)\n", nChar );
if ((nChar == 0x09) && (m_pTabRing))
m_pTabRing->SetFocus();
}
void CSummaryView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
bool shiftKeyDown = (GetKeyState(VK_SHIFT) < 0);
bool controlKeyDown = (GetKeyState(VK_CONTROL) < 0);
int nMapMode;
SIZE sizeTotal, sizePage, sizeLine;
GetDeviceScrollSizes( nMapMode, sizeTotal, sizePage, sizeLine );
switch (nChar) {
case VK_UP:
if ((m_FrameContext->m_PacketCount != 0) && (m_FrameContext->m_CurrentPacket > 0))
m_FrameContext->SetCurrentPacket( m_FrameContext->m_CurrentPacket - 1);
break;
case VK_DOWN:
if ((m_FrameContext->m_PacketCount != 0) && (m_FrameContext->m_CurrentPacket < (m_FrameContext->m_PacketCount - 1)))
m_FrameContext->SetCurrentPacket( m_FrameContext->m_CurrentPacket + 1);
break;
case VK_PRIOR:
if (m_FrameContext->m_PacketCount != 0)
ScrollToPosition( CPoint( 0, GetScrollPosition().y - sizePage.cy ) );
break;
case VK_NEXT:
if (m_FrameContext->m_PacketCount != 0)
ScrollToPosition( CPoint( 0, GetScrollPosition().y + sizePage.cy ) );
break;
case VK_HOME:
if (m_FrameContext->m_PacketCount != 0) {
if (controlKeyDown)
m_FrameContext->SetCurrentPacket( 0 );
else
ScrollToPosition( CPoint( 0, 0 ) );
}
break;
case VK_END:
if (m_FrameContext->m_PacketCount != 0) {
if (controlKeyDown)
m_FrameContext->SetCurrentPacket( m_FrameContext->m_PacketCount - 1 );
else
ScrollToPosition( CPoint( 0, m_FrameContext->m_PacketCount * m_cyScreen ) );
}
break;
default:
CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
break;
}
}
void CSummaryView::OnCancelMode()
{
CScrollView::OnCancelMode();
// TODO: Add your message handler code here
}
void CSummaryView::OnSetFocus(CWnd* pOldWnd)
{
TRACE0( "CSummaryView::OnSetFocus()\n" );
CScrollLineView::OnSetFocus(pOldWnd);
}
void CSummaryView::OnKillFocus(CWnd* pNewWnd)
{
TRACE0( "CSummaryView::OnKillFocus()\n" );
CScrollLineView::OnKillFocus(pNewWnd);
}
//CChildFrame* CSummaryView::GetFrame()
//{
// CWnd* parent = GetParent();
//
// while (parent) {
// if (parent->IsKindOf(RUNTIME_CLASS(CChildFrame)))
// return (CChildFrame*)parent;
// parent = parent->GetParent();
// }
//
// // bad news, this view is not a child of CChildFrame
// return NULL;
void CSummaryView::ContextChange( CFrameContext::Signal s )
{
switch (s) {
case CFrameContext::eNewPacketCount:
SetLineCount( m_FrameContext->m_PacketCount );
break;
case CFrameContext::eNewCurrentPacket:
SetSelectedLine( m_FrameContext->m_CurrentPacket );
break;
}
}
//
// CSummaryView::GetLineData
//
// This function is called to get the ASCII description of the packet to
// be displayed in the summary view. Note that it cannot rely on the
// current packet, because it is independant of the current packet!
//
CString* CSummaryView::GetLineData(int lineNo)
{
CString* pString = new CString()
;
char theTime[16]
;
//MAD_DB VTSPacket pkt;
VTSPacketPtr ppkt = m_FrameContext->m_pDoc->GetPacket(lineNo);
if ( ppkt == NULL || pString == NULL )
return NULL;
// format the packet number
pString->Format( "%5d ", lineNo );
// read the packet, the frame context holds the information
//MAD_DB m_FrameContext->m_pDoc->m_pDB->ReadPacket( lineNo, pkt );
// format the time
FILETIME locFileTime
;
SYSTEMTIME st
;
//MAD_DB ::FileTimeToLocalFileTime( &pkt.packetHdr.packetTime, &locFileTime );
::FileTimeToLocalFileTime( &(ppkt->packetHdr.packetTime), &locFileTime );
::FileTimeToSystemTime( &locFileTime, &st );
sprintf( theTime, "%02d:%02d:%02d.%03d "
, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds
);
*pString += theTime;
#if 1
int i, len = 9
;
char nameBuff[32], addrBuff[32], *addr
;
const char *name
;
// look up the source
//MAD_DB name = m_FrameContext->m_pDoc->m_Names.AddrToName( pkt.packetHdr.packetSource, pkt.packetHdr.packetPortID );
name = m_FrameContext->m_pDoc->AddrToName( ppkt->packetHdr.packetSource, ppkt->packetHdr.m_szPortName );
if (name)
sprintf( nameBuff, "%-*.*s", len+1, len, name );
else {
addrBuff[0] = 0;
addr = addrBuff;
/* MAD_DB
for (i = 0; i < pkt.packetHdr.packetSource.addrLen; i++) {
sprintf( addr, "%02X", pkt.packetHdr.packetSource.addrAddr[i] );
addr += 2;
}
*/
for (i = 0; i < ppkt->packetHdr.packetSource.addrLen; i++)
{
sprintf( addr, "%02X", ppkt->packetHdr.packetSource.addrAddr[i] );
addr += 2;
}
sprintf( nameBuff, "%-*.*s", len+1, len, addrBuff );
}
*pString += nameBuff;
// look up the destination
//MAD_DB name = m_FrameContext->m_pDoc->m_Names.AddrToName( pkt.packetHdr.packetDestination, pkt.packetHdr.packetPortID );
name = m_FrameContext->m_pDoc->AddrToName( ppkt->packetHdr.packetDestination, ppkt->packetHdr.m_szPortName );
if (name)
sprintf( nameBuff, "%-*.*s", len+1, len, name );
else {
addrBuff[0] = 0;
addr = addrBuff;
/* MAD_DB
for (i = 0; i < pkt.packetHdr.packetDestination.addrLen; i++) {
sprintf( addr, "%02X", pkt.packetHdr.packetDestination.addrAddr[i] );
addr += 2;
}
*/
for (i = 0; i < ppkt->packetHdr.packetDestination.addrLen; i++)
{
sprintf( addr, "%02X", ppkt->packetHdr.packetDestination.addrAddr[i] );
addr += 2;
}
sprintf( nameBuff, "%-*.*s", len+1, len, addrBuff );
}
*pString += nameBuff;
#endif
#if 1
// format the summary line
BACnetPIInfo summary( true, false );
/*MAD_DB
summary.Interpret( (BACnetPIInfo::ProtocolType)pkt.packetHdr.packetProtocolID
, (char *)pkt.packetData
, pkt.packetLen
);
*/
summary.Interpret( (BACnetPIInfo::ProtocolType) ppkt->packetHdr.packetProtocolID, (char *) ppkt->packetData, ppkt->packetLen );
*pString += summary.summaryLine;
#endif
return pString;
}
BOOL CSummaryView::CreateView(CWnd* pParent,CCreateContext* pContext,RECT rect)
{
DWORD dwStyle = AFX_WS_DEFAULT_VIEW;
// dwStyle &= ~WS_BORDER;
// Create with the right size (wrong position)
CRect rect1(0,0,300,300);
if (!Create(NULL, NULL, dwStyle,
rect1, pParent, AFX_IDW_PANE_FIRST,pContext))
{
TRACE0("Warning: couldn't create treeview pane!. \n");
return FALSE;
}
return TRUE;
}
void CSummaryView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CWnd* parent = GetParentFrame();
if(! ((CChildFrame*)parent)->m_pwndDetailViewBar->IsVisible())
((CChildFrame*)parent)->ShowControlBar( ((CChildFrame*)parent)->m_pwndDetailViewBar, TRUE, FALSE);
CScrollView::OnLButtonDblClk(nFlags, point);
}
void CSummaryView::OnCaptureChanged(CWnd *pWnd)
{
// TODO: Add your message handler code here
CScrollView::OnCaptureChanged(pWnd);
}