What are you looking for?

Single thread callbacks

This program displays basic information about CIC events generated by a grabber, using the CallbackSingleThread model. This is the C# version of the C++ CallbackSingleThread example:

using System;

namespace Callbacks {
    class CallbackExample {
        static void showEvents(Euresys.EGrabberCallbackSingleThread grabber) {
            grabber.runScript("config.js");                                             // 1

            grabber.onCicEvent = delegate(Euresys.EGrabberCallbackSingleThread g,       // 2
                                          Euresys.CicData data) {
                System.Console.WriteLine("timestamp: {0} us, {1}",                      // 3
                                         data.timestamp, data.numid);
            };                                                                          // 4

            grabber.enableCicDataEvent();                                               // 5

            grabber.reallocBuffers(3);                                                  // 6
            grabber.start();                                                            // 6
            while (true) {                                                              // 6
            }
        }

        static void Main() {
            try {
                using (Euresys.EGenTL gentl = new Euresys.EGenTL()) {
                    using (Euresys.EGrabberCallbackSingleThread grabber =
                           new Euresys.EGrabberCallbackSingleThread(gentl)) {
                        showEvents(grabber);
                    }
                }
            } catch (System.Exception e) {
                System.Console.WriteLine("error: {0}", e.Message);
            }
        }
    }
}
  1. Run a config.js script which should:
    • properly configure the camera and frame grabber;
    • enable notifications for CIC events.
  2. Register the callback function for CIC events:
    • create a delegate that will be called by EGrabber when a CIC event occurs; this delegate will be called with two arguments: the grabber and the CicData containing information about the event;
    • set the grabber's onDataStreamEvent to this delegate function.
  3. In the body of the callback function, simply display basic information about the event.
  4. This ends the definition of the onCicEvent callback function.
  5. Enable onCicEvent callbacks.
  6. Start the grabber and enter an infinite loop. CIC events will be notified in a dedicated thread.

Example of program output:

timestamp: 2790824897 us, EVENT_DATA_NUMID_CIC_CAMERA_TRIGGER_RISING_EDGE
timestamp: 2790824897 us, EVENT_DATA_NUMID_CIC_STROBE_RISING_EDGE
timestamp: 2790824902 us, EVENT_DATA_NUMID_CIC_CXP_TRIGGER_ACK
timestamp: 2790825897 us, EVENT_DATA_NUMID_CIC_STROBE_FALLING_EDGE
timestamp: 2790830397 us, EVENT_DATA_NUMID_CIC_CAMERA_TRIGGER_FALLING_EDGE
timestamp: 2790830401 us, EVENT_DATA_NUMID_CIC_CXP_TRIGGER_ACK
timestamp: 2790842190 us, EVENT_DATA_NUMID_CIC_ALLOW_NEXT_CYCLE
timestamp: 2790842190 us, EVENT_DATA_NUMID_CIC_CAMERA_TRIGGER_RISING_EDGE
timestamp: 2790842191 us, EVENT_DATA_NUMID_CIC_STROBE_RISING_EDGE
timestamp: 2790842195 us, EVENT_DATA_NUMID_CIC_CXP_TRIGGER_ACK