$schema: https://yaml-schema.net/yaml-schema.yaml title: AuDaGe Extension Schema description: Schema for extensions to AuDaGe. # Definitions $defs: exportColumn: type: object minProperties: 1 additionalProperties: false properties: const: $ref: "#/$defs/scalar" translate: $ref: "#/$defs/translate" formatNames: enum: - csv - xml - xlsx - xsy formatExtension: description: >- The file extension to save files with. The value of `name` is used if `extension` is not provided. type: string insertRow: description: >- A row of data to insert into the dataframe at the specified location. type: object required: - location - value additionalProperties: false properties: location: type: integer value: oneOf: - $ref: "#/$defs/scalar" - type: object - type: array operation: description: >- An operation to perform on a value to convert it from one format to another. oneOf: # Mapping - description: >- Map one set of values to another. Returns the value of the `default` property if no other key matches. For `rregexmapping`, the mapping keys are treated as regular expressions. type: object required: - operation - mapping minProperties: 2 additionalProperties: $ref: "#/$defs/scalar" properties: operation: enum: - mapping # Exact match - regexmapping # Search term is regex, keys are strings - rregexmapping # Search term is string, keys are regexes mapping: type: - string # Path to data file (YAML) - object # In-place mapping column: type: integer default: default: null $ref: "#/$defs/scalar" # Math, Logic & Predefined Functions - description: >- Mathematical operations and pre-defined functions to be applied to the value. type: object required: - operation additionalProperties: false properties: operation: enum: # a = value # b = arg, args[0], kwargs["b"], or 1/True* in order of priority. # * Unless specified otherwise. - not - and - or - xor - add # a + b - radd # b + a (for concatenating strings/iterables) - sub # a - b - rsub # b - a - mul # a * b - rmul # b * a (for repeating strings/iterables) - div # a / b - rdiv # b / a - mod # a % b - rmod # b % a - pow # a ** b, default b = 2 - exp # b ** a, default b = math.e - log # log_b(a), default b = math.e - rlog # log_a(b) - ceil # round up to integer - floor # round down to integer - round # round `a` to `b` decimal places, default b = 0 - rround # round `b` to `a` decimal places - address_iec_to_modbus - address_modbus_to_iec - type_iec_to_opcua - type_opcua_to_iec # format the value `a` according the format spec `b`, # default b = "d" - format - rformat # format the value `b` according the format spec `a` - index # return the index of the current row arg: description: One positional argument. $ref: "#/$defs/scalar" args: description: List of positional arguments. type: array items: $ref: "#/$defs/scalar" kwargs: description: Keyword arguments. type: object # Python function - description: >- A custom Python function that accepts either one scalar or iterable argument and returns a value. This option allows execution of arbitrary code and is disabled by default. type: object required: - operation - code additionalProperties: false properties: operation: const: python code: description: >- A Python function definition with zero or one arguments, a docstring, and at least one return statement. type: string pattern: 'def \w+\(\w*\)( -> \w+)?:\r?\n """.+?"""\r?\n(( )+.*?\r?\n)*?( )+return .+?\r?\n(( )+.*?\r?\n)*?' # Regex substitution - description: A regular expression substitution. type: object required: - operation - pattern additionalProperties: false properties: operation: enum: - match - rmatch - replace - rreplace pattern: type: string repl: type: string default: "" - description: >- A reverse regular expression substitution (the primary argument is the replacement rather than the original string). type: object required: - operation - pattern additionalProperties: false properties: operation: const: rregex pattern: type: string string: type: string operations: description: >- One or more operations to perform on a value. oneOf: - $ref: "#/$defs/operation" - type: array minItems: 1 items: $ref: "#/$defs/operation" scalar: anyOf: - type: boolean - type: integer - type: number - type: string - type: "null" translate: type: object required: - columns additionalProperties: false properties: columns: description: >- One or more column names from the source dataframe to use to generate the value for this column. oneOf: - type: string - type: array minItems: 1 items: type: string operations: description: >- Operations to perform on the raw value(s) to generate the value for this column. $ref: "#/$defs/operations" # Schema type: object required: - $schema - format - import - export additionalProperties: false properties: $schema: type: string format: description: >- The file format used for storing the data handled by this extension. oneOf: # Just the format name as a string. - $ref: "#/$defs/formatNames" # Just a `name` property. - type: object required: - name additionalProperties: false properties: name: description: >- The name of the file format. $ref: "#/$defs/formatNames" # CSV with options. - type: object required: - name properties: name: description: >- The file format used for storing the data handled by this extension. const: csv sep: description: >- The delimiter to be used in the CSV/delimited file. Default ",". type: string default: "," extension: $ref: "#/$defs/formatExtension" # XML (including XSY) with options. - type: object required: - name additionalProperties: false properties: name: description: >- The file format used for storing the data handled by this extension. enum: - xml - xsy # Remove when the Expander API is done. extension: $ref: "#/$defs/formatExtension" importStylesheets: description: >- One or more stylesheets used for importing data from an XML file. oneOf: - type: string - type: array items: type: string exportStylesheets: description: >- One or more stylesheets used for exporting data to an XML file. oneOf: - type: string - type: array items: type: string definitions: description: Additional files to import definitions from. oneOf: - type: string - type: array items: type: string import: description: >- Configuration for translating from AuDaGeFrame. type: object required: - columns additionalProperties: false properties: filter: description: >- Condition that must evaluate to True for the row to be included in the new dataframe. $ref: "#/$defs/translate" columns: description: >- Information for generating and validating the columns of this format. type: object minProperties: 1 additionalProperties: type: object additionalProperties: false properties: type: description: The data type required by this column. enum: - bool - float - int - str enum: description: Values allowed in this column. type: array minItems: 1 items: $ref: "#/$defs/scalar" parse: description: >- Operation(s) to process data for this column when reading from a file. $ref: "#/$defs/operations" const: $ref: "#/$defs/scalar" translate: description: >- Translate object for generating this column from an AuDaGeFrame. $ref: "#/$defs/translate" insertRows: description: Insert custom data into the dataframe. oneOf: - $ref: "#/$defs/insertRow" - type: array items: $ref: "#/$defs/insertRow" export: description: >- Translate objects for converting this format to the standard AuDaGeFrame columns. Must include translators for the four mandatory columns (name, type, address, comment). Translators for additional columns are allowed and optional. type: object required: - tagname - datatype - address - comment additionalProperties: $ref: "#/$defs/exportColumn" properties: tagname: $ref: "#/$defs/exportColumn" datatype: $ref: "#/$defs/exportColumn" address: $ref: "#/$defs/exportColumn" comment: $ref: "#/$defs/exportColumn"