📄 demo_alldlg.cpp
字号:
// demo_allDlg.cpp : implementation file
//
#include "stdafx.h"
#include "demo_all.h"
#include "demo_allDlg.h"
// ICP DAS Include .h Files
#include "WinconSDK.h"
#include "UARTCE.h"
#include "I7000CE.h"
#define i87055 0x87055
#define i87055_slot 1
// #define i87K default setting value
#define comport 1 //com port of Wincon-8000 slot1 is 1
#define baudrate 115200
#define address 0
#define parity 0
#define timeout 100
#define checksum 0
#define databit 8
#define stopbit 0
#define flag 0
// define basic var (Remote)
static WORD m_ComPort=3;
static WORD m_DataBit=8;
static WORD m_StopBit=0;
static WORD m_Baudrate=9600;
static WORD m_Parity=0;
static WORD m_TimeOut=100;
static WORD m_Checksum=0;
static WORD m_7012Addr=0;
static WORD m_87017Addr=1;
static WORD m_NetID=2; //8024Addr=2
static WORD m_8024Slot=0;
static WORD m_wBuf[12];
static DWORD m_dwBuf[12];
static float m_fBuf[12];
static char m_szSend[100];
static char m_szReceive[100];
static bool timerOn=true;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDemo_allDlg dialog
CDemo_allDlg::CDemo_allDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDemo_allDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDemo_allDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDemo_allDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDemo_allDlg)
DDX_Control(pDX, IDC_G3, m_G3);
DDX_Control(pDX, IDC_G2, m_G2);
DDX_Control(pDX, IDC_G1, m_G1);
DDX_Control(pDX, IDC_DOon1, m_DOon1);
DDX_Control(pDX, IDC_ARITHMETIC3, m_ARITHMETIC3);
DDX_Control(pDX, IDC_ARITHMETIC2, m_ARITHMETIC2);
DDX_Control(pDX, IDC_ARITHMETIC1, m_ARITHMETIC1);
DDX_Control(pDX, IDC_DOon, m_DOon);
DDX_Control(pDX, IDC_DOoff, m_DOoff);
DDX_Control(pDX, IDC_VIN1, m_VIN1);
DDX_Control(pDX, IDC_VIN2, m_VIN2);
DDX_Control(pDX, IDC_VOUT, m_VOUT);
DDX_Control(pDX, IDC_DO_HEX, m_DO_HEX);
DDX_Control(pDX, IDC_STOP, m_STOP);
DDX_Control(pDX, IDC_START, m_START);
DDX_Control(pDX, IDC_87055_DO7, m_87055_DO7);
DDX_Control(pDX, IDC_87055_DO6, m_87055_DO6);
DDX_Control(pDX, IDC_87055_DO5, m_87055_DO5);
DDX_Control(pDX, IDC_87055_DO4, m_87055_DO4);
DDX_Control(pDX, IDC_87055_DO3, m_87055_DO3);
DDX_Control(pDX, IDC_87055_DO2, m_87055_DO2);
DDX_Control(pDX, IDC_87055_DO1, m_87055_DO1);
DDX_Control(pDX, IDC_87055_DO0, m_87055_DO0);
DDX_Control(pDX, IDC_87055_DI7, m_87055_DI7);
DDX_Control(pDX, IDC_87055_DI6, m_87055_DI6);
DDX_Control(pDX, IDC_87055_DI5, m_87055_DI5);
DDX_Control(pDX, IDC_87055_DI4, m_87055_DI4);
DDX_Control(pDX, IDC_87055_DI3, m_87055_DI3);
DDX_Control(pDX, IDC_87055_DI2, m_87055_DI2);
DDX_Control(pDX, IDC_87055_DI1, m_87055_DI1);
DDX_Control(pDX, IDC_87055_DI0, m_87055_DI0);
DDX_Control(pDX, IDC_8041_DO9, m_8041_DO9);
DDX_Control(pDX, IDC_8041_DO8, m_8041_DO8);
DDX_Control(pDX, IDC_8041_DO7, m_8041_DO7);
DDX_Control(pDX, IDC_8041_DO6, m_8041_DO6);
DDX_Control(pDX, IDC_8041_DO5, m_8041_DO5);
DDX_Control(pDX, IDC_8041_DO4, m_8041_DO4);
DDX_Control(pDX, IDC_8041_DO31, m_8041_DO31);
DDX_Control(pDX, IDC_8041_DO30, m_8041_DO30);
DDX_Control(pDX, IDC_8041_DO3, m_8041_DO3);
DDX_Control(pDX, IDC_8041_DO29, m_8041_DO29);
DDX_Control(pDX, IDC_8041_DO28, m_8041_DO28);
DDX_Control(pDX, IDC_8041_DO27, m_8041_DO27);
DDX_Control(pDX, IDC_8041_DO26, m_8041_DO26);
DDX_Control(pDX, IDC_8041_DO25, m_8041_DO25);
DDX_Control(pDX, IDC_8041_DO24, m_8041_DO24);
DDX_Control(pDX, IDC_8041_DO23, m_8041_DO23);
DDX_Control(pDX, IDC_8041_DO22, m_8041_DO22);
DDX_Control(pDX, IDC_8041_DO21, m_8041_DO21);
DDX_Control(pDX, IDC_8041_DO20, m_8041_DO20);
DDX_Control(pDX, IDC_8041_DO2, m_8041_DO2);
DDX_Control(pDX, IDC_8041_DO19, m_8041_DO19);
DDX_Control(pDX, IDC_8041_DO18, m_8041_DO18);
DDX_Control(pDX, IDC_8041_DO17, m_8041_DO17);
DDX_Control(pDX, IDC_8041_DO16, m_8041_DO16);
DDX_Control(pDX, IDC_8041_DO15, m_8041_DO15);
DDX_Control(pDX, IDC_8041_DO14, m_8041_DO14);
DDX_Control(pDX, IDC_8041_DO13, m_8041_DO13);
DDX_Control(pDX, IDC_8041_DO12, m_8041_DO12);
DDX_Control(pDX, IDC_8041_DO11, m_8041_DO11);
DDX_Control(pDX, IDC_8041_DO10, m_8041_DO10);
DDX_Control(pDX, IDC_8041_DO1, m_8041_DO1);
DDX_Control(pDX, IDC_8041_DO0, m_8041_DO0);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemo_allDlg, CDialog)
//{{AFX_MSG_MAP(CDemo_allDlg)
ON_BN_CLICKED(IDC_START, OnStart)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_BN_CLICKED(IDC_ARITHMETIC1, OnArithmetic1)
ON_BN_CLICKED(IDC_ARITHMETIC2, OnArithmetic2)
ON_BN_CLICKED(IDC_ARITHMETIC3, OnArithmetic3)
ON_WM_TIMER()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemo_allDlg UI message handlers
void CDemo_allDlg::ArithmeticDO()
{
//---------------------- output -------------------------------------
// dwBuf[0]; // RS-232 port number: 1/2/3/4..../255
// dwBuf[1]; // module address: 0x00 to 0xFF
// dwBuf[2]; // module ID: 0x87054/55/56/57/60/63/64/65/66/68
// dwBuf[3]; // checksum: 0=disable, 1=enable
// dwBuf[4]; // TimeOut constant: normal=100
// dwBuf[5]; // 16-bit digital data to output
// dwBuf[6]; // flag: 0=no save, 1=save send/receive string
m_dwBuf[0]=comport;
m_dwBuf[1]=address;
m_dwBuf[2]=i87055;
m_dwBuf[3]=checksum;
m_dwBuf[4]=timeout;
//m_dwBuf[5]=1;
m_dwBuf[6]=flag;
ChangeSlotTo87K(i87055_slot);
DigitalOut_87K(m_dwBuf,m_fBuf,m_szSend,m_szReceive);
}
void CDemo_allDlg::ArithmeticDI()
{
unsigned char InTemp=0;
//---------------------- input -------------------------------------
// dwBuf[0]; // RS-232 port number: 1/2/3/4..../255
// dwBuf[1]; // module address: 0x00 to 0xFF
// dwBuf[2]; // module ID: 0x8051/52/53/54/55/63
// dwBuf[3]; // checksum: 0=disable, 1=enable
// dwBuf[4]; // TimeOut constant: normal=100
// dwBuf[6]; // flag: 0=no save, 1=save send/receive string
//---------------------- output ------------------------------------
// dwBuf[5]; // Read 16-bit input digital data
m_dwBuf[0]=comport;
m_dwBuf[1]=address;
m_dwBuf[2]=i87055;
m_dwBuf[3]=checksum;
m_dwBuf[4]=timeout;
m_dwBuf[6]=flag;
Sleep(2);
ChangeSlotTo87K(i87055_slot);
DigitalIn_87K(m_dwBuf,m_fBuf,m_szSend,m_szReceive);
InTemp=(unsigned char)m_dwBuf[5];
if ((InTemp&0x01)==0)
{
m_87055_DI0.SetBitmap(m_DOoff.GetBitmap());
}
else
m_87055_DI0.SetBitmap(m_DOon1.GetBitmap());
if ((InTemp&0x02)==0)
{
m_87055_DI1.SetBitmap(m_DOoff.GetBitmap());
}
else
m_87055_DI1.SetBitmap(m_DOon1.GetBitmap());
if ((InTemp&0x04)==0)
{
m_87055_DI2.SetBitmap(m_DOoff.GetBitmap());
}
else
m_87055_DI2.SetBitmap(m_DOon1.GetBitmap());
}
/////////////////////////////////////////////////////////////////////////////
// CDemo_allDlg message handlers
BOOL CDemo_allDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization hereOpen_Com(comport, baudrate, databit, parity, stopbit);
m_START.EnableWindow(true);
m_STOP.EnableWindow(false);
Open_Com(comport, baudrate, databit, parity, stopbit);
m_ARITHMETIC1.EnableWindow(false);
m_ARITHMETIC2.EnableWindow(true);
m_ARITHMETIC3.EnableWindow(true);
m_87055_DO0.SetBitmap(m_DOon.GetBitmap());
m_87055_DO1.SetBitmap(m_DOoff.GetBitmap());
m_87055_DO2.SetBitmap(m_DOoff.GetBitmap());
m_dwBuf[5]=1;
ArithmeticDO();
ArithmeticDI();
return TRUE; // return TRUE unless you set the focus to a control
}
void CDemo_allDlg::OnStart()
{
// TODO: Add your control notification handler code here
m_START.EnableWindow(false);
m_STOP.EnableWindow(true);
Open_Com((char)m_ComPort, m_Baudrate, (char)m_DataBit, (char)m_Parity, (char)m_StopBit);
SetTimer(10,200,NULL);
}
void CDemo_allDlg::OnStop()
{
// TODO: Add your control notification handler code here
m_START.EnableWindow(true);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -