Skip to content

Commit

Permalink
Removing uuid feature
Browse files Browse the repository at this point in the history
Note: Keeping UUID as bit in binary output
Signed-off-by: Erik Jaegervall <[email protected]>
  • Loading branch information
erikbosch committed Oct 3, 2024
1 parent 4e186f2 commit 9f38e48
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 173 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It includes changes that are included in released version, but also changes plan
*This document only contain changes introduced in VSS-Tools 3.0 or later!*


## Planned changes for VSS-Tools 6.0
## Implemented changes for VSS-Tools 6.0

### Change in UUID handling.

Expand All @@ -16,6 +16,8 @@ the legacy uuid functionality.

* The parameters `--uuid`/`--no-uuid` are now removed.

Columns (or similar) for UUID in generated output has also been removed.
An exception is binary output which still contain a byte for UUID, however always 0.

## VSS-Tools 5.0

Expand Down
4 changes: 2 additions & 2 deletions docs/ddsidl.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ Below elements are considered only if the switch `--all-idl-features` is supplie
### Input VSS block with "arraysize" attribute
| VSS | DDS-IDL |
|--------|----------------|
| <pre>Safety.SpeedLimit:<br> datatype : float[]<br> arraysize: 5<br> type: actuator<br> unit: m/s<br> description: Maximum allowed speed of the vehicle</pre> | <pre>struct SpeedLimit{<br>string uuid;<br>sequence&lt;float&gt; value;<br>}<br></pre> |
| <pre>Safety.SpeedLimit:<br> datatype : float[]<br> arraysize: 5<br> type: actuator<br> unit: m/s<br> description: Maximum allowed speed of the vehicle</pre> | <pre>struct SpeedLimit{<br>sequence&lt;float&gt; value;<br>}<br></pre> |
### Input VSS block with "allowed" attribute

| VSS | DDS-IDL |
|--------|----------------|
| <pre>Direction:<br> datatype:string<br> type: actuator<br> allowed: ['FORWARD','BACKWARD']<br> description: Driving direction of the vehicle</pre> | <pre>module Direction_M {<br>enum DirectionValues{FORWARD,BACKWARD};<br>};<br>struct Direction<br>{<br>string uuid;<br>DirectionValues value;<br>};</pre>
| <pre>Direction:<br> datatype:string<br> type: actuator<br> allowed: ['FORWARD','BACKWARD']<br> description: Driving direction of the vehicle</pre> | <pre>module Direction_M {<br>enum DirectionValues{FORWARD,BACKWARD};<br>};<br>struct Direction<br>{<br>DirectionValues value;<br>};</pre>

To comply with DDS-IDL rules and limitations in IDL compilers VSS string literals that start with a digit will get a `d` as prefix.

Expand Down
1 change: 0 additions & 1 deletion docs/id.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ identifiers.
│ [default: no-strict] │
│ --aborts -a [unknown-attribute|name-style] Abort on selected option. The '--strict'
│ option enables all of them. │
│ --uuid/--no-uuid Whether to add UUIDs. [default: no-uuid] │
│ --expand/--no-expand Whether to expand the tree. │
│ [default: expand] │
│ --overlays -l FILE Overlay files to apply on top of the vspec. │
Expand Down
17 changes: 0 additions & 17 deletions docs/vspec.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ Terminates parsing, when the name of a signal does not follow [VSS Naming Conven
### --strict/--no-strict
Enables `--aborts unknown-attribute` and `--aborts name-style`

### --uuid/--no-uuid
Request the exporter to output UUIDs. The UUID generated is an RFC 4122 Version 5 UUID created from the qualified name
of the node and the UUID of the namespace `vehicle_signal_specification`.

Note that not all exporters support that arugment

> [!WARNING]
> The UUID feature is deprecated and will be removed in VSS-tools 6.0.
> If you need identifiers consider using [vspec id exporter](id.md)
### --expand/--no-expand

By default all tools expand instance information so that instance information like "Row1" become a branch just like
Expand Down Expand Up @@ -358,7 +348,6 @@ Lets the exporter generate _all_ extended metadata attributes found in the model
| deprecation | x-deprecation |
| aggregate | x-aggregate |
| comment | x-comment |
| uuid | x-uuid |

Not that strict JSON schema validators might not accept jsonschemas with such extra, non-standard entries.

Expand All @@ -381,12 +370,6 @@ If the paramter is set it will pretty-print the JSON output, otherwise you will
### --extended-all-attributes
Lets the exporter generate _all_ extended metadata attributes found in the model. By default the exporter is generating only those given by the `-e`/`--extended-attributes` parameter.

## DDS-IDL exporter notes
The DDS-IDL exporter never generates uuid, i.e. the `--uuid` option has no effect.

## Graphql exporter notes
The Graphql exporter never generates uuid, i.e. the `--uuid` option has no effect.

### --all-idl-features
Will also generate non-payload const attributes such as unit/datatype. Default is not to generate them/comment them out because at least Cyclone DDS and FastDDS do not support const. For more information check the [DDS-IDL exporter docs](ddsidl.md).

Expand Down
2 changes: 0 additions & 2 deletions src/vss_tools/vspec/cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def validate_attribute(value):
show_choices=True,
)

uuid_opt = option("--uuid/--no-uuid", help="Whether to add UUIDs.", show_default=True, default=False)

expand_opt = option(
"--expand/--no-expand",
default=True,
Expand Down
5 changes: 0 additions & 5 deletions src/vss_tools/vspec/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def get_trees(
aborts: tuple[str, ...] = (),
strict: bool = False,
extended_attributes: tuple[str, ...] = (),
uuid: bool = False,
quantities: tuple[Path, ...] = (),
units: tuple[Path, ...] = (),
types: tuple[Path, ...] = (),
Expand Down Expand Up @@ -228,10 +227,6 @@ def get_trees(
if expand:
root.expand_instances()

if uuid:
log.warning("UUID support is deprecated and will be removed in VSS-tools 6.0")
root.add_uuids()

try:
root.resolve()
except ModelValidationException as e:
Expand Down
11 changes: 0 additions & 11 deletions src/vss_tools/vspec/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from __future__ import annotations

import re
import uuid
from copy import deepcopy
from typing import Any

Expand Down Expand Up @@ -63,7 +62,6 @@ class VSSNode(Node): # type: ignore[misc]
def __init__(self, name: str, fqn: str | None, data: dict[str, Any], **kwargs: Any) -> None:
super().__init__(name, **kwargs)
self.data = get_vss_raw(data, fqn)
self.uuid: str | None = None

def copy(self) -> VSSNode:
node = VSSNode(
Expand Down Expand Up @@ -142,13 +140,6 @@ def merge(self, other: VSSNode) -> None:
else:
child.parent = self

def add_uuids(self) -> None:
VSS_NAMESPACE = "vehicle_signal_specification"
namespace_uuid = uuid.uuid5(uuid.NAMESPACE_OID, VSS_NAMESPACE)
node: VSSNode
for node in PreOrderIter(self):
node.uuid = uuid.uuid5(namespace_uuid, node.get_fqn()).hex

def get_instance_nodes(self) -> tuple[VSSNode, ...]:
return findall(
self,
Expand Down Expand Up @@ -317,8 +308,6 @@ def as_flat_dict(self, with_extra_attributes: bool, extended_attributes: tuple[s
for node in PreOrderIter(self):
key = node.get_fqn()
data[key] = node.data.as_dict(with_extra_attributes, extended_attributes=extended_attributes)
if node.uuid:
data[key]["uuid"] = node.uuid
return data


Expand Down
50 changes: 25 additions & 25 deletions src/vss_tools/vspec/vssexporters/vss2apigear.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@

import abc
import typing
import yaml
from enum import Enum, Flag, auto
from math import inf
from pathlib import Path

import rich_click as click
import vss_tools.vspec.cli_options as clo
import yaml

from enum import Enum, Flag, auto
import vss_tools.vspec.cli_options as clo
from vss_tools import log
from vss_tools.vspec.tree import VSSNode
from vss_tools.vspec.model import VSSDataBranch, VSSDataStruct, VSSDataDatatype
from vss_tools.vspec.datatypes import Datatypes
from vss_tools.vspec.main import get_trees
from pathlib import Path
from math import inf
from vss_tools.vspec.model import VSSDataBranch, VSSDataDatatype, VSSDataStruct
from vss_tools.vspec.tree import VSSNode


class SolutionLayers(Flag):
Expand Down Expand Up @@ -62,7 +63,7 @@ def __init__(self, name: str):
self.variants: typing.List[tuple[str, int | None]] = []


class ApiGearType():
class ApiGearType:
def __init__(self, type: str):
super().__init__()

Expand All @@ -76,7 +77,7 @@ def array(cls, type: str):
return t


class ApiGearProperty():
class ApiGearProperty:
def __init__(self, type: ApiGearType):
super().__init__()

Expand Down Expand Up @@ -234,7 +235,7 @@ def export_node(node: VSSNode, module: ApiGearModule, interface: ApiGearInterfac

def export_data_type_node(node: VSSNode | None, module: ApiGearModule, structure: ApiGearStructure | None = None):
"""This method is used to traverse through the root VSS Data Types node to build
-> ApiGear equivalent string buffer and to serialize it accordingly into a module
-> ApiGear equivalent string buffer and to serialize it accordingly into a module
"""
if node is None:
return
Expand Down Expand Up @@ -271,7 +272,7 @@ def generate_module(directory: Path, module: ApiGearModule, module_name: str, mo
"schema": "apigear.module/1.0",
"name": module_name,
"version": "1.0",
"interfaces": []
"interfaces": [],
}

for interface in module.interfaces:
Expand Down Expand Up @@ -342,15 +343,16 @@ def generate_module(directory: Path, module: ApiGearModule, module_name: str, mo
log.info(f"Module file generated at location: {module_path}")


def generate_solution(directory: Path, module_filename: str, module_name: str,
layers: typing.Dict[SolutionLayers, Path]):
def generate_solution(
directory: Path, module_filename: str, module_name: str, layers: typing.Dict[SolutionLayers, Path]
):
log.debug("Generating solution file")

yaml_dict: typing.Dict[str, typing.Any] = {
"schema": "apigear.solution/1.0",
"name": module_name,
"version": "1.0",
"layers": []
"layers": [],
}
unreal: typing.Dict[str, typing.Any] = {
"name": "unreal",
Expand Down Expand Up @@ -410,10 +412,11 @@ def export_yaml(file_name, content_dict):
)


def export_apigear(directory: Path, root: VSSNode, data_type_tree: VSSNode | None,
layers: typing.Dict[SolutionLayers, Path]):
def export_apigear(
directory: Path, root: VSSNode, data_type_tree: VSSNode | None, layers: typing.Dict[SolutionLayers, Path]
):
"""This method is used to traverse through the root VSS node to build
-> ApiGear equivalent string buffer and to serialize it accordingly into a file
-> ApiGear equivalent string buffer and to serialize it accordingly into a file
"""
module = ApiGearModule()
module_name = root.name
Expand All @@ -423,7 +426,7 @@ def export_apigear(directory: Path, root: VSSNode, data_type_tree: VSSNode | Non
log.debug(f"Module name: {module_name}")
log.debug(f"Module filename: {module_filename}")

if (not layers):
if not layers:
layers = {SolutionLayers.CPP: Path("./cppservice")}
log.warning(f"No layers provided! Defaulting to CPP in {layers[SolutionLayers.CPP]}")

Expand All @@ -442,7 +445,6 @@ def export_apigear(directory: Path, root: VSSNode, data_type_tree: VSSNode | Non
@clo.extended_attributes_opt
@clo.strict_opt
@clo.aborts_opt
@clo.uuid_opt
@clo.overlays_opt
@clo.quantities_opt
@clo.units_opt
Expand Down Expand Up @@ -479,7 +481,6 @@ def cli(
extended_attributes: tuple[str],
strict: bool,
aborts: tuple[str],
uuid: bool,
overlays: tuple[Path],
quantities: tuple[Path],
units: tuple[Path],
Expand All @@ -499,7 +500,6 @@ def cli(
aborts=aborts,
strict=strict,
extended_attributes=extended_attributes,
uuid=uuid,
quantities=quantities,
units=units,
types=types,
Expand All @@ -512,13 +512,13 @@ def cli(
output_dir.mkdir(exist_ok=True, parents=True)

layers = {}
if (apigear_template_unreal_path is not None):
if apigear_template_unreal_path is not None:
layers[SolutionLayers.UNREAL] = apigear_template_unreal_path
if (apigear_template_cpp_path is not None):
if apigear_template_cpp_path is not None:
layers[SolutionLayers.CPP] = apigear_template_cpp_path
if (apigear_template_qt5_path is not None):
if apigear_template_qt5_path is not None:
layers[SolutionLayers.QT5] = apigear_template_qt5_path
if (apigear_template_qt6_path is not None):
if apigear_template_qt6_path is not None:
layers[SolutionLayers.QT6] = apigear_template_qt6_path

export_apigear(output_dir, tree, data_type_tree, layers)
18 changes: 6 additions & 12 deletions src/vss_tools/vspec/vssexporters/vss2binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# The order of fields (where each field is composed of
# fieldlength + fielddata) is:
#
# name (vsspath), type, uuid, description, datatype, min, max, unit,
# name (vsspath), type, description, datatype, min, max, unit,
# allowed, default, validate
#
# if a field is not present (e.g. min, max, unit, allowed, default, validate),
Expand Down Expand Up @@ -73,16 +73,13 @@ def create_l16v_string(s: str) -> bytes:
return pack


def export_node(node: VSSNode, generate_uuid, f: BinaryIO):
def export_node(node: VSSNode, f: BinaryIO):
data = node.get_vss_data().as_dict()

f.write(create_l8v_string(node.name))
f.write(create_l8v_string(data.get("type", "")))
if node.uuid is None:
log.debug(("No UUID for node %s", node.name))
f.write(struct.pack("B", 0))
else:
f.write(create_l8v_string(node.uuid))
# Keeping UUID field in output for now (always 0)
f.write(struct.pack("B", 0))

f.write(create_l16v_string(data.get("description", "")))
f.write(create_l8v_string(data.get("datatype", "")))
Expand All @@ -101,7 +98,7 @@ def export_node(node: VSSNode, generate_uuid, f: BinaryIO):
f.write(struct.pack("B", len(node.children)))

for child in node.children:
export_node(child, generate_uuid, f)
export_node(child, f)


@click.command()
Expand All @@ -111,7 +108,6 @@ def export_node(node: VSSNode, generate_uuid, f: BinaryIO):
@clo.extended_attributes_opt
@clo.strict_opt
@clo.aborts_opt
@clo.uuid_opt
@clo.overlays_opt
@clo.quantities_opt
@clo.units_opt
Expand All @@ -122,7 +118,6 @@ def cli(
extended_attributes: tuple[str],
strict: bool,
aborts: tuple[str],
uuid: bool,
overlays: tuple[Path],
quantities: tuple[Path],
units: tuple[Path],
Expand All @@ -137,12 +132,11 @@ def cli(
aborts=aborts,
strict=strict,
extended_attributes=extended_attributes,
uuid=uuid,
quantities=quantities,
units=units,
overlays=overlays,
)
log.info("Generating binary output...")
with open(str(output), "wb") as f:
export_node(tree, uuid, f)
export_node(tree, f)
log.info("Binary output generated in %s", output)
Loading

0 comments on commit 9f38e48

Please sign in to comment.