summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-04-01 14:58:35 +0200
committerDominik Holland <dominik.holland@qt.io>2020-04-02 12:02:47 +0200
commitb7bc4dc7adb541c21c49305485d1dbaa83ac6812 (patch)
treeb59c2d9b3f4874c417afb3023ba5807e7ecd52ba
parenta051faa209cad89d16f7155198083e691f2ec779 (diff)
downloadqtivi-b7bc4dc7adb541c21c49305485d1dbaa83ac6812.tar.gz
ivigenerator: Improve support support for zoned default_value data
When creating the simulationData for structs the zoned values where ignored and always ended in qface errors. The filter function which generates the simulationData is now able to handle those zoned values as well and they are now also part of the autotests. Change-Id: Ie097b1cba2498d0d1e61fb0524548869c2c96502 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r--src/tools/ivigenerator/generator/filters.py15
-rw-r--r--tests/auto/core/ivigenerator/org.example.echo.yaml47
2 files changed, 48 insertions, 14 deletions
diff --git a/src/tools/ivigenerator/generator/filters.py b/src/tools/ivigenerator/generator/filters.py
index 737143c..b7ee9ff 100644
--- a/src/tools/ivigenerator/generator/filters.py
+++ b/src/tools/ivigenerator/generator/filters.py
@@ -437,8 +437,19 @@ def simulationData(module):
and p in property.tags['config_simulator']):
if property.name not in iData:
iData[property.name] = {}
- iData[property.name][p] = symbolToJson(property.tags['config_simulator'][p],
- property.type)
+ if p not in iData[property.name]:
+ iData[property.name][p] = {}
+ zones = iData.get('zones', None)
+ res = property.tags['config_simulator'][p]
+ if isinstance(res, dict) and zones:
+ for zone in zones:
+ if zone in res:
+ iData[property.name][p][zone] = symbolToJson(res[zone], property.type)
+ # Also check the entry for the general zone (=)
+ if "=" in res:
+ iData[property.name][p]["="] = symbolToJson(res["="], property.type)
+ else:
+ iData[property.name][p] = symbolToJson(res, property.type)
data[interface.name] = iData
return json.dumps(data, indent=' ')
diff --git a/tests/auto/core/ivigenerator/org.example.echo.yaml b/tests/auto/core/ivigenerator/org.example.echo.yaml
index 10953f0..d1750bf 100644
--- a/tests/auto/core/ivigenerator/org.example.echo.yaml
+++ b/tests/auto/core/ivigenerator/org.example.echo.yaml
@@ -1,15 +1,47 @@
+org.example.echo.EchoZoned#stringValue:
+ config_simulator:
+ default: "two"
+
+org.example.echo.Echo#intValue:
+ config_simulator:
+ default_value: 61
+ range_high: 150
+ range_low: 0
+
+org.example.echo.Echo#contact:
+ config_simulator:
+ zoned: true
+ default: [ "foo", 23, true, 1234 ]
+
+org.example.echo.Echo#combo:
+ config_simulator:
+ zoned: true
+ default: [ [ "foo", 23, true, 1234 ], WeekDay.Monday ]
+
+org.example.echo.Echo#intList:
+ config_simulator:
+ default: [1, 2, 3, 4]
+
+org.example.echo.Echo#comboList:
+ config_simulator:
+ default: [[ [ "foo", 23, true, 1234 ], WeekDay.Monday ], [ [ "bar", 21, false, "foo" ], WeekDay.Tuesday ]]
+
+org.example.echo.Echo#contactList:
+ config_simulator:
+ default: [[ "foo", 23, true, WeekDay.Monday ], [ "bar", 12, false, false ]]
+
org.example.echo.EchoZoned:
config_simulator:
zones: [ FrontLeft, FrontRight, Rear ]
org.example.echo.EchoZoned#stringValue:
config_simulator:
- default: "two"
+ default: { FrontLeft: "two", Rear: "one", =: "general" }
org.example.echo.EchoZoned#intValue:
config_simulator:
default: 11
- range: [10, 33]
+ range: { FrontLeft: [10, 33], Rear: [0, 11] }
org.example.echo.EchoZoned#zonedValue:
config_simulator:
@@ -35,16 +67,10 @@ org.example.echo.EchoZoned#rangedValueWithDefault:
range_high: 150
range_low: 0
-org.example.echo.Echo#intValue:
- config_simulator:
- default_value: 61
- range_high: 150
- range_low: 0
-
org.example.echo.EchoZoned#contact:
config_simulator:
zoned: true
- default: [ "foo", 23, true, 1234 ]
+ default: { FrontLeft: [ "foo", 23, true, 1234 ], Rear: [ "bar", 1, false, 3456 ] }
org.example.echo.EchoZoned#combo:
config_simulator:
@@ -59,6 +85,3 @@ org.example.echo.EchoZoned#comboList:
config_simulator:
default: [[ [ "foo", 23, true, 1234 ], WeekDay.Monday ], [ [ "bar", 21, false, "foo" ], WeekDay.Tuesday ]]
-org.example.echo.Echo#contactList:
- config_simulator:
- default: [[ "foo", 23, true, WeekDay.Monday ], [ "bar", 12, false, false ]]