Skip to content
Snippets Groups Projects
Commit ae17fc6d authored by am0ebe's avatar am0ebe
Browse files

[good] fix ptr/construction issues. tested duration setting

parent f5573fdc
Branches
No related tags found
No related merge requests found
......@@ -24,7 +24,9 @@ _ip(ip),
_id(""),
_state(disconnected),
_rec()
{}
{
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
}
// Cam::Cam(const Cam& other) : IPrinter(), std::enable_shared_from_this<Cam>(other)
// _cam(other._cam),
......@@ -190,9 +192,13 @@ void Cam::printFeatures( QStringList features)
QString Cam::camInfo()
{
QString camInfo = _name + DELIM + _ip + DELIM;
camInfo += "recDur:" + formatTime( _rec->dur().count() * 1000 ) + DELIM; //XXX mv down
if( state() == Cam::disconnected )
return camInfo + "disconnected";
try
{
camInfo += name() + DELIM;
......@@ -200,10 +206,6 @@ QString Cam::camInfo()
camInfo += id() + DELIM;
std::string str;
// g(_cam->GetName( str ));
// _name = QString::fromStdString(str);
// camInfo += _name + DELIM;
g(_cam->GetModel( str ));
camInfo += QString::fromStdString(str) + DELIM;
......@@ -216,6 +218,7 @@ QString Cam::camInfo()
camInfo += stateToString(_state);
if( _state == recording)
_rec->showProgress();
//else dur
}
catch(const std::exception& e)
......
......@@ -2,6 +2,7 @@
#include "iprinter.h"
#include "typeDefinitions.h"
#include <chrono>
class Cam : public IPrinter
{
......@@ -15,16 +16,9 @@ public:
recording
};
// const QString& name, const int& nThreads
Cam(QString name, QString ip);
// Cam(const Cam&);
// Cam& operator=(const Cam& other);
// Cam(CameraPtr pCamera);
// Delete copy constructor and assignment operator
Cam(const Cam&) = delete;
Cam(const Cam&) = delete; // Delete copy constructor and assignment operator
Cam& operator=(const Cam&) = delete;
~Cam();
QString id();
......@@ -32,6 +26,7 @@ public:
QString ip() const;
RecordPtr rec();
State state() const;
void setState(const State&);
......@@ -53,6 +48,7 @@ public:
inline void setCameraPtr( CameraPtr pCamera ) { _cam = pCamera; }
friend class FrameObserver;
friend class Core;
private:
CameraPtr _cam;
......
......@@ -104,8 +104,7 @@ void Console::printHelp()
<< "-------------------------------"
<< "h: print this help"
<< "1-9: select camera"
<< "d: change record duration of current camera"
<< "D: change record duration of all cameras"
<< "d/D: change record duration of current/all camera(s)"
<< "o: open current camera"
<< "c: close current camera"
<< "r: start recording"
......
......@@ -45,10 +45,14 @@ void Core::init()
return;
}
//create cams and add 'em to list
//create cams and their corresponding record objects and add 'em to list
for ( auto cam : parsedCameras )
{
auto pcam = std::make_shared<Cam>(cam.first,cam.second);
auto prec = std::make_shared<Record>();
prec->init(pcam);
pcam->_rec = prec;
_cameras.push_back(pcam);
}
......@@ -76,9 +80,8 @@ void Core::detectCams()
if( VmbErrorSuccess == _sys.GetCameraByID( cam->ip().toStdString(), VmbAccessModeFull, pcam ) )
{
cam->setCameraPtr(pcam); //triggers camobserver changed signal > set state
cam->rec()->init(cam);
//create Vimba Camera
//init valid 'cam and record objects
//now valid 'cam and record objects
}
}
}
......
......@@ -151,8 +151,9 @@ int IPrinter::getTerminalWidth()
QString IPrinter::formatTime(const int& milliseconds)
{
int seconds = milliseconds / 1000;
int minutes = seconds / 60;
seconds %= 60;
return QString::asprintf("%02d:%02d", minutes, seconds);
int total_seconds = milliseconds / 1000;
int hours = total_seconds / 3600;
int minutes = (total_seconds % 3600) / 60;
int seconds = total_seconds % 60;
return QString::asprintf("%02dh:%02dm:%02ds", hours, minutes, seconds);
}
......@@ -43,8 +43,10 @@ public:
QString progressBar(QTimer*, int width=0);
QString progressBar(int, int width=0);
private:
protected:
QString formatTime(const int&);
private:
int getTerminalWidth();
};
#include "record.h"
#include "qjsonvalue.h"
#include "utils.h"
#include "cam.h"
#include "frameobserver.h"
......@@ -21,6 +22,7 @@ _pixelFormat(""),
_frames(FramePtrVector(utils::threadsPerCam()))
{
_timer->setSingleShot(true);
_timer->setInterval( duration_cast<milliseconds>(utils::recDuration()) );
connect(_timer, SIGNAL(timeout()), this, SLOT(stop()));
_updateTimer->setInterval(1000);
......@@ -47,6 +49,7 @@ void Record::init(CamPtr cam)
void Record::setDur(seconds dur)
{
// qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
if( _cam->state() == Cam::recording )
return error("cant change dur, while cam is recording");
......@@ -240,7 +243,7 @@ bool Record::checkDirExists()
return false;
}
checkDiskSpace(utils::outDir(), duration_cast<seconds>(_timer->intervalAsDuration()));
checkDiskSpace(utils::outDir(), dur());
info("writing frames to: " + _dir);
return true;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment