Example #1
0
//------------------------------------------------------------------------------
// queueIncomingMessage() -- Queue up an incoming message
//------------------------------------------------------------------------------
bool Datalink::queueIncomingMessage(Basic::Object* const msg)
{
   // Only queue message if Ownship is local.  IPlayer messages are processed on their local systems
   if ((getOwnship() == nullptr) || !(getOwnship()->isLocalPlayer())) {
      return true;
   }

   //if (isMessageEnabled(MSG_INFO)) {
   //std::cout << getOwnship()->getID() << "\tincomming QQueue Size: " << inQueue->entries() << std::endl;
   //}

   if(inQueue->isFull()) {
      if (isMessageEnabled(MSG_WARNING)) {
         std::cerr << "dumping 10 oldest messages in Datalink::inQueue" << std::endl;
      }

      for(int i = 0; i < 10; i++) {
         Basic::Object* obj = inQueue->get();
         obj->unref();
      } //clear out 10 oldest messages
   }
   if (msg != nullptr) {
      msg->ref();
      inQueue->put(msg);
   }
   return true;
}
Example #2
0
// DataRecordTest builder
static DataRecordTest* builder(const char* const filename)
{
   // read configuration file
   int errors = 0;
   Basic::Object* obj = Basic::lcParser(filename, Factory::createObj, &errors);
   if (errors > 0) {
      std::cerr << "File: " << filename << ", errors: " << errors << std::endl;
      std::exit(EXIT_FAILURE);
   }

   // test to see if an object was created
   if (obj == 0) {
      std::cerr << "Invalid configuration file, no objects defined!" << std::endl;
      std::exit(EXIT_FAILURE);
   }

   // do we have a Basic::Pair, if so, point to object in Pair, not Pair itself
   Basic::Pair* pair = dynamic_cast<Basic::Pair*>(obj);
   if (pair != 0) {
      obj = pair->object();
      obj->ref();
      pair->unref();
   }

   // try to cast to proper object, and check
   DataRecordTest* dataRecordTest = dynamic_cast<DataRecordTest*>(obj);
   if (dataRecordTest == 0) {
      std::cerr << "Invalid configuration file!" << std::endl;
      std::exit(EXIT_FAILURE);
   }
   return dataRecordTest;
}
Example #3
0
// display builder
static Glut::GlutDisplay* builder(const char* const filename)
{
   // read configuration file
   int errors = 0;
   Basic::Object* obj = Basic::lcParser(filename, factory, &errors);
   if (errors > 0) {
      std::cerr << "File: " << filename << ", errors: " << errors << std::endl;
      std::exit(EXIT_FAILURE);
   }

   // test to see if an object was created
   if (obj == nullptr) {
      std::cerr << "Invalid configuration file, no objects defined!" << std::endl;
      std::exit(EXIT_FAILURE);
   }

   // do we have a Basic::Pair, if so, point to object in Pair, not Pair itself
   Basic::Pair* pair = dynamic_cast<Basic::Pair*>(obj);
   if (pair != nullptr) {
      obj = pair->object();
      obj->ref();
      pair->unref();
   }

   // try to cast to proper object, and check
   Glut::GlutDisplay* glutDisplay = dynamic_cast<Glut::GlutDisplay*>(obj);
   if (glutDisplay == nullptr) {
      std::cerr << "Invalid configuration file!" << std::endl;
      std::exit(EXIT_FAILURE);
   }
   return glutDisplay;
}
Example #4
0
//------------------------------------------------------------------------------
// clearQueues() -- clear all queues
//------------------------------------------------------------------------------
void Datalink::clearQueues()
{
   Basic::Object* msg = inQueue->get();
   while (msg != 0) {
      msg->unref();
      msg = inQueue->get();
   }
   msg = outQueue->get();
   while (msg != 0) {
      msg->unref();
      msg = outQueue->get();
   }
}
Example #5
0
//------------------------------------------------------------------------------
// queueOutgoingMessage() -- Queue up an out going message -- 
//------------------------------------------------------------------------------
bool Datalink::queueOutgoingMessage(Basic::Object* const msg)
{
    //if (isMessageEnabled(MSG_INFO)) {
    //std::cout << getOwnship()->getID() << "\tOutgoing QQueue Size: " << outQueue->entries() << std::endl;
    //}

    if(outQueue->isFull()) {
        if (isMessageEnabled(MSG_WARNING)) {
        std::cerr << "dumping 10 oldest messages in Datalink::outQueue" << std::endl;
        }

        for(int i = 0; i < 10; i++) {
            Basic::Object* obj = outQueue->get();
            if (obj != 0) obj->unref();
        } //clear out 10 oldest messages
    }
    if (msg != 0) {
       msg->ref();
       outQueue->put(msg);
    }
    return true;
}
Example #6
0
//------------------------------------------------------------------------------
// copyData() -- copy member data
//------------------------------------------------------------------------------
void SlSymbol::copyData(const SlSymbol& org, const bool cc)
{
    BaseClass::copyData(org);
    if (cc) initData();

    visibility = org.visibility;
    llFlg = org.llFlg;
    acFlg = org.acFlg;
    scrnFlg = org.scrnFlg;

    type = org.type;
    lcStrcpy(id, sizeof(id), org.id);

    xPos = org.xPos;
    yPos = org.yPos;

    xScreenPos = org.xScreenPos;
    yScreenPos = org.yScreenPos;

    hdg = org.hdg;
    hdgValid = org.hdgValid;
    setHdgGraphics(0);
    setHdgAngleObj(0);

    {
        Basic::Object* copy = 0;
        if (org.value != 0) copy = org.value->clone();
        setValue(copy);
        if (copy != 0) copy->unref();
    }

    {
        Basic::Pair* copy = 0;
        if (org.pntr != 0) copy = org.pntr->clone();
        setSymbolPair(copy);
        if (copy != 0) copy->unref();
    }
}