Defining fields and variables examples
Example: scalar field declaration
OSC2 code: scalar field declaration
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
actor my_car:
# Current car speed
var current_speed: speed
# Car max_speed
max_speed: speed with:
keep(soft it == 120kph)
Example: list field declaration
OSC2 code: list field declaration
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
extend traffic:
var my_cars: list of vehicle
Example: list field declaration with constraints
OSC2 code: list field declaration with constraints
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
actor my_car_convoy:
first_car: vehicle
cars: list of vehicle
# the list will have between 2 and 10 items
# the first item is first_car
keep(soft cars.size() <= 10)
keep(soft cars.size() >= 2)
keep(cars[0] == first_car) # list indexing
Example: string field declaration
OSC2 code: string field declaration
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
struct data:
name: string with:
keep(it == "John Smith")
Example: struct field declaration
OSC2 code: struct field declaration
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
actor my_car:
max_speed: speed
extend traffic:
car1: my_car with:
keep(it.max_speed == 60kph)
Example: scenario field declaration
OSC2 code: scenario field declaration
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
enum storm_type: [rain, ice, snow]
struct storm_data:
storm: storm_type
wind_velocity: speed
scenario environment.snowstorm:
storm_data: storm_data with:
keep(it.storm == snow)
keep(soft it.wind_velocity >= 30kph)
cover(wind_velocity, expression: it.wind_velocity, unit: kph)
Example: variable field declaration with sample()
OSC2 code: variable field declaration with sample()
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
scenario sut.cut_in:
car1: vehicle
do serial:
get_ahead: car1.drive() with:
speed(speed: [30..70]kph)
extend sut.cut_in:
var speed_car1_get_ahead_end := sample(car1.state.speed, @get_ahead.end) with:
cover(speed_car1_get_ahead_end,
text: "Speed of car1 at get_ahead end (in kph)", unit: kph,
range: [10..130], every: 10)
Example: field declaration with implicit type
OSC2 code: field declaration with implicit type
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
scenario vehicle.my_scenario1:
legal_speed: speed
var too_fast:= true