|
|
@@ -22,7 +22,7 @@ QString param::table_ftp = "ftp"; //FTP配置表
|
|
|
QString param::table_ftp_other = "ftp_other"; //FTP对接配置表
|
|
|
QString param::table_camera = "camera"; //相机参数配置表
|
|
|
QString param::table_location = "location"; //定位信息参数配置表
|
|
|
-QString param::table_mqtt_historydata = "data"; //mqtt历史数据表
|
|
|
+QString param::table_config = "config"; //参数配置表
|
|
|
|
|
|
|
|
|
|
|
|
@@ -48,7 +48,7 @@ public:
|
|
|
|
|
|
public slots:
|
|
|
void qmlSlot() {
|
|
|
- qDebug() << "Received from QML:";
|
|
|
+ LOG("Received from QML");
|
|
|
emit recvqmlslot();
|
|
|
}
|
|
|
void systemPage(){
|
|
|
@@ -117,20 +117,9 @@ public:
|
|
|
this, SLOT(positionUpdated(QGeoPositionInfo)));
|
|
|
positionSource->setUpdateInterval(1000);//设置刷新时间 单位毫秒
|
|
|
positionSource->startUpdates();//启动设备
|
|
|
-
|
|
|
-// connect(this,&GPSInfo::position_success,[&](){
|
|
|
-// gpsConfig->OpenDb();
|
|
|
-// if(gpsConfig->isTableExist(param::table_location)){
|
|
|
-// gpsConfig->UpdateData(param::table_location,"gps_lat",param::gps_lat);
|
|
|
-// gpsConfig->UpdateData(param::table_location,"gps_lng",param::gps_lng);
|
|
|
-// gpsConfig->CloseDb();
|
|
|
-// }
|
|
|
- //positionSource->stopUpdates();
|
|
|
-// disconnect(positionSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
|
|
|
-// this, SLOT(positionUpdated(QGeoPositionInfo)));
|
|
|
-// });
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
signals:
|
|
|
void position_success();
|
|
|
private:
|
|
|
@@ -193,7 +182,7 @@ void sendBroadcastFromQt(QString btn_type) {
|
|
|
QJniObject java_imei= jClass.callObjectMethod("getAndroidIMEI","(Landroid/content/Context;)Ljava/lang/String;",qtContext.object());
|
|
|
if(java_imei.isValid()){
|
|
|
QString imei = java_imei.toString();
|
|
|
- if(!imei.isEmpty()){
|
|
|
+ if(!imei.isEmpty()&¶m::imei.isEmpty()){
|
|
|
param::imei = imei;
|
|
|
}
|
|
|
LOG("IMEI:{}",param::imei.toStdString());
|
|
|
@@ -228,6 +217,33 @@ void sendBroadcastFromQt(QString btn_type) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 定义函数:设置每日8:00重启的定时器
|
|
|
+auto setDailyRebootTimer = []() {
|
|
|
+ // 获取当前时间(本地时间)
|
|
|
+ QDateTime currentTime = QDateTime::currentDateTime();
|
|
|
+
|
|
|
+ // 构造当天8:00的目标时间(基于本地时间的0点+8小时)
|
|
|
+ QDateTime targetTime = currentTime.date().startOfDay().addSecs(8 * 3600); // 8:00 = 8 * 3600秒
|
|
|
+
|
|
|
+ // 如果当前时间已过今日8:00,目标时间调整为次日8:00
|
|
|
+ if (currentTime >= targetTime) {
|
|
|
+ targetTime = targetTime.addDays(1); // 加1天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算当前时间到目标时间的毫秒间隔
|
|
|
+ qint64 intervalMs = currentTime.msecsTo(targetTime);
|
|
|
+
|
|
|
+ // 设置单次定时器,触发后执行重启逻辑,并重新设置下一日的定时器
|
|
|
+ QTimer::singleShot(intervalMs, []() {
|
|
|
+ LOG("触发每日8:00重启");
|
|
|
+ sendBroadcastFromQt("rebootSystem"); // 发送重启广播
|
|
|
+
|
|
|
+ // 注意:若需要严格每日执行,建议在重启前重新设置定时器(根据实际需求)
|
|
|
+ // 若系统重启后会自动启动本程序,可省略此处(程序重启后会重新设置定时器)
|
|
|
+ // setDailyRebootTimer();
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
//adb shell input keyevent 26 // 224 关
|
|
|
|
|
|
@@ -276,16 +292,10 @@ int main(int argc, char *argv[])
|
|
|
LOG("appPicPath:{}",appPicPath.toStdString());
|
|
|
#endif
|
|
|
|
|
|
- sendBroadcastFromQt("imei");
|
|
|
sendBroadcastFromQt("iccid");
|
|
|
sendBroadcastFromQt("csq");
|
|
|
|
|
|
|
|
|
- CurlFtpUploader uploader_ftp; // 成员变量
|
|
|
- QString remotepath ="/photo_hard/" + param::imei;
|
|
|
- uploader_ftp.setFtpParams("bzy_user", "YFkj@6O2O", "8.136.98.49", 21, remotepath);
|
|
|
-
|
|
|
-
|
|
|
// // 连接信号
|
|
|
// QObject::connect(&uploader_ftp, &CurlFtpUploader::progressChanged,
|
|
|
// [](double percent) {
|
|
|
@@ -311,6 +321,9 @@ int main(int argc, char *argv[])
|
|
|
sqlConfig->QueryAllData(param::table_mqtt);
|
|
|
}else{
|
|
|
sqlConfig->QueryAllData(param::table_mqtt);
|
|
|
+ if(param::imei.isEmpty()){
|
|
|
+ sendBroadcastFromQt("imei");
|
|
|
+ }
|
|
|
}
|
|
|
if(!sqlConfig->isTableExist(param::table_mqtt_other))
|
|
|
{
|
|
|
@@ -353,12 +366,22 @@ int main(int argc, char *argv[])
|
|
|
//相机图像参数
|
|
|
if(!sqlConfig->isTableExist(param::table_camera)){
|
|
|
sqlConfig->CreateTable(param::table_camera);
|
|
|
- config_class.camera_db = {"uvc","static",2,1000,1000,"0"};
|
|
|
+ config_class.camera_db = {"hikrobot","static",2,1000,1000,"0","f80","b80","f80","b80"};
|
|
|
sqlConfig->InsertData(config_class,param::table_camera);
|
|
|
sqlConfig->QueryAllData(param::table_camera);
|
|
|
}else{
|
|
|
sqlConfig->QueryAllData(param::table_camera);
|
|
|
}
|
|
|
+ //配置
|
|
|
+ if(!sqlConfig->isTableExist(param::table_config)){
|
|
|
+ sqlConfig->CreateTable(param::table_config);
|
|
|
+ config_class.config_db = {1,1,1000,500,0,0};
|
|
|
+ sqlConfig->InsertData(config_class,param::table_config);
|
|
|
+ sqlConfig->QueryAllData(param::table_config);
|
|
|
+ }else{
|
|
|
+ sqlConfig->QueryAllData(param::table_config);
|
|
|
+ }
|
|
|
+
|
|
|
//sqlConfig->CloseDb();
|
|
|
//InsertJson_mqtt();
|
|
|
|
|
|
@@ -371,11 +394,14 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
LOG("信息(Info)");
|
|
|
|
|
|
+ TreeModel model;
|
|
|
engine.setOfflineStoragePath(appDataPath); //设置数据库存储路径
|
|
|
engine.rootContext()->setContextProperty("appdir", qApp->applicationDirPath()); //使用QApplication::applicationDirPath()获取,并注册到qml中
|
|
|
+ engine.rootContext()->setContextProperty("treeModel",&model);
|
|
|
qmlRegisterType<EasyTableModel>("EasyModel",1,0,"EasyTableModel"); //注册C++模块到QML中
|
|
|
qmlRegisterType<DatabaseInterface>("com.example.database", 1, 0, "DatabaseInterface");
|
|
|
qmlRegisterType<CustomItem>("ExampleCustomMaterial",1,0,"CustomItem");
|
|
|
+
|
|
|
// Set an optional license key from project file
|
|
|
// This does not work if using Felgo Live, only for Felgo Cloud Builds and local builds
|
|
|
//felgo.setLicenseKey(PRODUCT_LICENSE_KEY);
|
|
|
@@ -393,44 +419,6 @@ int main(int argc, char *argv[])
|
|
|
//felgo.setMainQmlFileName(QStringLiteral("qrc:/qml/Main.qml"));
|
|
|
const QUrl url(felgo.mainQmlFileName());
|
|
|
|
|
|
- // 注册到QML
|
|
|
- ImageStitcher imagestitcher;
|
|
|
- //qmlRegisterType<ImageStitcher>("com.opencv.stitch", 1, 0, "ImageStitcher");
|
|
|
- engine.rootContext()->setContextProperty("stitcher", &imagestitcher);
|
|
|
- QObject::connect(&imagestitcher,&ImageStitcher::change_stitch_photonum,[&](int val){
|
|
|
- //将param::stitchphoto保存
|
|
|
- param::stitch_photonum = val;
|
|
|
- sqlConfig->OpenDb();
|
|
|
- if(sqlConfig->isTableExist(param::table_camera)){
|
|
|
- sqlConfig->UpdateData(param::table_camera,"stitch_photonum",QString::number(param::stitch_photonum));
|
|
|
- }
|
|
|
- sqlConfig->CloseDb();
|
|
|
- LOG("保存拼接数量:{}",param::stitch_photonum);
|
|
|
- });
|
|
|
-
|
|
|
- QObject::connect(&imagestitcher,&ImageStitcher::stitchFailed,[&](){
|
|
|
- //将param::stitchphoto保存
|
|
|
- param::stitch_mode = "done";
|
|
|
- sqlConfig->OpenDb();
|
|
|
- if(sqlConfig->isTableExist(param::table_camera)){
|
|
|
- sqlConfig->UpdateData(param::table_camera,"mode",param::stitch_mode);
|
|
|
- }
|
|
|
- sqlConfig->CloseDb();
|
|
|
- });
|
|
|
-
|
|
|
- QObject::connect(&imagestitcher,&ImageStitcher::stitchSuccess,[&](){
|
|
|
- //将param::stitchphoto保存
|
|
|
- param::stitch_mode = "done";
|
|
|
- sqlConfig->OpenDb();
|
|
|
- if(sqlConfig->isTableExist(param::table_camera)){
|
|
|
- sqlConfig->UpdateData(param::table_camera,"mode",param::stitch_mode);
|
|
|
- }
|
|
|
- sqlConfig->CloseDb();
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- qmlRegisterType<TreeModel>("PhotoViewer", 1, 0, "TreeModel");
|
|
|
-
|
|
|
Qt6QCamera::Frames::registerQmlType();
|
|
|
|
|
|
SerialThread serialThread;
|
|
|
@@ -439,6 +427,10 @@ int main(int argc, char *argv[])
|
|
|
engine.rootContext()->setContextProperty("serial", &serialThread);
|
|
|
|
|
|
|
|
|
+ CurlFtpUploader uploader_ftp; // 成员变量
|
|
|
+ QString remotepath ="/photo_hard/" + param::imei;
|
|
|
+ uploader_ftp.setFtpParams("bzy_user", "YFkj@6O2O", "8.136.98.49", 21, remotepath);
|
|
|
+
|
|
|
YMODEM m_ymodem(&serialThread);
|
|
|
#if 1 //厦门四信
|
|
|
|
|
|
@@ -450,14 +442,21 @@ int main(int argc, char *argv[])
|
|
|
QSerialPort::NoParity, QSerialPort::OneStop,
|
|
|
QSerialPort::NoFlowControl);
|
|
|
#endif
|
|
|
+
|
|
|
+
|
|
|
MqttHandler mqttHandler;
|
|
|
+ mqttHandler.storage()->setJsonCacheEnabled(param::jsonCacheEnable);
|
|
|
+ mqttHandler.storage()->setImageCacheEnabled(param::imageCacheEnable);
|
|
|
+ mqttHandler.storage()->setMaxJsonEntries(param::maxJsonEntries);
|
|
|
+ mqttHandler.storage()->setMaxImageEntries(param::maxImageEntries);
|
|
|
CurlHandler curlHandler("ftp://8.136.98.49/_UPDATE_FILE/Android/BZYV2/app.apk",appDataPath+"/app.apk"); //app升级
|
|
|
|
|
|
+ NetworkInfoHelper networkMonitor;
|
|
|
engine.rootContext()->setContextProperty("mqtt", &mqttHandler);
|
|
|
engine.rootContext()->setContextProperty("curl", &curlHandler);
|
|
|
engine.rootContext()->setContextProperty("ymodem",&m_ymodem);
|
|
|
engine.rootContext()->setContextProperty("curl_picture",&uploader_ftp);
|
|
|
-
|
|
|
+ engine.rootContext()->setContextProperty("networkMonitor", &networkMonitor);
|
|
|
serialThread.start();
|
|
|
|
|
|
QObject::connect(&serialThread,&SerialThread::dataUpload,&mqttHandler,&MqttHandler::publish_m); //串口到MQTT
|
|
|
@@ -465,6 +464,21 @@ int main(int argc, char *argv[])
|
|
|
QObject::connect(&serialThread,&SerialThread::updatestart,&m_ymodem,&YMODEM::start_ymodem); //串口到Ymodem
|
|
|
QObject::connect(&m_ymodem,&YMODEM::modem_result,&serialThread,&SerialThread::getmodemresult); //Ymodem到串口
|
|
|
|
|
|
+ QObject::connect(&networkMonitor,&NetworkInfoHelper::reachabilityChanged,[&](QNetworkInformation::Reachability newReachability){
|
|
|
+ if(newReachability==QNetworkInformation::Reachability::Online){
|
|
|
+ WARN("网络连接!");
|
|
|
+ param::net_alive = 1;
|
|
|
+ }else{
|
|
|
+ param::net_alive = 0;
|
|
|
+ WARN("网络断开!");
|
|
|
+ mqttHandler.disconnectFromBroker();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ QObject::connect(&uploader_ftp, &CurlFtpUploader::finished,
|
|
|
+ &mqttHandler,&MqttHandler::storage_Picture);
|
|
|
+ QObject::connect(&mqttHandler, &MqttHandler::signal_reupload_image,
|
|
|
+ &uploader_ftp,&CurlFtpUploader::uploadFileAsync);
|
|
|
+
|
|
|
QObject::connect(&mqttHandler,&MqttHandler::updateStm32,[&](){
|
|
|
curlHandler.seturl("ftp://8.136.98.49/_UPDATE_FILE/A7/STM32/Application_BZYV2.rbl");
|
|
|
curlHandler.setfilepath(appDataPath+"/rtthread.rbl");
|
|
|
@@ -498,7 +512,14 @@ int main(int argc, char *argv[])
|
|
|
sqlConfig->CloseDb();
|
|
|
|
|
|
});
|
|
|
-
|
|
|
+ QObject::connect(&mqttHandler,&MqttHandler::signal_imei_change,[&](QString NEW_IMEI){
|
|
|
+ sqlConfig->OpenDb();
|
|
|
+ if(sqlConfig->isTableExist(param::table_mqtt)){
|
|
|
+ qDebug() << "UpdateData imei !!!!!";
|
|
|
+ sqlConfig->UpdateData(param::table_mqtt,"imei",NEW_IMEI);
|
|
|
+ }
|
|
|
+ sqlConfig->CloseDb();
|
|
|
+ });
|
|
|
QObject::connect(&curlHandler,&CurlHandler::downloadFinished,[&](bool result,QString mtype){
|
|
|
LOG("downloadFinished:{}-{}",result,mtype.toStdString());
|
|
|
if(result&&mtype.contains("App")){
|
|
|
@@ -537,15 +558,6 @@ int main(int argc, char *argv[])
|
|
|
if(autoFocus_Page){
|
|
|
QMetaObject::invokeMethod(autoFocus_Page, "autotake",Q_ARG(QVariant,stat));
|
|
|
//将param::stitchphoto保存
|
|
|
- if(stat){
|
|
|
- param::stitch_mode = "start";
|
|
|
- sqlConfig->OpenDb();
|
|
|
- if(sqlConfig->isTableExist(param::table_camera)){
|
|
|
- sqlConfig->UpdateData(param::table_camera,"mode",param::stitch_mode);
|
|
|
- }
|
|
|
- sqlConfig->CloseDb();
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}); //mqtt到QML,控制qml跳转到自动对焦界面,开始对焦拍照
|
|
|
@@ -602,36 +614,31 @@ int main(int argc, char *argv[])
|
|
|
// 获取根 QML 对象
|
|
|
QObject *autofocus_item = rootItem->findChild<QObject*>("autofocus_Item");
|
|
|
if(autofocus_item){
|
|
|
- bool isConnect_frame = false;
|
|
|
+ bool isConnect_frame = true;
|
|
|
//const QMetaObject *metaObj = autofocus_item->metaObject();
|
|
|
- qDebug() << "autofocus_item is !!!!!";
|
|
|
+ LOG("Found autofocus_item!");
|
|
|
QObject::connect(autofocus_item, SIGNAL(selected()),&myCppClass,SLOT(qmlSlot()));
|
|
|
QObject::connect(&myCppClass, &MyCppClass::recvqmlslot,[&](){
|
|
|
+ LOG("connect myCppClass");
|
|
|
Qt6QCamera::Frames *m_frames = qobject_cast<Qt6QCamera::Frames*>(rootItem->findChild<QObject*>("Frames"));
|
|
|
- if(m_frames&&!isConnect_frame){
|
|
|
- qDebug() << "m_frames is !!!!!";
|
|
|
+ if(!m_frames) {ERROR("m_frames is null!!!");}
|
|
|
+ if(m_frames&&isConnect_frame){
|
|
|
+ LOG("m_frames connected!");
|
|
|
//engine.addImageProvider("ucamera",m_frames->getImageProvider());
|
|
|
QObject::connect(m_frames,&Qt6QCamera::Frames::serial_data,&serialThread,&SerialThread::sendData); //Frame到串口
|
|
|
QObject::connect(&serialThread,&SerialThread::takephotodone,m_frames,&Qt6QCamera::Frames::saveImage); //串口到QML,控制qml跳转到自动对焦界面
|
|
|
- QObject::connect(m_frames,&Qt6QCamera::Frames::signal_stitch,&imagestitcher,&ImageStitcher::stitch_thread);
|
|
|
+ //QObject::connect(m_frames,&Qt6QCamera::Frames::signal_stitch,&imagestitcher,&ImageStitcher::stitch_thread);
|
|
|
QObject::connect(&serialThread,&SerialThread::signal_movy,m_frames,&Qt6QCamera::Frames::onMovDone);
|
|
|
QObject::connect(m_frames,&Qt6QCamera::Frames::dataUpload,&mqttHandler,&MqttHandler::publish_m); //frames到MQTT
|
|
|
- QObject::connect(m_frames,&Qt6QCamera::Frames::signal_photoerr,[&](){
|
|
|
- param::stitch_mode = "done";
|
|
|
- sqlConfig->OpenDb();
|
|
|
- if(sqlConfig->isTableExist(param::table_camera)){
|
|
|
- sqlConfig->UpdateData(param::table_camera,"mode",param::stitch_mode);
|
|
|
- }
|
|
|
- sqlConfig->CloseDb();
|
|
|
- });
|
|
|
// 修改信号槽连接方式
|
|
|
QObject::connect(m_frames, &Qt6QCamera::Frames::signal_wait_upload,
|
|
|
&uploader_ftp, &CurlFtpUploader::uploadFileAsync);
|
|
|
QObject::connect(&uploader_ftp, &CurlFtpUploader::finished,
|
|
|
m_frames,&Qt6QCamera::Frames::handle_reult_upload);
|
|
|
- isConnect_frame = true;
|
|
|
+
|
|
|
+ isConnect_frame = false;
|
|
|
}else{
|
|
|
- qDebug() << "m_frames no !!!!!";
|
|
|
+ ERROR("m_frames no !!!!!");
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -651,6 +658,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
GPSInfo *gps_start = new GPSInfo;
|
|
|
QObject::connect(gps_start,&GPSInfo::position_success,[&](){
|
|
|
+ emit serialThread.gpsSuccess();
|
|
|
sqlConfig->OpenDb();
|
|
|
if(sqlConfig->isTableExist(param::table_location)){
|
|
|
sqlConfig->UpdateData(param::table_location,"gps_lat",param::gps_lat);
|
|
|
@@ -660,15 +668,7 @@ int main(int argc, char *argv[])
|
|
|
gps_start->positionSource->stopUpdates();
|
|
|
gps_start->deleteLater();
|
|
|
});
|
|
|
-
|
|
|
- // 每过24小时重启系统
|
|
|
- QTimer::singleShot(1000*60*60*24, [](){
|
|
|
- LOG("重启");
|
|
|
- sendBroadcastFromQt("rebootSystem");
|
|
|
- });
|
|
|
|
|
|
-
|
|
|
return app.exec();
|
|
|
}
|
|
|
-
|
|
|
#include "main.moc"
|