MFC工控项目实例三十四模拟量实时监控数字显示效果

点击监控按钮,对选中模拟量用数字显示效果实时显示数值。

SenSet.cpp中相关代码

cpp 复制代码
UINT m_nCounterID_1[6] = 
	{		
			IDC_STATIC0,
			IDC_STATIC1,
			IDC_STATIC2,
			IDC_STATIC3,
			IDC_STATIC4,
			IDC_STATIC5,
							
	};

UINT m_nCounterID_2[7] = 
	{		
			IDC_STATIC7,
			IDC_STATIC8,
			IDC_STATIC9,
			IDC_STATIC10,
			IDC_STATIC11,
			IDC_STATIC12,
			IDC_STATIC13,
							
	};


SenSet::SenSet(CWnd* pParent /*=NULL*/)
	: CDialog(SenSet::IDD, pParent)
{
m_font.CreateFont(-28,0,0,0,700,FALSE,FALSE,
					0,134,OUT_DEFAULT_PRECIS,
					CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
					FF_SWISS,"楷体_GB2312");  
}


void SenSet::OnSelchangeList1() 
{
	KillTimer(1);
	 for(int j_1=0  ; j_1 <6 ; j_1++)    
		  {
	        SetDlgItemText(m_nCounterID_1[j_1],"-");
		  }
for(int j_2=0  ; j_2 <7; j_2++)    
		  {
		int   j_3=j_2+6;
		   SetDlgItemText(m_nCounterID_1[j_3],"-");
		  }

...


void SenSet::OnButton6() 
{
GetPrivateProfileString("AD输入",nSel_str,NULL,CHO_AD.GetBuffer(20),20,theApp.strFilePath); 
		SetTimer(1,500,NULL);	
}


void SenSet::OnTimer(UINT nIDEvent) 
{
	 CString str1,str2;
    CString str[30];
	 CString str_1[30];
	if( nIDEvent == 1 )
	{
		//16通道,2 = -5000 -- 5000 mV采集
	nSel =m_IDC_LIST1.GetCurSel();
    m_IDC_LIST1.GetText(nSel,nSel_str);
	CString str;
	str.Format("%d",nSel);	
	CString str6[16],str7[16],str8[16],str9[16];
	GetPrivateProfileString("A/D设置",nSel_str+"零点电压",NULL,str6[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"零点数值",NULL,str7[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"量程电压",NULL,str8[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"量程数值",NULL,str9[16].GetBuffer(20),20,theApp.strFilePath);
//	float MON_AD=(float) atof(str9[16])/(float) atof(str8[16])*AI6325ASingle(theApp.nAddr_AD_1,2,atoi(CHO_AD))+ theApp.flo_AD_SET_ZERO_NUM[atoi(CHO_AD)];  
//	float MON_AD=(float) atof(str9[16])/(float) atof(str8[16])*AI6325ASingle(theApp.nAddr_AD_1,2,atoi(CHO_AD))+ (float) atof(str7[16]);
    float MON_AD;
	if (  str7[16]!="")
	{
	  MON_AD=(float) atof(str7[16]);  
	}
	else  MON_AD=0.0;
    
str1.Format("%6.2f",(float)(AI6325ASingle(theApp.nAddr_AD_1,2,atoi(CHO_AD))));
str2.Format("%7.2f",MON_AD);

SetDlgItemText(IDC_STATIC99,str2); 		
	}

	 int j_1 , j_2;
 	  for( j_1=0  ; j_1 <6 ; j_1++)    
		  {
	     	GetDlgItem(m_nCounterID_1[j_1])->SetFont(&m_font);
            str[j_1]=str1.Mid(j_1,1);
		    SetDlgItemText(m_nCounterID_1[j_1],str[j_1]);
		  }
for( j_2=0  ; j_2 <7; j_2++)    
		  {
		//	
          str_1[j_2]=str2.Mid(j_2,1);
		int   j_3=j_2+6;
		GetDlgItem(m_nCounterID_1[j_3])->SetFont(&m_font);
		SetDlgItemText(m_nCounterID_1[j_3],str_1[j_2]);
		  }
	CDialog::OnTimer(nIDEvent);
}


}
相关推荐
山登绝顶我为峰 3(^v^)31 小时前
如何录制带备注的演示文稿(LaTex Beamer + Pympress)
c++·线性代数·算法·计算机·密码学·音视频·latex
十五年专注C++开发4 小时前
CMake基础:条件判断详解
c++·跨平台·cmake·自动化编译
QuantumStack6 小时前
【C++ 真题】P1104 生日
开发语言·c++·算法
天若有情6736 小时前
01_软件卓越之道:功能性与需求满足
c++·软件工程·软件
whoarethenext7 小时前
使用 C++/OpenCV 和 MFCC 构建双重认证智能门禁系统
开发语言·c++·opencv·mfcc
Jay_5158 小时前
C++多态与虚函数详解:从入门到精通
开发语言·c++
xiaolang_8616_wjl9 小时前
c++文字游戏_闯关打怪
开发语言·数据结构·c++·算法·c++20
FrostedLotus·霜莲9 小时前
C++主流编辑器特点比较
开发语言·c++·编辑器
liulilittle13 小时前
深度剖析:OPENPPP2 libtcpip 实现原理与架构设计
开发语言·网络·c++·tcp/ip·智能路由器·tcp·通信
十年编程老舅14 小时前
跨越十年的C++演进:C++20新特性全解析
c++·c++11·c++20·c++14·c++23·c++17·c++新特性