1 package org.opentrafficsim.imb.transceiver.urbanstrategy; 2 3 import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface; 4 import org.opentrafficsim.core.network.OTSNetwork; 5 import org.opentrafficsim.imb.IMBException; 6 import org.opentrafficsim.imb.connector.Connector; 7 import org.opentrafficsim.imb.connector.Connector.IMBEventType; 8 import org.opentrafficsim.imb.transceiver.AbstractTransceiver; 9 10 import nl.tudelft.simulation.language.Throw; 11 12 /** 13 * IMB transceiver for the network. <br> 14 * OTS publishes events about the Network to IMB to be able to identify the network. At the start of the OTS simulation, or when 15 * a (sub) network is added later, a NEW message is sent to IMB to identify the network's id. No CHANGE or DELETE messages are posted. 16 * <p> 17 * <style>table,th,td {border:1px solid grey; border-style:solid; text-align:left; border-collapse: collapse;}</style> 18 * <h2>NEW</h2> 19 * <table summary="" style="width:800px;"> 20 * <thead> 21 * <tr> 22 * <th style="width:25%;">Variable</th> 23 * <th style="width:15%;">Type</th> 24 * <th style="width:60%;">Comments</th> 25 * </tr> 26 * </thead><tbody> 27 * <tr> 28 * <td>timestamp</td> 29 * <td>double</td> 30 * <td>time of the event, in simulation time seconds</td> 31 * </tr> 32 * <tr> 33 * <td>networkId</td> 34 * <td>String</td> 35 * <td>Name of the network as used in e.g., Link messages</td> 36 * </tr> 37 * </tbody> 38 * </table> 39 * </p> 40 * <p> 41 * <h2>CHANGE</h2> Not sent 42 * </p> 43 * <p> 44 * <h2>DELETE</h2> Not sent 45 * </p> 46 * <p> 47 * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 48 * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>. 49 * </p> 50 * @version $Revision$, $LastChangedDate$, by $Author$, initial version Sep 16, 2016 <br> 51 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 52 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 53 */ 54 public class NetworkTransceiver extends AbstractTransceiver 55 { 56 /** */ 57 private static final long serialVersionUID = 20160918L; 58 59 /** 60 * Construct a new NetworkTransceiver. 61 * @param connector Connector; the IMB connector through which this transceiver communicates 62 * @param simulator OTSDEVSSimulatorInterface; the simulator to retrieve the timestamp 63 * @param network OTSNetwork; the OTS network 64 * @throws IMBException when the message cannot be sent 65 * @throws NullPointerException in case one of the arguments is null. 66 */ 67 public NetworkTransceiver(final Connector connector, final OTSDEVSSimulatorInterface simulator, final OTSNetwork network) 68 throws IMBException 69 { 70 super("Network", connector, simulator); 71 Throw.whenNull(network, "Network cannot be null"); 72 connector.postIMBMessage("Network", IMBEventType.NEW, 73 new Object[] { simulator.getSimulatorTime().get().si, network.getId() }); 74 } 75 76 }