<< Click to Display Table of Contents > 

Scanner Card Interface > Example Code > External Trigger

External Trigger
Previous pageReturn to chapter overviewNext page

The following pieces of code demonstrate how to work with an external trigger where the marking operation can be started using an external hardware signal (OptoIn_0).

long executing,triggerCount,exposureEnd;
MSG  msg;
 

// set continuous working mode
m_optic_module->ScContinuousMode = 1;

// enable external triggering

m_optic_module->ScExternalTrigger = 1;

// do not hide the output window
m_optic_ctrl_wnd->SetScHideOutputWindow(0);

// start execution
m_optic_module->ScExecute = 1;

 

At this position the program can output its vector data, as presented in the preceding example (start the stream sequence, send the stream commands containing the vector data, sending the end stream ident).

The following loop waits for a trigger event - only necessary if the program wants to act on the event:

m_optic_module->ScGetExternalTriggerCount(&triggerCount);
// check if the trigger count has changed, means a trigger event occurred

 
while (triggerCount == 0)

{

 SleepEx(1,TRUE);
 m_optic_module->ScGetExternalTriggerCount(&triggerCount);

 
 if (PeekMessage(&msg,(HWND)NULL,0,0,PM_REMOVE))
 // handle Windows messages to avoid blocking of the system
 {

   DispatchMessage(&msg);
 }
}

 

The next loop waits for exposure end, thus until the stream has finished executing or was aborted by the user.

m_optic_module->ScIsExposureEnd(&exposureEnd);

 

while (exposureEnd == 0)
{

 SleepEx(1,TRUE);
 m_optic_module->ScIsExposureEnd(&exposureEnd);

 
 if (PeekMessage(&msg,(HWND)NULL,0,0,PM_REMOVE))
 // handle Windows messages to avoid blocking of the system
 {
   DispatchMessage(&msg);
 }
}