{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "",
    "type": "object",
    "properties": {
        "$schema": {
            "type": "string",
            "minLength": 1
        },
        "meta": {
            "type": "object",
            "properties": {
                "inputFileType": {
                    "type": "string",
                    "minLength": 1
                },
                "inputFileVersion": {
                    "type": "string",
                    "minLength": 1
                },
                "targetMachine": {
                    "type": "string",
                    "minLength": 1
                },
                "programName": {
                    "type": "string",
                    "minLength": 1
                },
                "programVersion": {
                    "type": "string",
                    "minLength": 1
                }
            },
            "required": [
                "inputFileType",
                "inputFileVersion",
                "targetMachine",
                "programName",
                "programVersion"
            ],
            "examples": [
                {
                    "inputFileType": "LumiScan-Ctrlx-Camera-Configuration",
                    "inputFileVersion": "0.0.1",
                    "targetMachine": "CtrlX7",
                    "programName": "lumiscan-cam-driver",
                    "programVersion": "2.1.0"
                }
            ]
        },
        "id": {
            "type": "string",
            "minLength": 1,
            "description": "Unique ID of the camera module: its name on the Data Layer (hdvisionsystems/lumiscan-cam-driver/<id>/...). Lower-case letters [a-z], digits [0-9], '-' and '_' only; a module with another id is not loaded.",
            "pattern": "^[a-z0-9_-]+$",
            "examples": [
                "camera1",
                "camera-left"
            ]
        },
        "cameraId": {
            "type": "string",
            "minLength": 1,
            "description": "The camera this module drives: the cameraId of an entry of 'cameras' in the application settings, which names its serial, its driver (GenTL producer, camera plugin, or a folder of images for a simulated camera) and its feature files. A camera is driven by one module at most.",
            "examples": [
                "camera1",
                "camera-left"
            ]
        },
        "exposureTimeUS": {
            "type": "integer",
            "minimum": 500,
            "maximum": 2000000,
            "default": 6000,
            "description": "Exposure time in microseconds. This is used as default value on datalayer and can be overwriten by the user."
        },
        "pixelFormat": {
            "type": "string",
            "minLength": 1,
            "enum": [
                "Mono8",
                "RGB8",
                "BGR8",
                "Mono12",
                "RGB12",
                "BGR12",
                "BayerGR8",
                "BayerRG8"
            ],
            "default": "Mono8",
            "description": "Pixel format of the camera. Use bayer format if the camera support color and faster frame rate is required. This is used as default value on datalayer and can be overwriten by the user."
        },
        "exportPixelFormat": {
            "type": "string",
            "minLength": 1,
            "enum": [
                "Mono8",
                "RGB8",
                "BGR8",
                "Mono12",
                "RGB12",
                "BGR12"
            ],
            "description": "Pixel format of the exported (saved) image. Left out: the same as pixelFormat. This is used as default value on datalayer and can be overwriten by the user."
        },
        "packetSize": {
            "type": "integer",
            "minimum": 576,
            "maximum": 9000,
            "default": 1500,
            "description": "GigE Vision packet size in bytes (GevSCPSPacketSize, and DeviceStreamChannelPacketSize where the camera has it). It must fit the smallest MTU of the network path, and the camera may accept only multiples of its own increment. When the camera refuses it, the Cam Driver falls back to 1500 bytes and no packet delay. This is used as default value on datalayer and can be overwriten by the user. It is writeable only before the camera is connected.",
            "examples": [
                1500,
                8192
            ]
        },
        "packetDelay_us": {
            "type": "integer",
            "minimum": 0,
            "maximum": 12449,
            "default": 0,
            "description": "Delay between packets, passed to the camera's GevSCPD unchanged despite its name: in the camera's own unit, nanoseconds or ticks of GevTimestampTickFrequency depending on the manufacturer. Default is 0. Increase it if image is corrupted or faild to capture image. This is used as default value on datalayer and can be overwriten by the user."
        },
        "timeout_ms": {
            "type": "integer",
            "minimum": 100,
            "maximum": 10000,
            "default": 2000,
            "description": "Timeout in milliseconds. Default is 2000 milliseconds. How long to wait for the image to be captured before giving up. This is used as default value on datalayer and can be overwriten by the user."
        },
        "timestampSource": {
            "type": "string",
            "enum": [
                "Camera",
                "System"
            ],
            "default": "Camera",
            "description": "Source of the timestamp for each frame. 'Camera' uses the timestamp provided by the camera hardware, while 'System' uses the system clock of the device the Cam Driver runs on."
        },
        "clearBufferBeforeCapture": {
            "type": "boolean",
            "default": false,
            "description": "If true, the buffer will be cleared before capture, this is useful when the camera is running in continuous mode and we want to get the latest image."
        },
        "triggerBeforeAcquire": {
            "type": "boolean",
            "default": true,
            "description": "The start value of input/trigger-before-acquire. true: capture fires the camera's trigger - its software trigger while it is in software trigger mode - and then acquires the image. false: capture only acquires the next image the camera delivers, so a program can fire the trigger itself beforehand with control/trigger/execute; the buffer is then not cleared before the capture, whatever clearBufferBeforeCapture says."
        },
        "stream": {
            "type": "object",
            "description": "Experimental: the image stream (control/publish). Only its tag is kept here; whether it runs is not saved.",
            "properties": {
                "tag": {
                    "type": "string",
                    "description": "the tag on the module's frames: the camera's step in the lineage of each streamed frame carries it, so a reader downstream sees which camera module took it. Empty or absent: the module id. Saved by control/publish/execute."
                }
            }
        }
    },
    "required": [
        "meta",
        "id",
        "cameraId"
    ],
    "examples": [
        {
            "$schema": "schemas/lumiscan-cam-driver-module.schema.json",
            "meta": {
                "inputFileType": "LumiScan-Ctrlx-Camera-Configuration",
                "inputFileVersion": "0.0.1",
                "targetMachine": "CtrlX7",
                "programName": "lumiscan-cam-driver",
                "programVersion": "2.1.0"
            },
            "id": "camera1",
            "cameraId": "camera1",
            "exposureTimeUS": 6000,
            "pixelFormat": "Mono8",
            "exportPixelFormat": "RGB8",
            "packetSize": 1500,
            "packetDelay_us": 0,
            "timeout_ms": 2000,
            "timestampSource": "System",
            "clearBufferBeforeCapture": false
        },
        {
            "$schema": "schemas/lumiscan-cam-driver-module.schema.json",
            "meta": {
                "inputFileType": "LumiScan-Ctrlx-Camera-Configuration",
                "inputFileVersion": "0.0.1",
                "targetMachine": "CtrlX7",
                "programName": "lumiscan-cam-driver",
                "programVersion": "2.1.0"
            },
            "id": "camera-left",
            "cameraId": "camera-left",
            "exposureTimeUS": 10000,
            "pixelFormat": "BayerRG8",
            "exportPixelFormat": "BGR8",
            "packetSize": 8192,
            "packetDelay_us": 1000,
            "timeout_ms": 2000,
            "timestampSource": "Camera",
            "clearBufferBeforeCapture": true,
            "triggerBeforeAcquire": false
        }
    ]
}
