传感器采样复用拍照的定时器机制

N938
Matthew 6 months ago
parent 5f48449da6
commit d435bab3c2

@ -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<std::pair<unsigned char, unsigned char> > channelsAndPresets;
std::vector<std::pair<uint16_t, uint8_t> > 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<std::pair<unsigned char, unsigned char> >::const_iterator it = channelsAndPresets.cbegin(); it != channelsAndPresets.cend(); ++it)
for (std::vector<std::pair<uint16_t, uint8_t> >::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<CTerminal *>(handler);
if (pTerminal == NULL)
{
return NULL;
}
map<unsigned char, vector<unsigned int>> photoTime;
if (!pTerminal->GetPhotoTime(photoTime) || photoTime.empty())
{
return NULL;
}
size_t numberOfData = photoTime.size() * photoTime.begin()->second.size();
if (numberOfData == 0)
{
return NULL;
}
vector<jlong> dataArray;
dataArray.reserve(numberOfData);
unsigned long val = 0;
jint channel = 0;
for (map<unsigned char, vector<unsigned int>>::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<unsigned int>::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,

@ -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();
}

@ -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);

Loading…
Cancel
Save