From d435bab3c2d5d14eea26b2182ddbaede281713ca Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 17 Dec 2024 22:53:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=A0=E6=84=9F=E5=99=A8=E9=87=87=E6=A0=B7?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E6=8B=8D=E7=85=A7=E7=9A=84=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E5=99=A8=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/MicroPhoto.cpp | 92 ++++--------------- app/src/main/cpp/PhoneDevice.cpp | 36 ++++---- .../com/xypower/mpapp/MicroPhotoService.java | 8 +- 3 files changed, 38 insertions(+), 98 deletions(-) diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index 2306bcfd..2d0e18d9 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -358,7 +358,7 @@ Java_com_xypower_mpapp_MicroPhotoService_notifyToTakePhoto( JNIEnv* env, jobject pThis, jlong handler, jint channel, jint preset, jlong scheduleTime, jboolean photoOrVideo) { - if (channel < 1 || channel > 0xFF) + if (channel < 1 || channel > 0x1FF) { return JNI_FALSE; } @@ -371,7 +371,16 @@ Java_com_xypower_mpapp_MicroPhotoService_notifyToTakePhoto( unsigned char type = photoOrVideo ? 0 : 1; // std::thread th(&Runner::RequestCapture, pTerminal, (unsigned int)channel, (unsigned int)preset, type, (unsigned long)scheduleTime, 0, true); // th.detach(); - pTerminal->RequestCapture((unsigned int)channel, (unsigned int)preset, type, (unsigned long)scheduleTime, 0, true); + if (channel < 0x100) + { + pTerminal->RequestCapture((uint32_t)channel, (unsigned int)preset, type, (unsigned long)scheduleTime, 0, true); + } + else + { + uint32_t packetType = channel; + packetType &= 0xFF; + pTerminal->RequestSampling(packetType, (unsigned long)scheduleTime, 0); + } return JNI_TRUE; } @@ -612,7 +621,7 @@ Java_com_xypower_mpapp_MicroPhotoService_getPhotoTimeData( unsigned int scheduleTime = 0; time_t zeroPointTime = 0; - std::vector > channelsAndPresets; + std::vector > channelsAndPresets; if (!pTerminal->GetAndRefreshLatestScheduleTime(startTime, zeroPointTime, scheduleTime, channelsAndPresets)) { return NULL; @@ -631,13 +640,13 @@ Java_com_xypower_mpapp_MicroPhotoService_getPhotoTimeData( dataArray.push_back((jlong)channelsAndPresets.size()); unsigned long val = 0; - for (std::vector >::const_iterator it = channelsAndPresets.cbegin(); it != channelsAndPresets.cend(); ++it) + for (std::vector >::const_iterator it = channelsAndPresets.cbegin(); it != channelsAndPresets.cend(); ++it) { - val = (unsigned long)scheduleTime << 24; + val = (unsigned long)scheduleTime << 28; // channel - val |= ((unsigned long)(it->first)) << 16; + val |= ((unsigned long)(it->first)) << 12; // preset - val |= ((unsigned long)(it->second)) << 8; + val |= ((unsigned long)(it->second)) << 4; dataArray.push_back((jlong)val); } @@ -735,75 +744,6 @@ Java_com_xypower_mpapp_MicroPhotoService_recoganizePicture( return data; } - -/* -extern "C" JNIEXPORT jlongArray JNICALL -Java_com_xypower_mpapp_MicroPhotoService_getNextScheduleItem( - JNIEnv* env, - jobject pThis, jlong handler) { - - CTerminal* pTerminal = reinterpret_cast(handler); - if (pTerminal == NULL) - { - return NULL; - } - - map> photoTime; - if (!pTerminal->GetPhotoTime(photoTime) || photoTime.empty()) - { - return NULL; - } - - size_t numberOfData = photoTime.size() * photoTime.begin()->second.size(); - if (numberOfData == 0) - { - return NULL; - } - - vector dataArray; - dataArray.reserve(numberOfData); - - unsigned long val = 0; - jint channel = 0; - for (map>::const_iterator it = photoTime.cbegin(); it != photoTime.cend(); ++it) - { - if (it->second.empty()) - { - continue; - } - - channel = (jint)((unsigned short)it->first); - // dataArray.push_back(channel); - - // val = (jint)it->second.size(); - // dataArray.push_back(val); - for (vector::const_iterator it2 = it->second.cbegin(); it2 != it->second.cend(); ++it2) - { - // time - val = ((unsigned long)((*it2) & 0xFFFFFF00)) << 24; - // channel - val |= ((unsigned long)channel) << 16; - // preset - val |= ((unsigned long)((*it2) & 0xFF)) << 8; - - dataArray.push_back((jlong)val); - } - } - - std::sort(dataArray.begin(), dataArray.end()); - - jlongArray data = env->NewLongArray(dataArray.size()); - if (data == NULL) { - return NULL; - } - - env->SetLongArrayRegion(data, 0, dataArray.size(), &dataArray[0]); - - return data; -} - */ - - extern "C" JNIEXPORT void JNICALL Java_com_xypower_mpapp_MicroPhotoService_captureFinished( JNIEnv* env, diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 99c828ae..196ce40d 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1772,24 +1772,24 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< GetPhotoSerialsParamCb(param); std::thread t([localPhotoInfo, param, pThis,wid_serial]() mutable - { - if (localPhotoInfo.preset != 0 && localPhotoInfo.preset != 0xFF) - { - CameraPhotoCmd(time(NULL), localPhotoInfo.channel, MOVE_PRESETNO, 0, localPhotoInfo.preset, param.serfile, param.baud, param.addr); - std::this_thread::sleep_for(std::chrono::seconds(3)); - } - time_t ts = time(NULL); - if(!pThis->GetPTZSensorsStatus() && !pThis->GetCameraStatus()) - { - pThis->OpenPTZSensors(localPhotoInfo.selfTestingTime); - } - CameraPhotoCmd(ts, localPhotoInfo.channel, 0, localPhotoInfo.resolution, 0, param.serfile, param.baud, param.addr); - XYLOG(XYLOG_SEVERITY_INFO, "Taking photo over"); - pThis->TakePTZPhotoCb(3, localPhotoInfo); - pThis->ClosePTZSensors(localPhotoInfo.closeDelayTime); - GpioControl::setCam3V3Enable(false, localPhotoInfo.closeDelayTime); - pThis->ReleaseWakelock(wid_serial); - }); + { + if (localPhotoInfo.preset != 0 && localPhotoInfo.preset != 0xFF) + { + CameraPhotoCmd(time(NULL), localPhotoInfo.channel, MOVE_PRESETNO, 0, localPhotoInfo.preset, param.serfile, param.baud, param.addr); + std::this_thread::sleep_for(std::chrono::seconds(3)); + } + time_t ts = time(NULL); + if(!pThis->GetPTZSensorsStatus() && !pThis->GetCameraStatus()) + { + pThis->OpenPTZSensors(localPhotoInfo.selfTestingTime); + } + CameraPhotoCmd(ts, localPhotoInfo.channel, 0, localPhotoInfo.resolution, 0, param.serfile, param.baud, param.addr); + XYLOG(XYLOG_SEVERITY_INFO, "Taking photo over"); + pThis->TakePTZPhotoCb(3, localPhotoInfo); + pThis->ClosePTZSensors(localPhotoInfo.closeDelayTime); + GpioControl::setCam3V3Enable(false, localPhotoInfo.closeDelayTime); + pThis->ReleaseWakelock(wid_serial); + }); t.detach(); } diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index 7de2ceaf..3a3ae1a4 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -449,9 +449,9 @@ public class MicroPhotoService extends Service { for (int idx = 0; idx < cnt; idx++) { long val = intent.getLongExtra(EXTRA_PARAM_SCHEDULE + idx, 0); - int channel = (int) ((val & 0xFF0000L) >> 16); - int preset = (int) ((val & 0xFF00L) >> 8); - boolean photoOrVideo = ((val & 0xFFL) == 0); + int channel = (int) ((val & 0xFF000L) >> 12); + int preset = (int) ((val & 0xFF0L) >> 4); + boolean photoOrVideo = ((val & 0xFL) == 0); Log.i(TAG, "PhotoTimer Fired: CH=" + channel + " PR=" + preset); mService.notifyToTakePhoto(mService.mNativeHandle, channel, preset, ts, photoOrVideo); @@ -664,7 +664,7 @@ public class MicroPhotoService extends Service { for (int idx = 0; idx < cnt; idx++) { val = schedules.get(idx).longValue(); intent.putExtra(EXTRA_PARAM_SCHEDULE + idx, schedules.get(idx).longValue()); - channelStr.append("(" + ((val & 0XFF0000) >> 16) + "-" + Long.toString (((val & 0XFF00) >> 8), 16).toUpperCase() + ") "); + channelStr.append("(" + ((val & 0XFF000) >> 12) + "-" + Long.toString (((val & 0XFF0) >> 4), 16).toUpperCase() + ") "); } intent.putExtra(EXTRA_PARAM_TIME, scheduleTime);