Skip to content

Commit

Permalink
Adding --no-expand option
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Jaegervall <erik.jaegervall@se.bosch.com>
  • Loading branch information
erikbosch committed Sep 20, 2023
1 parent 7aec59a commit 854e499
Show file tree
Hide file tree
Showing 25 changed files with 1,398 additions and 10 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repos:
exclude_types: ["csv", "proto"]
- id: end-of-file-fixer
exclude_types: ["json", "proto"]
exclude: '.*.fidl'
- id: check-yaml
- id: check-added-large-files

Expand Down
14 changes: 12 additions & 2 deletions docs/vspec2x.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ The supported arguments might look like this

```
usage: vspec2x.py [-h] [-I dir] [-e EXTENDED_ATTRIBUTES] [-s] [--abort-on-unknown-attribute] [--abort-on-name-style]
[--format format] [--uuid] [--no-uuid] [-o overlays] [-u unit_file]
[--format format] [--uuid] [--no-uuid] [--no_expand] [-o overlays] [-u unit_file]
[-vt vspec_types_file] [-ot <types_output_file>]
[--json-all-extended-attributes] [--json-pretty]
[--yaml-all-extended-attributes] [-v version] [--all-idl-features] [--gqlfield GQLFIELD GQLFIELD]
<vspec_file> <output_file>
```

A common commandline to convert the VSS standard catalog into a JSON file is
An example command line to convert the VSS standard catalog into a JSON file is

```
% python vspec2x.py --format json -I ../spec -u ../spec/units.yaml ../spec/VehicleSignalSpecification.vspec vss.json
Expand Down Expand Up @@ -68,6 +68,12 @@ This is currently the default behavior. From VSS 4.0 `--no-uuid` will be the def
Request the exporter to not output uuids.
From VSS 4.0 this will be the default behavior and then this parameter will be deprecated.

### --no-expand

By default all tools expand instance information so that instance information like "Row1" become a branch just like
any other branch. If this argument is used and the exporter supports it no expansion will take place.
Instead instance information will be kept as additional information for the branch.

## Handling of Data Types

COVESA supports a number of pre-defined types, see [VSS documentation](https://covesa.github.io/vehicle_signal_specification/rule_set/data_entry/data_types/).
Expand Down Expand Up @@ -239,6 +245,10 @@ signal and not expand it further. If using an overlay to redefine a specific sig
(like `Vehicle.Cabin.Door.Row1.Left.IsChildLockActive`) has precedence over data specified for not yet extended signals
(like `Vehicle.Cabin.Door.IsChildLockActive`).

*Note: If using `--no-expand` together with overlays for specific instances then the result will be a combination*
*of expanded and unexpanded paths. For the example above `Vehicle.Cabin.Door.Row1.Left.NewSignal` will be expanded*
*but all other signals in `Vehicle.Cabin.Door` will remain unexpanded!*

It is possible to use `-o` multiple times, e.g.

```
Expand Down
3 changes: 3 additions & 0 deletions docs/vspec2x_arch.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This will result in that e.g. `Vehicle.Cabin.Door` is expanded to the following
* `Vehicle.Cabin.Door.Row2.Left`
* `Vehicle.Cabin.Door.Row2.Right`

For some exporters expansion can be suppressed by using the `--no_expand` option.
Then instance information will be represented by other means in the resulting output.

## Expansion and Overlays

Sometimes an overlay only refers to a signal in a specific branch, like:
Expand Down
10 changes: 10 additions & 0 deletions tests/vspec/test_no_expand/expected.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"Signal","Type","DataType","Deprecated","Unit","Min","Max","Desc","Comment","Allowed","Default","Instances"
"A","branch","","","","","","Branch A.","","",""
"A.B","branch","","","","","","Branch with explicit instances.","","","","[['Test1', 'Test2', 'Test3']]"
"A.B.S","sensor","int8","","km","","","Signal A.B.S.","","",""
"A.C","branch","","","","","","Branch with instance range.","","","","Test[1,4]"
"A.C.S","sensor","int8","","km","","","Signal A.C.S.","","",""
"A.D","branch","","","","","","Branch with complex instance combination.","","","","[['Test1'], 'Test[2,3]', ['Test4', 'Test5', 'Test6'], ['Test7', 'Test8', 'Test9', 'Test10'], ['Test11']]"
"A.D.S","sensor","int8","","km","","","Signal A.D.S.","","",""
"A.E","branch","","","","","","Branch without instances for reference.","","",""
"A.E.S","sensor","int8","","km","","","Signal A.E.S.","","",""
62 changes: 62 additions & 0 deletions tests/vspec/test_no_expand/expected.fidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

// Copyright (C) 2022, COVESA
//
// This program is licensed under the terms and conditions of the
// Mozilla Public License, version 2.0. The full text of the
// Mozilla Public License is at https://www.mozilla.org/MPL/2.0/

const UTF8String VSS_VERSION = "None"

struct SignalSpec {
UInt32 id
String name
String type
String description
String datatype
String unit
Double min
Double max
}

const SignalSpec[] signal_spec = [
{ name: "A.B",
type: "branch",
description: "Branch with explicit instances."
},
{ name: "A.B.S",
type: "sensor",
description: "Signal A.B.S.",
datatype: "int8",
unit: "km"
},
{ name: "A.C",
type: "branch",
description: "Branch with instance range."
},
{ name: "A.C.S",
type: "sensor",
description: "Signal A.C.S.",
datatype: "int8",
unit: "km"
},
{ name: "A.D",
type: "branch",
description: "Branch with complex instance combination."
},
{ name: "A.D.S",
type: "sensor",
description: "Signal A.D.S.",
datatype: "int8",
unit: "km"
},
{ name: "A.E",
type: "branch",
description: "Branch without instances for reference."
},
{ name: "A.E.S",
type: "sensor",
description: "Signal A.E.S.",
datatype: "int8",
unit: "km"
}
]
98 changes: 98 additions & 0 deletions tests/vspec/test_no_expand/expected.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
type Query {
vehicle(
"""VIN of the vehicle that you want to request data for."""
id: String!

"""
Filter data to only provide information that was sent from the vehicle after that timestamp.
"""
after: String
): A
}

"""Branch A."""
type A {
"""Branch with explicit instances."""
b: A_B

"""Branch with instance range."""
c: A_C

"""Branch with complex instance combination."""
d: A_D

"""Branch without instances for reference."""
e: A_E
}

"""Branch with explicit instances."""
type A_B {
"""Signal A.B.S."""
s: A_B_S
}

"""Signal A.B.S."""
type A_B_S {
"""Value: Signal A.B.S."""
value: Int

"""Timestamp: Signal A.B.S."""
timestamp: String

"""Unit of Signal A.B.S."""
unit: String
}

"""Branch with instance range."""
type A_C {
"""Signal A.C.S."""
s: A_C_S
}

"""Signal A.C.S."""
type A_C_S {
"""Value: Signal A.C.S."""
value: Int

"""Timestamp: Signal A.C.S."""
timestamp: String

"""Unit of Signal A.C.S."""
unit: String
}

"""Branch with complex instance combination."""
type A_D {
"""Signal A.D.S."""
s: A_D_S
}

"""Signal A.D.S."""
type A_D_S {
"""Value: Signal A.D.S."""
value: Int

"""Timestamp: Signal A.D.S."""
timestamp: String

"""Unit of Signal A.D.S."""
unit: String
}

"""Branch without instances for reference."""
type A_E {
"""Signal A.E.S."""
s: A_E_S
}

"""Signal A.E.S."""
type A_E_S {
"""Value: Signal A.E.S."""
value: Int

"""Timestamp: Signal A.E.S."""
timestamp: String

"""Unit of Signal A.E.S."""
unit: String
}
47 changes: 47 additions & 0 deletions tests/vspec/test_no_expand/expected.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module A
{
module B
{
struct S
{
octet value;
//const string unit="km";
//const string type ="sensor";
//const string description="Signal A.B.S.";
};
};

module C
{
struct S
{
octet value;
//const string unit="km";
//const string type ="sensor";
//const string description="Signal A.C.S.";
};
};

module D
{
struct S
{
octet value;
//const string unit="km";
//const string type ="sensor";
//const string description="Signal A.D.S.";
};
};

module E
{
struct S
{
octet value;
//const string unit="km";
//const string type ="sensor";
//const string description="Signal A.E.S.";
};
};

};
84 changes: 84 additions & 0 deletions tests/vspec/test_no_expand/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"A": {
"children": {
"B": {
"children": {
"S": {
"datatype": "int8",
"description": "Signal A.B.S.",
"type": "sensor",
"unit": "km"
}
},
"description": "Branch with explicit instances.",
"instances": [
[
"Test1",
"Test2",
"Test3"
]
],
"type": "branch"
},
"C": {
"children": {
"S": {
"datatype": "int8",
"description": "Signal A.C.S.",
"type": "sensor",
"unit": "km"
}
},
"description": "Branch with instance range.",
"instances": "Test[1,4]",
"type": "branch"
},
"D": {
"children": {
"S": {
"datatype": "int8",
"description": "Signal A.D.S.",
"type": "sensor",
"unit": "km"
}
},
"description": "Branch with complex instance combination.",
"instances": [
[
"Test1"
],
"Test[2,3]",
[
"Test4",
"Test5",
"Test6"
],
[
"Test7",
"Test8",
"Test9",
"Test10"
],
[
"Test11"
]
],
"type": "branch"
},
"E": {
"children": {
"S": {
"datatype": "int8",
"description": "Signal A.E.S.",
"type": "sensor",
"unit": "km"
}
},
"description": "Branch without instances for reference.",
"type": "branch"
}
},
"description": "Branch A.",
"type": "branch"
}
}
26 changes: 26 additions & 0 deletions tests/vspec/test_no_expand/expected.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";


message A {
AB B = 1;
AC C = 2;
AD D = 3;
AE E = 4;
}

message AB {
int32 S = 1;
}

message AC {
int32 S = 1;
}

message AD {
int32 S = 1;
}

message AE {
int32 S = 1;
}

Loading

0 comments on commit 854e499

Please sign in to comment.