LCOV - code coverage report
Current view: top level - src/microsim/devices - MSDevice.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 93.6 % 78 73
Test Date: 2024-11-22 15:46:21 Functions: 75.0 % 8 6

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2013-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    MSDevice.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @date    14.08.2013
      18              : ///
      19              : // Abstract in-vehicle device
      20              : /****************************************************************************/
      21              : #include <config.h>
      22              : 
      23              : #include <utils/options/OptionsCont.h>
      24              : #include <utils/common/StringUtils.h>
      25              : #include <microsim/MSVehicle.h>
      26              : #include <microsim/transportables/MSTransportable.h>
      27              : #include <microsim/MSVehicleControl.h>
      28              : #include <microsim/MSEdge.h>
      29              : 
      30              : #include "MSDevice_Vehroutes.h"
      31              : #include "MSDevice_Tripinfo.h"
      32              : #include "MSDevice_Routing.h"
      33              : #include "MSDevice_Emissions.h"
      34              : #include "MSDevice_BTreceiver.h"
      35              : #include "MSDevice_BTsender.h"
      36              : #include "MSDevice_Example.h"
      37              : #include "MSDevice_StationFinder.h"
      38              : #include "MSDevice_Battery.h"
      39              : #include "MSDevice_SSM.h"
      40              : #include "MSDevice_ToC.h"
      41              : #include "MSDevice_DriverState.h"
      42              : #include "MSDevice_Bluelight.h"
      43              : #include "MSDevice_FCD.h"
      44              : #include "MSDevice_Taxi.h"
      45              : #include "MSDevice_GLOSA.h"
      46              : #include "MSDevice_ElecHybrid.h"
      47              : #include "MSTransportableDevice_Routing.h"
      48              : #include "MSTransportableDevice_FCD.h"
      49              : #include "MSTransportableDevice_FCDReplay.h"
      50              : #include "MSRoutingEngine.h"
      51              : #include "MSDevice_Friction.h"
      52              : #include "MSDevice_FCDReplay.h"
      53              : #include "MSDevice.h"
      54              : 
      55              : 
      56              : // ===========================================================================
      57              : // static member variables
      58              : // ===========================================================================
      59              : std::map<std::string, std::set<std::string> > MSDevice::myExplicitIDs;
      60              : SumoRNG MSDevice::myEquipmentRNG("deviceEquipment");
      61              : 
      62              : // ===========================================================================
      63              : // debug flags
      64              : // ===========================================================================
      65              : //#define DEBUG_DEVICE_PARAMS
      66              : 
      67              : 
      68              : // ===========================================================================
      69              : // method definitions
      70              : // ===========================================================================
      71              : // ---------------------------------------------------------------------------
      72              : // static initialisation methods
      73              : // ---------------------------------------------------------------------------
      74              : void
      75        43644 : MSDevice::insertOptions(OptionsCont& oc) {
      76        43644 :     MSDevice_Routing::insertOptions(oc);
      77        43644 :     MSDevice_Emissions::insertOptions(oc);
      78        43644 :     MSVehicleDevice_BTreceiver::insertOptions(oc);
      79        43644 :     MSVehicleDevice_BTsender::insertOptions(oc);
      80        43644 :     MSDevice_Example::insertOptions(oc);
      81        43644 :     MSDevice_StationFinder::insertOptions(oc);
      82        43644 :     MSDevice_Battery::insertOptions(oc);
      83        43644 :     MSDevice_SSM::insertOptions(oc);
      84        43644 :     MSDevice_ToC::insertOptions(oc);
      85        43644 :     MSDevice_DriverState::insertOptions(oc);
      86        43644 :     MSDevice_Bluelight::insertOptions(oc);
      87        43644 :     MSDevice_FCD::insertOptions(oc);
      88        43644 :     MSDevice_ElecHybrid::insertOptions(oc);
      89        43644 :     MSDevice_Taxi::insertOptions(oc);
      90        43644 :     MSDevice_GLOSA::insertOptions(oc);
      91        43644 :     MSDevice_Tripinfo::insertOptions(oc);
      92        43644 :     MSDevice_Vehroutes::insertOptions(oc);
      93        43644 :     MSDevice_Friction::insertOptions(oc);
      94        43644 :     MSDevice_FCDReplay::insertOptions(oc);
      95              : 
      96        43644 :     MSTransportableDevice_Routing::insertOptions(oc);
      97        43644 :     MSTransportableDevice_FCD::insertOptions(oc);
      98        43644 :     MSTransportableDevice_BTsender::insertOptions(oc);
      99        43644 :     MSTransportableDevice_BTreceiver::insertOptions(oc);
     100        43644 : }
     101              : 
     102              : 
     103              : bool
     104        43320 : MSDevice::checkOptions(OptionsCont& oc) {
     105              :     bool ok = true;
     106        43320 :     ok &= MSDevice_Routing::checkOptions(oc);
     107        43320 :     return ok;
     108              : }
     109              : 
     110              : 
     111              : void
     112      5104379 : MSDevice::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
     113      5104379 :     MSDevice_Vehroutes::buildVehicleDevices(v, into);
     114      5104379 :     MSDevice_Tripinfo::buildVehicleDevices(v, into);
     115      5104379 :     MSDevice_Routing::buildVehicleDevices(v, into);
     116      5104373 :     MSDevice_Emissions::buildVehicleDevices(v, into);
     117      5104373 :     MSVehicleDevice_BTreceiver::buildVehicleDevices(v, into);
     118      5104373 :     MSVehicleDevice_BTsender::buildVehicleDevices(v, into);
     119      5104373 :     MSDevice_Example::buildVehicleDevices(v, into);
     120              :     const size_t numBefore = into.size();
     121      5104373 :     MSDevice_StationFinder::buildVehicleDevices(v, into);
     122      5104373 :     MSDevice_Battery::buildVehicleDevices(v, into, into.size() == numBefore ? nullptr : static_cast<MSDevice_StationFinder*>(into.back()));
     123      5104373 :     MSDevice_SSM::buildVehicleDevices(v, into);
     124      5104373 :     MSDevice_ToC::buildVehicleDevices(v, into);
     125      5104369 :     MSDevice_DriverState::buildVehicleDevices(v, into);
     126      5104369 :     MSDevice_Bluelight::buildVehicleDevices(v, into);
     127      5104369 :     MSDevice_FCD::buildVehicleDevices(v, into);
     128      5104369 :     MSDevice_ElecHybrid::buildVehicleDevices(v, into);
     129      5104369 :     MSDevice_Taxi::buildVehicleDevices(v, into);
     130      5104363 :     MSDevice_GLOSA::buildVehicleDevices(v, into);
     131      5104363 :     MSDevice_Friction::buildVehicleDevices(v, into);
     132      5104363 :     MSDevice_FCDReplay::buildVehicleDevices(v, into);
     133      5104363 : }
     134              : 
     135              : 
     136              : void
     137       501966 : MSDevice::buildTransportableDevices(MSTransportable& p, std::vector<MSTransportableDevice*>& into) {
     138       501966 :     MSTransportableDevice_Routing::buildDevices(p, into);
     139       501966 :     MSTransportableDevice_FCD::buildDevices(p, into);
     140       501966 :     MSTransportableDevice_BTsender::buildDevices(p, into);
     141       501966 :     MSTransportableDevice_BTreceiver::buildDevices(p, into);
     142       501966 :     MSTransportableDevice_FCDReplay::buildDevices(p, into);
     143       501966 : }
     144              : 
     145              : 
     146              : void
     147        40275 : MSDevice::cleanupAll() {
     148        40275 :     MSRoutingEngine::cleanup();
     149        40275 :     MSDevice_Tripinfo::cleanup();
     150        40275 :     MSDevice_FCD::cleanup();
     151        40275 :     MSDevice_Taxi::cleanup();
     152        40275 : }
     153              : 
     154              : void
     155      1003812 : MSDevice::insertDefaultAssignmentOptions(const std::string& deviceName, const std::string& optionsTopic, OptionsCont& oc, const bool isPerson) {
     156      1833048 :     const std::string prefix = (isPerson ? "person-device." : "device.") + deviceName;
     157      1833048 :     const std::string object = isPerson ? "person" : "vehicle";
     158      1003812 :     oc.doRegister(prefix + ".probability", new Option_Float(-1.0));// (default: no need to call RNG)
     159      3011436 :     oc.addDescription(prefix + ".probability", optionsTopic, "The probability for a " + object + " to have a '" + deviceName + "' device");
     160              : 
     161      1003812 :     oc.doRegister(prefix + ".explicit", new Option_StringVector());
     162      2007624 :     oc.addSynonyme(prefix + ".explicit", prefix + ".knownveh", true);
     163      3011436 :     oc.addDescription(prefix + ".explicit", optionsTopic, "Assign a '" + deviceName + "' device to named " + object + "s");
     164              : 
     165      1003812 :     oc.doRegister(prefix + ".deterministic", new Option_Bool(false));
     166      4015248 :     oc.addDescription(prefix + ".deterministic", optionsTopic, "The '" + deviceName + "' devices are set deterministic using a fraction of 1000");
     167      1003812 : }
     168              : 
     169              : 
     170              : void
     171            0 : MSDevice::saveState(OutputDevice& /* out */) const {
     172            0 :     WRITE_WARNINGF(TL("Device '%' cannot save state"), getID());
     173            0 : }
     174              : 
     175              : 
     176              : void
     177            0 : MSDevice::loadState(const SUMOSAXAttributes& /* attrs */) {
     178            0 : }
     179              : 
     180              : 
     181              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1