{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/sil-kit-participant-configuration.json",
  "additionalProperties": false,
  "definitions": {
    "Description": {
      "type": "string",
      "description": "Free text commenting on or summarizing this configuration. Optional",
      "default": ""
    },
    "Name": {
      "type": "string",
      "description": "Name of the endpoint"
    },
    "Network": {
      "type": "string",
      "description": "Name of the network. Optional; Defaults to the endpoint name"
    },
    "UseTraceSinks": {
      "type": "array",
      "description": "Names of trace sinks to use",
      "examples": ["Sink1"]
    },
    "Replay": {
      "type": "object",
      "properties": {
        "UseTraceSource": {
          "type": "string",
          "description": "Name of a trace source used as a simulation message source for this controller",
          "examples": ["Source1"]
        },
        "Direction": {
          "type": "string",
          "description": "Filter messages to use from the trace source by their direction. May be Send, Receive or Both",
          "enum": ["Send", "Receive", "Both"],
          "examples": ["Send", "Receive", "Both"]
        },
        "MdfChannel": {
          "type": "object",
          "properties": {
            "ChannelName": {
              "type": "string",
              "description": "Name of an MDF channel in the trace source",
              "examples": ["MyTestChannel1"]
            },
            "ChannelSource": {
              "type": "string",
              "description": "Name of an MDF channel's source information object",
              "examples": ["path/to/myTestChannel1"]
            },
            "ChannelPath": {
              "type": "string",
              "description": "Path of an MDF channel's source information object",
              "examples": ["MyTestChannel"]
            },
            "GroupName": {
              "type": "string",
              "description": "Name of an MDF channel group",
              "examples": ["MyTestGroup"]
            },
            "GroupSource": {
              "type": "string",
              "description": "Name of an MDF channel group's source information object",
              "examples": ["path/to/myTestGroup1"]
            },
            "GroupPath": {
              "type": "string",
              "description": "Path of an MDF channel group's source information object",
              "examples": ["MyTestGroup"]
            }
          }
        }
      }
    },
    "FlexrayClusterParameters": {
      "type": "object",
      "properties": {
        "gColdstartAttempts": {
          "type": "integer",
          "minimum": 2,
          "maximum": 31,
          "description": "Number of attempts for a cold start before giving up (range 2-31)",
          "examples": [8]
        },
        "gCycleCountMax": {
          "type": "integer",
          "minimum": 7,
          "maximum": 63,
          "description": "Max cycle count value in a given cluster (range 7-63, must be an odd integer)",
          "examples": [63]
        },
        "gdActionPointOffset": {
          "type": "integer",
          "minimum": 1,
          "maximum": 63,
          "description": "Time offset for a static slot in macroticks (range 1 - 63)",
          "examples": [2]
        },
        "gdDynamicSlotIdlePhase": {
          "type": "integer",
          "minimum": 0,
          "maximum": 2,
          "description": "Duration of the idle phase within a dynamic slot in gdMiniSlots (range 0 - 2)",
          "examples": [1]
        },
        "gdMiniSlot": {
          "type": "integer",
          "minimum": 2,
          "maximum": 63,
          "description": "Duration of a mini slot in macroticks (2 - 63)",
          "examples": [5]
        },
        "gdMiniSlotActionPointOffset": {
          "type": "integer",
          "minimum": 1,
          "maximum": 31,
          "description": "Time offset for a mini slot in macroticks (range 1- 31)",
          "examples": [2]
        },
        "gdStaticSlot": {
          "type": "integer",
          "minimum": 3,
          "maximum": 664,
          "description": "Duration of a static slot in macroticks (range 3 - 664)",
          "examples": [31]
        },
        "gdSymbolWindow": {
          "type": "integer",
          "minimum": 0,
          "maximum": 162,
          "description": "Duration of the symbol window in macroticks (range 0 - 162)",
          "examples": [1]
        },
        "gdSymbolWindowActionPointOffset": {
          "type": "integer",
          "minimum": 1,
          "maximum": 63,
          "description": "Time offset for a static symbol windows in macroticks (range 1 - 63)",
          "examples": [1]
        },
        "gdTSSTransmitter": {
          "type": "integer",
          "minimum": 1,
          "maximum": 15,
          "description": "Duration of TSS (Transmission Start Sequence) in gdBits (range 1 - 15)",
          "examples": [9]
        },
        "gdWakeupTxActive": {
          "type": "integer",
          "minimum": 15,
          "maximum": 60,
          "description": "Duration of LOW Phase of a wakeup symbol in gdBit (range 15 - 60)",
          "examples": [60]
        },
        "gdWakeupTxIdle": {
          "type": "integer",
          "minimum": 45,
          "maximum": 180,
          "description": "Duration of the idle of a wakeup symbol in gdBit (45 - 180)",
          "examples": [180]
        },
        "gListenNoise": {
          "type": "integer",
          "minimum": 2,
          "maximum": 16,
          "description": "Upper limit for the startup listen timeout and wakeup listen timeout in the presence of noise; Used as a multiplier of pdListenTimeout (range 2 - 16)",
          "examples": [2]
        },
        "gMacroPerCycle": {
          "type": "integer",
          "minimum": 8,
          "maximum": 16000,
          "description": "Number of macroticks per cycle (range 8 - 16000)",
          "examples": [3636]
        },
        "gMaxWithoutClockCorrectionFatal": {
          "type": "integer",
          "minimum": 1,
          "maximum": 15,
          "description": "Threshold used for testing the vClockCorrectionFailed counter (range 1 - 15)",
          "examples": [2]
        },
        "gMaxWithoutClockCorrectionPassive": {
          "type": "integer",
          "minimum": 1,
          "maximum": 15,
          "description": "Threshold used for testing the vClockCorrectionFailed counter (range 1 - 15)",
          "examples": [2]
        },
        "gNumberOfMiniSlots": {
          "type": "integer",
          "minimum": 0,
          "maximum": 7988,
          "description": "Number of mini slots (range 0 - 7988)",
          "examples": [291]
        },
        "gNumberOfStaticSlots": {
          "type": "integer",
          "minimum": 2,
          "maximum": 1023,
          "description": "Number of static slots in a cycle (range 2 - 1023)",
          "examples": [70]
        },
        "gPayloadLengthStatic": {
          "type": "integer",
          "minimum": 0,
          "maximum": 127,
          "description": "Length of the payload of a static frame in 16-Bits words (range 0 - 127)",
          "examples": [16]
        },
        "gSyncFrameIDCountMax": {
          "type": "integer",
          "minimum": 2,
          "maximum": 15,
          "description": "Maximum number of distinct sync frame identifiers present in a given cluster (range 2 - 15)",
          "examples": [15]
        }
      }
    },
    "FlexrayNodeParameters": {
      "type": "object",
      "properties": {
        "pAllowHaltDueToClock": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1,
          "description": "Controls the transition to halt state due to clock synchronization errors. (values 0, 1)",
          "examples": [1]
        },
        "pAllowPassiveToActive": {
          "type": "integer",
          "minimum": 0,
          "maximum": 31,
          "description": "Required number of consecutive even / odd cycle pairs for normal passive to normal active (range 0 - 31)",
          "examples": [0]
        },
        "pChannels": {
          "type": "string",
          "enum": ["A", "B", "AB", "None"],
          "description": "Channel(s) to which the controller is connected",
          "examples": ["AB"]
        },
        "pClusterDriftDamping": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10,
          "description": "Cluster drift damping factor for rate correction in microticks (range 0 - 10)",
          "examples": [2]
        },
        "pdAcceptedStartupRange": {
          "type": "integer",
          "minimum": 29,
          "maximum": 2743,
          "description": "Allowed deviation for startup frames during integration in microticks (range 29 - 2743)",
          "examples": [212]
        },
        "pdListenTimeout": {
          "type": "integer",
          "minimum": 1926,
          "maximum": 2567692,
          "description": "Duration of listen phase in microticks (range 1926 - 2567692)",
          "examples": [400162]
        },
        "pKeySlotId": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1023,
          "description": "Slot ID of the key slot (range 0 - 1023; value 0 means that there is no key slot)",
          "examples": [10]
        },
        "pKeySlotOnlyEnabled": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1,
          "description": "Shall the node enter key slot only mode after startup. (values 0, 1) (AUTOSAR pSingleSlotEnabled)",
          "examples": [0]
        },
        "pKeySlotUsedForStartup": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1,
          "description": "Key slot is used for startup (values 0, 1)",
          "examples": [1]
        },
        "pKeySlotUsedForSync": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1,
          "description": "Key slot is used for sync (values 0, 1)",
          "examples": [0]
        },
        "pLatestTx": {
          "type": "integer",
          "minimum": 0,
          "maximum": 7988,
          "description": "Last mini slot which can be transmitted (range 0 - 7988)",
          "examples": [249]
        },
        "pMacroInitialOffsetA": {
          "type": "integer",
          "minimum": 2,
          "maximum": 68,
          "description": "Initial startup offset for frame reference point on channel A (range 2 - 68 macroticks)",
          "examples": [3]
        },
        "pMacroInitialOffsetB": {
          "type": "integer",
          "minimum": 2,
          "maximum": 68,
          "description": "Initial startup offset for frame reference point on channel B (range 2 - 68 macroticks)",
          "examples": [3]
        },
        "pMicroInitialOffsetA": {
          "type": "integer",
          "minimum": 0,
          "maximum": 239,
          "description": "Offset between secondary time reference and MT boundary (range 0 - 239 microticks)",
          "examples": [6]
        },
        "pMicroInitialOffsetB": {
          "type": "integer",
          "minimum": 0,
          "maximum": 239,
          "description": "Offset between secondary time reference and MT boundary (range 0 - 239 microticks)",
          "examples": [6]
        },
        "pMicroPerCycle": {
          "type": "integer",
          "minimum": 960,
          "maximum": 1280000,
          "description": "Nominal number of microticks in the communication cycle (range 960 - 1280000)",
          "examples": [200000]
        },
        "pOffsetCorrectionOut": {
          "type": "integer",
          "minimum": 15,
          "maximum": 16082,
          "description": "Maximum permissible offset correction value (range 15 - 16082 microticks)",
          "examples": [127]
        },
        "pOffsetCorrectionStart": {
          "type": "integer",
          "minimum": 7,
          "maximum": 15999,
          "description": "Start of the offset correction phase within the NIT, (7 - 15999 macroticks)",
          "examples": [3632]
        },
        "pRateCorrectionOut": {
          "type": "integer",
          "minimum": 3,
          "maximum": 3846,
          "description": "Maximum permissible rate correction value (range 3 - 3846 microticks)",
          "examples": [81]
        },
        "pWakeupChannel": {
          "type": "string",
          "enum": ["A", "B"],
          "description": "Channel used by the node to send a wakeup pattern",
          "examples": ["A"]
        },
        "pWakeupPattern": {
          "type": "integer",
          "minimum": 0,
          "maximum": 63,
          "description": "Number of repetitions of the wakeup symbol (range 0 - 63, value 0 or 1 prevents sending of WUP)",
          "examples": [33]
        },
        "pdMicrotick": {
          "type": "string",
          "enum": ["12.5ns", "25ns", "50ns"],
          "description": "Duration of a FlexRay microtick",
          "examples": ["25ns"]
        },
        "pSamplesPerMicrotick": {
          "type": "integer",
          "minimum": 1,
          "maximum": 2,
          "description": "Number of samples per microtick (values 1, 2)",
          "examples": [2]
        }
      }
    },
    "FlexrayTxBufferConfigurations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "channels": {
            "type": "string",
            "enum": ["A", "B", "AB", "None"],
            "description": "Channel(s)",
            "examples": ["A"]
          },
          "slotId": {
            "type": "integer",
            "minimum": 0,
            "maximum": 65535,
            "description": "The slot Id of frame",
            "examples": [0]
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "maximum": 63,
            "description": "Base offset for cycle multiplexing (values 0 - 63)",
            "examples": [0]
          },
          "repetition": {
            "type": "integer",
            "minimum": 0,
            "maximum": 64,
            "description": "Repetition for cycle multiplexing (values 1, 2, 4, 8, 16, 32, 64)",
            "examples": [0]
          },
          "PPindicator": {
            "type": "boolean",
            "description": "Set the PPindicator",
            "examples": [false]
          },
          "headerCrc": {
            "type": "integer",
            "description": "Header CRC, 11 bits",
            "examples": [0]
          },
          "transmissionMode": {
            "type": "string",
            "enum": ["SingleShot", "Continuous"],
            "description": "SingleShot or Continuous transmission mode",
            "examples": ["Continuous"]
          }
        }
      }
    },
    "FlexrayController": {
      "type": "object",
      "properties": {
        "Name": {
          "$ref": "#/definitions/Name",
          "examples": ["FlexRay1"]
        },
        "Network": {
          "$ref": "#/definitions/Network"
        },
        "UseTraceSinks": {
          "$ref": "#/definitions/UseTraceSinks"
        },
        "Replay": {
          "$ref": "#/definitions/Replay"
        },
        "ClusterParameters": {
          "$ref": "#/definitions/FlexrayClusterParameters"
        },
        "NodeParameters": {
          "$ref": "#/definitions/FlexrayNodeParameters"
        },
        "TxBufferConfigurations": {
          "$ref": "#/definitions/FlexrayTxBufferConfigurations"
        }
      },
      "additionalProperties": false,
      "required": ["Name"]
    },
    "FlexrayControllers": {
      "type": "array",
      "description": "Reconfigures the FlexrayControllers of the participant",
      "items": {
        "$ref": "#/definitions/FlexrayController"
      }
    },
    "Topic": {
      "type": "string",
      "description": "Name of the communication channel between DataPublisher and DataSubscribers"
    },
    "RpcFunctionName": {
      "type": "string",
      "description": "Name of the RPC function called by RpcClients on RpcServers"
    },
    "Logging": {
      "type": "object",
      "description": "Configures the properties of the SIL Kit Logging Service",
      "properties": {
        "LogFromRemotes": {
          "type": "boolean",
          "description": "Enables receiving of remote log messages from other participants",
          "examples": [false, true],
          "default": false
        },
        "FlushLevel": {
          "type": "string",
          "enum": [
            "Critical",
            "Error",
            "Warn",
            "Info",
            "Debug",
            "Trace",
            "Off"
          ],
          "examples": [
            "Critical",
            "Error",
            "Warn",
            "Info",
            "Debug",
            "Trace",
            "Off"
          ]
        },
        "Sinks": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "Type": {
                "type": "string",
                "enum": ["Remote", "File", "Stdout"],
                "examples": ["Remote", "File", "Stdout"]
              },
              "Level": {
                "type": "string",
                "enum": [
                  "Critical",
                  "Error",
                  "Warn",
                  "Info",
                  "Debug",
                  "Trace",
                  "Off"
                ],
                "examples": [
                  "Critical",
                  "Error",
                  "Warn",
                  "Info",
                  "Debug",
                  "Trace",
                  "Off"
                ],
                "default": "Info"
              },
              "LogName": {
                "type": "string",
                "description": "Log name; Results in the following filename: <LogName>_%y-%m-%dT%h-%m-%s.txt",
                "examples": ["MyLog1"],
                "default": "MyLog1"
              }
            },
            "additionalProperties": false,
            "required": ["Type"]
          }
        }
      },
      "additionalProperties": false,
      "required": ["Sinks"]
    }
  },
  "description": "JSON schema for SIL Kit Participant configuration files",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "The schema file",
      "default": "",
      "examples": ["./ParticipantConfiguration.schema.json"]
    },
    "schemaVersion": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "string"
        }
      ],
      "default": 0,
      "description": "Version of the schema used to validate this document"
    },
    "Description": {
      "$ref": "#/definitions/Description"
    },
    "ParticipantName": {
      "type": "string",
      "description": "Name of the participant"
    },
    "CanControllers": {
      "type": "array",
      "description": "Reconfigures the CanControllers of the participant",
      "items": {
        "type": "object",
        "properties": {
          "Name": {
            "$ref": "#/definitions/Name",
            "examples": ["CAN1"]
          },
          "Network": {
            "$ref": "#/definitions/Network",
            "examples": ["CAN1"]
          },
          "UseTraceSinks": {
            "$ref": "#/definitions/UseTraceSinks"
          },
          "Replay": {
            "$ref": "#/definitions/Replay"
          }
        },
        "additionalProperties": false,
        "required": ["Name"]
      }
    },
    "LinControllers": {
      "type": "array",
      "description": "Reconfigures the LinControllers of the participant",
      "items": {
        "type": "object",
        "properties": {
          "Name": {
            "$ref": "#/definitions/Name",
            "examples": ["LIN1"]
          },
          "Network": {
            "$ref": "#/definitions/Network",
            "examples": ["LIN1"]
          },
          "UseTraceSinks": {
            "$ref": "#/definitions/UseTraceSinks"
          },
          "Replay": {
            "$ref": "#/definitions/Replay"
          }
        },
        "additionalProperties": false,
        "required": ["Name"]
      }
    },
    "FlexrayControllers": {
      "$ref": "#/definitions/FlexrayControllers"
    },
    "EthernetControllers": {
      "type": "array",
      "description": "Reconfigures the EthernetControllers of the participant",
      "items": {
        "type": "object",
        "properties": {
          "Name": {
            "$ref": "#/definitions/Name",
            "examples": ["ETH0"]
          },
          "Network": {
            "$ref": "#/definitions/Network"
          },
          "UseTraceSinks": {
            "$ref": "#/definitions/UseTraceSinks"
          },
          "Replay": {
            "$ref": "#/definitions/Replay"
          }
        },
        "additionalProperties": false,
        "required": ["Name"]
      }
    },
    "DataPublishers": {
      "type": "array",
      "description": "Reconfigures the DataPublishers of the participant",
      "items": {
        "type": "object",
        "properties": {
          "Name": {
            "$ref": "#/definitions/Name",
            "examples": ["Publisher1"]
          },
          "Topic": {
            "$ref": "#/definitions/Topic",
            "examples": ["Temperature"]
          },
          "UseTraceSinks": {
            "$ref": "#/definitions/UseTraceSinks",
            "examples": ["Sink1"]
          }
        },
        "additionalProperties": false,
        "required": ["Name"]
      }
    },
    "DataSubscribers": {
      "type": "array",
      "description": "Reconfigures the DataSubscribers of the participant",
      "items": {
        "type": "object",
        "properties": {
          "Name": {
            "$ref": "#/definitions/Name",
            "examples": ["Subscriber1"]
          },
          "Topic": {
            "$ref": "#/definitions/Topic",
            "examples": ["Temperature"]
          },
          "UseTraceSinks": {
            "$ref": "#/definitions/UseTraceSinks",
            "examples": ["Sink1"]
          }
        },
        "additionalProperties": false,
        "required": ["Name"]
      }
    },
    "RpcClients": {
      "type": "array",
      "description": "Reconfigures the RpcClients of the participant",
      "items": {
        "type": "object",
        "properties": {
          "Name": {
            "$ref": "#/definitions/Name"
          },
          "FunctionName": {
            "$ref": "#/definitions/RpcFunctionName"
          },
          "UseTraceSinks": {
            "$ref": "#/definitions/UseTraceSinks"
          }
        },
        "additionalProperties": false,
        "required": ["Name"]
      }
    },
    "RpcServers": {
      "type": "array",
      "description": "Reconfigures the RpcServers of the participant",
      "items": {
        "type": "object",
        "properties": {
          "Name": {
            "$ref": "#/definitions/Name",
            "examples": ["Server1"]
          },
          "FunctionName": {
            "$ref": "#/definitions/RpcFunctionName",
            "examples": ["Function1"]
          },
          "UseTraceSinks": {
            "$ref": "#/definitions/UseTraceSinks"
          }
        },
        "additionalProperties": false,
        "required": ["Name"]
      }
    },
    "Logging": {
      "$ref": "#/definitions/Logging"
    },
    "HealthCheck": {
      "type": "object",
      "description": "Node to configure properties to determine the health status of the simulation",
      "properties": {
        "SoftResponseTimeout": {
          "type": "integer",
          "description": "If a simulation step is not finished before this limit, a warning is logged. Optional; Unit is in milliseconds",
          "examples": [500]
        },
        "HardResponseTimeout": {
          "type": "integer",
          "description": "If a simulation step is not finished before this limit, the participant enters error state. Optional; Unit is in milliseconds",
          "examples": [5000]
        }
      },
      "additionalProperties": false
    },
    "Tracing": {
      "type": "object",
      "description": "Configures the tracing service of the participant",
      "properties": {
        "TraceSinks": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "Name": {
                "type": "string",
                "description": "Name of the trace sink",
                "examples": ["SomeTraceSink"]
              },
              "OutputPath": {
                "type": "string",
                "description": "File path of output file",
                "examples": ["path/to/Output1.mf4"]
              },
              "Type": {
                "type": "string",
                "enum": ["PcapFile", "PcapPipe", "Mdf4File"],
                "description": "File format specifier",
                "examples": ["PcapFile", "PcapPipe", "Mdf4File"],
                "default": "Mdf4File"
              }
            },
            "additionalProperties": false
          }
        },
        "TraceSources": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "Name": {
                "type": "string",
                "description": "Name of the trace source",
                "examples": ["SomeTraceSource"]
              },
              "InputPath": {
                "type": "string",
                "description": "File path of input file",
                "examples": ["path/to/Source1.mf4"]
              },
              "Type": {
                "type": "string",
                "enum": ["PcapFile", "PcapPipe", "Mdf4File"],
                "description": "File format specifier",
                "examples": ["PcapFile", "PcapPipe", "Mdf4File"],
                "default": "Mdf4File"
              }
            },
            "additionalProperties": false
          }
        }
      }
    },
    "Extensions": {
      "type": "object",
      "description": "Optional configuration for the extension loading mechanism",
      "properties": {
        "SearchPathHints": {
          "type": "array",
          "items": {
            "type": "string",
            "description": "A filesystem path to additionally search for extensions"
          },
          "examples": ["path/to/extensions1", "path/to/extensions2"]
        }
      },
      "additionalProperties": false
    },
    "Includes": {
      "type": "object",
      "description": "Optional configuration to include other participant configurations files",
      "properties": {
        "SearchPathHints": {
          "type": "array",
          "items": {
            "type": "string",
            "description": "A filesystem path to additionally search for files to be included",
            "examples": [
              "/urs/etc/sil-kit-configs/",
              "C:\\Temp\\sil-kit-configs\\"
            ]
          }
        },
        "Files": {
          "type": "array",
          "items": {
            "type": "string",
            "description": "Participant configuration files to be included",
            "examples": [
              "relative/path/to/included.silkit.yaml",
              "logging.silkit.yaml"
            ]
          }
        }
      }
    },
    "Middleware": {
      "type": "object",
      "description": "Optional configuration of the SIL Kit middleware",
      "properties": {
        "RegistryUri": {
          "type": "string",
          "examples": ["silkit://0.0.0.0:8501", "silkit://localhost:8500"],
          "default": "silkit://localhost:8500"
        },
        "ConnectAttempts": {
          "type": "integer",
          "default": 1
        },
        "TcpNoDelay": {
          "type": "boolean",
          "default": true
        },
        "TcpQuickAck": {
          "type": "boolean",
          "default": false
        },
        "TcpSendBufferSize": {
          "type": "integer",
          "examples": [3456]
        },
        "TcpReceiveBufferSize": {
          "type": "integer",
          "examples": [3456]
        }
      },
      "additionalProperties": false
    }
  },
  "type": "object"
}
