当前位置: 首页>>代码示例>>C++>>正文


C++ Track::GetThreatID方法代码示例

本文整理汇总了C++中Track::GetThreatID方法的典型用法代码示例。如果您正苦于以下问题:C++ Track::GetThreatID方法的具体用法?C++ Track::GetThreatID怎么用?C++ Track::GetThreatID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Track的用法示例。


在下文中一共展示了Track::GetThreatID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Run

/******************************************************************************
*
*        Name: Run
*
* Description: Performs the main function of the thread.
* 
*  Attributes: None
*
*      Return: N/A
*
*      Author: Austin Dionne
*
******************************************************************************/
void CMControllerThread::Run(void)
{
  try
  {
    // This task loops forever, updating the CM.
    while (true)
    {
      // This loop will search for the highest priority track. If expired 
      // tracks are found it will remove them and continue searching. 
      // The loop terminates when a valid track is found and the CM is 
      // directed at the track, or when there are no tracks left.
      bool doneTrackLoop = false;
      while (!doneTrackLoop)
      {
        // Get the highest priority threat.
        Track* track = trackDatabase->GetFirstTrack();
        if (track == NULL)
        {
          // There are no more tracks to jam. If the countermeasure was
          // previously enabled, send the TurnOffCM message.
          if (enabledCM)
          {
            enabledCM = false;
            MCCMTransceiver::Instance()->SendTurnOffCMMessage();
          }

          // The track loop is done.
          doneTrackLoop = true;
        }
        else
        {
          // Determine if the track is still a threat.
          if (track->GetTimeOfArrival() > SystemClock::Instance()->GetCurrentTime())
          {
            // Look up the threat type in the threat database in order to determine
            // the jam code to use.
            Threat* threat = threatDatabase->FindThreatByID(track->GetThreatID());
            
            // Determine the azimuth in platform coordinates to direct the CM.
            float targetAzimuth = track->GetAngleOfArrival() -
              PlatformOrientation::Instance()->GetCurrentAzimuth();

            // Keep the calculated azimuth within the valid range.
            if (targetAzimuth > 360.0)
            {
              targetAzimuth -= 360.0;
            }
            else if (targetAzimuth < 0.0)
            {
              targetAzimuth += 360.0;
            }

            // Send the AllocateCM message via the MCCMTransceiver.
            enabledCM = true;
            MCCMTransceiver::Instance()->SendAllocateCMMessage(targetAzimuth, threat->GetJamCode());

            // The track loop is done.
            doneTrackLoop = true;
          }
          else
          {
            // The track has expired. Remove it from the track database and the
            // next iteration of the loop will attempt to find a valid track.
            trackDatabase->RemoveFirstTrack();
          }
        }
      }

      /* The following code does not work with the current version of Mother,
         because Mother can not respond to AllocateCM messages quickly enough.

      // Determine whether or not the countermeasure will require updating
      // faster than the normal rate. If the current angular velocity of the
      // platform is great enough that we will not stay within the tolerable
      // error, no delay will occur before the next CM update. Note that the
      // default CM update delay is in milliseconds.
      float expectedError = abs(PlatformOrientation::Instance()->GetCurrentAngularVelocity()
                                * DEFAULT_CM_UPDATE_DELAY / 1000.0);

      if (expectedError < MAXIMUM_CM_ERROR_TOLERANCE)
      {
        Sleep(DEFAULT_CM_UPDATE_DELAY);
      }
      */

      Sleep(DEFAULT_CM_UPDATE_DELAY);
    }
//.........这里部分代码省略.........
开发者ID:CarlosPlusPlus,项目名称:wpi-grad,代码行数:101,代码来源:CMControllerThread.cpp


注:本文中的Track::GetThreatID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。