AirsideFlightConflict* AirsideFlightConflict::ReadLog( ArctermFile& inFile )
{
	long varInt;
	//char strbuf[MAX_STRBUF_SIZE];
	//get id
	int uUId;
	inFile.getInteger( uUId );

	////delay type
	//inFile.getInteger(varInt);
	AirsideFlightConflict* theConflict = new AirsideFlightConflict();
	if(theConflict) // read data
	{		
		theConflict->m_nUniqueID = uUId;

		inFile.getInteger(varInt);
		ElapsedTime tTime; tTime.setPrecisely(varInt);
		theConflict->m_tTime = tTime;

		inFile.getInteger(varInt);
		theConflict->m_nReportAreaID =varInt;

		inFile.getInteger(varInt);
		theConflict->m_nFltUID = varInt;

		inFile.getInteger(varInt);
		theConflict->m_nConflictMobileID = varInt;

		inFile.getInteger(varInt);
		theConflict->m_eConflictType =(FlightConflict::ConflictType)varInt;

		inFile.getInteger(varInt);
		theConflict->m_eLocationType = (FlightConflict::LocationType)varInt;

		inFile.getInteger(varInt);
		theConflict->m_eOperationType = (FlightConflict::OperationType)varInt;

		inFile.getInteger(varInt);
		theConflict->m_eActionType = (FlightConflict::ActionType)varInt;

	}
	inFile.getLine();
	return theConflict;
}
예제 #2
0
int MovingTrain::move(ElapsedTime currentTime,bool bNoLog)
{
	PLACE_METHOD_TRACK_STRING();
	switch(state)
	{
	case Birth:
		{
			InitTrain();
			state = TrainFreeMoving;
			generateEvent(currentTime,false);
		}
		break;
	case TrainFreeMoving:
		{
			if (m_iPreState == Birth)
			{
				GetSchedule(currentTime);
			}
			else
			{
				GetSchedule(currentTime - m_TrainLogEntry.GetTurnAroundTime());
			}

			int nCount = m_movePath.size();
			double dPrevHeading = 0.0;

			for( int i=0; i<nCount; i++ )
			{
				CViehcleMovePath movePath = m_movePath[i];
				int nPathCount = movePath.GetCount();
				float fPrevHeading;
				for( int z=0; z<nPathCount; z++ )
				{
					CStateTimePoint timePt = movePath.GetItem( z );
					TrainEventStruct event;
					ElapsedTime t;
					event.time = timePt.GetTime();
					t.setPrecisely(event.time);
					if (currentTime < t)
					{
						currentTime = t;
					}
					event.x = (float)timePt.getX();
					event.y = (float)timePt.getY();
					event.z = (short)timePt.getZ();
					if( z < nPathCount - 1 )
					{
						CStateTimePoint nextTimePt = movePath.GetItem( z+1 );
						double dNewHeading = ( nextTimePt - timePt ).getHeading();
						event.heading = (float)dNewHeading;
						fPrevHeading = event.heading;
					}
					else
					{
						event.heading = fPrevHeading;
					}
					event.state = timePt.GetState();
					m_TrainLogEntry.addEvent( event );
				}
			}
			ElapsedTime delayTime;
			delayTime.setPrecisely(01l); 

			generateEvent(currentTime - delayTime,false);//notify passenger train arrival
			m_iPreState = state;
			state = TrainArriveAtStation;
		}
		break;
	case TrainArriveAtStation:
		{
			if (m_nFlowIndex + 1 == (int)m_TrainFlow.size())
			{
				m_nFlowIndex = 0;
			}
			m_nFlowIndex++;
			IntegratedStation* pSourceStation = GetSourceStation(m_nFlowIndex);
			pSourceStation->SetTrain(this);
			ElapsedTime delayTime;
			delayTime.setPrecisely(01l); 
			generateEvent(currentTime + delayTime,false);//for correct time to leave
			state = TrainWaitForLeave;
		}
		break;
	case TrainWaitForLeave:
		{
			currentTime += m_TrainLogEntry.GetTurnAroundTime();
			generateEvent(currentTime,false);
			m_iPreState = state;
			state = TrainLeaveStation;
		}
		break;
	case TrainLeaveStation:
		{
			if (m_TrainLogEntry.GetEndTime() < currentTime)
			{
				generateEvent(currentTime,false);
				state = Death;
			}
			else
			{
				generateEvent(currentTime,false);
				m_iPreState = state;
				state = TrainFreeMoving;
			}
			IntegratedStation* pSourceStation = GetSourceStation(m_nFlowIndex);
			pSourceStation->ClearStationTrain(this);
			ClearThisStationPerson(pSourceStation);

		}
		break;
	case Death:
		{
			FlushLog();
		}
		break;
	default:
		break;
	}
	return TRUE;
}
double CFlightFuelBurningCalculator::CalculateFuelBurnByEvenFlightLog( AirsideFlightLogEntry& logEntry ,int _fromIndx,int _toIndex ,AirsideFlightDescStruct& _flttype,CFlightFuelBurnReportItem& _reportItem)
{
	ARCEventLog* pLog = NULL ;
	FlightFuelState _Atstate ;
	FlightFuelState _PriAtState = STATE_UNKNOW ;
	AirsideFlightEventStruct _PriFlightEventlog  ;
	double totalFuelBurning = 0 ;
	double stateFuelBurn = 0 ;
	BOOL _arrBeginTime = FALSE;
	BOOL _arrEndTIme = FALSE;
	BOOL _DepBeginTime = FALSE;
	BOOL _dependTime = FALSE;
	for (int i = _fromIndx ; i <=_toIndex;i++)
	{
 		AirsideFlightEventStruct event = logEntry.getEvent(i);
		
		_Atstate = JuedgeWhichStateBelongTo((AirsideMobileElementMode)event.mode) ;

			if(event.mode <= OnHeldAtStand)
			{
				if(!_arrBeginTime)
				{
					_reportItem.m_ArrFromTime.setPrecisely(event.time) ;
					_arrBeginTime = TRUE ;
				}
				if(i == _toIndex)
				{
					_reportItem.m_ArrToTime.setPrecisely(event.time) ;
				}
			}else
			{
				if(_arrBeginTime && _arrEndTIme == FALSE)
				{
					_reportItem.m_ArrToTime.setPrecisely(event.time) ;
					_arrEndTIme = TRUE ;
				}
				if(!_DepBeginTime)
				{
					_reportItem.m_DepFromTime.setPrecisely(event.time) ;
					_DepBeginTime  = TRUE ;
				}
				if(i == _toIndex)
				{
					_reportItem.m_DepToTime.setPrecisely(event.time) ;
				}
			}
		if(_Atstate != _PriAtState)
		{
			if(_PriAtState != STATE_UNKNOW) //another state ,calculate fuel 
			{
				stateFuelBurn = GetFuelBurnAtEachStateByFlightType(_PriAtState,_flttype) ;
				ElapsedTime intervaltime ;
				intervaltime.setPrecisely(event.time - _PriFlightEventlog.time) ;
				if(event.mode < OnHeldAtStand)
				{
					_reportItem.m_FuelBurnArrival += stateFuelBurn/3600 * intervaltime.asSeconds() ;
				}
				else
				{
					_reportItem.m_FuleBurnDep += stateFuelBurn/3600 * intervaltime.asSeconds() ;
				}
			}
			_PriAtState = _Atstate ;
			_PriFlightEventlog = event ;
		}else
		{
			if(_PriAtState != STATE_UNKNOW && i == _toIndex) //all the log are in the one state .
			{
				stateFuelBurn = GetFuelBurnAtEachStateByFlightType(_PriAtState,_flttype) ;
				ElapsedTime intervaltime ;
				intervaltime.setPrecisely(event.time - _PriFlightEventlog.time) ;
				if(event.mode < OnHeldAtStand)
				{
					_reportItem.m_FuelBurnArrival += stateFuelBurn/3600 * intervaltime.asSeconds() ;
				}
				else
				{
					_reportItem.m_DepToTime.setPrecisely(event.time) ;
					_reportItem.m_FuleBurnDep += stateFuelBurn/3600 * intervaltime.asSeconds() ;
				}
			}
		}

	}
	return _reportItem.m_FuleBurnDep + _reportItem.m_FuelBurnArrival ;
}