コード例 #1
0
ファイル: InfoManager.C プロジェクト: dailypips/simx
/// [11/19/2008 by Guanhua Yan. ]
///
/// reads info from input file <Time> <EntityID> <ServiceAddr>
/// <InfoType> <info data .....> without any time constraints. Open a
/// file and then read all infos.
///≈
void InfoManager::readFullDataFile(const std::string& infoFiles )
{
  assert(false);
    /// these variables should be static because they will be reused may times
    static const Control::LpPtrMap& lpMap = Control::getLpPtrMap();
    SMART_ASSERT( lpMap.begin() != lpMap.end() );
    SMART_ASSERT( lpMap.begin()->second );
    static const LP& lp = *(lpMap.begin()->second); // get address of ANY lp on this computer node
    Time now = lp.getNow();

#ifdef DEBUG
    Logger::debug3() << "InfoManager: in readFullDataFile at time " << now
		     << ", infoFiles= " << infoFiles << endl;
#endif
    
    stringstream sstr;
    sstr << infoFiles;
    string fileName;
    // for each file, setup a reader
    while( sstr >> fileName )
    {
      InfoData::Reader reader(fileName);
      while ( reader.MoreData()) {
        InfoData data( reader.ReadData() );
	
	// see if we will send the info:
	LPID lpId = theEntityManager().findEntityLpId( data.getEntityId() );
	Control::LpPtrMap::const_iterator lpIter = lpMap.find(lpId);
        if( lpIter != lpMap.end() )
	  {
	    // the destination resides on one of LPs in this Unix process
	    // send the info:
#ifdef DEBUG
	    Logger::debug3() << "InfoManager: processing data: " << data << endl;
#endif
	    // get info object and fill it with data
	    boost::shared_ptr<Input> input( fInputHandler.createInput( data.getClassType(), data.getProfileId(), data.getData() ) );
	    boost::shared_ptr<Info> info = boost::dynamic_pointer_cast<Info>(input);
	    SMART_ASSERT( info );	/// the object MUST actually be a descendant of Info
#ifdef DEBUG
	    Logger::debug3() << "InfoManager: processing info: " << info << endl;
#endif
	    // set EventInfo parameters:
	    EventInfo event;
	    event.setTo( data.getEntityId(), data.getServiceAddress() );
	    event.setDelay( max (LOCAL_MINDELAY, data.getTime() - now ));
	    event.setInfo( info );
	    // send it off directly to the right LP
	    LP* lpPointer = lpIter->second;
	    SMART_ASSERT( lpPointer );
	    lpPointer->sendEventInfo(event);

	  } // else don't schedule it, other Unix process will

      } // while(MoreData)
    }
}
コード例 #2
0
ファイル: Entity.C プロジェクト: dailypips/simx
void Entity::processOutgoingInfo(const boost::shared_ptr<const Info> info, const Time& delay, const EntityID& dest, const ServiceAddress& serv) const
{
    if(Control::getSimPhase() != Control::kPhaseRun) {
        Logger::failure("Entity::processOutgoingInfo(): simulation not running!");    
    }
        
    EventInfo event;
    event.setTo(dest, serv);
    event.setDelay(delay);
    event.setInfo(info);

    // send it off
    fLP.sendEventInfo( event );
}
コード例 #3
0
ファイル: InfoManager.C プロジェクト: dailypips/simx
  void InfoManager::createPyInfoFromInfoData( PyInfoData& data ) {

    static const Control::LpPtrMap& lpMap = Control::getLpPtrMap();
    static const LP& lp = *(lpMap.begin()->second); // get address of ANY lp on this computer node
    Time now = lp.getNow();
    // see if we will send the info:
    LPID lpId = theEntityManager().findEntityLpId( data.getEntityId() );
    Control::LpPtrMap::const_iterator lpIter = lpMap.find(lpId);
    if( lpIter != lpMap.end() )
      {
	// the destination resides on one of LPs in this Unix process
	// send the info:
#ifdef DEBUG
	Logger::debug3() << "InfoManager: processing data: " << data << endl;
#endif
	// get info object and fill it with data
	boost::shared_ptr<Input> input( fInputHandler.createInput( data.getClassType(), data.getProfileId(), data.getProfile(), data.getData() ) );
	boost::shared_ptr<Info> info = boost::dynamic_pointer_cast<Info>(input);
	SMART_ASSERT( info );	/// the object MUST actually be a descendant of Info
#ifdef DEBUG
	Logger::debug3() << "InfoManager: processing info: " << info << endl;
#endif
	// set EventInfo parameters:
	EventInfo event;
	event.setTo( data.getEntityId(), data.getServiceAddress() );
	if( data.getTime() < now )
	  Logger::warn() << "InfoManager: Sending event at time " << now
			 << " which should have been sent at " << data.getTime() 
			 << " : Check if input is time sorted " << endl;
	event.setDelay( max (LOCAL_MINDELAY, data.getTime() - now ));
	event.setInfo( info );
	// send it off directly to the right LP
	LP* lpPointer = lpIter->second;
	SMART_ASSERT( lpPointer );
	lpPointer->sendEventInfo(event);
	
      } // else don't schedule it, other Unix process will
  }