{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://hg.ximc.ru/eyepoint/epcore/file/Schema1.1.1/epcore/doc/ufiv.schema.json",
  "version": "1.1.1",
  "title": "UFIV - Universal file format for IV-curve measurements.",
  "description": "This format describes set of IV-curve measurements for a set of electrical components on a single PCB.",
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "PCB": {
      "description": "Data related to the PCB (printed circuit board) and not the mounted components on the board.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "pcb_name": {
          "description": "PCB name, if any.",
          "type": "string"
        },
        "pcb_image_path": {
          "description": "Local path to the board image relative to the savefile.",
          "type": "string"
        },
        "image_resolution_ppcm": {
          "description": "Resolution of the PCB image in pixels per centimeter. An approximate value may be used for images with no defined or stable resolution over the image.",
          "type": "number"
        },
        "comment": {
          "description": "User comment for convinience.",
          "type": "string"
        }
      },
      "required": [
        "pcb_image_path"
      ]
    },
    "elements": {
      "description": "Array of elements, each of them represents a component on the PCB.",
      "minItems": 1,
      "uniqueItems": true,
      "type": "array",
      "items": {
        "description": "Component on the PCB. May be a integrated circuit or SMD chip. Sometimes a nonexistent component is created just to place testing points inside it. Each board should contain at least one component, real or faked. So basically component provides convinient wrapper for pins.",
        "additionalProperties": false,
        "type": "object",
        "properties": {
          "name": {
            "description": "Component name.",
            "type": "string"
          },
          "set_automatically": {
            "description": "This flag indicates that this component was set by the automated recognition system and all fields are in correspondence with basic internal representation for the current device. In case of manual component editing this flag should be reset. Empty field assumed false.",
            "type": "boolean"
          },
          "pins": {
            "description": "An array of testable pins of the PCB component. Pins are simple because they are just one point on the map, but they contain electrical data. Component may have no pins because there may be mechanical and not electrical components. They may still count for probe trajectory.",
            "uniqueItems": true,
            "type": "array",
            "items": {
              "description": "A pin for electrical test.",
              "additionalProperties": false,
              "type": "object",
              "properties": {
                "comment": {
                  "description": "Pin comment for user convenience.",
                  "type": "string"
                },
                "y": {
                  "description": "Y coordinate of the pin on the board image [pixels]",
                  "type": "number"
                },
                "x": {
                  "description": "X coordinate of the pin on the board image [pixels]",
                  "type": "number"
                },
                "iv_curves": {
                  "description": "An array of electrical measurements of the pin. There may be several reference measurements with various parameters, test measurements, or even no measurements because they haven't been done yet.",
                  "type": "array",
                  "items": {
                    "description": "IV curve measurement: measurement parameters and results (voltages and currents). Measurements can be reference, meaning the measurement from valid board and component.",
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "comment": {
                        "description": "Measurement comment for user convenience.",
                        "type": "string"
                      },
                      "measurement_settings": {
                        "description": "The measurement details.",
                        "additionalProperties": false,
                        "type": "object",
                        "properties": {
                          "probe_signal_frequency": {
                            "description": "Harmonic probe signal frequency. Units: Hz. Normally this parameter is set together with sampling rate for providing fixed resolution.",
                            "type": "number"
                          },
                          "max_voltage": {
                            "description": "Harmonic probe signal voltage amplitude. Units: Volts. This is open circuit voltage. Real voltage drop between probes during the measurement will be smaller due to finite current sensor impedance.",
                            "type": "number"
                          },
                          "precharge_delay": {
                            "description": "This parameter determines delay added for testing component precharge before measurement. During this delay appropriate probe signal is applied. If not presented assumed 0. Units: seconds",
                            "type": "number"
                          },
                          "sampling_rate": {
                            "description": "This rate determines the period between subsequent samples in measured curve. Units: samples / second. Normally this parameter is set together with probe signal frequency for providing fixed resolution, which is determined by the SamplingRate / ProbeSignalFrequency ratio.",
                            "type": "number"
                          },
                          "internal_resistance": {
                            "description": "Internal current sensor resistance, current limiting resistor and all other internal serial resistances in measurement circuit. Units: Ohms.",
                            "type": "number"
                          }
                        },
                        "required": [
                          "sampling_rate",
                          "internal_resistance",
                          "max_voltage",
                          "probe_signal_frequency"
                        ]
                      },
                      "is_dynamic": {
                        "description": "The electrical measurement can reveal that it differs from time to time. This is called dynamic iv_curve and marked with this flag. If flag is not present, then flag is false.",
                        "type": "boolean"
                      },
                      "is_reference": {
                        "description": "Some measurements are marked as reference. Other test measurements must be compared with reference ones. They are always considered true. If flag is not present, then flag is false.",
                        "type": "boolean"
                      },
                      "voltages": {
                        "description": "Circuit voltages measured with sampling rate. Together with currents they form an iv_curve of circuit under investigation, its analog signature. Units: Volts.",
                        "minItems": 4,
                        "type": "array",
                        "items": {
                          "type": "number"
                        }
                      },
                      "currents": {
                        "description": "Curcuit currents measured with sampling rate. Together with voltages they form an iv_curve of circuit under investigation, its analog signature. Units: Amperes.",
                        "minItems": 4,
                        "type": "array",
                        "items": {
                          "type": "number"
                        }
                      }
                    },
                    "required": [
                      "currents",
                      "voltages",
                      "measurement_settings"
                    ]
                  }
                }
              },
              "required": [
                "iv_curves",
                "x",
                "y"
              ]
            }
          },
          "package": {
            "description": "Element package name. Names from IPC-7351B standard should be used if possible.",
            "type": "string"
          },
          "center": {
            "description": "Defines 2D coordinates for component center [pixels]. First x, then y.",
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "number"
            }
          },
          "bounding_zone": {
            "description": "bounding_zone, if present, sets a polygon on the board which is occupied by the element. There must be no overlapping polygons. It is an array with 4 or 12 vertixes when used. 4 vertixes for simple rectangular component. 12 vertixes for intergated circuits that are found by 4 corners (16 corners minus 4 inner corners).",
            "minItems": 4,
            "maxItems": 12,
            "type": "array",
            "items": {
              "description": "A 2D coordinates of bounding_zone polygon.",
              "type": "array",
              "items": {
                "type": "number"
              }
            }
          },
          "rotation": {
            "description": "Each automatically recognized PCB component can be placed on the board in 4 different rotations - each one by additionl 90 degrees from the original. This parameter is reqired for correct placement of component and its picture.",
            "minimum": 0,
            "maximum": 3,
            "type": "integer"
          },
          "width": {
            "description": "Component width in mm (measured by marginal pins).",
            "type": "number"
          },
          "height": {
            "description": "Component height in mm (measured by marginal pins).",
            "type": "number"
          }
        },
        "required": [
          "pins"
        ]
      }
    },
    "version": {
      "description": "Schema version",
      "type": "string"
    }
  },
  "required": [
    "elements",
    "version"
  ]
}
