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:
| Layer | Job |
|---|---|
| Stream | The interface with the ICD structures — translates raw bytes into ICD-compliant blocks your models and states consume, and back again. |
| Driver | The bridge between a stream and the hardware — the CDriverBase subclass a stream talks to (Send()/Recv()). |
| API layer | The 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.
| Convention | Use 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. |
Raw2Eng()/Eng2Raw() code for you; see
Raw ↔ Eng Conversion for how these calls are used (once per LRU) inside OnRun().
3. Set It Up
- 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.
- Generate the DBSim code from the ICD with DBSimGenerator.
- Define the stream and its driver in streams.json.
- 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.
- 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 | |
|---|---|---|---|
interfaceAPILib | GenICamGeneralUSBAPI (default) | GenICamUSBAPI (GenTL producer + GenApi) | GenICamGigEAPI (GenTL producer + GenApi) |
| Extra fields | none | apiOptions.producer (the vendor .cti file or folder), apiOptions.discoveryTimeoutMs | |
cameraName | device id from the discovery report | device ID, serial, user name, display name or model | |
- 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.
- 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 } } - 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.nullforformat,width,heightorfpskeeps the value the camera has (set it once in the vendor's viewer). - For a hardware-triggered camera add
"externalSync": { "line": "Line1", "activation": "RisingEdge" }. - 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.