本文整理汇总了C++中Sensor::StopSensor方法的典型用法代码示例。如果您正苦于以下问题:C++ Sensor::StopSensor方法的具体用法?C++ Sensor::StopSensor怎么用?C++ Sensor::StopSensor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sensor
的用法示例。
在下文中一共展示了Sensor::StopSensor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StopTrack
void Tracker::StopTrack()
{
MOJING_FUNC_TRACE(g_Sensorlogger);
MojingSDKStatus *pStatus = MojingSDKStatus::GetSDKStatus();
if (pStatus->GetTrackerStatus() != TRACKER_START)
{
#ifdef MJ_OS_ANDROID
if (pStatus->GetTrackerStatus() == TRACKER_START_NOW && pStatus->GetSensorOrigin() == SENSOR_FROM_JAVA)
{
//陀螺仪来源是SDK_JAVA, 可能由于数据未收到而未将状态置为TRACKER_START或TRACKER_STOP, 此时仍因运行继续继续Stop操作
}
else
#endif
{
return;
}
}
int count = AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, -1);
if (count < 0)// ==0表示已经退出过了,不要在下面+1
{
m_bSensorfusionInit = false;
AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, 1);
MOJING_TRACE(g_Sensorlogger, "Stop Tracker without Start Tracker first! ");
pStatus->SetTrackerStatus(TRACKER_STOP);
}
else if (count == 1)
{
// It really need stop
m_bSensorfusionInit = false;
pStatus->SetTrackerStatus(TRACKER_STOP_NOW);
if (m_pSensorfusion)
{
Manager* pManager = Manager::GetMojingManager();
Sensor* pSensor = pManager->GetSensor();
pSensor->StopSensor();
//delete m_pSensorfusion;
//m_pSensorfusion = NULL;
}
pStatus->SetTrackerStatus(TRACKER_STOP);
}
else
{
MOJING_TRACE(g_Sensorlogger, "Stop Tracker mismatch. Too many Start.");
}
}
示例2: StartTrack
bool Tracker::StartTrack(int nSampleFrequence/*, const char *pRecordPath*/, const char * lpszModel /* = NULL*/, const char* szGlassName)
{
MOJING_FUNC_TRACE(g_Sensorlogger);
MojingSDKStatus *pStatus = MojingSDKStatus::GetSDKStatus();
if (AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, 1) >= 1)
{
MOJING_TRACE(g_Sensorlogger, "Start Tracker do not match! Start already. ");
pStatus->SetTrackerStatus(TRACKER_START);
}
else
{
pStatus->SetTrackerStatus(TRACKER_START_NOW);
MOJING_TRACE(g_Sensorlogger, "Set sensor frequence as " << nSampleFrequence << " / " << GetMaxSensorsSampleRate() << "(Max)");
Manager* pManager = Manager::GetMojingManager();
pManager->SetSensor(szGlassName);
Sensor* pSensor = pManager->GetSensor();
int nCheck = pSensor->CheckSensors();
if (nCheck & (SENSOR_GryoTooSlow | SENSOR_NoGryo))
{
pStatus->SetTrackerStatus(TRACKER_STOP);
MOJING_ERROR(g_APIlogger, "GryoTooSlow or SENSOR_NoGryo , CheckSensors = " << nCheck);
AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, -1);
return false;
}
Parameters* pParameters = pManager->GetParameters();
m_pSensorfusion->Initialize(pSensor, pParameters, lpszModel);
if (GetDataFromExternal() && szGlassName == NULL)
{
#ifdef MJ_OS_ANDROID
pStatus->SetSensorOrigin(SENSOR_FROM_JAVA);
#endif
MOJING_TRACE(g_Sensorlogger, "Use sensor data from SDK_Java.");
m_bSensorfusionInit = true;
m_nSkipSamples = 10;
memset(&m_sensorFrame, 0, sizeof(MessageBodyFrame));
m_sensorFrame.LastSampleTime = m_sensorFrame.lastTempTime = NanoSecondToSecond(Timer::GetTicksNanos());
m_sensorFrame.Temperature = getTemperature();
if (m_sensorFrame.Temperature < 0) m_sensorFrame.Temperature = 2500; // 如果不能拿到温度值,则设置成25度
}
else
{
#ifdef MJ_OS_ANDROID
if (szGlassName)
{
pStatus->SetSensorOrigin(SENSOR_FROM_SERVICE);
MOJING_TRACE(g_Sensorlogger, "Use sensor data from Service. Name: " << szGlassName );
}
else
{
pStatus->SetSensorOrigin(SENSOR_FROM_NATIVE);
MOJING_TRACE(g_Sensorlogger, "Use sensor data from SDK_Native.");
}
#endif
if (!pSensor->StartSensor(nSampleFrequence/*, pRecordPath*/))
{
pStatus->SetTrackerStatus(TRACKER_STOP);
MOJING_ERROR(g_APIlogger, "pSensor->StartSensor failed");
AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, -1);
return false;
}
int iCount = 0;
MojingSDKStatus *pStatus = MojingSDKStatus::GetSDKStatus();
if (pStatus->GetEngineStatus() != ENGINE_UNREAL)
{ // 特殊处理:在进行等待第一个Sample的等待的时候,Unreal 4.11以及4.12
// 会陷入闪退。疑似等待时间过长导致。暂时屏蔽掉这里的代码,详细原因待查。
while (!m_pSensorfusion->m_bHasData && iCount++ < 1000)
{// 5ms
usleep(5000);
}
}
if (iCount > 1000)
{// 由于陀螺仪故障导致完全无法获取数据,这种情况下要通知调用方初始化失败
pSensor->StopSensor();
pStatus->SetTrackerStatus(TRACKER_STOP);
MOJING_ERROR(g_APIlogger, "Can not get any data in 5 Secs");
// Sensor data failed maybe temporary so recover RefCount
AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, -1);
return false;
}
else
{
pStatus->SetTrackerStatus(TRACKER_START);
}
SetYaw();
}
}
return true;
}