整合GPS同步并修复UI刷新bug
- 将InitSystemParams功能整合到SetupSubscriptions中 - 修复Widget_M300RTK运算符错误(&改为&&) - 添加UI定时刷新功能Slot_flash_screen - 添加密码保护功能(123456) - WDA传感器添加结束符格式TODO注释 - 调整widget控件索引映射
This commit is contained in:
@ -256,7 +256,7 @@ int VehicleController::SetupEnvironment_M300RTK()
|
||||
qDebug() << "VehicleController: Func DjiPlatform_RegHalUartHandler. Register hal uart handler error";
|
||||
throw std::runtime_error("Register hal uart handler error.");
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
returnCode = DjiPlatform_RegHalNetworkHandler(&networkHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
printf("register hal network handler error");
|
||||
@ -270,6 +270,17 @@ int VehicleController::SetupEnvironment_M300RTK()
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
}else {
|
||||
// returnCode = DjiPlatform_RegHalNetworkHandler(&networkHandler);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
// printf("register hal network handler error");
|
||||
// return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
// }
|
||||
// // //Attention: if you want to use camera stream view function, please uncomment it.
|
||||
// returnCode = DjiPlatform_RegSocketHandler(&socketHandler);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
// printf("register osal socket handler error");
|
||||
// return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
// }
|
||||
returnCode = DjiPlatform_RegHalUsbBulkHandler(&usbBulkHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
printf("register hal usb bulk handler error");
|
||||
@ -363,15 +374,17 @@ int VehicleController::StartupPSDK_M300RTK()
|
||||
USER_LOG_ERROR("power management init error");
|
||||
}
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
SetupWidget();//<2F>?<EFBFBD><C9BC>?<EFBFBD><DFBC><3E><><EFBFBD>
|
||||
SetupWidget();//<2F>?<EFBFBD><C9BC>?<EFBFBD><DFBC><3E><><EFBFBD>
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
SetupMessagePipe();//widget<65><74>vehicle
|
||||
// SetupWaypointStatusCallback();
|
||||
// InitSystemParams();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?<EFBFBD>?<EFBFBD><E4A3AC><EFBFBD><EFBFBD>???<CDB3>??<E4A3AC><C8BB>?<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>?<EFBFBD><C4A3><EFBFBD>?<EFBFBD>?<EFBFBD>??<CDAC><CAB1><EFBFBD><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SetupSubscriptions();//?<><CAB5><EFBFBD><EFBFBD>?<EFBFBD>?<EFBFBD><C4B6>?<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD>?<EFBFBD><CCAB><EFBFBD><EFBFBD>
|
||||
//InitSystemParams();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?<EFBFBD>?<EFBFBD><E4A3AC><EFBFBD><EFBFBD>???<CDB3>??<E4A3AC><C8BB>?<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>?<EFBFBD><C4A3><EFBFBD>?<EFBFBD>?<EFBFBD>??<CDAC><CAB1><EFBFBD><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//?<><CAB5><EFBFBD><EFBFBD>?<EFBFBD>?<EFBFBD><C4B6>?<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD>?<EFBFBD><CCAB><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
qDebug()<<"M300RTK PSDK Channel Started.";
|
||||
m_clsWidget.stratmessageflash();
|
||||
SetupSubscriptions();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -463,7 +476,10 @@ int VehicleController::GetOneDataFrame(M300RTKDataFrame& M300RTKDataFrame)
|
||||
|
||||
int VehicleController::SetupSubscriptions()
|
||||
{
|
||||
QString qstrInfo = QString("Waiting for airborn gps Time Valide");
|
||||
emit Signal_UpdateVehicleMessage(qstrInfo, 0);
|
||||
T_DjiReturnCode tDjiReturnCode;
|
||||
QString qstrWBackPath("/home/data/Settings/MainSettings.ini");
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_Init();
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
@ -476,10 +492,39 @@ int VehicleController::SetupSubscriptions()
|
||||
qDebug() << "init data subscription module finished.";
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_HEIGHT_FUSION, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, DjiTest_FcSubscriptionReceiveHeightCallback);
|
||||
// Subscribe GPS related topics for time sync and homepoint altitude
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "Subscribe topic GPS_SIGNAL_LEVEL error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "Subscribe topic GPS_DATE error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_TIME, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "Subscribe topic GPS_TIME error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "Subscribe topic ALTITUDE_OF_HOMEPOINT error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
// Subscribe other flight data topics
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_HEIGHT_FUSION, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, DjiTest_FcSubscriptionReceiveHeightCallback);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_HEIGHT_FUSION error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
@ -487,7 +532,6 @@ int VehicleController::SetupSubscriptions()
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_VELOCITY, DJI_DATA_SUBSCRIPTION_TOPIC_5_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_VELOCITY error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
@ -502,7 +546,6 @@ int VehicleController::SetupSubscriptions()
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_QUATERNION, DJI_DATA_SUBSCRIPTION_TOPIC_5_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_QUATERNION error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
@ -510,12 +553,89 @@ int VehicleController::SetupSubscriptions()
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_BAROMETER, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_BAROMETER error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
// Wait for GPS signal and sync system time
|
||||
T_DjiOsalHandler* osalHandler = DjiPlatform_GetOsalHandler();
|
||||
bool bStop = false;
|
||||
#ifdef ZZ_FLAG_TEST
|
||||
bStop = 1;
|
||||
#endif
|
||||
|
||||
T_DjiFcSubscriptionGpsSignalLevel tDjiGpsSignalLevel = { 0 };
|
||||
T_DjiDataTimestamp tTimestamp = { 0 };
|
||||
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
QTime qtStart = QTime::currentTime();
|
||||
int iRetryTime = 0;
|
||||
|
||||
while (!bStop)
|
||||
{
|
||||
if (iRetryTime > 60)
|
||||
{
|
||||
bStop = 1;
|
||||
}
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL, (uint8_t*)&tDjiGpsSignalLevel, sizeof(T_DjiFcSubscriptionGpsSignalLevel), &tTimestamp);
|
||||
qDebug() << "GPS_SIGNAL_LEVEL:" << tDjiGpsSignalLevel;
|
||||
QTime qtElapsed = QTime::currentTime();
|
||||
if (tDjiGpsSignalLevel > 1)
|
||||
{
|
||||
bStop = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString qstrInfo = QString("Warning:Weak GPS signal, Waiting....GPS_SIGNAL_LEVEL:%1, Elapsed time:%2").arg(tDjiGpsSignalLevel).arg(qtStart.msecsTo(qtElapsed));
|
||||
emit Signal_UpdateVehicleMessage(qstrInfo, 0);
|
||||
}
|
||||
iRetryTime++;
|
||||
}
|
||||
|
||||
|
||||
// Get GPS datetime and sync system time
|
||||
T_DjiFcSubscriptionGpsDate tGpsDate = { 0 };
|
||||
T_DjiFcSubscriptionGpsTime tGpsTime = { 0 };
|
||||
T_DjiFcSubscriptionAltitudeOfHomePoint tAltOfHP = { 0 };
|
||||
T_DjiFcSubscriptionGpsPosition tDjiGpsPosition = { 0 };
|
||||
|
||||
DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE, (uint8_t*)&tGpsDate, sizeof(T_DjiFcSubscriptionGpsDate), &tTimestamp);
|
||||
DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_TIME, (uint8_t*)&tGpsTime, sizeof(T_DjiFcSubscriptionGpsTime), &tTimestamp);
|
||||
DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT, (uint8_t*)&tAltOfHP, sizeof(T_DjiFcSubscriptionAltitudeOfHomePoint), &tTimestamp);
|
||||
DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION, (uint8_t*)&tDjiGpsPosition, sizeof(T_DjiFcSubscriptionGpsPosition), &tTimestamp);
|
||||
|
||||
// Save homepoint altitude to config
|
||||
m_fHeightOfHomePoint_BM = tAltOfHP;
|
||||
float fHeightOfHomePoint_GPS = tDjiGpsPosition.z;
|
||||
QSettings qsMainSettings(qstrWBackPath, QSettings::Format::IniFormat);
|
||||
qsMainSettings.setValue(QString("WBACK/HeightOfHomePoint_BM"), QString("%1").arg(m_fHeightOfHomePoint_BM));
|
||||
qsMainSettings.setValue(QString("WBACK/HeightOfHomePoint_GPS"), QString("%1").arg(fHeightOfHomePoint_GPS));
|
||||
qDebug() << "HeightOfHomePoint_BM:" << m_fHeightOfHomePoint_BM;
|
||||
qDebug() << "HeightOfHomePoint_GPS:" << fHeightOfHomePoint_GPS;
|
||||
|
||||
// Sync system time from GPS
|
||||
QDateTime qdtDateTime;
|
||||
QString qstrDate = QString::number(tGpsDate);
|
||||
QString qstrTime = QString::number(tGpsTime);
|
||||
if (qstrTime.length() == 5)
|
||||
{
|
||||
qstrTime = "0" + qstrTime;
|
||||
}
|
||||
QString qstrDateTime = qstrDate + qstrTime;
|
||||
qdtDateTime = QDateTime::fromString(qstrDateTime, "yyyyMMddhhmmss");
|
||||
|
||||
if (qdtDateTime.isValid())
|
||||
{
|
||||
QString command = "date -s \"" + qdtDateTime.toString("yyyy-MM-dd hh:mm:ss") + "\"";
|
||||
system(command.toLatin1().data());
|
||||
|
||||
time_t stdTime = qdtDateTime.toTime_t();
|
||||
stime(&stdTime);
|
||||
qDebug() << "System time synced from GPS:" << qdtDateTime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
}
|
||||
qstrInfo = QString("begin system");
|
||||
emit Signal_UpdateVehicleMessage(qstrInfo, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -602,7 +722,7 @@ int VehicleController::SetupMessagePipe()
|
||||
int VehicleController::SetupWidget()
|
||||
{
|
||||
m_clsWidget.SetUIFilePath("/home/DJI/Widget",100);
|
||||
// m_clsWidget.SetUIFilePath("/home/pi/airborn/configfile/DJI/Widget",100);
|
||||
//m_clsWidget.SetUIFilePath("/home/pi/airborn/configfile/DJI/Widget",100);
|
||||
|
||||
|
||||
m_clsWidget.SetSettings(m_struUIConfig);
|
||||
@ -611,251 +731,6 @@ int VehicleController::SetupWidget()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::InitSystemParams()
|
||||
{
|
||||
T_DjiReturnCode tDjiReturnCode;
|
||||
QString qstrWBackPath("/home/data/Settings/MainSettings.ini");
|
||||
|
||||
|
||||
///Init
|
||||
tDjiReturnCode = DjiFcSubscription_Init();
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "init data subscription module error.";
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "InitSystemDateTime started.";
|
||||
}
|
||||
|
||||
///SubscribeTopic GPS_SIGNAL_LEVEL
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL error.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
///SubscribeTopic GPS_DATE
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE error.";
|
||||
return -2;
|
||||
}
|
||||
|
||||
///SubscribeTopic GPS_TIME
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_TIME, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_GPS_TIME error.";
|
||||
return -3;
|
||||
}
|
||||
|
||||
///SubscribeTopic ALTITUDE_OF_HOMEPOINT
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT error.";
|
||||
return -4;
|
||||
}
|
||||
|
||||
///SubscribeTopic DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION error.";
|
||||
return -5;
|
||||
}
|
||||
|
||||
///Make sure Gps avalible
|
||||
T_DjiOsalHandler* osalHandler = DjiPlatform_GetOsalHandler();
|
||||
bool bStop = false;
|
||||
/////for test
|
||||
#ifdef ZZ_FLAG_TEST
|
||||
|
||||
bStop = 1;
|
||||
#endif
|
||||
|
||||
|
||||
T_DjiFcSubscriptionGpsSignalLevel tDjiGpsSignalLevel = { 0 };
|
||||
T_DjiDataTimestamp tTimestamp = { 0 };
|
||||
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
QTime qtStart = QTime::currentTime();
|
||||
|
||||
int iRetryTime = 0;
|
||||
|
||||
while (!bStop)
|
||||
{
|
||||
if (iRetryTime>60)
|
||||
{
|
||||
bStop = 1;
|
||||
}
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL, (uint8_t*)&tDjiGpsSignalLevel, sizeof(T_DjiFcSubscriptionGpsSignalLevel), &tTimestamp);
|
||||
qDebug() << "DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL" << tDjiGpsSignalLevel;
|
||||
QTime qtElapsed = QTime::currentTime();
|
||||
if (tDjiGpsSignalLevel>1)
|
||||
{
|
||||
bStop = 1;
|
||||
//emit Signal_UpdatePSDKFloatMessage("");
|
||||
}
|
||||
else
|
||||
{
|
||||
QString qstrInfo = QString("Warning:Weak GPS signal, Waiting....GPS_SIGNAL_LEVEL:%1, Elapsed time:%2").arg(tDjiGpsSignalLevel).arg(qtStart.msecsTo(qtElapsed));
|
||||
emit Signal_UpdateVehicleMessage(qstrInfo);
|
||||
}
|
||||
|
||||
iRetryTime++;
|
||||
}
|
||||
//osalHandler->TaskSleepMs(2000);
|
||||
|
||||
///Get GPS Datetime
|
||||
T_DjiFcSubscriptionGpsDate tGpsDate = { 0 };
|
||||
T_DjiFcSubscriptionGpsTime tGpsTime = { 0 };
|
||||
///Get Other
|
||||
T_DjiFcSubscriptionAltitudeOfHomePoint tAltOfHP = { 0 };
|
||||
T_DjiFcSubscriptionGpsPosition tDjiGpsPosition = { 0 };
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE, (uint8_t*)&tGpsDate, sizeof(T_DjiFcSubscriptionGpsDate), &tTimestamp);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_GetLatestValueOfTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_TIME, (uint8_t*)&tGpsTime, sizeof(T_DjiFcSubscriptionGpsTime), &tTimestamp);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_GetLatestValueOfTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE.";
|
||||
return -2;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT, (uint8_t*)&tAltOfHP, sizeof(T_DjiFcSubscriptionAltitudeOfHomePoint), &tTimestamp);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_GetLatestValueOfTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT.";
|
||||
return -3;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION, (uint8_t*)&tDjiGpsPosition, sizeof(T_DjiFcSubscriptionGpsPosition), &tTimestamp);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_GetLatestValueOfTopic error.DJI_FC_SUBSCRIPTION_TOPIC_VELOCITY";
|
||||
return -4;
|
||||
}
|
||||
|
||||
m_fHeightOfHomePoint_BM = tAltOfHP;
|
||||
float fHeightOfHomePoint_GPS= tDjiGpsPosition.z;
|
||||
QString qstrHeightOfHomePoint_BM = QString("%1").arg(m_fHeightOfHomePoint_BM);
|
||||
QString qstrHeightOfHomePoint_GPS = QString("%1").arg(tDjiGpsPosition.z);
|
||||
//////////////////////////////////////////////////////////////////////////write back AOHP
|
||||
QSettings qsMainSettings(qstrWBackPath, QSettings::Format::IniFormat);
|
||||
qsMainSettings.setValue(QString("WBACK/HeightOfHomePoint_BM"), qstrHeightOfHomePoint_BM);
|
||||
qsMainSettings.setValue(QString("WBACK/HeightOfHomePoint_GPS"), qstrHeightOfHomePoint_GPS);
|
||||
qDebug() << qstrHeightOfHomePoint_BM << m_fHeightOfHomePoint_BM;
|
||||
qDebug() << qstrHeightOfHomePoint_GPS << tDjiGpsPosition.z;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//qDebug() << "Date" << tGpsDate << "Time" << tGpsTime;
|
||||
|
||||
QDateTime qdtDateTime;
|
||||
QString qstrDate, qstrTime,qstrDateTime;
|
||||
qstrDate = QString::number(tGpsDate);
|
||||
qstrTime = QString::number(tGpsTime);
|
||||
if (qstrTime.length()==5)
|
||||
{
|
||||
qstrTime = "0" + qstrTime/*+"000"*/;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// qstrTime= qstrTime + "000";
|
||||
// }
|
||||
// QDate qd;
|
||||
// qd = QDate::fromString("20121022", "yyyyMMdd");
|
||||
// QTime qt;
|
||||
// qt.fromString(qstrTime,"hhmmsszzz");
|
||||
qstrDateTime = qstrDate + qstrTime;
|
||||
qdtDateTime = QDateTime::fromString(qstrDateTime, "yyyyMMddhhmmss");
|
||||
QString command="date -s \""+qdtDateTime.toString("yyyy-MM-dd hh:mm:ss")+"\"";
|
||||
system(command.toLatin1().data());
|
||||
|
||||
time_t stdTime = qdtDateTime.toTime_t();
|
||||
|
||||
if (qdtDateTime.isValid())
|
||||
{
|
||||
stime(&stdTime);
|
||||
}
|
||||
#ifndef ZZ_FLAG_TEST
|
||||
//stime(&stdTime);
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
// qDebug() << qstrDate;
|
||||
// qDebug() << qstrTime;
|
||||
// qDebug() << qd.isValid();
|
||||
// qDebug() << qd.toString("yyyyMMdd");
|
||||
// qDebug() << qt.isValid();
|
||||
// qDebug() << qt;
|
||||
qDebug() <<"[GPS Time Check]" << qdtDateTime.isValid();
|
||||
qDebug() <<"[GPS Time:]" << qstrDateTime << "####" << qdtDateTime.toString("yyyyMMddhhmmsszzz");
|
||||
|
||||
///UnSubscribeTopic
|
||||
/*tDjiReturnCode = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_UnSubscribeTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL.";
|
||||
return -11;
|
||||
}*/
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_UnSubscribeTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_GPS_SIGNAL_LEVEL.";
|
||||
return -11;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_UnSubscribeTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_GPS_DATE.";
|
||||
return -12;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_TIME);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_UnSubscribeTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_GPS_TIME.";
|
||||
return -13;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_UnSubscribeTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT.";
|
||||
return -14;
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "DjiFcSubscription_UnSubscribeTopic module error,DJI_FC_SUBSCRIPTION_TOPIC_ALTITUDE_OF_HOMEPOINT.";
|
||||
return -15;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::Slot_OnChangeCaptureMode(char cMode)
|
||||
{
|
||||
//ZZ_Widget_M300RTK* test = qobject_cast<ZZ_Widget_M300RTK*>(sender());
|
||||
|
||||
@ -70,7 +70,7 @@ private:
|
||||
int SetupWidget();
|
||||
///
|
||||
public:///for test
|
||||
int InitSystemParams();
|
||||
// int InitSystemParams();
|
||||
int SetupSubscriptions();
|
||||
///
|
||||
public:///for test
|
||||
@ -84,7 +84,7 @@ signals:
|
||||
int Signal_StartCapture();
|
||||
int Signal_StopCapture();
|
||||
|
||||
void Signal_UpdateVehicleMessage(QString qstrMessage);
|
||||
void Signal_UpdateVehicleMessage(QString qstrMessage,int lineid);
|
||||
public slots:
|
||||
int Slot_OnChangeCaptureMode(char cMode);
|
||||
///for test
|
||||
|
||||
Reference in New Issue
Block a user