1. iorodeo
  2. bias

Commits

iorodeo  committed e143585

Added methods to external control server to set and get the video file name.

  • Participants
  • Parent commits 89c7eb0
  • Branches default

Comments (0)

Files changed (4)

File src/gui/basic_http_server.cpp

View file
  • Ignore whitespace
         {
             cmdMap = handleGetStatus();
         }
+        else if (name == QString("set-video-file"))
+        {
+            cmdMap = handleSetVideoFile(value);
+        }
+        else if (name == QString("get-video-file"))
+        {
+            cmdMap = handleGetVideoFile();
+        }
         else if (name == QString("close"))
         {
             cmdMap.insert("success", true);
     }
 
 
+    QVariantMap BasicHttpServer::handleSetVideoFile(QString fileName)
+    {
+        QVariantMap cmdMap;
+        RtnStatus status = cameraWindowPtr_ -> setVideoFile(fileName);
+        cmdMap.insert("success", status.success);
+        cmdMap.insert("message", status.message);
+        cmdMap.insert("value", "");
+        return cmdMap;
+    }
+
+
+    QVariantMap BasicHttpServer::handleGetVideoFile()
+    {
+        QVariantMap cmdMap;
+        QString fileName = cameraWindowPtr_ -> getVideoFileFullPath();
+        cmdMap.insert("success", true);
+        cmdMap.insert("message", "Video file name retrieved successfully");
+        cmdMap.insert("value", fileName);
+        return cmdMap;
+    }
+
+
     void BasicHttpServer::sendBadRequestResp(QTextStream &os, QString msg)
     { 
-
         os << "HTTP/1.0 400 Bad Request\r\n";
         os << "Content-Type: text/html; charset=\"utf-8\"\r\n\r\n";
         os << "<html>\n";

File src/gui/basic_http_server.hpp

View file
  • Ignore whitespace
             QVariantMap handleGetCameraGuid();
             QVariantMap handleGetFrameCount();
             QVariantMap handleGetStatus();
+            QVariantMap handleSetVideoFile(QString fileName);
+            QVariantMap handleGetVideoFile();
 
             void sendBadRequestResp(QTextStream &os, QString msg);
             void sendRunningResp(QTextStream &os);

File src/gui/camera_window.cpp

View file
  • Ignore whitespace
     }
 
 
+    RtnStatus CameraWindow::setVideoFile(QString videoFileString)
+    {
+        RtnStatus rtnStatus;
+
+        if (logging_)
+        {
+            rtnStatus.success = false;
+            rtnStatus.message = QString("Unable to set video file: logging in progress");
+            return rtnStatus;
+        }
+        
+        QFileInfo videoFileInfo = QFileInfo(videoFileString);
+        QDir videoFileDir = videoFileInfo.dir();
+        QString videoFileName = videoFileInfo.baseName();
+
+        rtnStatus.success = true;
+        rtnStatus.message = QString("Video file name set successfully");
+        if (videoFileName.isEmpty())
+        {
+            if (currentVideoFileName_.isEmpty())
+            {
+                videoFileName = DEFAULT_VIDEO_FILE_NAME;
+            }
+            else
+            {
+                videoFileName = currentVideoFileName_;
+            }
+            videoFileDir = currentVideoFileDir_;
+            rtnStatus.success = false;
+            rtnStatus.message = QString("Video file name is missing");
+        }
+
+        if (!videoFileDir.exists())
+        {
+            videoFileDir = defaultVideoFileDir_;
+            QString msgText("Directory does not exist");
+            if (!rtnStatus.success)
+            {
+                rtnStatus.message = QString("%s, %s").arg(rtnStatus.message).arg(msgText);
+            }
+            else
+            {
+                rtnStatus.success = false;
+                rtnStatus.message = msgText;
+            }
+        }
+        currentVideoFileDir_ = videoFileDir;
+        currentVideoFileName_ = videoFileName;
+        return rtnStatus;
+    }
+
+
+    QString CameraWindow::getVideoFileFullPath()
+    {
+        QString fileExtension;
+        if (videoFileFormat_ != VIDEOFILE_FORMAT_BMP)
+        {
+            fileExtension = VIDEOFILE_EXTENSION_MAP[videoFileFormat_];
+        }
+        else
+        {
+            fileExtension = "";
+
+        }
+        QString fileName = currentVideoFileName_;
+        if (!fileExtension.isEmpty())
+        {
+            fileName +=  "." + fileExtension;
+        }
+        QFileInfo videoFileInfo(currentVideoFileDir_, fileName);
+        QString videoFileFullPath = videoFileInfo.absoluteFilePath();
+        return videoFileFullPath;
+    }
+
+
     unsigned long CameraWindow::getFrameCount()
     {
         return frameCount_;
 
     void CameraWindow::actionLoggingEnabledTriggered()
     {
-        if (haveDefaultVideoFileDir_) {
-            logging_ = actionLoggingEnabledPtr_ -> isChecked();
+        if (actionLoggingEnabledPtr_ -> isChecked())
+        {
+            if (haveDefaultVideoFileDir_) {
+                logging_ = true; 
+            }
+            else
+            {
+                actionLoggingEnabledPtr_ -> setChecked(false);
+                logging_ = false;
+                QString msgTitle("Logging Enable Error");
+                QString msgText("Unable to determine default location for video files.");
+                QMessageBox::critical(this, msgTitle, msgText);
+            }
         }
         else
         {
-            actionLoggingEnabledPtr_ -> setChecked(false);
             logging_ = false;
-            QString msgTitle("Initialization Error");
-            QString msgText("Unable to determine default location for video files.");
-            QMessageBox::critical(this, msgTitle, msgText);
-        }
-        std::cout << "logging: ";
-        std::cout << std::boolalpha << logging_ << std::noboolalpha;
-        std::cout << std::endl;
+        }
     }
 
 
                 QString("Select Video File"),
                 videoFileInfo.absoluteFilePath()
                 );
-        videoFileInfo = QFileInfo(videoFileString);
-
-        QDir videoFileDir = videoFileInfo.dir();
-        QString videoFileName = videoFileInfo.baseName();
-
-        // Check return results and assign values
-        if (videoFileName.isEmpty())
-        {
-            if (currentVideoFileName_.isEmpty())
-            {
-                videoFileName = DEFAULT_VIDEO_FILE_NAME;
-            }
-            else
-            {
-                videoFileName = currentVideoFileName_;
-            }
-            videoFileDir = currentVideoFileDir_;
-        }
-        if (!videoFileDir.exists())
-        {
-            videoFileDir = defaultVideoFileDir_;
-        }
-
-        currentVideoFileDir_ = videoFileDir;
-        currentVideoFileName_ = videoFileName;
-
-        std::cout << "dir:  " << currentVideoFileDir_.absolutePath().toStdString() << std::endl;
-        std::cout << "file: " << currentVideoFileName_.toStdString() << std::endl;
+
+        setVideoFile(videoFileString);
     }
     
 
     }
 
 
-    QString CameraWindow::getVideoFileFullPath()
-    {
-        QString fileExtension;
-        if (videoFileFormat_ != VIDEOFILE_FORMAT_BMP)
-        {
-            fileExtension = VIDEOFILE_EXTENSION_MAP[videoFileFormat_];
-        }
-        else
-        {
-            fileExtension = "";
-
-        }
-        QString fileName = currentVideoFileName_;
-        if (!fileExtension.isEmpty())
-        {
-            fileName +=  "." + fileExtension;
-        }
-        QFileInfo videoFileInfo(currentVideoFileDir_, fileName);
-        QString videoFileFullPath = videoFileInfo.absoluteFilePath();
-        return videoFileFullPath;
-    }
-
     QString CameraWindow::getVideoFileFullPathWithGuid()
     {
         cameraPtr_ -> acquireLock();

File src/gui/camera_window.hpp

View file
  • Ignore whitespace
                     QString fileName, 
                     bool showErrorDlg=true
                     );
+
             QString getCameraGuidString(RtnStatus &rtnStatus);
+            RtnStatus setVideoFile(QString videoFileString);
+            QString getVideoFileFullPath();
 
             unsigned long getFrameCount();
             bool isConnected();
             void setMenuChildrenEnabled(QWidget *parentWidgetPtr, bool value);
             void setCaptureTimeLabel(double timeStamp);
 
-            QString getVideoFileFullPath();
             QString getVideoFileFullPathWithGuid();
             QString getConfigFileFullPath();
 
-
             bool setCameraFromMap(QVariantMap cameraMap);
             bool setLoggingFromMap(QVariantMap loggingMap);
             bool setTimerFromMap(QVariantMap timerMap);