Example #1
0
void Rest::getRefData(EntitySet es, Time now, ostream& out) const
{
  int i{0};
  out << '{';
  // FIXME: validate entities.
  if (es.asset()) {
    out << "\"assets\":";
    getAsset(now, out);
    ++i;
  }
  if (es.contr()) {
    if (i > 0) {
      out << ',';
    }
    out << "\"contrs\":";
    getContr(now, out);
    ++i;
  }
  if (es.market()) {
    if (i > 0) {
      out << ',';
    }
    out << "\"markets\":";
    getMarket(now, out);
    ++i;
  }
  out << '}';
}
Example #2
0
void ConfigFileWriter::writeEntitiesFile(std::string filename, NodeSet& ns)
{
    std::fstream out;
    out.open(filename.c_str(), std::fstream::out | std::fstream::trunc);

    EntitySet entitySet = ns.getEntitySet();
    EntitySet::iterator it = entitySet.begin();
    while (it != entitySet.end())
    {
        EntityStruct* ent = *it;
        if (ent)
        {
            int len = strlen((char*)ent->marking.markingData);
            if (len == 0 || len > 11)
            {
                it++;
                continue;
            }
            std::stringstream text;
            text << ent->marking << ", ";
            text << ent->forceIdentifier << ", ";
            text << getCountryString(ent->entityType.countryCode) << ", ";
            text << ent->worldLocation << ", ";
            text << ent->entityType;
            out << ent->marking << ", ";

            if (ent->forceIdentifier ==
                                    SNT_SYNCH::ForceIdentifierEnum::Friendly)
            {
                out << "F" << ", ";
            }
            else if (ent->forceIdentifier ==
                                    SNT_SYNCH::ForceIdentifierEnum::Opposing)
            {
                out << "O" << ", ";
            }
            else
            {
                out << "N" << ", ";
            }
            out << getCountryString(ent->entityType.countryCode) << ", ";
            out << ent->worldLocation << ", ";
            out << ent->entityType;
            out << std::endl;
        }
        it++;
    }
    out.close();
}
Example #3
0
void Rest::getAccnt(Mnem mnem, EntitySet es, Page page, Time now, ostream& out) const
{
  const auto& accnt = serv_.accnt(mnem);
  int i{0};
  out << '{';
  if (es.market()) {
    out << "\"markets\":";
    getMarket(now, out);
    ++i;
  }
  if (es.order()) {
    if (i > 0) {
      out << ',';
    }
    out << "\"orders\":";
    detail::getOrder(accnt, out);
    ++i;
  }
  if (es.exec()) {
    if (i > 0) {
      out << ',';
    }
    out << "\"execs\":";
    detail::getExec(accnt, page, out);
    ++i;
  }
  if (es.trade()) {
    if (i > 0) {
      out << ',';
    }
    out << "\"trades\":";
    detail::getTrade(accnt, out);
    ++i;
  }
  if (es.posn()) {
    if (i > 0) {
      out << ',';
    }
    out << "\"posns\":";
    detail::getPosn(accnt, out);
    ++i;
  }
  out << '}';
}
Example #4
0
bool  HeadsUpDisplay::DrawHyperRadar(const FontManager&fontmanager_ref,
									 const EntitySet& entityset_ref,
									 const KernelSettings& kernelsettings_ref) const
{
	float fx = kernelsettings_ref.iAppWidth/2;
	float fy = kernelsettings_ref.iAppHeight/2;

	glPushMatrix();
	//draw radar circle
	glLineWidth(3);
	glColor4f(1,0,0,0.5);
	glBegin(GL_LINE_LOOP);
	for (int i=0; i < 360; i+=5)
	{
		float degInRad = i*DEG2RAD;
		glVertex2f(cos(degInRad)*RADAR_RADIUS+fx,sin(degInRad)*RADAR_RADIUS+fy);
	}
	glEnd();

	//draw entities on radar
	glPointSize(10);
	glBegin(GL_POINTS);
	for (int i = 0; i < entityset_ref.GetList().size(); i++)
	{
		float fHyper = entityset_ref.GetList().at(i)->fHVS[0];
		float degInRada = fHyper*DEG2RAD;
		if (entityset_ref.GetList().at(i)->iType < 20)
		{
			glColor4f(0,1,1,0.5);
		}
		else
		{
			glColor4f(1,0,0,0.5);
		}
		glVertex2f(cos(degInRada)*RADAR_RADIUS+fx,sin(degInRada)*RADAR_RADIUS+fy);
	}
	glEnd();

	glPopMatrix();

	//return true
	return true;
}
Example #5
0
bool HeadsUpDisplay::DisplayCameraAndControlInfo(const FontManager& fontmanager_ref, const EntitySet& entityset_ref, const KernelSettings kernelsettings_ref) const
{
	//display entity number in lower half of HUD
	stringstream ss1;
	string s1,s2;
	ss1 << entityset_ref.GetControlTargetID();
	ss1 >> s1;
	s2 = "Entity Control: " + s1;
	fontmanager_ref.RenderText(s2.c_str(),10,kernelsettings_ref.iAppHeight-10,kernelsettings_ref);
	
	//display entity number in lower half of HUD
	stringstream ss2;
	s1 = "";
	s2 = "";
	//display camera source in lower half of HUD
	ss2 << entityset_ref.GetCameraTargetID();
	ss2 >> s1;
	s2 = "Camera Source: " + s1;
	fontmanager_ref.RenderText(s2.c_str(),10,kernelsettings_ref.iAppHeight-25,kernelsettings_ref);

	stringstream ss3;
	s1 = "";
	s2 = "";
	//display hyperfactor of control entity
	ss3 << entityset_ref.GetControlTargetRef()->fHVS[0];
//	ss3 << MathManipulations::SizVEC(entityset_ref.GetControlTargetRef()->vSVS[3]);
	ss3 >> s1;
	s2 = "HyperFactor: " + s1;
	fontmanager_ref.RenderText(s2.c_str(),200,kernelsettings_ref.iAppHeight-25,kernelsettings_ref);
//	fontmanager_ref.RenderText(s2.c_str(),200,kernelsettings_ref.iAppHeight-25,kernelsettings_ref);

	//Redner User Info
	fontmanager_ref.RenderText("Martin Goulet - Copyright 2005", 770,15,kernelsettings_ref);
	fontmanager_ref.RenderText("*****@*****.**", 825,30,kernelsettings_ref);

	return true;
}
Example #6
0
void EntityPanel::OnEntityAssetRefresh( Inspect::Button* button )
{
    Core::Scene* scene = NULL;

    // when we refresh, reload the common class set information in case
    // we did something like reexport an art class, while luna is still opened
    std::set< EntitySet* > reloadQueue;     // entities we want to reload

    std::set< tstring > files;

    OS_SelectableDumbPtr::Iterator selectionIter = m_Selection.Begin();
    OS_SelectableDumbPtr::Iterator selectionEnd = m_Selection.End();
    for (; selectionIter != selectionEnd; ++selectionIter )
    {
        Core::Entity* entity = Reflect::ObjectCast< Core::Entity >( *selectionIter );

        if ( !scene )
        {
            Core::SceneNode* node = Reflect::ObjectCast< Core::SceneNode >( *selectionIter );
            scene = node->GetOwner();
        }

        if( entity->GetClassSet( ) )
        {
            reloadQueue.insert( entity->GetClassSet( ) );
        }

        if (entity->IsGeometryVisible())
        {
            for ( int i=0; i<GeometryModes::Count; i++ )
            {
                Core::Scene* nestedScene = entity->GetNestedScene(entity->GetOwner()->GetViewport()->GetGeometryMode());

                if (nestedScene)
                {
                    if ( files.insert( nestedScene->GetPath().Get() ).second )
                    {
                        // Only reload the scene if we haven't already done so during this iteration.
                        nestedScene->Reload();
                    }
                }
            }
        }
    }

    std::set< EntitySet* >::iterator itr = reloadQueue.begin();
    std::set< EntitySet* >::iterator end = reloadQueue.end();

    while( itr != end )
    {
        EntitySet* entClassSet = ObjectCast< EntitySet >( *itr );

        if( entClassSet )
        {
            entClassSet->LoadAssetClass( );
        }

        itr++;
    }

    if (scene)
    {
        scene->Execute(false);
    }
}
Example #7
0
void BulkData::change_entity_owner( const std::vector<EntityProc> & arg_change )
{
  static const char method[] = "stk::mesh::BulkData::change_entity_owner" ;

  const MetaData  & meta = m_mesh_meta_data ;
  const unsigned  p_rank = m_parallel_rank ;
  const unsigned  p_size = m_parallel_size ;
  ParallelMachine p_comm = m_parallel_machine ;

  //------------------------------
  // Verify the input changes, generate a clean local change list, and
  // generate the remote change list so that all processes know about
  // pending changes.

  std::vector<EntityProc> local_change( arg_change );

  // Parallel synchronous clean up and verify the requested changes:
  clean_and_verify_parallel_change( method , *this , local_change );

  //----------------------------------------
  // Parallel synchronous determination of changing
  // shared and ghosted.

  std::vector<EntityProc> ghosted_change ;
  std::vector<EntityProc> shared_change ;

  generate_parallel_change( *this , local_change ,
                            shared_change , ghosted_change );

  //------------------------------
  // Have enough information to delete all effected ghosts.
  // If the closure of a ghost contains a changing entity
  // then that ghost must be deleted.
  // Request that all ghost entities in the closure of the ghost be deleted.

  typedef std::set<EntityProc,EntityLess> EntityProcSet;
  typedef std::set<Entity*,EntityLess> EntitySet;

  // Closure of the owner change for impacted ghost entities.

  EntityProcSet send_closure ;

  for ( std::vector<EntityProc>::iterator
        i = local_change.begin() ; i != local_change.end() ; ++i ) {
    insert_closure_send( *i , send_closure );
  }

  {
    EntitySet work ;

    for ( std::vector<EntityProc>::const_iterator
          i = ghosted_change.begin() ; i != ghosted_change.end() ; ++i ) {
      insert_transitive_ghost( i->first , m_parallel_rank , work );
    }

    for ( std::vector<EntityProc>::const_iterator
          i = shared_change.begin() ; i != shared_change.end() ; ++i ) {
      insert_transitive_ghost( i->first , m_parallel_rank , work );
    }

    for ( EntityProcSet::iterator
          i = send_closure.begin() ; i != send_closure.end() ; ++i ) {
      insert_transitive_ghost( i->first , m_parallel_rank , work );
    }

    // The ghosted change list will become invalid
    ghosted_change.clear();

    std::vector<EntityProc> empty ;
    std::vector<Entity*> effected_ghosts( work.begin() , work.end() );

    // Skip 'm_ghosting[0]' which is the shared subset.
    for ( std::vector<Ghosting*>::iterator
          ig = m_ghosting.begin() + 1 ; ig != m_ghosting.end() ; ++ig ) {
      // parallel synchronous:
      internal_change_ghosting( **ig , empty , effected_ghosts );
    }
  }

  //------------------------------
  // Consistently change the owner on all processes.
  // 1) The local_change list is giving away ownership.
  // 2) The shared_change may or may not be receiving ownership

  {
    PartVector owned( 1 );
    owned[0] = & meta.locally_owned_part();

    for ( std::vector<EntityProc>::iterator
          i = local_change.begin() ; i != local_change.end() ; ++i ) {
      // Giving ownership, change the parts first and then
      // the owner rank to pass the ownership test.
      change_entity_parts( * i->first , PartVector() , owned );

      m_entity_repo.set_entity_owner_rank( *(i->first), i->second);
    }

    for ( std::vector<EntityProc>::iterator
          i = shared_change.begin() ; i != shared_change.end() ; ++i ) {
      m_entity_repo.set_entity_owner_rank( *(i->first), i->second);
      if ( p_rank == i->second ) { // I receive ownership
        change_entity_parts( * i->first , owned , PartVector() );
      }
    }
  }

  //------------------------------
  // Send entities, along with their closure, to the new owner processes
  {
    std::ostringstream error_msg ;
    int error_count = 0 ;

    CommAll comm( p_comm );

    for ( std::set<EntityProc,EntityLess>::iterator
          i = send_closure.begin() ; i != send_closure.end() ; ++i ) {
      CommBuffer & buffer = comm.send_buffer( i->second );
      Entity     & entity = * i->first ;
      pack_entity_info( buffer , entity );
      pack_field_values( buffer , entity );
    }

    comm.allocate_buffers( p_size / 4 );

    for ( std::set<EntityProc,EntityLess>::iterator
          i = send_closure.begin() ; i != send_closure.end() ; ++i ) {
      CommBuffer & buffer = comm.send_buffer( i->second );
      Entity     & entity = * i->first ;
      pack_entity_info( buffer , entity );
      pack_field_values( buffer , entity );
    }

    comm.communicate();

    for ( unsigned p = 0 ; p < p_size ; ++p ) {
      CommBuffer & buf = comm.recv_buffer(p);
      while ( buf.remaining() ) {
        PartVector parts ;
        std::vector<Relation> relations ;
        EntityKey key ;
        unsigned  owner = ~0u ;

        unpack_entity_info( buf, *this, key, owner, parts, relations );

        // Received entity information will be correct,
        // modulo the owned and shared parts

        remove( parts , meta.globally_shared_part() );

        if ( owner == p_rank ) {
          // Must have the locally_owned_part
          insert( parts , meta.locally_owned_part() );
        }
        else {
          // Must not have the locally_owned_part
          remove( parts , meta.locally_owned_part() );
        }

        std::pair<Entity*,bool> result =
          m_entity_repo.internal_create_entity( key );

        m_entity_repo.log_created_parallel_copy( *(result.first) );

        // The entity was copied and not created.

        m_entity_repo.set_entity_owner_rank( *(result.first), owner);

        internal_change_entity_parts( *result.first , parts , PartVector() );

        declare_relation( *result.first , relations );

        if ( ! unpack_field_values( buf , * result.first , error_msg ) ) {
          ++error_count ;
        }
      }
    }

    all_reduce( p_comm , ReduceSum<1>( & error_count ) );

    if ( error_count ) { throw std::runtime_error( error_msg.str() ); }

    // Any entity that I sent and is not in an owned closure is deleted.
    // The owned closure will be effected by received entities, so can
    // only clean up after the newly owned entities have been received.
    // Destroy backwards so as not to invalidate closures in the process.

    {
      Entity * entity = NULL ;

      for ( std::set<EntityProc,EntityLess>::iterator
            i = send_closure.end() ; i != send_closure.begin() ; ) {

        Entity * e = (--i)->first ;

        // The same entity may be sent to more than one process.
        // Only evaluate it once.

        if ( entity != e ) {
          entity = e ;
          if ( ! member_of_owned_closure( *e , p_rank ) ) {
            if ( ! destroy_entity( e ) ) {
              throw std::logic_error(std::string("BulkData::destroy_entity FAILED"));
            }
          }
        }
      }
    }

    send_closure.clear(); // Has been invalidated
  }
}