From 327f98f56de99358f9a1b37d52626d31f18c0d86 Mon Sep 17 00:00:00 2001 From: Karl Schrab Date: Wed, 24 Feb 2021 11:45:36 +0100 Subject: [PATCH] Completed JSON Schema for scenario_config.json (#47) * completed scheme for scenario_config.json Signed-off-by: Karl Schrab * define config file in separate file (website) rather than in the title of the Scheme Signed-off-by: Karl Schrab --- .../src/main/resources/CCellScheme.json | 2 +- .../src/main/resources/CNetworkScheme.json | 2 +- .../src/main/resources/CRegionScheme.json | 2 +- .../main/resources/CEnvironmentScheme.json | 2 +- .../resources/CMappingAmbassadorScheme.json | 6 +- .../src/main/resources/CSnsScheme.json | 2 +- .../src/main/resources/CSumoScheme.json | 2 +- .../rti/time/SequentialTimeManagement.java | 4 +- .../src/main/resources/CScenarioScheme.json | 186 ++++++++++++------ 9 files changed, 133 insertions(+), 75 deletions(-) diff --git a/fed/mosaic-cell/src/main/resources/CCellScheme.json b/fed/mosaic-cell/src/main/resources/CCellScheme.json index 5415fa946..d788f6f38 100644 --- a/fed/mosaic-cell/src/main/resources/CCellScheme.json +++ b/fed/mosaic-cell/src/main/resources/CCellScheme.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "CCellScheme", + "title": "Cell", "description": "This schema describes the JSON file structure for the cell configuration, which provides general configuration for the ambassador, such as paths to the regions and network configuration files.", "type": "object", "properties": { diff --git a/fed/mosaic-cell/src/main/resources/CNetworkScheme.json b/fed/mosaic-cell/src/main/resources/CNetworkScheme.json index 8537a253b..a33d6c65c 100644 --- a/fed/mosaic-cell/src/main/resources/CNetworkScheme.json +++ b/fed/mosaic-cell/src/main/resources/CNetworkScheme.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "CNetworkScheme", + "title": "Network", "description": "Schema describing the JSON file structure for the network configuration. It is is used to define the properties of the global network. If defined as a number, then the default unit is Gb. Alternatively this can be defined as a string to specify the unit of measurement (e.g. '3 MB').", "type": "object", "properties": { diff --git a/fed/mosaic-cell/src/main/resources/CRegionScheme.json b/fed/mosaic-cell/src/main/resources/CRegionScheme.json index 3ad94879e..f03952854 100644 --- a/fed/mosaic-cell/src/main/resources/CRegionScheme.json +++ b/fed/mosaic-cell/src/main/resources/CRegionScheme.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "CRegionSchema", + "title": "Regions", "description": "Schema describing the JSON file structure for the regional networks configuration. It is is used to extend the network with regional information, which enables the emulation of mobile networks. If configured very granular, these regions can reflect cells as used in the real world. Though for most use-cases it is sufficient to approximate the behaviour by defining larger regions.", "type": "object", "properties": { diff --git a/fed/mosaic-environment/src/main/resources/CEnvironmentScheme.json b/fed/mosaic-environment/src/main/resources/CEnvironmentScheme.json index 1c38f5450..27c05774a 100644 --- a/fed/mosaic-environment/src/main/resources/CEnvironmentScheme.json +++ b/fed/mosaic-environment/src/main/resources/CEnvironmentScheme.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "CEnvironmentScheme", + "title": "Environment Events", "description": "Schema describing the JSON file structure for the environment configuration. It is is used to define which events are evaluated by the simulator. Entities entering the areas of the events, are notified by the 'EnvironmentSensorUpdates' interaction", "type": "object", "properties": { diff --git a/fed/mosaic-mapping/src/main/resources/CMappingAmbassadorScheme.json b/fed/mosaic-mapping/src/main/resources/CMappingAmbassadorScheme.json index 250ac52b8..f8c8f49a5 100644 --- a/fed/mosaic-mapping/src/main/resources/CMappingAmbassadorScheme.json +++ b/fed/mosaic-mapping/src/main/resources/CMappingAmbassadorScheme.json @@ -1,11 +1,11 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "CMappingAmbassadorScheme", + "title": "Mapping", "description": "This schema describes the JSON file structure for the mapping configuration, which is used to define simulation entities.", "type": "object", "properties": { "config": { - "description": "Object to deifne additional configuration options for the mapping.", + "description": "Object to define additional configuration options for the mapping.", "$ref": "#/definitions/config" }, "prototypes": { @@ -529,7 +529,7 @@ "required": [ "radius", "center" ] }, "geoPoint": { - "title": "geoPoint", + "title": "GeoPoint", "description": "Object to define geographical point coordinates.", "type": "object", "properties": { diff --git a/fed/mosaic-sns/src/main/resources/CSnsScheme.json b/fed/mosaic-sns/src/main/resources/CSnsScheme.json index 3bb2e4270..fc88ccec8 100644 --- a/fed/mosaic-sns/src/main/resources/CSnsScheme.json +++ b/fed/mosaic-sns/src/main/resources/CSnsScheme.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "CSnsScheme", + "title": "SNS", "description": "Schema describing the JSON file structure for the sns configuration.", "type": "object", "properties": { diff --git a/fed/mosaic-sumo/src/main/resources/CSumoScheme.json b/fed/mosaic-sumo/src/main/resources/CSumoScheme.json index 0716747de..0362aad8f 100644 --- a/fed/mosaic-sumo/src/main/resources/CSumoScheme.json +++ b/fed/mosaic-sumo/src/main/resources/CSumoScheme.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "title": "CSumoScheme", + "title": "SUMO", "description": "Schema describing the JSON file structure for the SUMO configuration.", "properties": { "updateInterval": { diff --git a/rti/mosaic-rti-core/src/main/java/org/eclipse/mosaic/rti/time/SequentialTimeManagement.java b/rti/mosaic-rti-core/src/main/java/org/eclipse/mosaic/rti/time/SequentialTimeManagement.java index 149c0fdba..a1a4df13b 100644 --- a/rti/mosaic-rti-core/src/main/java/org/eclipse/mosaic/rti/time/SequentialTimeManagement.java +++ b/rti/mosaic-rti-core/src/main/java/org/eclipse/mosaic/rti/time/SequentialTimeManagement.java @@ -66,7 +66,9 @@ public void runSimulation() throws InternalFederateException, IllegalValueExcept while (this.time < getEndTime()) { // sync with real time - realtimeSync.sync(this.time); + if (this.time > 0) { + realtimeSync.sync(this.time); + } // remove all events at the head of the queue that are created by the same federate synchronized (this.events) { diff --git a/rti/mosaic-starter/src/main/resources/CScenarioScheme.json b/rti/mosaic-starter/src/main/resources/CScenarioScheme.json index 0704c0024..1b83640e3 100644 --- a/rti/mosaic-starter/src/main/resources/CScenarioScheme.json +++ b/rti/mosaic-starter/src/main/resources/CScenarioScheme.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema", - "$id": "http://example.com/example.json", + "title": "Scenario", + "description": "Schema describing the JSON file structure for the main scenario configuration.", "type": "object", "required": [ "simulation", @@ -8,7 +9,21 @@ ], "properties": { "simulation": { + "$ref": "#/definitions/simulation" + }, + "federates": { + "description": "Defines the list of ambassadors/simulators which are used by the simulation. For each simulator (referenced by its id) a boolean value must be given, which enables or disables the simulator.", "type": "object", + "additionalProperties": { + "type": "boolean" + } + } + }, + "definitions": { + "simulation": { + "type": "object", + "title": "simulation", + "description": "Basic properties of the simulation scenario.", "required": [ "id", "duration", @@ -16,87 +31,128 @@ ], "properties": { "id": { + "description": "The id or name of the simulation scenario.", "type": "string" }, "duration": { + "description": "The duration of the simulation. If defined as a number, then the unit to be applied is ns. Alternatively this can be defined as a string to include the unit of measurement (e.g. '300 s')", "anyOf": [ { "type": "string", "maxLength": 20 }, { "type": "number", "minimum": 0 } ] }, "randomSeed": { - "type": "integer" + "type": "integer", + "description": "The random seed to apply. This influences the application mapping, the communication models, and any use of randomness inside of applications. If not set, the random number generator will be initialized without a seed resulting in different results for each run. Note that several other simulators (e.g. SUMO) come with their own random number generators which are not affected by this property." }, "projection": { - "type": "object", - "required": [ - "centerCoordinates", - "cartesianOffset" - ], - "properties": { - "centerCoordinates": { - "type": "object", - "required": [ - "latitude", - "longitude" - ], - "properties": { - "latitude": { "type": "number" }, - "longitude": { "type": "number" } - } - }, - "cartesianOffset": { - "type": "object", - "required": [ - "x", - "y" - ], - "properties": { - "x": { "type": "number" }, - "y": { "type": "number" } - } - } - } + "$ref": "#/definitions/projection" }, "network": { - "title": "The network schema", - "properties": { - "netMask": { - "type": "string", - "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" - }, - "vehicleNet": { - "type": "string", - "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" - }, - "rsuNet": { - "type": "string", - "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" - }, - "tlNet": { - "type": "string", - "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" - }, - "csNet": { - "type": "string", - "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" - }, - "serverNet": { - "type": "string", - "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" - }, - "tmcNet": { - "type": "string", - "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" - } - } + "$ref": "#/definitions/network" } } }, - "federates": { + "projection" : { + "type": "object", + "title": "Projection", + "description": "Configures the projection used to transform geographical coordinates (WGS84) to local cartesian coordinates used by various simulators (e.g. SUMO, or OMNeT++). The projection is based on UTM and must be adapted to the used traffic network.", + "required": [ + "centerCoordinates", + "cartesianOffset" + ], + "properties": { + "centerCoordinates": { + "description": "Geographic coordinates of the rough center of the map / playground used in this scenario. This is just used to determine the UTM zone used for any further projection.", + "$ref": "#/definitions/geoPoint" + }, + "cartesianOffset": { + "description": "A cartesian offset which is added to the UTM transformation. In most cases, this must be the exact offset which can be found in the `location.netOffset` of the `*.net.xml` of the scenario.", + "$ref": "#/definitions/cartesianOffset" + } + } + }, + "network" : { + "title": "Network Addressing", + "type": "object", + "default": "default network", + "description": "Defines the subnets (e.g. 10.0.0.0) used for generating IP addresses for each unit in the simulation. Each type of unit is configured with its own subnet. A default configuration is used, when left out from the configuration.", + "properties": { + "netMask": { + "description": "The net mask used for IP generation.", + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", + "default": "255.0.0.0" + }, + "vehicleNet": { + "description": "The subnet used for assigning IPs to vehicles.", + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", + "default": "10.0.0.0" + }, + "rsuNet": { + "description": "The subnet used for assigning IPs to road side units.", + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", + "default": "11.0.0.0" + }, + "tlNet": { + "description": "The subnet used for assigning IPs to traffic lights.", + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", + "default": "12.0.0.0" + }, + "csNet": { + "description": "The subnet used for assigning IPs to charging stations.", + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", + "default": "13.0.0.0" + }, + "serverNet": { + "description": "The subnet used for assigning IPs to servers.", + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", + "default": "14.0.0.0" + }, + "tmcNet": { + "description": "The subnet used for assigning IPs to traffic management centers.", + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", + "default": "15.0.0.0" + } + } + }, + "geoPoint": { + "title": "GeoPoint", + "description": "Geographic coordinates of the rough center of the map / playground used in this scenario. This is just used to determine the UTM zone used for any further projection.", "type": "object", - "additionalProperties" : { - "type" : "boolean" + "properties": { + "longitude": { + "description":"East-west position of a point on earth.", + "type": "number", + "maximum": 180, + "minimum": -180 + }, + "latitude": { + "description":"North-south position of a point on earth.", + "type": "number", + "maximum": 90, + "minimum": -90 + } + }, + "required": [ "longitude", "latitude" ] + }, + "cartesianOffset": { + "title": "CartesianOffset", + "description": "A cartesian offset which is added to the UTM transformation. In most cases, this must be the exact offset which can be found in the `location.netOffset` of the `*.net.xml` of the scenario.", + "type": "object", + "required": [ + "x", + "y" + ], + "properties": { + "x": { "type": "number", "description": "The value to add to the X coordinate after UTM transformation" }, + "y": { "type": "number", "description": "The value to add to the Y coordinate after UTM transformation" } } } }