-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimelapsecommand.cpp
More file actions
39 lines (36 loc) · 1.01 KB
/
timelapsecommand.cpp
File metadata and controls
39 lines (36 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "timelapsecommand.h"
#include <QTimer>
#include <QCoreApplication>
#include <QDebug>
TimeLapseCommand::TimeLapseCommand(MCamera *camera, Message* message, QObject *parent) :
Command(camera, message, parent)
{
m_camera = camera;
TimeLapseMessage* tlMessage = dynamic_cast<TimeLapseMessage*>(message);
m_nbShot = tlMessage->nbShot();
m_time = tlMessage->time();
}
bool TimeLapseCommand::execute()
{
m_index = 0;
connect(&m_timer, SIGNAL(timeout()), SLOT(capture()));
m_timer.start(m_time*1000);
qDebug() << "TimeLapseCommand";
return false;
}
void TimeLapseCommand::capture()
{
QString fileName("TimeLapseCommand_Photo_%1.jpg");
QString indexString = QString::number(m_index++);
qDebug() << fileName.arg(indexString);
if(m_camera->capture(fileName.arg(indexString)) != MCamera::NoError)
{
m_timer.stop();
emit p_timeLapseFinish(false);
}
if(m_index > m_nbShot)
{
m_timer.stop();
emit p_timeLapseFinish(true);
}
}