//method called by Passenger to update visitor's location, state.
int VisitorTerminalBehavior::update( ElapsedTime _time, Point _OwnerPreLocation, bool _bBackup )
{
	int nNextState = GetOwner()->getState();
	PaxTerminalBehavior* spTerminalBehavior = (PaxTerminalBehavior*)GetOwner()->getBehavior(MobElementBehavior::TerminalBehavior);
	if (spTerminalBehavior == NULL)
	{
		return 1;
	}

	if (IfHaveOwnFlow(_time))
	{
		//////create ConvergePair,and add to GreetPool.            6.21.2004
		//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

		TrayHostList* pTrayHostList = m_pTerm->GetTrayHostList();

		if (pTrayHostList->IfNonPaxExsit(m_pPerson->getType().GetTypeIndex()) && !m_bInTray)
		{
			spTerminalBehavior->CopyVisitListToTrayHost(_time);
		}

		if (pTrayHostList->FindHostItem(m_pPerson->getType().GetTypeIndex()) || !pTrayHostList->IfNonPaxExsit(m_pPerson->getType().GetTypeIndex())\
			|| (pTrayHostList->IfNonPaxExsit(m_pPerson->getType().GetTypeIndex()) && !m_bInTray))
		{
			if (!spTerminalBehavior->StickForDestProcsOverload(_time) && !StickNonPaxDestProcsOverload(_time))
			{
				GetVisitor()->NewConvergePair(GetOwnerId(),true);
				if(GetOwner()) GetOwner()->NewConvergePair(m_pPerson->getID(),m_pPerson->getType().GetTypeIndex());

				m_pPerson->setState(FreeMoving);
				m_nFreeMoving = 1;
				m_nFreeMovingIndex = m_pPerson->getLogEntry().getCurrentCount();
				//	m_bWithOwner = false;
				m_pPerson->m_pGroupInfo->SetFollowerWithOwner(false);
				setDestination(_OwnerPreLocation);
				ElapsedTime eTime = _time + moveTime();
				generateEvent(eTime,false);

				if( getNextProcessor( eTime ) )
					generateEvent( eTime+moveTime(),false );//

				return 0;
			}
			return 1;
		}
		return 0;
	}

	m_pPerson->setState(nNextState);
	m_nQueuePathSegmentIndex = spTerminalBehavior->getCurrentIndex();
	m_pProcessor = spTerminalBehavior->getProcessor();

	CString sstr1= m_pProcessor->getID()->GetIDString();
	// write log entry
	//writeLog( _time );
	//CString _strOwnerProcessor = m_pOwnerPax->getProcessor()->getID()->GetIDString();
	GetVisitor()->writeVisitorLog( _time,_OwnerPreLocation, _bBackup, false);
	return 1;
}
void ArrivalPaxLandsideBehavior::processGetOnVehicle_old( const ElapsedTime& t )
{
	WriteLogEntry(t);
	//get on to vehicle
	ARCVector3 vehiclepos = m_pVehicle->getState(t).pos;
	setDestination(vehiclepos);
	ElapsedTime etime = moveTime();
	//setLocation(vehiclepos);	
	WriteLogEntry(etime + t);
	m_pPerson->setState(On_Vehicle);
	GenerateEvent(etime+t);
}
void ArrivalPaxLandsideBehavior::processPutBag( const ElapsedTime& t )
{
	WriteLogEntry(t);

	//go to the pak
	ARCVector3 bagPos = m_pVehicle->getLastState().pos;
	setDestination(bagPos);
	ElapsedTime dNextTime = t;
	dNextTime += moveTime();
	//setLocation(bagPos);		
	WriteLogEntry(dNextTime);

	//write bag log
	Passenger* pPassenger = (Passenger*)m_pPerson;
	int nCount = pPassenger->m_pVisitorList.size();
	for( int i=nCount-1; i>=0; i-- )
	{
		PaxVisitor* pVis = pPassenger->m_pVisitorList[i];
		if (pVis == NULL)
			continue;
		VisitorLandsideBehavior* pCarryonBehavior = (VisitorLandsideBehavior*)pVis->getLandsideBehavior();
		ASSERT(pCarryonBehavior);
		//non passenger move to ground
		if(pCarryonBehavior)
		{
			pCarryonBehavior->setDestination(bagPos);			
			ElapsedTime eTime = moveTime();
			pCarryonBehavior->setLocation(bagPos);
			pCarryonBehavior->WriteLogEntry(eTime+t, i);
		}

		//detach to passenger
		pPassenger->m_pVisitorList[i] = NULL;		
	}

	setState(GetOn_Vehicle);
	GenerateEvent(dNextTime);

}
void ArrivalPaxLandsideBehavior::ProcessMoveToVehicle( const ElapsedTime& eEventTime )
{
	WriteLogEntry(eEventTime);
	//get on to vehicle
	ARCVector3 vehiclepos = m_pVehicle->getState(eEventTime).pos;
	setDestination(vehiclepos);
	ElapsedTime eMovetime = moveTime();

	ElapsedTime eCurTime = eMovetime + eEventTime;
	//setLocation(vehiclepos);	
	WriteLogEntry(eCurTime);
	m_pPerson->setState(PutCarryonToVehicle);
	GenerateEvent(eCurTime);
}
Esempio n. 5
0
task main()
{
	//////////////////////////////////////////////////////////////////////////////////
	waitForStart(); // Wait for the beginning of autonomous phase.
	initializeRobot();
	//////////////////////////////////////////////////////////////////////////////////
	if(OnRamp)
	{
		moveTime(100,5000);//get off the ramp
		turn(90);
		moveTime(100,1100);
		turn(-90);
		moveTime(100,3000);
		servo[Tower1]=15;
		servo[Autonomous1] = 100;
	  servo[Autonomous2] = 155;
	  wait1Msec(1000);
	  motor[LBDMotor] = 0;
		motor[LFDMotor] = 0;
		motor[RBDMotor] = 0;
		motor[RFDMotor] = 0;
		wait1Msec(150000000);
	}
}
void ArrivalPaxLandsideBehavior::ProcessGetOffVehicle( const ElapsedTime& eEventTime )
{
	//get vehicle

	//get
	//the position where the vehicle stops
	//
	WriteLogEntry(eEventTime);

	setState(GetOffVehicle);
	setDestination(m_pVehicle->getLastState().pos);
	//setLocation(m_pVechile->getState().pos);
	WriteLogEntry(eEventTime);

	CPoint2008 nextPt(0,0,0);

	LandsideBusStationInSim*  pBusStation = NULL;
	if( LandsideResourceInSim* pRes = getResource())
	{
		pBusStation =  pRes->toBusSation();
		if ( pBusStation)
		{
			nextPt = pBusStation->GetPaxWaitPos();
		}
	}
	//move outside vehicle
	CPoint2008 nextpos = m_pVehicle->getOffVehiclePos(nextPt);
	setDestination(nextpos);
	ElapsedTime eMovetime = moveTime();
	ElapsedTime eCurTime = eMovetime + eEventTime;

	//setLocation(nextpos);
	WriteLogEntry(eCurTime);

	m_pVehicle->RemoveOnPax(this, eCurTime);

	//start to pick the Bag
	
	m_pPerson->setState(PickCarryOnFromVehicle);
	GenerateEvent(eCurTime);


}
Esempio n. 7
0
void moveBackwardTime(int power, int time){
	moveTime(-power, -power, -power, -power, time);
}
Esempio n. 8
0
void moveRightTime(int power, int time){
	moveTime(power, -power, -power, power, time);
}
Esempio n. 9
0
void moveLeftTime(int power, int time){
	moveTime(-power, power, power, -power, time);
}
Esempio n. 10
0
void moveForwardTime(int power, int time){
	moveTime(power, power, power, power, time);
}
void ArrivalPaxLandsideBehavior::ProcessMoveToFacility( const ElapsedTime& eEventTime )
{
	LandsideResourceInSim *pDestResource = getDestResource();
	if(pDestResource->toParkLotSpot())
	{
		LandsideParkingSpotInSim* pParkSpot = pDestResource->toParkLotSpot();

		ARCVector3 nextPos = pParkSpot->getPos();
		CPoint2008 endPos;
		endPos.init(nextPos.n[VX],nextPos.n[VY],nextPos.n[VZ]);

		CLandsideTrafficSystem* pLandsideTrafficInSim = m_pLandsideSim->GetLandsideTrafficeManager();
//		LandsideResourceInSim* pStartLandsideResInSim = getResource();
//		LandsideResourceInSim* pEndLandsideResInSim = pParkSpot->getParkingLot();

		CPoint2008 startPos;
		startPos.init(getPoint().n[VX],getPoint().n[VY],getPoint().n[VZ]);

		if( !pLandsideTrafficInSim->EnterTrafficSystem(eEventTime,ArriveAtFacility,this,startPos,endPos))
		{
			ElapsedTime dNextTime = eEventTime;
			setDestination(endPos);
			ElapsedTime etime = moveTime();
			//setLocation(nextPos);	
			dNextTime += etime;
			WriteLogEntry(dNextTime);
			m_pPerson->setState(ArriveAtFacility);
			GenerateEvent(dNextTime);
			return;
		}
	}
	else if(pDestResource->toLaneSpot())//move to curbside
	{
		//go to the waiting area of curbside
		IParkingSpotInSim *pCurbsideSpot = pDestResource->toLaneSpot();
		LandsideResourceInSim *pParentResource = pCurbsideSpot->GetParentResource();
		LandsideCurbSideInSim *pCurbsideInsim = pParentResource->toCurbSide();
		ASSERT(pCurbsideInsim != NULL);
		CPoint2008 pPaxWaitAreaPosInCurbside = pCurbsideInsim->GetPaxWaitPos();

		CPoint2008 startPos;
		startPos.init(getPoint().n[VX],getPoint().n[VY],getPoint().n[VZ]);

		CPoint2008 endPos = pPaxWaitAreaPosInCurbside;

		CLandsideTrafficSystem* pLandsideTrafficInSim = m_pLandsideSim->GetLandsideTrafficeManager();
		if( !pLandsideTrafficInSim->EnterTrafficSystem(eEventTime,ArriveAtFacility,this,startPos,endPos))
		{
			ElapsedTime dNextTime = eEventTime;
			setDestination(endPos);
			ElapsedTime etime = moveTime();
			//setLocation(nextPos);	
			dNextTime += etime;
			WriteLogEntry(dNextTime);
			m_pPerson->setState(ArriveAtFacility);
			GenerateEvent(dNextTime);
			return;
		}

	}
	else
	{
		ASSERT(FALSE);
		terminate(eEventTime);
	}

}