Beispiel #1
0
PathItem PathTree::pathItem(Segment::PtrConst p) {
    Segment::PtrConst retSeg = seg(p->returnSegment());
    PathItem pI;
    pI.loc = loc(retSeg->source());
    pI.seg = p ;
    pI.returnSeg = seg(p->returnSegment());
    return pI;
}
Beispiel #2
0
float PathTree::segmentTime(Segment::PtrConst s,Segment::ExpediteSupport expediteSupport) const{
    Segment::SegmentType st = s->type();
    float tSpeed = speed(st).value();
    if (s->expediteSupport() == Segment::fullExpediteSupport() && expediteSupport == Segment::fullExpediteSupport()){
        tSpeed *= 1.3;
    };
    return s->length().value() / tSpeed;
};
Beispiel #3
0
float PathTree::segmentCost(Segment::PtrConst s, Segment::ExpediteSupport expediteSupport) const{
    Segment::SegmentType st = s->type();
    float newCost = s->length().value() * cost(st).value() * s->difficulty().value();
    if (s->expediteSupport() == Segment::fullExpediteSupport() && expediteSupport == Segment::fullExpediteSupport()){
        newCost*= 1.5;
    };
    return newCost;
};
Beispiel #4
0
void Stats::onSegmentExpUpdate(Segment::PtrConst _p) {
    FWK_DEBUG("Stats::onSegmentUpdate with " << _p->name());
    if (_p->expediteSupport() == Segment::fullExpediteSupport()) {
        expeditedSupportCount_++;
    } else {
        expeditedSupportCount_--;
    }
    updateExpPercentage();
}
Beispiel #5
0
void Conn::onSegmentDel(Segment::PtrConst seg0){
    FWK_DEBUG("Conn::onSegmentDel() with name: " << seg0->name());
    if (graphSegment_.find(seg0->name()) == graphSegment_.end()){
        FWK_DEBUG("Conn::onSegmentDel() did not find any segment called "
            << seg0->name() << " in the graph");
        return;
    }
    removeGraphSegment(seg0);
    if (seg0->returnSegment() != "")
        removeGraphSegment(graphSegment_[seg0->returnSegment()]);
};
Beispiel #6
0
void Stats::onSegmentNew(Segment::PtrConst _p) {
    FWK_DEBUG("Stats::onSegmentNew(" << _p->name() << ")");
    if (_p->type() == Segment::boatSegment()) {
        boatSegmentCount_++;
    } else if (_p->type() == Segment::truckSegment()) {
        truckSegmentCount_++;
    } else if (_p->type() == Segment::planeSegment()) {
        planeSegmentCount_++;
    }

    if (_p->expediteSupport() == Segment::fullExpediteSupport()) {
        expeditedSupportCount_++;
    }
    totalSegmentCount_++;
    updateExpPercentage();
}
Beispiel #7
0
void Conn::onLocationShipmentNew(Location::PtrConst _cur,
    Shipment::Ptr _shipment) {
        FWK_DEBUG("Conn::onLocationShipmentNew() with name: " << _cur->name());

        Location::PtrConst next =
            routeTable_->nextLocation(_cur, _shipment->destination());
        Segment::Ptr out;
        Location::OutSegmentIteratorConst it = _cur->outSegmenterIterConst();
        for (int i =0; i < _cur->outSegments(); ++i, ++it) {
            Segment::PtrConst r = graphSegment_.at((*it)->returnSegment());
            if (r->source() == next->name()){
                out = *it;
                break;
            }
        }
        //Segment * s = const_cast<Segment *> (out.ptr());
        Location::Ptr p =  const_cast<Location *>(next.ptr());
        out->shipmentEnq(_shipment,p);
};
Beispiel #8
0
Conn::Insertable Conn::isInsertable(Segment::PtrConst seg){
    FWK_DEBUG("Conn::isInsertable() with name: " << seg->name());
    if (!owner_->entityManager()->segment(seg->returnSegment())){
        FWK_DEBUG("Conn::isInsertable() Missing Return");
        return missingReturn_;
    }
    if (!owner_->entityManager()->location(seg->source())){
        FWK_DEBUG("Conn::isInsertable() Missing Source");
        return missingSource_;
    }
    if (!owner_->entityManager()->location(
        owner_->entityManager()->segment(
        seg->returnSegment())->source())) {
            FWK_DEBUG("Conn::isInsertable() Missing Return Source");
            return missingReturnSource_;
    }
    FWK_DEBUG("Conn::isInsertable() Insertable");
    return insertable_;
};
Beispiel #9
0
void
Segment::NotifieeConst::notifierIs(const Segment::PtrConst& _notifier) {
	Segment::Ptr notifierSave(const_cast<Segment *>(notifier_.ptr()));
   if(_notifier==notifier_) return;
   notifier_ = _notifier;
   if(notifierSave) {
      notifierSave->deleteNotifiee(this);
   }
   if(_notifier) {
      _notifier->newNotifiee(this);
   }
   if(isNonReferencing_) {
      if(notifierSave) notifierSave->newRef();
      if(notifier_) notifier_->deleteRef();
   }
}
Beispiel #10
0
void Conn::removeGraphSegment(Segment::PtrConst seg) {
    FWK_DEBUG("Conn::removeGraphSegment() with name: " << seg->name());
    graphSegment_.erase(seg->name());
    if (graphLocation_.find(seg->source()) != graphLocation_.end())
        removeGraphLocation(graphLocation_[seg->source()]);
};
Beispiel #11
0
void Conn::onSegmentUpdate(Segment::PtrConst seg0) {
    FWK_DEBUG("Conn::onSegmentUpdate() with name: " << seg0->name());
    if (graphSegment_.find(seg0->name()) == graphSegment_.end()){
        FWK_DEBUG("Conn::onSegmentUpdate() did not find any segment called "
            << seg0->name() << " in the graph");
        if (isInsertable(seg0) == insertable_){
            Segment::PtrConst seg1 = 
                owner_->entityManager()->segment(seg0->returnSegment());
            FWK_DEBUG("Conn::onSegmentUpdate() Adding " << 
                seg0->name() << " to graph");
            graphSegment_[seg0->name()] = seg0;
            FWK_DEBUG("Conn::onSegmentUpdate() Adding " <<
                seg1->name() << " to graph");
            graphSegment_[seg1->name()] = seg1;
            if (graphLocation_.find(seg0->source()) == graphLocation_.end()) {
                Location::PtrConst loc0 =
                    owner_->entityManager()->location(seg0->source());
                FWK_DEBUG("Conn::onSegmentUpdate() Adding " << 
                    loc0->name() << " to graph");
                graphLocation_[loc0->name()] = loc0;
                routeTable_->statusIs(RouteTable::needsUpdate);
            }
            if (graphLocation_.find(seg1->source()) == graphLocation_.end()){
                Location::PtrConst loc1 = 
                    owner_->entityManager()->location(seg1->source());
                FWK_DEBUG("Conn::onSegmentUpdate() Adding " <<
                    loc1->name() << " to graph");
                graphLocation_[loc1->name()] = loc1;
                routeTable_->statusIs(RouteTable::needsUpdate);
            }
        } else {
            FWK_DEBUG("Conn::onSegmentUpdate() " << seg0->name() <<
                " is not insertable");
            return;
        }
    }
    if (seg0->source() == ""){
        removeGraphSegment(seg0);
        removeGraphSegment(graphSegment_[seg0->returnSegment()]);
    }
    if (seg0->returnSegment() == ""){
        removeGraphSegment(seg0);
    }
};
Beispiel #12
0
TEST_F(LocationTest, TerminalLocationSegmentAttr) {
	loc3->segmentIs(truckSegs[0]);
	Segment::PtrConst s = loc3->segment(0);
	EXPECT_EQ(truckSegs[0].ptr(), s.ptr());
}
Beispiel #13
0
TEST_F(LocationTest, CustomerLocationSegmentAttr) {
	loc1->segmentIs(truckSegs[0]);
	Segment::PtrConst s = loc1->segment(0);
	EXPECT_EQ(truckSegs[0].ptr(), s.ptr());
}