SetWriteCallback
Top  Previous  Next

Description

Sets up a callback function which will be called when a client application modifies a feature value.

[C++]
int
 SetWriteCallback(void* context, FeatureCallback callback);

   
where FeatureCallback type is defined as

    bool (*FeatureCallback)(void* context, const char* feature);


Parameters
[C/C++]
 
[in] void* context  
Address of the context in which the callback function will operate.  
 
[in] FeatureCallback callback  
Address of the callback function  
 
[in] const char* feature  
String containing the name of the feature that has just been modified by a client application.  
 

Return Values


S_OK  
Success  
E_FAIL  
Failure  
 

Example


This fragment of an MFC code uses a feature write callback to intercept requests for the change of the image size and modifies the image buffer and acquisition parameters accordingly:

      int
 onFeatureWrite(void
* context, const
 char
* feature)
      {
          CGigemuDlg* dlg = (CGigemuDlg*) context;
          return
 dlg->onFeatureWrite(feature);
      }

int CGigemuDlg::onFeatureWrite(const char* feature)  
{  
    if(CString(feature)=="SizeX" || CString(feature)=="SizeY")  
  {  
     delete imgBuf;  
     m_pCamera->GetFeatureValue("SizeX",&m_SizeX);  
     m_pCamera->GetFeatureValue("SizeY",&m_SizeY);  
     imgBuf=new (m_SizeX * m_SizeY)  
       return 0;  
  }  
}  

      BOOL CGigemuDlg::OnInitDialog()
      {
  ....        
  m_pCamera->SetWriteCallback(this, &::onFeatureWrite);  
  ....  
}  
 


Remarks


The write callback function is called after the value of the feature has just been modified by a client application. Therefore, the callback can be used to update those parameters of virtual camera application that are associated with the modified feature.

If the write command is ignored, your callback function must return False, otherwise it must return True. In the latter case GigESim will return an acknowledge packet to the client application.


If you are using a callback function in the main thread of the simulation application, make sure that no lengthy processing is done in the body of the function as otherwise the connection to the remote client may become broken.