本文整理汇总了C++中SignalGroup::getLinkNo方法的典型用法代码示例。如果您正苦于以下问题:C++ SignalGroup::getLinkNo方法的具体用法?C++ SignalGroup::getLinkNo怎么用?C++ SignalGroup::getLinkNo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SignalGroup
的用法示例。
在下文中一共展示了SignalGroup::getLinkNo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assConn
std::string
NBLoadedTLDef::buildPhaseState(unsigned int time) const {
unsigned int pos = 0;
std::string state;
// set the green and yellow information first;
// the information whether other have to break needs those masks
// completely filled
for (SignalGroupCont::const_iterator i = mySignalGroups.begin(); i != mySignalGroups.end(); i++) {
SignalGroup* group = (*i).second;
unsigned int linkNo = group->getLinkNo();
bool mayDrive = group->mayDrive(time);
bool hasYellow = group->hasYellow(time);
char c = 'r';
if (mayDrive) {
c = 'g';
}
if (hasYellow) {
c = 'y';
}
for (unsigned int j = 0; j < linkNo; j++) {
const NBConnection& conn = group->getConnection(j);
NBConnection assConn(conn);
// assert that the connection really exists
if (assConn.check(*myEdgeCont)) {
state = state + c;
++pos;
}
}
}
// set the braking mask
pos = 0;
for (SignalGroupCont::const_iterator i = mySignalGroups.begin(); i != mySignalGroups.end(); i++) {
SignalGroup* group = (*i).second;
unsigned int linkNo = group->getLinkNo();
for (unsigned int j = 0; j < linkNo; j++) {
const NBConnection& conn = group->getConnection(j);
NBConnection assConn(conn);
if (assConn.check(*myEdgeCont)) {
if (!mustBrake(assConn, state, pos)) {
if (state[pos] == 'g') {
state[pos] = 'G';
}
if (state[pos] == 'y') {
state[pos] = 'Y';
}
}
pos++;
}
}
}
return state;
}
示例2: tst
void
NBLoadedTLDef::collectLinks() {
myControlledLinks.clear();
// build the list of links which are controled by the traffic light
for (EdgeVector::iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
NBEdge* incoming = *i;
unsigned int noLanes = incoming->getNumLanes();
for (unsigned int j = 0; j < noLanes; j++) {
std::vector<NBEdge::Connection> elv = incoming->getConnectionsFromLane(j);
for (std::vector<NBEdge::Connection>::iterator k = elv.begin(); k != elv.end(); k++) {
NBEdge::Connection el = *k;
if (el.toEdge != 0) {
myControlledLinks.push_back(NBConnection(incoming, j, el.toEdge, el.toLane));
}
}
}
}
// assign tl-indices to myControlledLinks
unsigned int pos = 0;
for (SignalGroupCont::const_iterator m = mySignalGroups.begin(); m != mySignalGroups.end(); m++) {
SignalGroup* group = (*m).second;
unsigned int linkNo = group->getLinkNo();
for (unsigned int j = 0; j < linkNo; j++) {
const NBConnection& conn = group->getConnection(j);
assert(conn.getFromLane() < 0 || (int) conn.getFrom()->getNumLanes() > conn.getFromLane());
NBConnection tst(conn);
tst.setTLIndex(pos);
if (tst.check(*myEdgeCont)) {
if (tst.getFrom()->mayBeTLSControlled(tst.getFromLane(), tst.getTo(), tst.getToLane())) {
for (NBConnectionVector::iterator it = myControlledLinks.begin(); it != myControlledLinks.end(); it++) {
NBConnection& c = *it;
if (c.getTLIndex() == NBConnection::InvalidTlIndex
&& tst.getFrom() == c.getFrom() && tst.getTo() == c.getTo()
&& (tst.getFromLane() < 0 || tst.getFromLane() == c.getFromLane())
&& (tst.getToLane() < 0 || tst.getToLane() == c.getToLane())) {
c.setTLIndex(pos);
}
}
//std::cout << getID() << " group=" << (*m).first << " tst=" << tst << "\n";
pos++;
}
} else {
WRITE_WARNING("Could not set signal on connection (signal: " + getID() + ", group: " + group->getID() + ")");
}
}
}
}
示例3:
void
NBLoadedTLDef::collectNodes() {
myControlledNodes.clear();
SignalGroupCont::const_iterator m;
for (m = mySignalGroups.begin(); m != mySignalGroups.end(); m++) {
SignalGroup* group = (*m).second;
unsigned int linkNo = group->getLinkNo();
for (unsigned int j = 0; j < linkNo; j++) {
const NBConnection& conn = group->getConnection(j);
NBEdge* edge = conn.getFrom();
NBNode* node = edge->getToNode();
myControlledNodes.push_back(node);
}
}
std::sort(myControlledNodes.begin(), myControlledNodes.end(), NBNode::nodes_by_id_sorter());
}
示例4: possProhibitor
bool
NBLoadedTLDef::mustBrake(const NBEdgeCont& ec,
const NBConnection& possProhibited,
const std::string& state,
unsigned int strmpos) const {
// check whether the stream has red
if (state[strmpos] != 'g' && state[strmpos] != 'G') {
return true;
}
// check whether another stream which has green is a higher
// priorised foe to the given
unsigned int pos = 0;
for (SignalGroupCont::const_iterator i = mySignalGroups.begin(); i != mySignalGroups.end(); i++) {
SignalGroup* group = (*i).second;
// get otherlinks that have green
unsigned int linkNo = group->getLinkNo();
for (unsigned int j = 0; j < linkNo; j++) {
// get the current connection (possible foe)
const NBConnection& other = group->getConnection(j);
NBConnection possProhibitor(other);
// if the connction ist still valid ...
if (possProhibitor.check(ec)) {
// ... do nothing if it starts at the same edge
if (possProhibited.getFrom() == possProhibitor.getFrom()) {
pos++;
continue;
}
if (state[pos] == 'g' || state[pos] == 'G') {
if (NBTrafficLightDefinition::mustBrake(possProhibited, possProhibitor, true)) {
return true;
}
}
pos++;
}
}
}
return false;
}
示例5: tst
void
NBLoadedTLDef::setTLControllingInformation(const NBEdgeCont& ec) const {
// assign the links to the connections
unsigned int pos = 0;
for (SignalGroupCont::const_iterator m = mySignalGroups.begin(); m != mySignalGroups.end(); m++) {
SignalGroup* group = (*m).second;
unsigned int linkNo = group->getLinkNo();
for (unsigned int j = 0; j < linkNo; j++) {
const NBConnection& conn = group->getConnection(j);
assert(conn.getFromLane() < 0 || (int) conn.getFrom()->getNumLanes() > conn.getFromLane());
NBConnection tst(conn);
tst.setTLIndex(pos);
if (tst.check(ec)) {
NBEdge* edge = conn.getFrom();
if (edge->setControllingTLInformation(tst, getID())) {
pos++;
}
} else {
WRITE_WARNING("Could not set signal on connection (signal: " + getID() + ", group: " + group->getID() + ")");
}
}
}
}