📄 age1968a.cpp
字号:
{
return vistat;
}
// set delay
asTXPowerDelay = "SETUP:TXPOWER:TRIGGER:DELAY " + IntToStr( iDelay ); // sec
vistat = age1960_cmd(vi,asTXPowerDelay.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
// set trigger qualifier
if (AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON == iTriQual)
{
asTXPowerTriQual = "SETUP:TXPOWER:TRIGGER:QUALIFIER ON";
}
else
{
asTXPowerTriQual = "SETUP:TXPOWER:TRIGGER:QUALIFIER OFF";
}
vistat = age1960_cmd(vi,asTXPowerTriQual.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
// set timeout
asTXPowerTimeout = "SETUP:TXPOWER:TIMEOUT:STIME " + IntToStr(iTimeout); // sec
vistat = age1960_cmd(vi,asTXPowerTimeout.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
return VI_SUCCESS;
}
//---------------------------------------------------------------------------
ViStatus age1968A_Config_EPSK_TxPower(ViSession vi, int iMeasureCount, int iTriSour, int iDelay, int iTriQual, int iTimeout)
{
AnsiString as_cmd;
ViStatus vistat;
// set modulation
// as_cmd = "SETup:ETXPower:MODulation EPSK";
// if ( vistat = age1960_cmd(vi, as_cmd.c_str())!= VI_SUCCESS )
// {
// return vistat;
//}
// set measurecount
as_cmd = "SETUP:ETXPOWER:COUNT:SNUMBER " + IntToStr(iMeasureCount);
vistat = age1960_cmd(vi, as_cmd.c_str());
if (vistat != VI_SUCCESS )
{
return vistat;
}
// triger source
switch (iTriSour)
{
case age1960_TRIG_AUTO:
{
as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE AUTO";
}
break;
case age1960_TRIG_PROT:
{
as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE PROTocol";
}
break;
case age1960_TRIG_RF_RISE:
{
as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE RISE";
}
break;
case age1960_TRIG_IMMEDIATE:
{
as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE IMMediate";
}
break;
default: // set to auto
{
as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE AUTO";
}
break;
}
vistat = age1960_cmd(vi, as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
// set delay
as_cmd = "SETUP:ETXPOWER:TRIGGER:DELAY " + IntToStr(iDelay); // sec
vistat = age1960_cmd(vi, as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
#if 0
// set trigger qualifier
if (iTriQual == AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON )
{
as_cmd = "SETUP:ETXPOWER:TRIGGER:QUALIFIER ON";
}
else
{
as_cmd = "SETUP:ETXPOWER:TRIGGER:QUALIFIER OFF";
}
if (vistat = age1960_cmd(vi, s_cmd.c_str())!= VI_SUCCESS )
{
return vistat;
}
// set timeout
as_cmd = "SETUP:ETXPOWER:TIMEOUT:STIME " + IntToStr( iTimeout ); // sec
if ( vistat = age1960_cmd(vi, as_cmd.c_str())!= VI_SUCCESS )
{
return vistat;
}
#endif
return vistat;
}
//------------------------------------------------------------------------------
ViStatus age1968A_ReadTxPower(ViSession vi, ViReal64 *p_virTX)
{
AnsiString asTXPowerRead, asStr, asIntegrity, asTxPower, asBase, asExponent;;
ViStatus vistat;
unsigned long num;
char buf[BUFSIZE];
asTXPowerRead = "READ:TXP?";
vistat=viWrite(vi, asTXPowerRead.c_str(), strlen(asTXPowerRead.c_str()), &num);
if( vistat!=VI_SUCCESS ) return vistat;
//Sleep( 100 );
vistat=viRead(vi, buf, BUFSIZE, &num);
if( vistat!=VI_SUCCESS ) return vistat;
buf[num-1]=NULL;
asStr=(AnsiString)buf;
if( getIntegrityFromStr( asStr, asIntegrity ) == false ) return VI_ERROR_ABORT;
if( (asIntegrity.ToInt() != (int) INTEGRITY_NORMAL) &&
(asIntegrity.ToInt() != (int) INTEGRITY_OVER_RANGE) &&
(asIntegrity.ToInt() != (int) INTEGRITY_UNDER_RANGE )
)
{
return VI_ERROR_ABORT;
}
if( getTxPowerFromStr( asStr, asTxPower ) == false ) return VI_ERROR_ABORT;
if( getBaseFromStr( asTxPower, asBase ) == false ) return VI_ERROR_ABORT;
if( getExponentFromStr( asTxPower, asExponent )== false ) return VI_ERROR_ABORT;
//if( asExponent.ToInt() >= 0 )
{
*p_virTX = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
}
//Application->MessageBox( temp.c_str() , "Warning", MB_OK );
//if( temp.Pos("NAN") ) return vistat;
//temp=temp.SubString(1, temp.Pos(",")-1);
//*p_virTX = atof(temp.c_str());
return vistat;
}
//------------------------------------------------------------------------------
ViStatus age1968A_ReadEGPRSTxPower(ViSession vi, ViReal64 *p_virTX)
{
AnsiString asTXPowerRead, asStr, asIntegrity, asTxPower, asBase, asExponent;;
ViStatus vistat;
unsigned long num;
char buf[BUFSIZE];
asTXPowerRead = "READ:ETXPower?";
vistat=viWrite(vi, asTXPowerRead.c_str(), strlen(asTXPowerRead.c_str()), &num);
if( vistat!=VI_SUCCESS ) return vistat;
//Sleep( 100 );
vistat=viRead(vi, buf, BUFSIZE, &num);
if( vistat!=VI_SUCCESS ) return vistat;
buf[num-1]=NULL;
asStr=(AnsiString)buf;
if( getEpskIntegrityFromStr( asStr, asIntegrity ) == false ) return VI_ERROR_ABORT;
if( (asIntegrity.ToInt() != (int) INTEGRITY_NORMAL) &&
(asIntegrity.ToInt() != (int) INTEGRITY_OVER_RANGE) &&
(asIntegrity.ToInt() != (int) INTEGRITY_UNDER_RANGE ) &&
(asIntegrity.ToInt() != (int) INTEGRITY_SYNC_NOT_FOUND) &&
(asIntegrity.ToInt() != (int) INTEGRITY_TRIGGER_EARLY_OR_FALL_EARLY) &&
(asIntegrity.ToInt() != (int) INTEGRITY_TRIGGER_LATE_OR_RISE_LATE)
)
{
return VI_ERROR_ABORT;
}
if( getEpskTxPowerFromStr( asStr, asTxPower ) == false ) return VI_ERROR_ABORT;
if( getEpskBaseFromStr( asTxPower, asBase ) == false ) return VI_ERROR_ABORT;
if( getEpskExponentFromStr( asTxPower, asExponent )== false ) return VI_ERROR_ABORT;
//if( asExponent.ToInt() >= 0 )
{
*p_virTX = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
}
//Application->MessageBox( temp.c_str() , "Warning", MB_OK );
//if( temp.Pos("NAN") ) return vistat;
//temp=temp.SubString(1, temp.Pos(",")-1);
//*p_virTX = atof(temp.c_str());
return vistat;
}
//==============================================================================
///////////////////////////////// PFER ////////////////////////////////////
//==============================================================================
ViStatus age1968A_confPFER(ViSession vi, int iMeasureCount, int iTriSour,
int iDelay, int iTriQual, int iTimeout)
{
AnsiString as_cmd;
ViStatus vistat;
// burst sync
as_cmd = "SETUP:PFERROR:SYNC MIDAMBLE";
vistat = age1960_cmd(vi, as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
// set measurecount
as_cmd = "SETup:PFERror:COUNt:NUMBer " + IntToStr(iMeasureCount);
vistat = age1960_cmd(vi, as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
// triger source
switch (iTriSour)
{
case age1960_TRIG_AUTO:
{
as_cmd = "SETup:PFERror:TRIG:SOURce AUTO";
}
break;
case age1960_TRIG_PROT:
{
as_cmd = "SETup:PFERror:TRIG:SOURce PROTocol";
}
break;
case age1960_TRIG_RF_RISE:
{
as_cmd = "SETup:PFERror:TRIG:SOURce RISE";
}
break;
case age1960_TRIG_IMMEDIATE:
{
as_cmd = "SETup:PFERror:TRIG:SOURce IMMediate";
}
break;
default: // set to auto
{
as_cmd = "SETup:PFERror:TRIG:SOURce AUTO";
}
break;
}
vistat = age1960_cmd(vi,as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
// set delay
as_cmd = "SETup:PFERror:TRIGger:DELay " + IntToStr(iDelay); // sec
vistat = age1960_cmd(vi, as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
// set trigger qualifier
if (AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON == iTriQual)
{
as_cmd = "SETup:PFERror:TRIGger:QUALifier:GSM ON";
}
else
{
as_cmd = "SETup:PFERror:TRIGger:QUALifier:GSM OFF";
}
vistat = age1960_cmd(vi, as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
// set timeout
as_cmd = "SETup:PFERror:TIMeout:TIME " + IntToStr(iTimeout); // sec
vistat = age1960_cmd(vi, as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
return VI_SUCCESS;
}
//------------------------------------------------------------------------------
ViStatus age1968A_ReadFreqError(ViSession vi, ViReal64 *p_virFreqErr)
{
AnsiString asPFERRead, asStr, asIntegrity, asTxPower, asBase, asExponent;;
ViStatus vistat;
unsigned long num;
char buf[BUFSIZE];
asPFERRead = "READ:PFER?";
vistat=viWrite(vi, asPFERRead.c_str(), strlen(asPFERRead.c_str()), &num);
if( vistat!=VI_SUCCESS ) return vistat;
vistat=viRead(vi, buf, BUFSIZE, &num);
if( vistat!=VI_SUCCESS ) return vistat;
buf[num-1]=NULL;
asStr=(AnsiString)buf;
if( getIntegrityFromStr( asStr, asIntegrity ) == false ) return VI_ERROR_ABORT;
if( (asIntegrity.ToInt() != (int) INTEGRITY_NORMAL) && (asIntegrity.ToInt() != (int) INTEGRITY_OVER_RANGE) && (asIntegrity.ToInt() != (int) INTEGRITY_UNDER_RANGE ))
{
return VI_ERROR_ABORT;
}
if( getTxPowerFromStr( asStr, asTxPower ) == false ) return VI_ERROR_ABORT;
if( getBaseFromStr( asTxPower, asBase ) == false ) return VI_ERROR_ABORT;
if( getExponentFromStr( asTxPower, asExponent )== false ) return VI_ERROR_ABORT;
{
*p_virFreqErr = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
}
return vistat;
}
//---------------------------------------------------------------------------
ViStatus age1968A_ConfigTSC(ViSession vi, int i_TSC)
{
AnsiString asTSC;
ViStatus vistat;
unsigned long num;
// set measurecount
asTSC = "CALL:BURSt:TYPE TSC" + IntToStr(i_TSC);
vistat = age1960_cmd(vi, asTSC.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
return vistat;
}
//------------------------------------------------------------------------------
ViReal64 __fastcall get_Original_Offset(ViReal64 *p_IQTFreqs, ViReal64 *p_IQTResults, ViInt32 IQTTuningCount)
{
for(int i=0; i<IQTTuningCount; i++)
{
if( *(p_IQTFreqs+i) == IQT_ORIGINAL_OFFSET_FREQ )
{
return *(p_IQTResults+i);
}
}
return NAN;
}
//------------------------------------------------------------------------------
ViReal64 __fastcall get_IQ_Imbalance(ViReal64 *p_IQTFreqs, ViReal64 *p_IQTResults, ViInt32 IQTTuningCount)
{
for(int i=0; i<IQTTuningCount; i++)
{
if( *(p_IQTFreqs+i) == IQT_IQ_IMBALANCE_FREQ )
{
return *(p_IQTResults+i);
}
}
return NAN;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ViStatus age1968A_Config_DynPower(ViSession vi, int iMeasureCount, int iTimeout)
{
AnsiString as_cmd;
ViStatus vistat;
as_cmd = "SETup:DPOWer:CONTinuous OFF";
vistat = age1960_cmd(vi,as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
as_cmd = "SETUP:DPOWER:COUNT:NUMBER:SELECTED " + IntToStr(iMeasureCount);
vistat = age1960_cmd(vi,as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
as_cmd = "SETup:DPOWer:TIMeout " + IntToStr( iTimeout ) + "S";
vistat = age1960_cmd(vi,as_cmd.c_str());
if (vistat != VI_SUCCESS)
{
return vistat;
}
return VI_SUCCESS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -