This guide covers connecting the CoreEngine to a real external device — a piece of hardware, another system, or a network endpoint that speaks its own wire protocol.

1. The Concept: Streams and Drivers

Three distinct layers carry data between your models and a device, each with one job:

LayerJob
StreamThe interface with the ICD structures — translates raw bytes into ICD-compliant blocks your models and states consume, and back again.
DriverThe bridge between a stream and the hardware — the CDriverBase subclass a stream talks to (Send()/Recv()).
API layerThe actual low-level interface to the hardware vendor's SDK, built as its own shared library the driver loads at runtime.

See Drivers and Streams for the full folder layout and the driver/API-layer split, and streams.json for how a stream and its driver are configured together.

2. Matching the Device's Memory Layout (Raw ↔ Eng)

A real external device rarely uses the same in-memory layout as your C++ structs — it may pack bits MSB-first, use a different byte order, or have no binary representation for some fields at all. APIC handles this with the raw ↔ eng conversion: every ICD block has a raw form (the exact bytes the device expects on the wire) and an eng form (the ordinary C++ value your model code uses). Your code always works with the eng side; the raw side is what actually gets sent to/received from the device.

ConventionUse it when the device...
NoRaw...doesn't apply — the block has no physical/binary form (internal/software-only data).
LElsb...uses Little-Endian bytes with bits numbered from the LSB (the natural C/C++ convention).
LEmsb...uses Little-Endian bytes with bits numbered from the MSB.
BElsb...uses Big-Endian ("network order") bytes with bits numbered from the LSB.
BEmsb...uses Big-Endian bytes with bits numbered from the MSB — common in avionics/MIL-STD ICDs.
Pick the convention that matches the device's actual documented wire format for each block — not what's convenient in C++. DBSimGenerator then generates the matching Raw2Eng()/Eng2Raw() code for you; see Raw ↔ Eng Conversion for how these calls are used (once per LRU) inside OnRun().

3. Set It Up

  1. Define the device's data layout as an ICD CSV, choosing the raw convention for each block to match the device's documented format — see DBSimGenerator for how to set this up.
  2. Generate the DBSim code from the ICD with DBSimGenerator.
  3. Define the stream and its driver in streams.json.
  4. If a driver for this device doesn't exist yet, implement its driver and API layer — see Drivers and Streams for the folder layout and the exact pattern to follow.
  5. Convert raw ↔ eng in your model's OnRun() and work with the eng-side values as usual.

4. Example: a GenICam Camera (USB3 Vision or GigE Vision)

A camera is an input-only device: each frame arrives as the raw bytes of an input block. GenICam cameras use the GenICamDriver; the transport is selected with interfaceAPILib:

USB3 Vision (Aravis)USB3 Vision (GenTL)GigE Vision
interfaceAPILibGenICamGeneralUSBAPI (default)GenICamUSBAPI (GenTL producer + GenApi)GenICamGigEAPI (GenTL producer + GenApi)
Extra fieldsnoneapiOptions.producer (the vendor .cti file or folder), apiOptions.discoveryTimeoutMs
cameraNamedevice id from the discovery reportdevice ID, serial, user name, display name or model
  1. Define the frame as an ICD block whose raw size equals the camera's frame size (width × height × bytes per pixel of the pixel format). Frames that do not fit the block are counted as errors.
  2. Add an input stream to streams.json:
    "CameraStream": {
      "blocks": [ { "raw": "LRU_Cam.Frame", "direction": "in", "framePerMS": -1 } ],
      "driver": {
        "name": "GenICamDriver",
        "interfaceAPILib": "GenICamGigEAPI",
        "apiOptions": { "producer": "C:/path/to/producer.cti" },
        "cameraName": "22104455",
        "format": "Mono8",
        "fps": 30,
        "features": { "GevSCPSPacketSize": 9000 },
        "waitForFrameTimeout_us": 0
      }
    }
  3. Start once with "cameraName": "?": the engine reports the connected cameras and all their features (pixel formats included) without opening them. Copy the values into the file. null for format, width, height or fps keeps the value the camera has (set it once in the vendor's viewer).
  4. For a hardware-triggered camera add "externalSync": { "line": "Line1", "activation": "RisingEdge" }.
  5. Read the frame block in your model, or attach the model to the block with a stream trigger so it runs on each new frame.

Full field list, start-up sequence and interface differences: GenICam driver reference and How to Set Up Streams.

No GigE camera at hand? Another simD program (e.g. BlackKite on a Rock 5B or a second PC) can be the camera: the UVCGadgetDeviceDriver with "interfaceAPILib": "UVCGadgetGigEAPI" answers on the network as a GigE Vision camera and sends the frames its model makes. Point cameraName at its name (e.g. "BlackKite"). See the board is the camera.

Something not working? See Troubleshooting Drivers and Streams for the messages, causes and fixes of each driver (serial, GenICam, sockets, input device and more).
Once wired up, use System Layout to see the device's data flow, rates, and errors live, and DIPanel to monitor or inject individual elements.