SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
TraCIServerAPI_Junction.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// APIs for getting/setting junction values via TraCI
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
23
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
#ifdef _MSC_VER
28
#include <
windows_config.h
>
29
#else
30
#include <
config.h
>
31
#endif
32
33
#ifndef NO_TRACI
34
35
#include "
TraCIConstants.h
"
36
#include <
microsim/MSJunction.h
>
37
#include <
microsim/MSJunctionControl.h
>
38
#include <
microsim/MSNet.h
>
39
#include "
TraCIServerAPI_Junction.h
"
40
41
#ifdef CHECK_MEMORY_LEAKS
42
#include <
foreign/nvwa/debug_new.h
>
43
#endif // CHECK_MEMORY_LEAKS
44
45
46
// ===========================================================================
47
// used namespaces
48
// ===========================================================================
49
using namespace
traci;
50
51
52
// ===========================================================================
53
// method definitions
54
// ===========================================================================
55
bool
56
TraCIServerAPI_Junction::processGet
(
TraCIServer
& server,
tcpip::Storage
& inputStorage,
57
tcpip::Storage
& outputStorage) {
58
std::string warning =
""
;
// additional description for response
59
// variable
60
int
variable = inputStorage.
readUnsignedByte
();
61
std::string
id
= inputStorage.
readString
();
62
// check variable
63
if
(variable !=
ID_LIST
&& variable !=
VAR_POSITION
&& variable !=
ID_COUNT
) {
64
server.
writeStatusCmd
(
CMD_GET_JUNCTION_VARIABLE
,
RTYPE_ERR
,
"Get Junction Variable: unsupported variable specified"
, outputStorage);
65
return
false
;
66
}
67
// begin response building
68
tcpip::Storage
tempMsg;
69
// response-code, variableID, objectID
70
tempMsg.
writeUnsignedByte
(
RESPONSE_GET_JUNCTION_VARIABLE
);
71
tempMsg.
writeUnsignedByte
(variable);
72
tempMsg.
writeString
(
id
);
73
if
(variable ==
ID_LIST
) {
74
std::vector<std::string> ids;
75
MSNet::getInstance
()->
getJunctionControl
().
insertIDs
(ids);
76
tempMsg.
writeUnsignedByte
(
TYPE_STRINGLIST
);
77
tempMsg.
writeStringList
(ids);
78
}
else
if
(variable ==
ID_COUNT
) {
79
std::vector<std::string> ids;
80
MSNet::getInstance
()->
getJunctionControl
().
insertIDs
(ids);
81
tempMsg.
writeUnsignedByte
(
TYPE_INTEGER
);
82
tempMsg.
writeInt
((
int
) ids.size());
83
}
else
{
84
MSJunction
* j =
MSNet::getInstance
()->
getJunctionControl
().
get
(
id
);
85
if
(j == 0) {
86
server.
writeStatusCmd
(
CMD_GET_JUNCTION_VARIABLE
,
RTYPE_ERR
,
"Junction '"
+
id
+
"' is not known"
, outputStorage);
87
return
false
;
88
}
89
switch
(variable) {
90
case
ID_LIST
:
91
break
;
92
case
VAR_POSITION
:
93
tempMsg.
writeUnsignedByte
(
POSITION_2D
);
94
tempMsg.
writeDouble
(j->
getPosition
().
x
());
95
tempMsg.
writeDouble
(j->
getPosition
().
y
());
96
break
;
97
default
:
98
break
;
99
}
100
}
101
server.
writeStatusCmd
(
CMD_GET_JUNCTION_VARIABLE
,
RTYPE_OK
, warning, outputStorage);
102
server.
writeResponseWithLength
(outputStorage, tempMsg);
103
return
true
;
104
}
105
106
#endif
107
108
109
/****************************************************************************/
110
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
traci-server
TraCIServerAPI_Junction.cpp
Generated on Mon Mar 24 2014 09:53:15 for SUMO - Simulation of Urban MObility by
1.8.1.2