리크 테스트 gui
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

943 lines
20 KiB

// Util9524Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "Util9524.h"
#include "Util9524Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CRect plotRect;
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CUtil9524Dlg dialog
CUtil9524Dlg::CUtil9524Dlg(I16 hCard, CWnd* pParent /*=NULL*/)
: CDialog(CUtil9524Dlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_hCard = hCard;
n_PlotWidth = n_PlotHeight = -1;
OnBrush = OffBrush = NULL;
min_val = 0x00;
max_val = 0xFFFF;
for( int i=0; i<MAX_CHAN_9524; i++ )
{
m_AIEnable[i] = 0x00;
m_oldY[i] = -1;
}
m_AIChan[0] = P9524_AI_GP_CH0; m_AIChan[1] = P9524_AI_GP_CH1; m_AIChan[2] = P9524_AI_GP_CH2; m_AIChan[3] = P9524_AI_GP_CH3;
m_OutData = 0x0000;
m_InData = 0x0000;
m_nTimer = -1;
m_wPollSpeed = P9524_ADC_60_SPS;
m_wGroup = P9524_AI_GP_Group;
m_wXMode = P9524_AI_XFER_POLL;
}
void CUtil9524Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SCROLLBAR1, m_scBarAO);
DDX_Control(pDX, IDC_COMBO_AI_RANGE, m_cbAIRange);
DDX_Control(pDX, IDC_COMBO_AO_CHANNEL, m_cbAOChannel);
DDX_Control(pDX, IDC_ICON_DI00, m_Icon_IN00);
DDX_Control(pDX, IDC_ICON_DI01, m_Icon_IN01);
DDX_Control(pDX, IDC_ICON_DI02, m_Icon_IN02);
DDX_Control(pDX, IDC_ICON_DI03, m_Icon_IN03);
DDX_Control(pDX, IDC_ICON_DI04, m_Icon_IN04);
DDX_Control(pDX, IDC_ICON_DI05, m_Icon_IN05);
DDX_Control(pDX, IDC_ICON_DI06, m_Icon_IN06);
DDX_Control(pDX, IDC_ICON_DI07, m_Icon_IN07);
}
BEGIN_MESSAGE_MAP(CUtil9524Dlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_WM_HSCROLL()
ON_WM_DESTROY()
ON_CBN_SELCHANGE(IDC_COMBO_AI_RANGE, &CUtil9524Dlg::OnAIRangeSelchange)
ON_CBN_SELCHANGE(IDC_COMBO_AO_CHANNEL, &CUtil9524Dlg::OnAOChannelSelchange)
ON_BN_CLICKED(IDC_RADIO_CH0, &CUtil9524Dlg::OnAI00Enable)
ON_BN_CLICKED(IDC_RADIO_CH1, &CUtil9524Dlg::OnAI01Enable)
ON_BN_CLICKED(IDC_RADIO_CH2, &CUtil9524Dlg::OnAI02Enable)
ON_BN_CLICKED(IDC_RADIO_CH3, &CUtil9524Dlg::OnAI03Enable)
ON_BN_CLICKED(IDC_CHECK_DO00, &CUtil9524Dlg::OnDo00)
ON_BN_CLICKED(IDC_CHECK_DO01, &CUtil9524Dlg::OnDo01)
ON_BN_CLICKED(IDC_CHECK_DO02, &CUtil9524Dlg::OnDo02)
ON_BN_CLICKED(IDC_CHECK_DO03, &CUtil9524Dlg::OnDo03)
ON_BN_CLICKED(IDC_CHECK_DO04, &CUtil9524Dlg::OnDo04)
ON_BN_CLICKED(IDC_CHECK_DO05, &CUtil9524Dlg::OnDo05)
ON_BN_CLICKED(IDC_CHECK_DO06, &CUtil9524Dlg::OnDo06)
ON_BN_CLICKED(IDC_CHECK_DO07, &CUtil9524Dlg::OnDo07)
ON_WM_TIMER()
END_MESSAGE_MAP()
// CUtil9524Dlg message handlers
BOOL CUtil9524Dlg::OnInitDialog()
{
SCROLLINFO info;
I16 err;
CString strTemp;
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
x_divider = 5; y_divider = 2;
OnBrush = CreateSolidBrush( RGB(255,0,0) );
OffBrush = CreateSolidBrush( RGB(125,0,0) );
RedPen.CreatePen( PS_SOLID, 1, RGB(255,0,0));
GreenPen.CreatePen( PS_SOLID, 1, RGB(0,255,0));
YellowPen.CreatePen( PS_SOLID, 1, RGB(255,255,0));
BluePen.CreatePen( PS_SOLID, 1, RGB(0,0,255));
LTBluePen.CreatePen( PS_SOLID, 1, RGB(0,128,255));
LTRedPen.CreatePen( PS_SOLID, 1, RGB(255,128,0));
LTGreenPen.CreatePen( PS_SOLID, 1, RGB(0,128,0));
WhitePen.CreatePen( PS_SOLID, 1, RGB(255,255,255));
if( n_PlotWidth == -1 && n_PlotHeight == -1 )
{
((CWnd*)GetDlgItem(IDC_STATIC_DRAW0))->GetWindowRect(&plotRect);
ScreenToClient(&plotRect);
n_PlotWidth = min( plotRect.Width(), 512);
// n_PlotHeight = plotRect.Height() - 10;
n_PlotHeight = plotRect.Height();
}
// TODO: Add extra initialization here
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_ALL;
info.nMin = 0;
info.nMax = 4096;
info.nPage = 2;
info.nPos = 0;
info.nTrackPos = 2;
m_scBarAO.SetScrollInfo(&info);
m_nAOValue = 0;
m_cbAIRange.SetCurSel( 0 );
max_range = 10.0;
min_range = -10.0;
m_wAdRange = AD_B_10_V;
m_cbAOChannel.SetCurSel( 0 );
m_wAOChannel = 0;
err = AI_9524_Config(m_hCard, m_wGroup, m_wXMode, 0, 0, 0);
if(err<0)
{
strTemp.Format( TEXT("AI_9524_PollConfig( P9524_AI_GP_CH0 ) Error: %d\n"), err);
return FALSE;
}
err = AI_9524_PollConfig(m_hCard, m_wGroup, P9524_AI_POLL_ALLCHANNELS, m_wAdRange, m_wPollSpeed);
if(err<0)
{
strTemp.Format( TEXT("AI_9524_PollConfig( P9524_AI_GP_CH0 ) Error: %d\n"), err);
return FALSE;
}
m_nTimer = SetTimer( 1, 50, NULL );
return TRUE; // return TRUE unless you set the focus to a control
}
void CUtil9524Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CUtil9524Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
redraw_display_area();
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CUtil9524Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CUtil9524Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int minpos;
int maxpos;
double fAOValue;
CString strTmp;
m_scBarAO.GetScrollRange(&minpos, &maxpos);
maxpos = m_scBarAO.GetScrollLimit();
// Get the current position of scroll box.
int curpos = m_scBarAO.GetScrollPos();
// Determine the new position of scroll box.
switch (nSBCode)
{
case SB_LINELEFT: // Scroll left.
if (curpos > minpos)
curpos--;
break;
case SB_LINERIGHT: // Scroll right.
if (curpos < maxpos)
curpos++;
break;
case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
curpos = nPos; // of the scroll box at the end of the drag operation.
break;
case SB_LEFT: // Scroll to far left.
case SB_RIGHT: // Scroll to far right.
case SB_ENDSCROLL: // End scroll.
case SB_PAGELEFT: // Scroll one page left.
case SB_PAGERIGHT: // Scroll one page right.
case SB_THUMBTRACK: // Drag scroll box to specified position. nPos is the
break;
}
// Set the new position of the thumb (scroll box).
m_scBarAO.SetScrollPos(curpos);
if( m_nAOValue != curpos )
{
// update the m_nAOValue value, and output AO
m_nAOValue = curpos;
fAOValue = ( 20.0 * (double)curpos / (double)(maxpos - minpos) ) - 10.0;
strTmp.Format( TEXT("%.02f"), fAOValue );
SetDlgItemText( IDC_EDIT_AO, strTmp );
AO_VWriteChannel(m_hCard, m_wAOChannel, fAOValue );
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CUtil9524Dlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
if( m_nTimer != -1 )
{
KillTimer( m_nTimer );
m_nTimer = -1;
}
if( OnBrush != NULL )
::DeleteObject( OnBrush );
if( OffBrush != NULL )
::DeleteObject( OffBrush );
RedPen.DeleteObject();
GreenPen.DeleteObject();
YellowPen.DeleteObject();
BluePen.DeleteObject();
LTBluePen.DeleteObject();
LTRedPen.DeleteObject();
LTGreenPen.DeleteObject();
WhitePen.DeleteObject();
}
void CUtil9524Dlg::OnAIRangeSelchange()
{
// TODO: Add your control notification handler code here
U16 tmpAdRange;
int nIndex;
double maxRange, minRange;
I16 err;
CString strTemp;
nIndex = m_cbAIRange.GetCurSel();
switch( nIndex )
{
case 0:
tmpAdRange = AD_B_10_V;
maxRange = 10.0;
minRange = -10.0;
break;
case 1:
tmpAdRange = AD_B_5_V;
maxRange = 5.0;
minRange = -5.0;
break;
case 2:
tmpAdRange = AD_B_2_5_V;
maxRange = 2.5;
minRange = -2.5;
break;
case 3:
tmpAdRange = AD_B_1_25_V;
maxRange = 1.25;
minRange = -1.25;
break;
}
if( tmpAdRange != m_wAdRange )
{ // update m_InPortA and configure the target Port
m_wAdRange = tmpAdRange;
// Re-Configure AI-Polling settings
err = AI_9524_PollConfig(m_hCard, P9524_AI_GP_Group, P9524_AI_POLL_ALLCHANNELS, m_wAdRange, m_wPollSpeed);
if(err<0)
{
strTemp.Format( TEXT("AI_9524_PollConfig( P9524_AI_GP_CH0 ) Error: %d\n"), err);
return;
}
max_range = maxRange;
min_range = minRange;
redraw_display_area();
}
}
void CUtil9524Dlg::OnAOChannelSelchange()
{
// TODO: Add your control notification handler code here
U16 tmpAOChannel;
int nIndex;
nIndex = m_cbAOChannel.GetCurSel();
switch( nIndex )
{
case 0:
tmpAOChannel = 0;
break;
case 1:
tmpAOChannel = 1;
break;
}
if( tmpAOChannel != m_wAOChannel )
{ // update m_InPortA and configure the target Port
m_wAOChannel = tmpAOChannel;
}
}
void CUtil9524Dlg::OnAI00Enable()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_RADIO_CH0 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_AIEnable[0] = 0x01;
}
else if( CheckSts == BST_UNCHECKED )
{
m_AIEnable[0] = 0x00;
}
}
void CUtil9524Dlg::OnAI01Enable()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_RADIO_CH1 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_AIEnable[1] = 0x01;
}
else if( CheckSts == BST_UNCHECKED )
{
m_AIEnable[1] = 0x00;
}
}
void CUtil9524Dlg::OnAI02Enable()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_RADIO_CH2 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_AIEnable[2] = 0x01;
}
else if( CheckSts == BST_UNCHECKED )
{
m_AIEnable[2] = 0x00;
}
}
void CUtil9524Dlg::OnAI03Enable()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_RADIO_CH3 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_AIEnable[3] = 0x01;
}
else if( CheckSts == BST_UNCHECKED )
{
m_AIEnable[3] = 0x00;
}
}
void CUtil9524Dlg::OnDo00()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO00 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_OutData |= 0x01;
}
else if( CheckSts == BST_UNCHECKED )
{
m_OutData &= (~0x01);
}
DO_WritePort(m_hCard, 0, m_OutData);
}
void CUtil9524Dlg::OnDo01()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO01 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_OutData |= 0x02;
}
else if( CheckSts == BST_UNCHECKED )
{
m_OutData &= (~0x02);
}
DO_WritePort(m_hCard, 0, m_OutData);
}
void CUtil9524Dlg::OnDo02()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO02 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_OutData |= 0x04;
}
else if( CheckSts == BST_UNCHECKED )
{
m_OutData &= (~0x04);
}
DO_WritePort(m_hCard, 0, m_OutData);
}
void CUtil9524Dlg::OnDo03()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO03 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_OutData |= 0x08;
}
else if( CheckSts == BST_UNCHECKED )
{
m_OutData &= (~0x08);
}
DO_WritePort(m_hCard, 0, m_OutData);
}
void CUtil9524Dlg::OnDo04()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO04 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_OutData |= 0x10;
}
else if( CheckSts == BST_UNCHECKED )
{
m_OutData &= (~0x10);
}
DO_WritePort(m_hCard, 0, m_OutData);
}
void CUtil9524Dlg::OnDo05()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO05 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_OutData |= 0x20;
}
else if( CheckSts == BST_UNCHECKED )
{
m_OutData &= (~0x20);
}
DO_WritePort(m_hCard, 0, m_OutData);
}
void CUtil9524Dlg::OnDo06()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO06 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_OutData |= 0x40;
}
else if( CheckSts == BST_UNCHECKED )
{
m_OutData &= (~0x40);
}
DO_WritePort(m_hCard, 0, m_OutData);
}
void CUtil9524Dlg::OnDo07()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO07 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_OutData |= 0x80;
}
else if( CheckSts == BST_UNCHECKED )
{
m_OutData &= (~0x80);
}
DO_WritePort(m_hCard, 0, m_OutData);
}
void CUtil9524Dlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
U32 dwPortData,dwChangeMask;
I16 err;
err = DI_ReadPort(m_hCard, 0, &dwPortData);
dwChangeMask = dwPortData ^ m_InData;
if( dwChangeMask != 0x00 ) // Input had been changed
{
m_InData = dwPortData;
if( (dwChangeMask & 0x0001) == 0x0001 ) // if the target bit is changed
{
if( (dwPortData & 0x0001) == 0x0001 )
{
m_Icon_IN00.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_IN00.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x0002) == 0x0002 ) // if the target bit is changed
{
if( (dwPortData & 0x0002) == 0x0002 )
{
m_Icon_IN01.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_IN01.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x0004) == 0x0004 ) // if the target bit is changed
{
if( (dwPortData & 0x0004) == 0x0004 )
{
m_Icon_IN02.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_IN02.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x0008) == 0x0008 ) // if the target bit is changed
{
if( (dwPortData & 0x0008) == 0x0008 )
{
m_Icon_IN03.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_IN03.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x0010) == 0x0010 ) // if the target bit is changed
{
if( (dwPortData & 0x0010) == 0x0010 )
{
m_Icon_IN04.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_IN04.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x0020) == 0x0020 ) // if the target bit is changed
{
if( (dwPortData & 0x0020) == 0x0020 )
{
m_Icon_IN05.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_IN05.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x0040) == 0x0040 ) // if the target bit is changed
{
if( (dwPortData & 0x0040) == 0x0040 )
{
m_Icon_IN06.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_IN06.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x0080) == 0x0080 ) // if the target bit is changed
{
if( (dwPortData & 0x0080) == 0x0080 )
{
m_Icon_IN07.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_IN07.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
}
for( int i=0; i<MAX_CHAN_9524; i++ )
{
err = AI_ScanReadChannels32(m_hCard, m_wGroup, m_wAdRange, m_AIData);
}
display_buffer_data();
CDialog::OnTimer(nIDEvent);
}
void CUtil9524Dlg::redraw_display_area(void)
{
CPen *oldPen;
int oldMode;
COLORREF oldColor;
CString y_lable;
CPen minor_tick( PS_SOLID,1,RGB(132,130,132) );
// CPen y_grid( PS_SOLID,1,RGB(206,203,132) );
int i, x_intv, y_intv;
// long total_sec;
CClientDC dc_plot(this);
// draw the base-line for x-y axises
oldPen = (CPen *)dc_plot.SelectStockObject(BLACK_PEN);
// redraw the background
dc_plot.FillSolidRect( plotRect, RGB(0,0,0) );
// Re-Draw the AREA for Y-Lable
{
CBrush DIALOG_BRUSH;
CRect redraw_area, full_client;
GetClientRect(&full_client);
ScreenToClient(&full_client);
redraw_area.left = full_client.left;
redraw_area.top = plotRect.top - 5;
redraw_area.right = plotRect.left - 3;
redraw_area.bottom = plotRect.bottom + 10;
DIALOG_BRUSH.CreateSysColorBrush( COLOR_3DFACE );
dc_plot.FillRect( redraw_area, &DIALOG_BRUSH );
DIALOG_BRUSH.DeleteObject();
}
dc_plot.MoveTo( plotRect.left - 3, plotRect.top );
dc_plot.LineTo( plotRect.left - 3, plotRect.bottom );
// calculate the interval for tick/grid
y_intv = (plotRect.Height() - 10) /y_divider;
x_intv = plotRect.Width()/x_divider;
// set the color for tick
oldColor = dc_plot.SetTextColor( RGB(0,0,0) );
oldMode = dc_plot.SetBkMode( TRANSPARENT );
for( i=0; i<= y_divider; i++ )
{
CString tick_str;
CRect tmp_rect, tick_rect;
// draw the tick for y-axis
dc_plot.MoveTo( plotRect.left -12, plotRect.bottom -5 - (i*y_intv) );
dc_plot.LineTo( plotRect.left -3, plotRect.bottom -5 - (i*y_intv) );
tick_str.Format( _T("%.3f"), ( ((max_range-min_range)/y_divider) * i)+min_range );
// calculate the rectangle for text
dc_plot.DrawText( tick_str, &tmp_rect, DT_CALCRECT|DT_SINGLELINE );
tick_rect.right = plotRect.left -14;
tick_rect.left = tick_rect.right - tmp_rect.Width();
tick_rect.top = plotRect.bottom -5 - (i*y_intv) - tmp_rect.Height()/2;
tick_rect.bottom = tick_rect.top + tmp_rect.Height();
// draw the text
dc_plot.DrawText( tick_str, &tick_rect, DT_SINGLELINE|DT_RIGHT );
}
// draw the minor_tick for Y axises
dc_plot.SelectObject(&minor_tick);
for( i=0; i< y_divider; i++ )
{
dc_plot.MoveTo( plotRect.left -9, plotRect.bottom -5 - (i*y_intv) - y_intv/2 );
dc_plot.LineTo( plotRect.left -4, plotRect.bottom -5 - (i*y_intv) - y_intv/2 );
}
dc_plot.SetTextColor( oldColor );
dc_plot.SetBkMode( oldMode );
dc_plot.SelectObject( oldPen );
}
int CUtil9524Dlg::display_buffer_data(void)
{
CClientDC dc_plot(this);
int nDraw_Bottom;
int cur_channel;
int newY;
I32 ai_data, nTemp;
dc_plot.BitBlt( plotRect.left+2, plotRect.top, n_PlotWidth-2, n_PlotHeight, &dc_plot, plotRect.left, plotRect.top, SRCCOPY );
for( int i=0; i<MAX_CHAN_9524; i++ )
{
if ( m_AIEnable[i] == 0x01 )
{
switch (i)
{
case 0:
dc_plot.SelectObject( &YellowPen);
nDraw_Bottom = ( plotRect.bottom ) - n_PlotHeight/2;
break;
case 1:
dc_plot.SelectObject( &LTGreenPen);
nDraw_Bottom = ( plotRect.bottom ) - n_PlotHeight/2;
break;
case 2:
dc_plot.SelectObject( &BluePen);
nDraw_Bottom = ( plotRect.bottom ) - n_PlotHeight/2;
break;
case 3:
dc_plot.SelectObject( &RedPen);
nDraw_Bottom = ( plotRect.bottom ) - n_PlotHeight/2;
break;
}
nTemp = (I32)(m_AIData[i]);
cur_channel = (int)((nTemp >> 4) & 0x0F);
ai_data = (nTemp >> 8);
newY = (int)( nDraw_Bottom - ((n_PlotHeight * ai_data) >> 24) ); // ( n_PlotHeight * ai_data / 16777216) ); // ( (n_PlotHeight/2) * ai_data/8388608 ) );
if ( m_oldY[i] !=-1 )
{
dc_plot.MoveTo( plotRect.left+2, newY );
dc_plot.LineTo( plotRect.left+5, m_oldY[i] );
}
m_oldY[i] = newY;
}
}
return 0;
}