예제 #1
0
//------------------------------------------------------------------------------
// reset() -- Reset parameters
//------------------------------------------------------------------------------
void RfSensor::reset()
{
    BaseClass::reset();

    // ---
    // Do we need to find the track manager?
    // ---
    if (getTrackManager() == 0 && getTrackManagerName() != 0 && getOwnship() != 0) {
        // We have a name of the track manager, but not the track manager itself
        const char* name = *getTrackManagerName();

        // Get the named track manager from the onboard computer
        OnboardComputer* obc = getOwnship()->getOnboardComputer();
        if (obc != 0) {
            setTrackManager( obc->getTrackManagerByName(name) );
        }

        if (getTrackManager() == 0) {
            // The assigned track manager was not found!
            std::cerr << "RfSensor::reset() ERROR -- track manager, " << name << ", was not found!" << std::endl;
            setTrackManagerName(0);
        }
    }

    scanning = false;
    scanBar = 0;
    if (nRanges > 0 && ranges != 0) {
        rngIdx = 1;
        if (initRngIdx >= 1 && initRngIdx <= nRanges) {
            rngIdx = initRngIdx;
        }
        setRange( ranges[rngIdx-1] );
    }
}
예제 #2
0
//------------------------------------------------------------------------------
// updateData() -- update background data here
//------------------------------------------------------------------------------
void IrSensor::updateData(const double dt)
{
    BaseClass::updateData(dt);

   // ---
   // Do we need to find the track manager?
   // ---
   if (getTrackManager() == nullptr && getTrackManagerName() != nullptr && getOwnship() != nullptr) {
      // We have a name of the track manager, but not the track manager itself
      const char* name = *getTrackManagerName();

      // Get the named track manager from the onboard computer
      OnboardComputer* obc = getOwnship()->getOnboardComputer();
      if (obc != nullptr) {
         setTrackManager( obc->getTrackManagerByName(name) );
      }

      if (getTrackManager() == nullptr) {
         // The assigned track manager was not found!
         if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "IrSensor::reset() ERROR -- track manager, " << name << ", was not found!" << std::endl;
         }
         setTrackManagerName(nullptr);
      }
   }
}
예제 #3
0
//------------------------------------------------------------------------------
// reset() -- Reset parameters
//------------------------------------------------------------------------------
void Datalink::reset()
{
   clearQueues();
   // ---
   // Do we need to find the track manager?
   // ---
   if (getTrackManager() == 0 && getTrackManagerName() != 0) {
        // We have a name of the track manager, but not the track manager itself
        const char* name = *getTrackManagerName();
        // Get the named track manager from the onboard computer
        Player* ownship = dynamic_cast<Player*>( findContainerByType(typeid(Player)) );
        if (ownship != 0) {
            OnboardComputer* obc = ownship->getOnboardComputer();
            if (obc != 0) {
               setTrackManager(obc->getTrackManagerByName(name));
            }
        }    
        if (getTrackManager() == 0) {
            // The assigned track manager was not found!
            //if (isMessageEnabled(MSG_ERROR)) {
            //std::cerr << "Datalink ERROR -- track manager, " << name << ", was not found!" << std::endl;
            //}
        }
   }
   // ---
   // Do we need to find the comm radio?
   // ---
   if (getRadio() == 0 && getRadioName() != 0) {
        // We have a name of the radio, but not the radio itself
        const char* name = *getRadioName();
        // Get the named radio from the component list of radios
        Player* ownship = dynamic_cast<Player*>( findContainerByType(typeid(Player)) );
        if (ownship != 0) {
            CommRadio* cr = dynamic_cast<CommRadio*>(ownship->getRadioByName(name));
            setRadio(cr);
        }
        CommRadio* rad = getRadio();
        if (rad == 0) {
            // The assigned radio was not found!
            if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "Datalink ERROR -- radio, " << name << ", was not found!" << std::endl;
        }
        }
        else {
            rad->setDatalink(this);
            rad->setReceiverEnabledFlag(true);
            rad->setTransmitterEnableFlag(true);
        }
   }
   BaseClass::reset();
}
//------------------------------------------------------------------------------
// reset() -- Reset parameters
//------------------------------------------------------------------------------
void MergingIrSensor::reset()
{
   BaseClass::reset();

   // check the type of our track manager - we need to use the AirAngleOnlyTrkMgrPT
   if (getTrackManager() != nullptr) {
      const AirAngleOnlyTrkMgrPT* a = dynamic_cast<const AirAngleOnlyTrkMgrPT*>(getTrackManager());
      if (a == nullptr) {
         if (isMessageEnabled(MSG_WARNING)) {
            std::cerr << "MergingIrSensor::reset() : track manager is not an AirAngleOnlyTrkMgrPT" << std::endl;
         }
      }
   }
}
예제 #5
0
void IrSensor::process(const double dt)
{
   BaseClass::process(dt);

   int numRecords = storedMessagesQueue.entries();
   if (numRecords > 0) {
      AngleOnlyTrackManager* tm = static_cast<AngleOnlyTrackManager*>(getTrackManager());
      if (tm != nullptr) {
         base::lock(storedMessagesLock);
         numRecords = storedMessagesQueue.entries();

         // Send on all messages EXCEPT those with signal below threshold and those merged
         // into another signal. Those will simply be ignored and unreferenced.

         for (int i=0; i < numRecords; i++) {
            IrQueryMsg* msg = storedMessagesQueue.get();
            if (msg->getQueryMergeStatus() != IrQueryMsg::MERGED_OUT) {
               if (msg->getSignalToNoiseRatio() > getThreshold())
                  tm->newReport(msg, msg->getSignalToNoiseRatio());
            }
            msg->unref();
         }
         base::unlock(storedMessagesLock);
      }
   }
}
예제 #6
0
//------------------------------------------------------------------------------
// process() -- process the TWS reports
//------------------------------------------------------------------------------
void Radar::process(const LCreal dt)
{
   BaseClass::process(dt);

   // Find the track manager
   TrackManager* tm = getTrackManager();
   if (tm == nullptr) {
      // No track manager! Then just flush the input queue.
      lcLock(myLock);
      for (Emission* em = rptQueue.get(); em != nullptr; em = rptQueue.get()) {
         em->unref();
         rptSnQueue.get();
      }
      lcUnlock(myLock);
   }

   // ---
   // When end of scan, send all unsent reports to the track manager
   // ---
   if (endOfScanFlg) {

      endOfScanFlg = false;

      lcLock(myLock);
      for (unsigned int i = 0; i < numReports && i < MAX_REPORTS; i++) {
         if (tm != nullptr) {
            tm->newReport(reports[i], rptMaxSn[i]);
         }
         reports[i]->unref();
         reports[i] = nullptr;
         rptMaxSn[i] = 0;
      }
      numReports = 0;
      lcUnlock(myLock);
   }


   // ---
   // Process our returned emissions into reports for the track manager
   //   1) Match each emission with existing reports
   //   2) On emission/report matches, if the S/N value of the new emission
   //      is greater than the report, use the new emission
   //   3) Create new reports for unmatched emissions
   // ---
   lcLock(myLock);
   while (rptQueue.isNotEmpty()) {

      // Get the emission
      Emission* em = rptQueue.get();
      LCreal snDbl = rptSnQueue.get();

      if (em != nullptr) {
         // ---
         // 1) Match the emission with existing reports
         // ---
         int matched = -1;
         for (unsigned int i = 0; i < numReports && matched < 0; i++) {
            // Compare targets
            if ( em->getTarget() == reports[i]->getTarget() ) {
               // We have a match!!!
               matched = i;
            }
         }

         // ---
         // 2) On emission/report match
         // ---
         if (matched >= 0) {
            if (snDbl > rptMaxSn[matched]) {
               // When the S/N value of the new emission is greater than the report,
               // we use the new emission
               reports[matched]->unref();
               em->ref();
               reports[matched] = em;
               rptMaxSn[matched] = snDbl;
            }
         }


         // ---
         // 3) Create a new report entry for the unmatched emission
         // ---

         if (matched < 0 && numReports < MAX_REPORTS) {
            em->ref();
            reports[numReports] = em;
            rptMaxSn[numReports] = snDbl;
            numReports++;
         }
         // finished
         em->unref();
      }
   }
   lcUnlock(myLock);
}
예제 #7
0
파일: Rwr.cpp 프로젝트: Stupefy/OpenEaagles
//------------------------------------------------------------------------------
// receive() -- process received emissions
//------------------------------------------------------------------------------
void Rwr::receive(const LCreal dt)
{
   BaseClass::receive(dt);

   // clear the back buffer
   clearRays(0);

   // Receiver losses
#if 0
   LCreal noise = getRfRecvNoise();
#else
   LCreal noise = getRfRecvNoise() * getRfReceiveLoss();
#endif

   // Process received emissions 
   TrackManager* tm = getTrackManager();
   Emission* em = 0;
   LCreal signal = 0;

   // Get an emission from the queue
   lcLock(packetLock);
   if (np > 0) {
      np--; // Decrement 'np', now the array index
      em = packets[np];
      signal = signals[np];
   }
   lcUnlock(packetLock);

   while (em != 0) {

      //std::cout << "Rwr::receive(" << em->getOwnship() << "): ";
      //std::cout << " pwr=" << em->getPower();
      //std::cout << " gain=" << em->getGain();
      //std::cout << " rl=" << rl;
      //std::cout << " pulses=" << pulses;
      //std::cout << " losses=" << losses;
      //std::cout << " signal=" << signal;
      //std::cout << " recvN=" << getRfRecvNoise();
      //std::cout << " sn=" << sn;
      //std::cout << " snDbl=" << snDbl;
      //std::cout << " thrs=" << getRfThreshold();
      //std::cout << std::endl;

      // CGB, if "signal <= 0.0", then "snDbl" is probably invalid
      if (signal > 0.0 && dt != 0.0) {

         // Signal over noise (equation 3-5)
         LCreal sn = signal / noise;
         LCreal snDbl = 10.0f * lcLog10(sn);

         // Is S/N above receiver threshold  ## dpg -- for now, don't include ECM emissions
         if (snDbl > getRfThreshold() && !em->isECM() && rptQueue.isNotFull()) {
            // Send report to the track manager
            if (tm != 0) {
               tm->newReport(em, snDbl);
            }

            // Get Angle Of Arrival
            LCreal aoa= em->getAzimuthAoi();

            // Store received power for real-beam display
            LCreal sigDbl = 10.0f * lcLog10(signal);
            LCreal signal10 = (sigDbl + 50.0f)/50.f;
            int idx = getRayIndex( static_cast<LCreal>(Basic::Angle::R2DCC * aoa) );
            rays[0][idx] = lim01(rays[0][idx] + signal10);
            //if (idx == 0 && getOwnship()->getID() == 1011) {
            //   std::cout << "sig = " << signal10 << std::endl;
            //}

            // Send to the track list processor
            em->ref();  // ref() for track list processing
            rptQueue.put(em);
         }
      }

      // finished
      em->unref();   // this unref() undoes the ref() done by RfSystem::rfReceivedEmission
      em = 0;


      // Get another emission from the queue
      lcLock(packetLock);
      if (np > 0) {
         np--;
         em = packets[np];
         signal = signals[np];
      }
      lcUnlock(packetLock);

   }

   // Transfer the rays
   xferRays();
}