下面你有你提到的功能的所有实现。正如您在第一种情况下看到的那样,评论getPositionAt()
说:
它旨在作为传递simTime()
并actualTime
返回实际位置。
似乎这些功能根本不涵盖您的情况。
你可以看到这些函数是如何工作的Move.h
。评论也够详细
/**
* @brief Returns the position of the Move (Host) at the specified point in time.
* It is intended to be passed simTime() as actualTime and returns the actual position.
*
* Assumes that direction represents a normalized vector (length equals 1.0).
* Further this function does not check whether the given time point is before
* the startTime of the actual move pattern. So in this case one might obtain
* an unintended result.
*
*/
virtual Coord getPositionAt(simtime_t_cref actualTime = simTime()) const
{
// if speed is very close to 0.0, the host is practically standing still
if ( FWMath::close(speed, 0.0) ) return startPos;
// otherwise: actualPos = startPos + ( direction * v * t )
return startPos + ( direction * speed * SIMTIME_DBL(actualTime - startTime) );
}
virtual const Coord& getCurrentPosition() const
{
if (lastPos.z != DBL_MAX)
return lastPos;
return startPos;
}
getPositionAt()
也被实施TraCIMobility.h
为:
virtual Coord getPositionAt(const simtime_t& t) const {
return move.getPositionAt(t) ;
}
并getCurrentPosition()
实施BaseMobility.h
为:
/** @brief Returns the current position at the current simulation time. */
virtual Coord getCurrentPosition(/*simtime_t_cref stWhen = simTime()*/) const {
//return move.getPositionAt(stWhen);
return move.getStartPos();
}