图3-13
相应的程序如下:
//******以下是对单选按钮的处理函数,通过单击按钮来进行相应的操作
void CGENERATER::OnRadioSin()
{ m_nEdit_Dcycle.EnableWindow(FALSE);}
void CGENERATER::OnRadioTriangle()
{ m_nEdit_Dcycle.EnableWindow(FALSE);}
void CGENERATER::OnRadioFwave()
{ m_nEdit_Dcycle.EnableWindow(TRUE);}
void CGENERATER::OnRadioRamp()
{ m_nEdit_Dcycle.EnableWindow(FALSE);}等等//********************************************以下是对基本波形选择处理函数
void CGENERATER::CheckWaveRadioButton()
{ int nID_SelectWaveF;
nID_SelectWaveF=GetCheckedRadioButton(IDC_RADIO_SIN,IDC_RADIO_DC);
switch(nID_SelectWaveF)
{//添加处理代码--即是对波形参数赋值
case IDC_RADIO_SIN:m_nBaseShape="SIN";break;
case IDC_RADIO_TRIANGLE:m_nBaseShape="TRI";break;
case IDC_RADIO_FWAVE:m_nBaseShape="SQU";break;
case IDC_RADIO_RAMP:m_nBaseShape="RAMP";break;
case IDC_RADIO_ARBI:m_nBaseShape=m_nArbdlg.m_nSet_Arbitrary;break;
case IDC_RADIO_NOISE:m_nBaseShape="NOISE";break;
case IDC_RADIO_PULSE:m_nBaseShape="PULSE";break;
case IDC_RADIO_DC:m_nBaseShape="DC";break;
default:return;}}
上面是对用户的选择进行的变量的赋值以备后用。
下面就是产生各种函数的部分(部分代码):
viPrintf(/*funcgen*/m_Session,"OUTPut:LOAD %s\n",m_nResistance);//输出端的设置
viPrintf(/*funcgen*/m_Session,"OUTPut:SYNC %s\n",m_nSignal);//设置同步信号
注意:下面这个是一个子程序,用来对用户的选择进行判断,并将用户选择的波形的相应的参数传递给一个字符串变量中。
CheckWaveRadioButton();//波形选择的判断--将波形的字符串存储在m_nBaseShape中
//**********************************判断用户选择的波形是否是方波
if(GetCheckedRadioButton(IDC_RADIO_SIN,IDC_RADIO_DC)==IDC_RADIO_FWAVE) { viPrintf(/*funcgen*/m_Session,"FUNC %s\n",m_nBaseShape);
viPrintf(/*funcgen*/m_Session,"FREQ %f\n",m_nFreq);
viPrintf(/*funcgen*/m_Session,"VOLT %f\n",m_nAmpl);
viPrintf(/*funcgen*/m_Session,"VOLT:OFFS %f\n",m_nOffs);
viPrintf(/*funcgen*/m_Session,"FUNC:SQU:DCYC %f\n",m_nDcycle);
}//******************************判断用户选择的是否是任意波
Else
if(GetCheckedRadioButton(IDC_RADIO_SIN,IDC_RADIO_DC)==IDC_RADIO_ARBI)
{
error=viPrintf(/*funcgen*/m_Session,"APPL:USER %f,%f,%f\n",m_nFreq,m_nAmpl,m_nOffs);
if(error!=VI_SUCCESS)
{error_handler(/*funcgen*/m_Session,error);
<< 上一页 [11] [12] [13] [14] [15] [16] 下一页