def test_controller():
    prop = OSC.Properties()
    prop.add_property('mything', '2')
    prop.add_property('theotherthing', 'true')

    cnt = OSC.Controller('mycontroler', prop)
    prettyprint(cnt.get_element())
def test_assign_controller_action():
    prop = OSC.Properties()
    prop.add_property('mything','2')
    prop.add_property('theotherthing','true')

    cnt = OSC.Controller('mycontroller',prop)
    
    
    aca = OSC.AssignControllerAction(cnt)
    prettyprint(aca.get_element())
def test_trafficdefinition():
    prop = OSC.Properties()
    prop.add_file('mycontrollerfile.xml')
    controller = OSC.Controller('mycontroller', prop)

    traffic = OSC.TrafficDefinition('my traffic')
    traffic.add_controller(controller, 0.5)
    traffic.add_controller(
        OSC.CatalogReference('ControllerCatalog', 'my controller'), 0.5)

    traffic.add_vehicle(OSC.VehicleCategory.car, 0.9)
    traffic.add_vehicle(OSC.VehicleCategory.bicycle, 0.1)

    prettyprint(traffic.get_element())
def test_trafficsinkaction():
    
    prop = OSC.Properties()
    prop.add_file('mycontrollerfile.xml')
    controller = OSC.Controller('mycontroller',prop)

    traffic = OSC.TrafficDefinition('my traffic')
    traffic.add_controller(controller,0.5)
    traffic.add_controller(OSC.CatalogReference('ControllerCatalog','my controller'),0.5)

    traffic.add_vehicle(OSC.VehicleCategory.car,0.9)
    traffic.add_vehicle(OSC.VehicleCategory.bicycle,0.1)

    sink_action = OSC.TrafficSinkAction(10,10,OSC.WorldPosition(),traffic)
    prettyprint(sink_action.get_element())
def test_controller_in_Entities():
    bb = OSC.BoundingBox(2, 5, 1.5, 1.5, 0, 0.2)
    fa = OSC.Axle(2, 2, 2, 1, 1)
    ba = OSC.Axle(1, 1, 2, 1, 1)
    veh = OSC.Vehicle('mycar', OSC.VehicleCategory.car, bb, fa, ba, 150, 10,
                      10)

    prop = OSC.Properties()
    prop.add_property('mything', '2')
    prop.add_property('theotherthing', 'true')

    cnt = OSC.Controller('mycontroler', prop)

    entities = OSC.Entities()
    entities.add_scenario_object('Ego', veh)
    entities.add_scenario_object('Target_1', veh, cnt)
    entities.add_entity_bytype('Target_2', OSC.ObjectType.vehicle)
    entities.add_entity_byref('Target_3', 'something')
    prettyprint(entities.get_element())

    prettyprint(veh.get_element())
fa = xosc.Axle(0.523598775598, 0.8, 1.68, 2.98, 0.4)
ba = xosc.Axle(0.523598775598, 0.8, 1.68, 0, 0.4)
red_veh = xosc.Vehicle('car_red', xosc.VehicleCategory.car, bb, fa, ba, 69, 10,
                       10)

red_veh.add_property_file('../models/car_red.osgb')
red_veh.add_property('model_id', '2')

## create entities

egoname = 'Ego'
targetname = 'Target'
prop = xosc.Properties()
prop.add_property(name="esminiController", value="SumoController")
prop.add_file("../sumo_inputs/e6mini.sumocfg")
cont = xosc.Controller('mycontroler', prop)
cont.dump_to_catalog('Controller.xosx', 'Controller', 'controllers',
                     'Mandolin')

entities = xosc.Entities()
entities.add_scenario_object(egoname, white_veh)
entities.add_scenario_object(targetname, red_veh, cont)

### create init

init = xosc.Init()
step_time = xosc.TransitionDynamics(xosc.DynamicsShapes.step,
                                    xosc.DynamicsDimension.time, 1)

egospeed = xosc.AbsoluteSpeedAction(10, step_time)
egostart = xosc.TeleportAction(xosc.LanePosition(25, 0, -3, 0))