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.
404 lines
8.3 KiB
404 lines
8.3 KiB
|
|
// Util6208Dlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "math.h"
|
|
#include "Util6208.h"
|
|
#include "Util6208Dlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
|
|
// 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()
|
|
|
|
|
|
// CUtil6208Dlg dialog
|
|
|
|
|
|
|
|
|
|
CUtil6208Dlg::CUtil6208Dlg(I16 hCard, CWnd* pParent /*=NULL*/)
|
|
: CDialog(CUtil6208Dlg::IDD, pParent)
|
|
{
|
|
int i;
|
|
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
m_hCard = hCard;
|
|
|
|
|
|
for( i=0; i<MAX_AO_CHANNELS; i++ )
|
|
{
|
|
m_AOValue[i] = 0;
|
|
}
|
|
|
|
m_bDIData = 0x00;
|
|
m_bDOData = 0x00;
|
|
|
|
m_nTimer = -1;
|
|
}
|
|
|
|
void CUtil6208Dlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_ICON_DI0, m_DI0_ON);
|
|
DDX_Control(pDX, IDC_ICON_DI1, m_DI1_ON);
|
|
DDX_Control(pDX, IDC_ICON_DI2, m_DI2_ON);
|
|
DDX_Control(pDX, IDC_ICON_DI3, m_DI3_ON);
|
|
DDX_Control(pDX, IDC_SLIDER_V0, m_sdAOLevel0);
|
|
DDX_Control(pDX, IDC_SLIDER_V1, m_sdAOLevel1);
|
|
DDX_Control(pDX, IDC_SLIDER_V2, m_sdAOLevel2);
|
|
DDX_Control(pDX, IDC_SLIDER_V3, m_sdAOLevel3);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CUtil6208Dlg, CDialog)
|
|
ON_WM_SYSCOMMAND()
|
|
ON_WM_PAINT()
|
|
ON_WM_QUERYDRAGICON()
|
|
//}}AFX_MSG_MAP
|
|
ON_BN_CLICKED(IDC_CHECK_DO0, &CUtil6208Dlg::OnDO0Clicked)
|
|
ON_BN_CLICKED(IDC_CHECK_DO1, &CUtil6208Dlg::OnDO1Clicked)
|
|
ON_BN_CLICKED(IDC_CHECK_DO2, &CUtil6208Dlg::OnDO2Clicked)
|
|
ON_BN_CLICKED(IDC_CHECK_DO3, &CUtil6208Dlg::OnDO3Clicked)
|
|
ON_WM_TIMER()
|
|
ON_WM_DESTROY()
|
|
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_V3, &CUtil6208Dlg::OnSliderV3Changed)
|
|
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_V2, &CUtil6208Dlg::OnSliderV2Changed)
|
|
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_V1, &CUtil6208Dlg::OnSliderV1Changed)
|
|
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_V0, &CUtil6208Dlg::OnSliderV0Changed)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CUtil6208Dlg message handlers
|
|
|
|
BOOL CUtil6208Dlg::OnInitDialog()
|
|
{
|
|
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
|
|
|
|
// TODO: Add extra initialization here
|
|
|
|
m_sdAOLevel0.SetRange( 0, 32767, TRUE );
|
|
m_sdAOLevel0.SetTicFreq( 5 );
|
|
|
|
m_sdAOLevel1.SetRange( 0, 32767, TRUE );
|
|
m_sdAOLevel1.SetTicFreq( 5 );
|
|
|
|
m_sdAOLevel2.SetRange( 0, 32767, TRUE );
|
|
m_sdAOLevel2.SetTicFreq( 5 );
|
|
|
|
m_sdAOLevel3.SetRange( 0, 32767, TRUE );
|
|
m_sdAOLevel3.SetTicFreq( 5 );
|
|
|
|
m_nTimer = SetTimer( 1, 200, NULL );
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
void CUtil6208Dlg::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 CUtil6208Dlg::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
|
|
{
|
|
CDialog::OnPaint();
|
|
}
|
|
}
|
|
|
|
// The system calls this function to obtain the cursor to display while the user drags
|
|
// the minimized window.
|
|
HCURSOR CUtil6208Dlg::OnQueryDragIcon()
|
|
{
|
|
return static_cast<HCURSOR>(m_hIcon);
|
|
}
|
|
|
|
|
|
void CUtil6208Dlg::OnDO0Clicked()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int CheckSts;
|
|
|
|
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO0 ))->GetCheck();
|
|
|
|
if( CheckSts == BST_CHECKED )
|
|
{
|
|
m_bDOData |= 0x01;
|
|
}
|
|
else if( CheckSts == BST_UNCHECKED )
|
|
{
|
|
m_bDOData &= (~0x01);
|
|
}
|
|
|
|
DO_WritePort( m_hCard, 0, m_bDOData );
|
|
}
|
|
|
|
void CUtil6208Dlg::OnDO1Clicked()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int CheckSts;
|
|
|
|
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO1 ))->GetCheck();
|
|
|
|
if( CheckSts == BST_CHECKED )
|
|
{
|
|
m_bDOData |= 0x02;
|
|
}
|
|
else if( CheckSts == BST_UNCHECKED )
|
|
{
|
|
m_bDOData &= (~0x02);
|
|
}
|
|
|
|
DO_WritePort( m_hCard, 0, m_bDOData );
|
|
}
|
|
|
|
void CUtil6208Dlg::OnDO2Clicked()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int CheckSts;
|
|
|
|
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO2 ))->GetCheck();
|
|
|
|
if( CheckSts == BST_CHECKED )
|
|
{
|
|
m_bDOData |= 0x04;
|
|
}
|
|
else if( CheckSts == BST_UNCHECKED )
|
|
{
|
|
m_bDOData &= (~0x04);
|
|
}
|
|
|
|
DO_WritePort( m_hCard, 0, m_bDOData );
|
|
}
|
|
|
|
void CUtil6208Dlg::OnDO3Clicked()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int CheckSts;
|
|
|
|
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO3 ))->GetCheck();
|
|
|
|
if( CheckSts == BST_CHECKED )
|
|
{
|
|
m_bDOData |= 0x08;
|
|
}
|
|
else if( CheckSts == BST_UNCHECKED )
|
|
{
|
|
m_bDOData &= (~0x08);
|
|
}
|
|
|
|
DO_WritePort( m_hCard, 0, m_bDOData );
|
|
}
|
|
|
|
void CUtil6208Dlg::OnTimer(UINT_PTR nIDEvent)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
U32 dwPortData;
|
|
|
|
DI_ReadPort( m_hCard, 0, &dwPortData);
|
|
|
|
dwPortData = ( dwPortData & 0x0F );
|
|
|
|
if( dwPortData != m_bDIData )
|
|
{
|
|
|
|
m_bDIData = (U8)( dwPortData & 0xFF );
|
|
|
|
if( (dwPortData & 0x01) == 0x01 )
|
|
{
|
|
m_DI0_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
|
|
}
|
|
else
|
|
{
|
|
m_DI0_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
|
|
}
|
|
|
|
if( (dwPortData & 0x02) == 0x02 )
|
|
{
|
|
m_DI1_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
|
|
}
|
|
else
|
|
{
|
|
m_DI1_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
|
|
}
|
|
|
|
if( (dwPortData & 0x04) == 0x04 )
|
|
{
|
|
m_DI2_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
|
|
}
|
|
else
|
|
{
|
|
m_DI2_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
|
|
}
|
|
|
|
if( (dwPortData & 0x08) == 0x08 )
|
|
{
|
|
m_DI3_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
|
|
}
|
|
else
|
|
{
|
|
m_DI3_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
|
|
}
|
|
}
|
|
|
|
CDialog::OnTimer(nIDEvent);
|
|
}
|
|
|
|
void CUtil6208Dlg::OnDestroy()
|
|
{
|
|
CDialog::OnDestroy();
|
|
|
|
// TODO: Add your message handler code here
|
|
if( m_nTimer != -1 )
|
|
KillTimer( m_nTimer );
|
|
}
|
|
|
|
|
|
void CUtil6208Dlg::OnSliderV0Changed(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int position;
|
|
|
|
position = m_sdAOLevel0.GetPos();
|
|
|
|
m_AOValue[0] = m_AOValue[1] = position;
|
|
|
|
AO_WriteChannel(m_hCard, 0, (I16)m_AOValue[0] );
|
|
AO_WriteChannel(m_hCard, 1, (I16)m_AOValue[1] );
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
void CUtil6208Dlg::OnSliderV1Changed(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int position;
|
|
|
|
position = m_sdAOLevel1.GetPos();
|
|
|
|
m_AOValue[2] = m_AOValue[3] = position;
|
|
|
|
AO_WriteChannel(m_hCard, 2, (I16)m_AOValue[2] );
|
|
AO_WriteChannel(m_hCard, 3, (I16)m_AOValue[3] );
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
void CUtil6208Dlg::OnSliderV2Changed(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int position;
|
|
|
|
position = m_sdAOLevel2.GetPos();
|
|
|
|
m_AOValue[4] = m_AOValue[5] = position;
|
|
|
|
AO_WriteChannel(m_hCard, 4, (I16)m_AOValue[4] );
|
|
AO_WriteChannel(m_hCard, 5, (I16)m_AOValue[5] );
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CUtil6208Dlg::OnSliderV3Changed(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int position;
|
|
|
|
position = m_sdAOLevel3.GetPos();
|
|
|
|
m_AOValue[6] = m_AOValue[7] = position;
|
|
|
|
AO_WriteChannel(m_hCard, 6, (I16)m_AOValue[6] );
|
|
AO_WriteChannel(m_hCard, 7, (I16)m_AOValue[7] );
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
|