Q:使用SDK付屬軟體StCamGigWare的GigEVisionCameraSelection畫面中的IP Address initialization Save將IP Address寫入相機的動作,用程式該如何實作?
A: 請參考下記的Sample Code將IP Address及Subnet Mask存放在Presistent的地方。
將GevCurrentIPConfigurationPersistentIP設為True的話,帶有Persistent屬性的IP Address、Submask以及Default Gateway都會變為有效:
GevCurrentIPAddress: 目前相機的IP Address
GevCurrentSubnetMask: 現在的Subnet Mask
GevPersistentIPAddress:GevCurrentIPConfigurationPersistentIP設為True時,相機在啟動後的IP Address設定值
GevPersistentSubnetMask:GevCurrentIPConfigurationPersistentIP設為True時,相機在啟動的的Subnet Mask設定值
這些相目皆於相機內部設定中。
您可以用StGigEPlayer連接相機後,在Device Control設定視窗中的TransportLayerControl中找到這些項目。
bool SetIPAddress( PvDevice *pDevice, bool bAuto )
{
PvResult pvResult;
PvGenParameterArray *lGenDevice = pDevice->GetGenParameters();
//GevCurrentIPConfigurationPersistentIP設為True讓PersistentIP變為有效
PvGenBoolean *lPersistentIPBoolean = dynamic_cast( lGenDevice->Get( “GevCurrentIPConfigurationPersistentIP” ) );
ASSERT( lPersistentIPBoolean != NULL );
if( bAuto==true ){ //自動(PersistentIP為無效的情況)
pvResult = lPersistentIPBoolean->SetValue(false);
}
else
{
PvGenInteger *lIPAddressParam = dynamic_cast( lGenDevice->Get( “GevCurrentIPAddress” ) );
PvGenInteger *lFlushIPAddressParam = dynamic_cast( lGenDevice->Get( “GevPersistentIPAddress” ) );
PvGenInteger *lSubnetMaskParam = dynamic_cast( lGenDevice->Get( “GevCurrentSubnetMask” ) );
PvGenInteger *lFlushSubnetMaskParam = dynamic_cast( lGenDevice->Get( “GevPersistentSubnetMask” ) );
ASSERT( lIPAddressParam != NULL );
ASSERT( lFlushIPAddressParam != NULL );
ASSERT( lSubnetMaskParam != NULL );
ASSERT( lFlushSubnetMaskParam != NULL );
//IP読込
// 讀取IP設定
PvInt64 lIPAddress = 0;
PvInt64 lSubnetMask = 0;
pvResult = lIPAddressParam->GetValue( lIPAddress ); //取得現在的IP Address
if( pvResult.IsOK() )
pvResult = lSubnetMaskParam->GetValue( lSubnetMask ); //取得現在的Submask
if( pvResult.IsOK() )
pvResult = lFlushIPAddressParam->SetValue( lIPAddress ); //將現在的IP Address設定為Persistent IP
if( pvResult.IsOK() )
pvResult = lFlushSubnetMaskParam->SetValue( lSubnetMask ); //將現在的Submask設定為Persistent Subnet Mask
if( pvResult.IsOK() )
lPersistentIPBoolean->SetValue(true); //將Persistent設為有效
}
return pvResult.IsOK();
}
———-