⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 analysissetupdlg.cpp

📁 串行通讯程序,为电池分析仪与电脑通讯软件,效果不错.
💻 CPP
字号:
// AnalysisSetupDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DigitalPowerAnalyst.h"
#include "AnalysisSetupDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAnalysisSetupDlg dialog


CAnalysisSetupDlg::CAnalysisSetupDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAnalysisSetupDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAnalysisSetupDlg)
	char tmp[10];
	m_RadioOffOn[1] = -1;
	m_RadioOffOn[2] = -1;
	m_RadioOffOn[3] = -1;
	for(int i=1;i<18;i++)
	m_AnalysisStation1[i] =_T("");//itoa(i,tmp,10);// 
	m_nCycle=1;
	m_nStation=1;
	m_pOwner=NULL;
	IsDlgShow=FALSE;
	//}}AFX_DATA_INIT
}


void CAnalysisSetupDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAnalysisSetupDlg)
	DDX_Radio(pDX, IDC_RADIO001, m_RadioOffOn[1]);
	DDX_Radio(pDX, IDC_RADIO003, m_RadioOffOn[2]);
	DDX_Radio(pDX, IDC_RADIO005, m_RadioOffOn[3]);
	DDX_Text(pDX, IDC_EDIT_Battery000, m_AnalysisStation1[0]);
	DDX_Text(pDX, IDC_EDIT_Battery001, m_AnalysisStation1[1]);
	DDX_Text(pDX, IDC_EDIT_Battery002, m_AnalysisStation1[2]);
//	DDX_Text(pDX, IDC_EDIT_Battery003, m_AnalysisStation1[3]);
	DDX_Text(pDX, IDC_EDIT_Battery004, m_AnalysisStation1[4]);
//	DDX_Text(pDX, IDC_EDIT_Battery005, m_AnalysisStation1[5]);
	DDX_Text(pDX, IDC_EDIT_Battery006, m_AnalysisStation1[6]);
	DDX_Text(pDX, IDC_EDIT_Battery007, m_AnalysisStation1[7]);
	DDX_Text(pDX, IDC_EDIT_Battery008, m_AnalysisStation1[8]);
	DDX_Text(pDX, IDC_EDIT_Battery009, m_AnalysisStation1[9]);
	DDX_Text(pDX, IDC_EDIT_Battery010, m_AnalysisStation1[10]);
	DDX_Text(pDX, IDC_EDIT_Battery011, m_AnalysisStation1[11]);
	DDX_Text(pDX, IDC_EDIT_Battery012, m_AnalysisStation1[12]);
	DDX_Text(pDX, IDC_EDIT_Battery013, m_AnalysisStation1[13]);
	DDX_Text(pDX, IDC_EDIT_Battery014, m_AnalysisStation1[14]);

	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAnalysisSetupDlg, CDialog)
	//{{AFX_MSG_MAP(CAnalysisSetupDlg)

	ON_BN_CLICKED(ID_ReadAnalysis, OnReadAnalysis)
 	ON_BN_CLICKED(ID_WriteAnalysis, OnWriteAnalysis)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAnalysisSetupDlg message handlers

BOOL CAnalysisSetupDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here]

	SetWindowText(m_sCaptionTiltle); 

	UpdateData(FALSE);
	//OnReadAnalysis();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CAnalysisSetupDlg::OnStartTimer() 
{
   m_nTimer = SetTimer(2, 2000, 0);
}

void CAnalysisSetupDlg::OnStopTimer() 
{
   KillTimer(m_nTimer);   
}




void  CAnalysisSetupDlg::OnOK() 
{
	// TODO: Add extra validation here
 	IsDlgShow=FALSE;
	CDialog::OnOK();
}

void CAnalysisSetupDlg::SetOwner(CView *m_pOwnerActul)
{
m_pOwner=m_pOwnerActul;
}


void CAnalysisSetupDlg::OnReadAnalysis()
{
	
      OnStartTimer(); 
      bWriteRead=FALSE;

}
void CAnalysisSetupDlg::OnWriteAnalysis() 
{
	

      OnStartTimer();
	  bWriteRead=TRUE;
}

void CAnalysisSetupDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	//OnReadAnalysis();

	CDialog::OnTimer(nIDEvent);
	if(bWriteRead==FALSE)
		ReadVar();
	else
		WriteVar();
}
void CAnalysisSetupDlg::AnalysisUpdate(BOOL m_boolUpdate)
{
   UpdateData( m_boolUpdate);
}



void CAnalysisSetupDlg::SendMessageToView(unsigned char cmd, unsigned char nStation, unsigned char ncycle)

{   unsigned int nStationCmd;
    UpdateData( TRUE);
	nStationCmd= nStation*256+cmd;
	m_AnalysisStation1[0]="";
	UpdateData( FALSE);
	::SendMessage(m_pOwner->m_hWnd, WM_COMM_READAnaly , (WPARAM) nStationCmd, (LPARAM) ncycle);
 
}

void CAnalysisSetupDlg::ReadVar()
{
    static long  nTimes=0;
    switch (nTimes%20)
	{
	case 0:
	SendMessageToView(0x81,m_nStation,0); ;
	break;
	case 1:
	SendMessageToView(0x93,m_nStation,0);
	break;
	case 2:
	SendMessageToView(0x83,m_nStation,m_nCycle);; 
	break;
   	case 3:
	SendMessageToView(0x88,m_nStation,0);; break;
	case  4:
	SendMessageToView(0x89,m_nStation,0);; break;
	case  5:
	SendMessageToView(0x8b,m_nStation,0);; break;
	case  6:
	SendMessageToView(0x90,m_nStation,0);; break;
	case  7:
	SendMessageToView(0x91,m_nStation,0);; break; 
	case  8:
	SendMessageToView(0x93,m_nStation,0);; break;
	case  9:
	SendMessageToView(0x95,m_nStation,0); ; break;
	   case  10:
	SendMessageToView(0xA7,m_nStation,0); ; break;
	   case  11:

	SendMessageToView(0xA9,m_nStation,0);; break;
	   case  12:
	SendMessageToView(0xAB,m_nStation,0);; break;
	   case  13:
	SendMessageToView(0x0AD,m_nStation,0);; break;
	   case  14:
	SendMessageToView(0xB1,m_nStation,0);; break;
	   case  15:
 
	SendMessageToView(0xAF,m_nStation,0);; break;/**/
              break;
  	   case  16:
 
 	SendMessageToView(0x8F,m_nStation,0);; break;/**/
              break;
	}
nTimes++;

if(nTimes>16)
{    nTimes=0;
 OnStopTimer() ;
}
}
/*
(0x81,m_nStation,0); 

	

	(0x81,m_nStation,0);
(0x82,m_nStation,0); 

	
	(0x82,m_nStation,0);
(0x83,m_nStation,m_nCycle); 

	
	(0x83,m_nStation,m_nCycle);
(0x84,m_nStation,m_nCycle); 

	
	(0x84,m_nStation,m_nCycle);


	
	(0x85,0,0);
(0x87,m_nStation,m_nCycle); 

	
	(0x87,m_nStation,m_nCycle);
(0x88,m_nStation,0); 

	
	(0x88,m_nStation,0);
(0x89,m_nStation,0); 

	
	(0x89,m_nStation,0);
(0x8b,m_nStation,0); 

	
(0x8b,m_nStation,0);
(0x8c,m_nStation,0); 

	
	(0x8c,m_nStation,0);
(0x90,m_nStation,0); 

	
	 (0x90,m_nStation,0);
(0x8f,m_nStation,0); 

	
	(0x8f,m_nStation,0);
(0x91,m_nStation,0); 

	
	(0x91,m_nStation,0);
(0x92,m_nStation,0); 

	
	(0x92,m_nStation,0);
(0x93,m_nStation,0); 

	
	(0x93,m_nStation,0);
(0x94,m_nStation,0); 

	
	(0x94,m_nStation,0);
(0x95,m_nStation,0); 

	
	(0x95,m_nStation,0);







(0xA7,m_nStation,0); 

	
	(0xA7,m_nStation,0);//39 Read D_code Name

(0xA8,m_nStation,0); 

	
	(0xA8,m_nStation,0);//40 Sets the name for a D_Code
(0xA9,m_nStation,0); 

	
	(0xA9,m_nStation,0);
(0xAA,m_nStation,0); 

	
	(0xAA,m_nStation,0);




(0xAB,m_nStation,0); 

	
	(0xAB,m_nStation,0);
(0xAC,m_nStation,0); 

	
	(0xAC,m_nStation,0);


(0x0AD,m_nStation,0); 

	
	(0x0AD,m_nStation,0);

(0xAE,m_nStation,0); 

	
	(0xAE,m_nStation,0);

(0xAF,m_nStation,0); 

	
	(0xAF,m_nStation,0);
(0xB0,m_nStation,0); 

	
	 (0xB0,m_nStation,0);
(0xB1,m_nStation,0); 

	
	(0xB1,m_nStation,0);

(0x85,0,0); 
*/
void CAnalysisSetupDlg::WriteVar()
{
    static long  nTimes=0;
    switch (nTimes%16)
	{
	case 1:
	SendMessageToView(0x82,m_nStation,0);;
		break;
	case 2:

	SendMessageToView(0x84,m_nStation,m_nCycle);; break;/**/
   	case 3:
	SendMessageToView(0x87,m_nStation,m_nCycle);; break;/**/
	case  4:
	SendMessageToView(0x8c,m_nStation,0);; break;/**/
	case  5:
	SendMessageToView(0x92,m_nStation,0);; break;/**/
	case  6:
	SendMessageToView(0x94,m_nStation,0);; break;/**/
	case  7:
	SendMessageToView(0xA8,m_nStation,0);; break;/**/
	case  8:
	SendMessageToView(0xAA,m_nStation,0);;break;/**/
	case  9:

	SendMessageToView(0xAC,m_nStation,0);;break;/**/
	   case  10:
	SendMessageToView(0xAE,m_nStation,0);;break;/**/
	   case  11:

	SendMessageToView(0xB0,m_nStation,0);;
	   case  12:
	   {
 	SendMessageToView(0xA0,m_nStation,0);; break;/**/
 break;
	   }
	}
nTimes++;

if(nTimes%30>12)
{
 OnStopTimer() ;

    nTimes=0;
}






}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -