diff --git a/VideoSliderControl.qml b/VideoSliderControl.qml index 82957af..1a5d48c 100644 --- a/VideoSliderControl.qml +++ b/VideoSliderControl.qml @@ -14,7 +14,7 @@ Item { property double min: 0.0 property double max: 100.0 property double stepSize: 1.0 - property double startValue: 0.0 + property double startValue: -1000.23948 property double displayValueScale: 1 property double displayValueOffset: 0 property double displayRotation: 0 diff --git a/VideoSpinBoxControl.qml b/VideoSpinBoxControl.qml index f002974..7fb0940 100644 --- a/VideoSpinBoxControl.qml +++ b/VideoSpinBoxControl.qml @@ -14,12 +14,11 @@ Item { property var iconPath: "img/icon/ewl.ico" property var displaySpinBoxValues: ["1", "2", "3"] - property var displayTextValues: [1,2,3] + property var displayTextValues: [1.0,2.0,3.0] property var outputValues: [1, 2, 3] property var startValue: "1" onStartValueChanged: { -// print(startValue) spinBox.value = displaySpinBoxValues.indexOf(startValue) } @@ -75,7 +74,7 @@ Item { from: 0 to: root.displaySpinBoxValues.length - 1 - value: 0 + value: 100 textFromValue: function(value) { return root.displaySpinBoxValues[value]; diff --git a/backend.cpp b/backend.cpp index 1412863..b4b84a6 100644 --- a/backend.cpp +++ b/backend.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "miniscope.h" #include "behaviorcam.h" @@ -222,17 +223,17 @@ void backEnd::constructUserConfigGUI() for (idx = 0; idx < ucMiniscopes.size(); idx++) { miniscope.append(new Miniscope(this, ucMiniscopes[idx].toObject())); QObject::connect(miniscope.last(), - SIGNAL (onPropertyChanged(QString, QString, double)), + SIGNAL (onPropertyChanged(QString, QString, QVariant)), dataSaver, - SLOT (devicePropertyChanged(QString, QString, double))); + SLOT (devicePropertyChanged(QString, QString, QVariant))); miniscope.last()->createView(); } for (idx = 0; idx < ucBehaviorCams.size(); idx++) { behavCam.append(new BehaviorCam(this, ucBehaviorCams[idx].toObject())); QObject::connect(behavCam.last(), - SIGNAL (onPropertyChanged(QString, QString, double)), + SIGNAL (onPropertyChanged(QString, QString, QVariant)), dataSaver, - SLOT (devicePropertyChanged(QString, QString, double))); + SLOT (devicePropertyChanged(QString, QString, QVariant))); behavCam.last()->createView(); } if (!ucExperiment.isEmpty()){ diff --git a/behaviorcam.cpp b/behaviorcam.cpp index 2882bb8..278162b 100644 --- a/behaviorcam.cpp +++ b/behaviorcam.cpp @@ -13,6 +13,7 @@ #include #include #include +#include BehaviorCam::BehaviorCam(QObject *parent, QJsonObject ucBehavCam) : QObject(parent), @@ -228,7 +229,7 @@ void BehaviorCam::configureBehavCamControls() { controlItem->setProperty(keys[j].toLatin1().data(), values[keys[j]].toDouble()); if (keys[j] == "startValue") // sends signal on initial setup of controls - emit onPropertyChanged(m_deviceName, controlName[i], values["startValue"].toDouble()); + emit onPropertyChanged(m_deviceName, controlName[i], values["startValue"].toVariant()); } } } @@ -361,7 +362,7 @@ void BehaviorCam::handlePropCangedSignal(QString type, double displayValue, doub // TODO: maybe add a check to make sure property successfully updates before signallng it has changed // qDebug() << "Sending updated prop signal to backend"; - emit onPropertyChanged(m_deviceName, type, displayValue); + emit onPropertyChanged(m_deviceName, type, QVariant(displayValue)); // TODO: Handle int values greater than 8 bits // for (int i = 0; i < m_controlSendCommand[type].length(); i++) { diff --git a/behaviorcam.h b/behaviorcam.h index 2943522..872644e 100644 --- a/behaviorcam.h +++ b/behaviorcam.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "videostreamocv.h" #include "videodisplay.h" @@ -42,7 +43,7 @@ class BehaviorCam : public QObject signals: // TODO: setup signals to configure camera in thread // void setPropertyI2C(long preambleKey, QVector packet); - void onPropertyChanged(QString devieName, QString propName, double propValue); + void onPropertyChanged(QString devieName, QString propName, QVariant propValue); void sendMessage(QString msg); void takeScreenShot(QString type); void newFrameAvailable(QString name, int frameNum); diff --git a/datasaver.cpp b/datasaver.cpp index 54d8bc7..1900453 100644 --- a/datasaver.cpp +++ b/datasaver.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include DataSaver::DataSaver(QObject *parent) : QObject(parent), @@ -244,7 +246,7 @@ void DataSaver::stopRecording() noteFile->close(); } -void DataSaver::devicePropertyChanged(QString deviceName, QString propName, double propValue) +void DataSaver::devicePropertyChanged(QString deviceName, QString propName, QVariant propValue) { deviceProperties[deviceName][propName] = propValue; qDebug() << deviceName << propName << propValue; @@ -339,7 +341,10 @@ QJsonDocument DataSaver::constructMiniscopeMetaData(int idx) // loop through device properties at the start of recording QStringList keys = deviceProperties[deviceName].keys(); for (int i = 0; i < keys.length(); i++) { - metaData[keys[i]] = deviceProperties[deviceName][keys[i]]; + if (deviceProperties[deviceName][keys[i]].userType() == QMetaType::QString) + metaData[keys[i]] = deviceProperties[deviceName][keys[i]].toString(); + else + metaData[keys[i]] = deviceProperties[deviceName][keys[i]].toDouble(); } jDoc.setObject(metaData); diff --git a/datasaver.h b/datasaver.h index a0cee0f..be1e077 100644 --- a/datasaver.h +++ b/datasaver.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,7 @@ public slots: void startRunning(); void startRecording(); void stopRecording(); - void devicePropertyChanged(QString deviceName, QString propName, double propValue); + void devicePropertyChanged(QString deviceName, QString propName, QVariant propValue); void takeScreenShot(QString type); void takeNote(QString note); @@ -50,7 +51,7 @@ public slots: QDateTime recordStartDateTime; QMap deviceDirectory; - QMap> deviceProperties; + QMap> deviceProperties; // Probably shoud turn all of this into a single struct QMap frameBuffer; diff --git a/miniscope.cpp b/miniscope.cpp index cfb17ad..b390c39 100644 --- a/miniscope.cpp +++ b/miniscope.cpp @@ -84,6 +84,9 @@ Miniscope::Miniscope(QObject *parent, QJsonObject ucMiniscope) : sendInitCommands(); videoStreamThread->start(); + + // Short sleep to make i2c initialize commands be sent before loading in user config controls + QThread::msleep(500); } void Miniscope::createView() @@ -110,7 +113,7 @@ void Miniscope::createView() QObject::connect(rootObject, SIGNAL( takeScreenShotSignal() ), this, SLOT( handleTakeScreenShotSignal() )); QObject::connect(rootObject, SIGNAL( vidPropChangedSignal(QString, double, double) ), - this, SLOT( handlePropCangedSignal(QString, double, double) )); + this, SLOT( handlePropChangedSignal(QString, double, double) )); configureMiniscopeControls(); vidDisplay = rootObject->findChild("vD"); @@ -238,15 +241,15 @@ void Miniscope::configureMiniscopeControls() { } else if (values[keys[j]].isString()) { controlItem->setProperty(keys[j].toLatin1().data(), values[keys[j]].toString()); -// if (keys[j] == "startValue") + if (keys[j] == "startValue") // sends signal on initial setup of controls -// emit onPropertyChanged(m_deviceName, controlName[i], values["startValue"].toString()); + emit onPropertyChanged(m_deviceName, controlName[i], values["startValue"].toVariant()); } else { controlItem->setProperty(keys[j].toLatin1().data(), values[keys[j]].toDouble()); if (keys[j] == "startValue") // sends signal on initial setup of controls - emit onPropertyChanged(m_deviceName, controlName[i], values["startValue"].toDouble()); + emit onPropertyChanged(m_deviceName, controlName[i], values["startValue"].toVariant()); } } } @@ -370,7 +373,7 @@ void Miniscope::sendNewFrame(){ } -void Miniscope::handlePropCangedSignal(QString type, double displayValue, double i2cValue) +void Miniscope::handlePropChangedSignal(QString type, double displayValue, double i2cValue) { // type is the objectName of the control // value is the control value that was just updated @@ -392,7 +395,7 @@ void Miniscope::handlePropCangedSignal(QString type, double displayValue, double // TODO: maybe add a check to make sure property successfully updates before signallng it has changed // qDebug() << "Sending updated prop signal to backend"; - emit onPropertyChanged(m_deviceName, type, displayValue); + emit onPropertyChanged(m_deviceName, type, QVariant(displayValue)); // TODO: Handle int values greater than 8 bits for (int i = 0; i < m_controlSendCommand[type].length(); i++) { diff --git a/miniscope.h b/miniscope.h index 54516d4..9a7e4f4 100644 --- a/miniscope.h +++ b/miniscope.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "videostreamocv.h" #include "videodisplay.h" @@ -51,14 +52,14 @@ class Miniscope : public QObject signals: // TODO: setup signals to configure camera in thread void setPropertyI2C(long preambleKey, QVector packet); - void onPropertyChanged(QString devieName, QString propName, double propValue); + void onPropertyChanged(QString devieName, QString propName, QVariant propValue); void sendMessage(QString msg); void takeScreenShot(QString type); public slots: void sendNewFrame(); void testSlot(QString, double); - void handlePropCangedSignal(QString type, double displayValue, double i2cValue); + void handlePropChangedSignal(QString type, double displayValue, double i2cValue); void handleTakeScreenShotSignal(); void close(); diff --git a/userConfigs/UserConfigExample.json b/userConfigs/UserConfigExample.json index 6ca4e3e..72cee73 100644 --- a/userConfigs/UserConfigExample.json +++ b/userConfigs/UserConfigExample.json @@ -37,8 +37,8 @@ "windowX": 800, "windowY": 100, "gain": "Low", - "ewl": 30, - "led0": 10, + "ewl": 50, + "led0": 30, "frameRate": "30FPS" } ],