AARCHMRS Schema 2.7.4

↚ Home

Fields.ConditionalField object

The ConditionalField is used to specify a field which has different properties under different conditions.

object

Properties Type Description
_meta Meta
See Meta for more information.
_type
Enum
Fields.ConditionalField
description Traits.HasDescription

Provides the description of this conditional field.

See properties.description in Fields.Field for more information.
display
  • string
  • null
See properties.display in Fields.Field for more information.
fields
array [
]

A list of objects with a field and condition, where the ConditionalField can resolve to one of the fields. Each field is accompanied by a condition to indicate when this field applies.

The objects are resolved sequentially, meaning the ConditionalField resolves to the first field with a condition that evaluates True. If all conditions are False then the default reserved_type property is used as a shorthand.

If a condition is null, then that Field will be considered the default.

WARNING: Since conditions are resolved sequentially the default (null) condition should be last.

Also note that the rangeset of the individual fields should be set relative the ConditionalField rangeset. For example, if the ConditionalField's Rangeset is 30:25, then all internal fields should have ranges 5:0.

Further note that a ConditionalField could resolve to a field or a list of fields (limited to all field types except Vectors and Arrays).

This is primarily to allow an Array or Vector to be replaced by a the list of fields they create when expanded.

Examples
[
    {
        "condition": {
            "_type": "AST.Function", 
            "arguments": [
                {
                    "_type": "AST.Identifier", 
                    "value": "MYFEATURE"
                }
            ], 
            "name": "IsFeatureImplemented"
        }, 
        "field": {
            "_type": "Fields.Field", 
            "name": "F1", 
            "rangeset": [
                {
                    "_type": "Range", 
                    "start": 0, 
                    "width": 2
                }
            ], 
            "description": {
                "_type": "Description", 
                "after": null, 
                "before": "A field that exist when MYFEATURE is implemented"
            }, 
            "values": {
                "_type": "Valuesets.Values", 
                "values": [
                    {
                        "_type": "Values.Value", 
                        "meaning": "First value", 
                        "value": "'00'"
                    }, 
                    {
                        "_type": "Values.Value", 
                        "meaning": "Second value", 
                        "value": "'10'"
                    }
                ]
            }
        }
    }, 
    {
        "condition": null, 
        "field": {
            "_type": "Fields.Field", 
            "name": "F1", 
            "rangeset": [
                {
                    "_type": "Range", 
                    "start": 0, 
                    "width": 2
                }
            ], 
            "description": {
                "_type": "Description", 
                "after": null, 
                "before": [
                    [
                        "A field that exists when all previous conditions fail. ", 
                        "In this case, this field exists when ", 
                        "MYFEATURE is not implemented"
                    ]
                ]
            }, 
            "values": {
                "_type": "Valuesets.Values", 
                "values": [
                    {
                        "_type": "Values.Value", 
                        "meaning": "First value", 
                        "value": "'00'"
                    }, 
                    {
                        "_type": "Values.Value", 
                        "meaning": "Second value", 
                        "value": "'10'"
                    }
                ]
            }
        }
    }
]
name
  • string
  • null
See properties.name in Fields.Field for more information.
rangeset Rangeset
See properties.rangeset in Fields.Field for more information.
reservedtype Enums.ReservedTypes

If no default conditional field is represented, then a Reserved field with the value of reservedtype is used to define the default case.

See Enums.ReservedTypes for more information.
resets FieldResets
See properties.resets in Fields.Field for more information.
volatile
  • boolean
See properties.volatile in Fields.Field for more information.
Additional Properties
Not Allowed
◊ Required
Properties marked with ◊ are required properties.
Examples
{
    "_type": "Fields.ConditionalField", 
    "name": "FOO", 
    "rangeset": [
        {
            "_type": "Range", 
            "start": 10, 
            "width": 11
        }
    ], 
    "description": {
        "_type": "Description", 
        "after": null, 
        "before": [
            [
                "A conditional field, where the field F1 (when MYFEATURE is implemented)", 
                "is located at 11:10 (absolute position), and bits 20:12 are RES0 due", 
                "to the reservedtype property."
            ], 
            [
                "When MYFEATURE is not implemented then bits 20:10 are RES0 which comes", 
                "from the reservedtype"
            ]
        ]
    }, 
    "fields": [
        {
            "condition": {
                "_type": "AST.Function", 
                "arguments": [
                    {
                        "_type": "AST.Identifier", 
                        "value": "MYFEATURE"
                    }
                ], 
                "name": "IsFeatureImplemented"
            }, 
            "field": {
                "_type": "Fields.Field", 
                "name": "F1", 
                "rangeset": [
                    {
                        "_type": "Range", 
                        "start": 0, 
                        "width": 2
                    }
                ], 
                "description": {
                    "_type": "Description", 
                    "after": null, 
                    "before": "A field that exists when MYFEATURE is implemented"
                }, 
                "values": {
                    "_type": "Valuesets.Values", 
                    "values": [
                        {
                            "_type": "Values.Value", 
                            "meaning": "First value", 
                            "value": "'00'"
                        }, 
                        {
                            "_type": "Values.Value", 
                            "meaning": "Second value", 
                            "value": "'10'"
                        }
                    ]
                }
            }
        }
    ], 
    "reservedtype": "RES0"
}
{
    "_type": "Fields.ConditionalField", 
    "name": "BAR", 
    "rangeset": [
        {
            "_type": "Range", 
            "start": 20, 
            "width": 10
        }
    ], 
    "description": {
        "_type": "Description", 
        "after": null, 
        "before": [
            [
                "A conditional field, which resolves to a list of fields.", 
                "The field F1's rangeset will change to 23:20 and the field F2's rangeset", 
                "will change to 29:26 after the conditional field is resolved.", 
                "The remaning rangeset of 25:24, will be filled with RES0."
            ]
        ]
    }, 
    "fields": [
        {
            "condition": {
                "_type": "AST.Bool", 
                "value": true
            }, 
            "field": [
                {
                    "_type": "Fields.Field", 
                    "name": "F1", 
                    "rangeset": [
                        {
                            "_type": "Range", 
                            "start": 0, 
                            "width": 4
                        }
                    ], 
                    "description": {
                        "_type": "Description", 
                        "after": null, 
                        "before": "After resolving, this field's rangeset becomes 23:20"
                    }, 
                    "values": {
                        "_type": "Valuesets.Values", 
                        "values": [
                            {
                                "_type": "Values.Value", 
                                "meaning": "First value", 
                                "value": "'00'"
                            }, 
                            {
                                "_type": "Values.Value", 
                                "meaning": "Second value", 
                                "value": "'10'"
                            }
                        ]
                    }
                }, 
                {
                    "_type": "Fields.Field", 
                    "name": "F2", 
                    "rangeset": [
                        {
                            "_type": "Range", 
                            "start": 6, 
                            "width": 4
                        }
                    ], 
                    "description": {
                        "_type": "Description", 
                        "after": null, 
                        "before": "After resolving, this field's rangeset becomes 29:26"
                    }, 
                    "values": {
                        "_type": "Valuesets.Values", 
                        "values": [
                            {
                                "_type": "Values.Value", 
                                "meaning": "First value", 
                                "value": "'00'"
                            }, 
                            {
                                "_type": "Values.Value", 
                                "meaning": "Second value", 
                                "value": "'10'"
                            }
                        ]
                    }
                }
            ]
        }
    ], 
    "reservedtype": "RES0"
}

Schema http://json-schema.org/draft-04/schema#

{
  "info": [
    "The ConditionalField is used to specify a field which has different properties under different conditions."
  ],
  "properties": {
    "_meta": {
      "$ref": "../Meta.json"
    },
    "_type": {
      "enum": [
        "Fields.ConditionalField"
      ]
    },
    "description": {
      "info": [
        "Provides the description of this conditional field."
      ],
      "$ref": "../Traits/HasDescription.json#/definitions/description",
      "see": "../Fields/Field.json"
    },
    "display": {
      "see": "../Fields/Field.json",
      "type": [
        "string",
        "null"
      ]
    },
    "fields": {
      "additionalItems": false,
      "info": [
        "A list of objects with a field and condition, where the ConditionalField can resolve to one of the fields. Each field is accompanied by a condition to indicate when this field applies.",
        "The objects are resolved sequentially, meaning the ConditionalField resolves to the first field with a condition that evaluates True. If all conditions are False then the default reserved_type property is used as a shorthand.",
        "If a condition is null, then that Field will be considered the default.",
        "**WARNING**: Since conditions are resolved sequentially the default (null) condition should be last.",
        [
          "Also note that the rangeset of the individual fields should be set relative ",
          "the `ConditionalField` rangeset. For example, if the ConditionalField's ",
          "[Rangeset](../Rangeset_schema.html) is `30:25`, then all internal fields should ",
          "have ranges `5:0`."
        ],
        "Further note that a ConditionalField could resolve to a field or a list of fields (limited to all field types except Vectors and Arrays).",
        "This is primarily to allow an Array or Vector to be replaced by a the list of fields they create when expanded."
      ],
      "items": {
        "additionalProperties": false,
        "properties": {
          "condition": {
            "$ref": "../Traits/HasCondition.json#/definitions/condition"
          },
          "field": {
            "oneOf": [
              {
                "$ref": "Field.json"
              },
              {
                "$ref": "ImplementationDefined.json"
              },
              {
                "$ref": "Reserved.json"
              },
              {
                "$ref": "ReservedInternal.json"
              },
              {
                "$ref": "Array.json"
              },
              {
                "$ref": "Dynamic.json"
              },
              {
                "$ref": "Vector.json"
              },
              {
                "$ref": "ConstantField.json"
              },
              {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "$ref": "Field.json"
                    },
                    {
                      "$ref": "ImplementationDefined.json"
                    },
                    {
                      "$ref": "Reserved.json"
                    },
                    {
                      "$ref": "ReservedInternal.json"
                    },
                    {
                      "$ref": "Dynamic.json"
                    },
                    {
                      "$ref": "ConstantField.json"
                    }
                  ]
                },
                "minItems": 1
              }
            ]
          }
        },
        "required": [
          "condition",
          "field"
        ],
        "type": "object"
      },
      "type": "array",
      "examples": [
        [
          {
            "condition": {
              "_type": "AST.Function",
              "arguments": [
                {
                  "_type": "AST.Identifier",
                  "value": "MYFEATURE"
                }
              ],
              "name": "IsFeatureImplemented"
            },
            "field": {
              "_type": "Fields.Field",
              "name": "F1",
              "rangeset": [
                {
                  "_type": "Range",
                  "start": 0,
                  "width": 2
                }
              ],
              "description": {
                "_type": "Description",
                "after": null,
                "before": "A field that exist when MYFEATURE is implemented"
              },
              "values": {
                "_type": "Valuesets.Values",
                "values": [
                  {
                    "_type": "Values.Value",
                    "meaning": "First value",
                    "value": "'00'"
                  },
                  {
                    "_type": "Values.Value",
                    "meaning": "Second value",
                    "value": "'10'"
                  }
                ]
              }
            }
          },
          {
            "condition": null,
            "field": {
              "_type": "Fields.Field",
              "name": "F1",
              "rangeset": [
                {
                  "_type": "Range",
                  "start": 0,
                  "width": 2
                }
              ],
              "description": {
                "_type": "Description",
                "after": null,
                "before": [
                  [
                    "A field that exists when all previous conditions fail. ",
                    "In this case, this field exists when ",
                    "MYFEATURE is not implemented"
                  ]
                ]
              },
              "values": {
                "_type": "Valuesets.Values",
                "values": [
                  {
                    "_type": "Values.Value",
                    "meaning": "First value",
                    "value": "'00'"
                  },
                  {
                    "_type": "Values.Value",
                    "meaning": "Second value",
                    "value": "'10'"
                  }
                ]
              }
            }
          }
        ]
      ]
    },
    "volatile": {
      "see": "../Fields/Field.json",
      "type": "boolean"
    },
    "name": {
      "see": "../Fields/Field.json",
      "type": [
        "string",
        "null"
      ]
    },
    "rangeset": {
      "see": "../Fields/Field.json",
      "$ref": "../Rangeset.json"
    },
    "reservedtype": {
      "info": [
        [
          "If no default conditional field is represented, then a Reserved field with the ",
          "value of `reservedtype` is used to define the default case."
        ]
      ],
      "$ref": "../Enums/ReservedTypes.json"
    },
    "resets": {
      "see": "../Fields/Field.json",
      "$ref": "../FieldResets.json"
    }
  },
  "required": [
    "name",
    "rangeset",
    "fields",
    "reservedtype"
  ],
  "title": "ConditionalField",
  "type": "object",
  "examples": [
    {
      "_type": "Fields.ConditionalField",
      "name": "FOO",
      "rangeset": [
        {
          "_type": "Range",
          "start": 10,
          "width": 11
        }
      ],
      "description": {
        "_type": "Description",
        "after": null,
        "before": [
          [
            "A conditional field, where the field F1 (when MYFEATURE is implemented)",
            "is located at 11:10 (absolute position), and bits 20:12 are RES0 due",
            "to the reservedtype property."
          ],
          [
            "When MYFEATURE is not implemented then bits 20:10 are RES0 which comes",
            "from the reservedtype"
          ]
        ]
      },
      "fields": [
        {
          "condition": {
            "_type": "AST.Function",
            "arguments": [
              {
                "_type": "AST.Identifier",
                "value": "MYFEATURE"
              }
            ],
            "name": "IsFeatureImplemented"
          },
          "field": {
            "_type": "Fields.Field",
            "name": "F1",
            "rangeset": [
              {
                "_type": "Range",
                "start": 0,
                "width": 2
              }
            ],
            "description": {
              "_type": "Description",
              "after": null,
              "before": "A field that exists when MYFEATURE is implemented"
            },
            "values": {
              "_type": "Valuesets.Values",
              "values": [
                {
                  "_type": "Values.Value",
                  "meaning": "First value",
                  "value": "'00'"
                },
                {
                  "_type": "Values.Value",
                  "meaning": "Second value",
                  "value": "'10'"
                }
              ]
            }
          }
        }
      ],
      "reservedtype": "RES0"
    },
    {
      "_type": "Fields.ConditionalField",
      "name": "BAR",
      "rangeset": [
        {
          "_type": "Range",
          "start": 20,
          "width": 10
        }
      ],
      "description": {
        "_type": "Description",
        "after": null,
        "before": [
          [
            "A conditional field, which resolves to a list of fields.",
            "The field F1's rangeset will change to 23:20 and the field F2's rangeset",
            "will change to 29:26 after the conditional field is resolved.",
            "The remaning rangeset of 25:24, will be filled with RES0."
          ]
        ]
      },
      "fields": [
        {
          "condition": {
            "_type": "AST.Bool",
            "value": true
          },
          "field": [
            {
              "_type": "Fields.Field",
              "name": "F1",
              "rangeset": [
                {
                  "_type": "Range",
                  "start": 0,
                  "width": 4
                }
              ],
              "description": {
                "_type": "Description",
                "after": null,
                "before": "After resolving, this field's rangeset becomes 23:20"
              },
              "values": {
                "_type": "Valuesets.Values",
                "values": [
                  {
                    "_type": "Values.Value",
                    "meaning": "First value",
                    "value": "'00'"
                  },
                  {
                    "_type": "Values.Value",
                    "meaning": "Second value",
                    "value": "'10'"
                  }
                ]
              }
            },
            {
              "_type": "Fields.Field",
              "name": "F2",
              "rangeset": [
                {
                  "_type": "Range",
                  "start": 6,
                  "width": 4
                }
              ],
              "description": {
                "_type": "Description",
                "after": null,
                "before": "After resolving, this field's rangeset becomes 29:26"
              },
              "values": {
                "_type": "Valuesets.Values",
                "values": [
                  {
                    "_type": "Values.Value",
                    "meaning": "First value",
                    "value": "'00'"
                  },
                  {
                    "_type": "Values.Value",
                    "meaning": "Second value",
                    "value": "'10'"
                  }
                ]
              }
            }
          ]
        }
      ],
      "reservedtype": "RES0"
    }
  ],
  "$schema": "http://json-schema.org/draft-04/schema#",
  "additionalProperties": false
}