{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "",
    "type": "object",
    "definitions": {
        "logFeature": {
            "type": "object",
            "description": "One scheduled diagnostic read: which features are read at which point of the camera's lifecycle, and where the line goes. Rendered as 'name=value;name=value;'. Keep the list short, above all for PER_CAPTURE: on GigE Vision the reads compete with the image packets.",
            "properties": {
                "when": {
                    "type": "string",
                    "enum": ["PER_CONNECT", "PER_START_ACQUISITION", "PER_CAPTURE"],
                    "default": "PER_CAPTURE",
                    "description": "PER_CONNECT: around opening and configuring the camera. PER_START_ACQUISITION: around starting the stream. PER_CAPTURE: around each capture."
                },
                "timing": {
                    "type": "string",
                    "enum": ["BEFORE", "AFTER"],
                    "default": "BEFORE",
                    "description": "Which side of 'when' the read happens on."
                },
                "features": {
                    "type": "array",
                    "description": "The feature names to read. A 'STREAM.' prefix reads from the stream's feature space.",
                    "items": { "type": "string", "minLength": 1 },
                    "minItems": 1,
                    "examples": [["ExposureTime", "DeviceTemperature"]]
                },
                "name": { "type": "string", "description": "A label, echoed into the line; never parsed." },
                "outputFile": { "type": "string", "description": "Appended to. Empty or left out: the line goes to the log." }
            },
            "required": ["features"]
        }
    },
    "properties": {
        "$schema": {
            "type": "string",
            "minLength": 1
        },
        "meta": {
            "description": "Meta information about the application and current setting. This is mainly for information purpose and not used by the application itself",
            "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-Cam-Driver",
                    "inputFileVersion": "1.0.0",
                    "targetMachine": "CtrlX7",
                    "programName": "lumiscan-cam-driver",
                    "programVersion": "2.1.0"
                }
            ]
        },
        "modules": {
            "type": "array",
            "description": "List of module setting files that will be loaded by the application. One camera per entry; each file is resolved next to this settings file.",
            "items": {
                "type": "string",
                "description": "Module setting file",
                "examples": [
                    "lumiscan-cam-driver-example-module.json"
                ]
            },
            "minItems": 1,
            "examples": [
                [
                    "lumiscan-cam-driver-example-module.json"
                ],
                [
                    "camera-left.json",
                    "camera-right.json"
                ]
            ]
        },
        "cameraDrivers": {
            "type": "array",
            "description": "How cameras are reached. Each camera of 'cameras' names one by its 'driverId'. The built-in GenTL producer 'default' (Baumer) needs no entry.",
            "items": {
                "type": "object",
                "oneOf": [
                    {
                        "description": "A GenTL producer (.cti): GigE Vision and USB3 Vision cameras.",
                        "properties": {
                            "driverType": { "type": "string", "enum": ["GenICam"] },
                            "id": { "type": "string", "minLength": 1, "examples": ["default", "basler-producer"] },
                            "gentlPath": {
                                "type": "string",
                                "minLength": 1,
                                "description": "Path to the GenTL producer (.cti). A relative path is resolved against this settings file's folder.",
                                "examples": ["GenTL_Producers/basler/ProducerGEV.cti", "/opt/lucid/lib64/TLTypeGEV.cti"]
                            },
                            "genTLConsumer": { "type": "string", "enum": ["DEFAULT"], "default": "DEFAULT" },
                            "enable": { "type": "boolean", "default": true, "description": "false: the driver is not initialised at all, and its SDK not loaded." }
                        },
                        "required": ["driverType", "id", "gentlPath"]
                    },
                    {
                        "description": "A camera plugin: a vendor SDK wrapped for HDV (e.g. FileCameraPlugin).",
                        "properties": {
                            "driverType": { "type": "string", "enum": ["Plugin"] },
                            "id": { "type": "string", "minLength": 1, "default": "plugin", "examples": ["file-camera"] },
                            "pluginPath": {
                                "type": "string",
                                "minLength": 1,
                                "description": "The plugin library. A name or relative path is looked for in this settings file's folder, beside the application and in its lib folder; the platform's file name is added (FileCameraPlugin: FileCameraPlugin.dll, libFileCameraPlugin.so).",
                                "examples": ["FileCameraPlugin", "plugins/LumiScanPlugin.dll"]
                            },
                            "pluginSettings": { "type": "string", "description": "Passed to the plugin as it is." },
                            "enable": { "type": "boolean", "default": true, "description": "false: the driver is not initialised at all, and its SDK not loaded." }
                        },
                        "required": ["driverType", "id", "pluginPath"]
                    },
                    {
                        "description": "A simulated camera: the images of a folder, played in turn.",
                        "properties": {
                            "driverType": { "type": "string", "enum": ["Virtual"] },
                            "id": { "type": "string", "minLength": 1, "examples": ["simulation-camera1"] },
                            "path": {
                                "type": "string",
                                "minLength": 1,
                                "description": "The folder of images. A relative path is resolved against this settings file's folder; a missing folder is created.",
                                "examples": ["images/camera1"]
                            },
                            "serial": { "type": "string", "description": "The serial the simulated camera reports." },
                            "fileType": { "type": "string", "enum": ["PNG", "BMP", "JPEG"], "default": "PNG" },
                            "pattern": { "type": "string", "description": "Instead of fileType: the file names to play, as a pattern. fileType wins when both are given." },
                            "layout": {
                                "type": "string",
                                "enum": ["AUTO", "FRAMES", "DATASETS", "CAMERAS"],
                                "default": "AUTO",
                                "description": "FRAMES: the images are in the folder itself."
                            },
                            "enable": { "type": "boolean", "default": true, "description": "false: the driver is not initialised at all." }
                        },
                        "required": ["driverType", "id", "path"]
                    }
                ]
            }
        },
        "cameras": {
            "type": "array",
            "description": "The cameras, each driven by the module whose 'cameraId' names it.",
            "items": {
                "type": "object",
                "properties": {
                    "cameraId": { "type": "string", "minLength": 1, "examples": ["camera1", "camera-left"] },
                    "serial": {
                        "type": "string",
                        "minLength": 1,
                        "description": "The camera's serial number, as its driver finds it (see found-camera-serials on the Data Layer). On a GenICam driver, a serial containing \"simulation\" makes a simulated camera: its module plays the images in its image folder (the Internal storage's rootPath, then the module id unless unifiedStorage).",
                        "examples": ["LX123456", "simulation"]
                    },
                    "driverId": { "type": "string", "minLength": 1, "description": "The id of a 'cameraDrivers' entry, or 'default'.", "examples": ["default"] },
                    "enable": { "type": "boolean", "default": true },
                    "featureFiles": {
                        "type": "array",
                        "description": "Feature files - '<FEATURENAME> <VALUE>' per line - applied in order each time the camera connects, after the Cam Driver has set it up (software trigger, packet size, pixel format), so a file can change those, e.g. switch to a hardware trigger. A feature the camera does not take is logged and skipped. A relative path is resolved against this settings file's folder.",
                        "items": { "type": "string", "minLength": 1 },
                        "examples": [["features/camera-left-features.txt"]]
                    },
                    "featureSetIds": {
                        "type": "array",
                        "description": "The ids of the 'featureSets' this camera may be switched to; empty or left out: any of them.",
                        "items": { "type": "string", "minLength": 1 }
                    },
                    "featuresNeedRestart": {
                        "type": "array",
                        "description": "Features this camera takes only while acquisition is stopped: a feature set that touches one of them is applied with acquisition stopped and restarted around it.",
                        "items": { "type": "string", "minLength": 1 },
                        "default": ["PixelFormat", "TriggerMode"]
                    },
                    "logFeatures": {
                        "type": "array",
                        "description": "Diagnostic reads that belong to the camera, whatever feature set is in use.",
                        "items": { "$ref": "#/definitions/logFeature" }
                    },
                    "featureMappingId": {
                        "type": "string",
                        "description": "The 'featureMappings' entry with this camera's own names for its trigger and other common features. Without one, the Cam Driver uses its built-in names alone.",
                        "examples": ["lucid"]
                    }
                },
                "required": ["cameraId", "serial", "driverId"]
            }
        },
        "featureSets": {
            "type": "array",
            "description": "Named feature configurations a camera can be switched to at run time, each an ordered list of feature files.",
            "items": {
                "type": "object",
                "properties": {
                    "id": { "type": "string", "minLength": 1, "description": "Unique among the feature sets. 'default' is reserved: the feature values the camera had when it was connected." },
                    "featureFiles": {
                        "type": "array",
                        "description": "Feature files - '<FEATURENAME> <VALUE>' per line - applied in order.",
                        "items": { "type": "string", "minLength": 1 }
                    },
                    "logFeatures": {
                        "type": "array",
                        "description": "Diagnostic reads while this set is in use.",
                        "items": { "$ref": "#/definitions/logFeature" }
                    }
                },
                "required": ["id"]
            }
        },
        "featureMappings": {
            "type": "array",
            "description": "A camera's own names for the common features - its software trigger command, trigger mode and source, ... - and for their entries, where the Cam Driver's built-in names do not cover them. A camera uses one by its 'featureMappingId'. A mapped name is tried first; one the camera does not have is logged as a warning and the built-in names are used.",
            "items": {
                "type": "object",
                "properties": {
                    "id": { "type": "string", "minLength": 1, "description": "Named by a camera's 'featureMappingId'.", "examples": ["lucid"] },
                    "features": {
                        "type": "object",
                        "description": "The camera's feature name for each common feature.",
                        "properties": {
                            "TriggerSoftware": { "type": "string", "minLength": 1, "description": "The command that fires a software trigger. Built in: TriggerSoftware, SoftwareTrigger.", "examples": ["TriggerSoftware"] },
                            "TriggerMode": { "type": "string", "minLength": 1, "description": "The enumeration that switches triggering on and off. Built in: TriggerMode.", "examples": ["TriggerMode"] },
                            "TriggerSource": { "type": "string", "minLength": 1, "description": "The enumeration that selects the trigger source. Built in: TriggerSource.", "examples": ["TriggerSource"] },
                            "TriggerSelector": { "type": "string", "minLength": 1, "description": "The enumeration that selects the trigger configured. Built in: TriggerSelector.", "examples": ["TriggerSelector"] },
                            "ExposureTime": { "type": "string", "minLength": 1, "description": "Built in: ExposureTime, ExposureTimeAbs, ExposureTimeRaw.", "examples": ["ExposureTime"] },
                            "FrameRate": { "type": "string", "minLength": 1, "description": "Built in: AcquisitionFrameRate, AcquisitionFrameRateAbs.", "examples": ["AcquisitionFrameRate"] },
                            "PixelFormat": { "type": "string", "minLength": 1, "description": "Built in: PixelFormat.", "examples": ["PixelFormat"] },
                            "Width": { "type": "string", "minLength": 1, "description": "Built in: Width.", "examples": ["Width"] },
                            "Height": { "type": "string", "minLength": 1, "description": "Built in: Height.", "examples": ["Height"] },
                            "Serial": { "type": "string", "minLength": 1, "description": "Built in: DeviceSerialNumber, DeviceID.", "examples": ["DeviceSerialNumber"] },
                            "VendorName": { "type": "string", "minLength": 1, "description": "Built in: DeviceVendorName.", "examples": ["DeviceVendorName"] },
                            "ModelName": { "type": "string", "minLength": 1, "description": "Built in: DeviceModelName.", "examples": ["DeviceModelName"] },
                            "FirmwareVersion": { "type": "string", "minLength": 1, "description": "Built in: DeviceFirmwareVersion, DeviceVersion.", "examples": ["DeviceFirmwareVersion"] }
                        },
                        "additionalProperties": false
                    },
                    "values": {
                        "type": "object",
                        "description": "The camera's entry for each common value of an enumeration. Taken as it is when the camera lists no entries.",
                        "properties": {
                            "TriggerSource_Software": { "type": "string", "minLength": 1, "description": "TriggerSource for a software trigger. Built in: SoftwareTrigger, Software, 1.", "examples": ["Software"] },
                            "TriggerSource_Hardware": { "type": "string", "minLength": 1, "description": "TriggerSource for a hardware trigger. Built in: Line0, Line1, 2.", "examples": ["Line0"] },
                            "TriggerMode_On": { "type": "string", "minLength": 1, "description": "TriggerMode on. Built in: On, Triggered, ON, on, 1.", "examples": ["On"] },
                            "TriggerMode_Off": { "type": "string", "minLength": 1, "description": "TriggerMode off. Built in: Off, FreeRunning, OFF, off, 0.", "examples": ["Off"] },
                            "TriggerSelector_FrameStart": { "type": "string", "minLength": 1, "description": "Built in: FrameStart.", "examples": ["FrameStart"] },
                            "TriggerSelector_FrameBurstStart": { "type": "string", "minLength": 1, "description": "Built in: FrameBurstStart.", "examples": ["FrameBurstStart"] }
                        },
                        "additionalProperties": false
                    }
                },
                "required": ["id"]
            },
            "examples": [
                [
                    {
                        "id": "lucid",
                        "features": { "TriggerSoftware": "TriggerSoftware", "TriggerMode": "TriggerMode", "TriggerSource": "TriggerSource" },
                        "values": { "TriggerSource_Software": "Software", "TriggerMode_On": "On", "TriggerMode_Off": "Off" }
                    }
                ]
            ]
        },
        "system": {
            "type": "object",
            "$ref": "system.schema.json"
        }
    },
    "required": [
        "meta",
        "modules"
    ],
    "examples": [
        {
            "$schema": "schemas/lumiscan-cam-driver.schema.json",
            "meta": {
                "inputFileType": "LumiScan-CtrlX-Cam-Driver",
                "inputFileVersion": "1.0.0",
                "targetMachine": "CtrlX7",
                "programName": "lumiscan-cam-driver",
                "programVersion": "2.1.0"
            },
            "modules": [
                "lumiscan-cam-driver-example-module.json"
            ],
            "cameraDrivers": [
                {
                    "driverType": "Virtual",
                    "id": "simulation-camera1",
                    "path": "images/camera1",
                    "fileType": "PNG",
                    "layout": "FRAMES"
                }
            ],
            "cameras": [
                {
                    "cameraId": "camera1",
                    "serial": "simulation",
                    "driverId": "simulation-camera1"
                }
            ],
            "system": {
                "debug": false,
                "logLevel": "INFO",
                "storage": {
                    "type": "Internal",
                    "parameters": {
                        "rootPath": "images"
                    }
                },
                "unifiedStorage": false
            }
        },
        {
            "$schema": "schemas/lumiscan-cam-driver.schema.json",
            "meta": {
                "inputFileType": "LumiScan-CtrlX-Cam-Driver",
                "inputFileVersion": "1.0.0",
                "targetMachine": "CtrlX7",
                "programName": "lumiscan-cam-driver",
                "programVersion": "2.1.0"
            },
            "modules": [
                "camera-left.json",
                "camera-right.json"
            ],
            "cameraDrivers": [
                {
                    "driverType": "GenICam",
                    "id": "basler-producer",
                    "gentlPath": "GenTL_Producers/basler/ProducerGEV.cti"
                }
            ],
            "cameras": [
                {
                    "cameraId": "camera-left",
                    "serial": "40012345",
                    "driverId": "basler-producer",
                    "featureFiles": ["features/camera-left-features.txt"]
                },
                {
                    "cameraId": "camera-right",
                    "serial": "LX123456",
                    "driverId": "default"
                }
            ],
            "system": {
                "debug": false,
                "logLevel": "INFO",
                "storage": {
                    "type": "Internal",
                    "parameters": {
                        "rootPath": "images"
                    }
                },
                "unifiedStorage": false
            }
        }
    ]
}
