Skip to content

Commit

Permalink
Correct MiniscopeLogo color displayed. Add check and error message fo…
Browse files Browse the repository at this point in the history
…r unique deviceName's. Move JSON file paths from resources to local file paths.
  • Loading branch information
daharoni committed Jan 18, 2020
1 parent a3eed32 commit 3fe35ca
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 66 deletions.
4 changes: 2 additions & 2 deletions ControlPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Item {
// Layout.preferredHeight: 40
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Layout.fillWidth: true
value: root.currentRecordTime/root.ucRecordLength
value: (root.ucRecordLength > 0) ? root.currentRecordTime/root.ucRecordLength : 1
from: 0
to:1
Layout.columnSpan: 1
Expand All @@ -169,7 +169,7 @@ Item {
id: recordTimeText
objectName: "recordTimeText"

text: root.currentRecordTime.toString() + "/" + root.ucRecordLength.toString() + "s"
text: (root.ucRecordLength > 0) ? root.currentRecordTime.toString() + "/" + root.ucRecordLength.toString() + "s" : root.currentRecordTime.toString() + "s"
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
font.pointSize: 12
font.family: "Arial"
Expand Down
2 changes: 1 addition & 1 deletion Miniscope-DAQ-QT-Software.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += quick widgets
QT += qml quick widgets
CONFIG += c++11


Expand Down
2 changes: 1 addition & 1 deletion VideoSliderControl.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Item {
property double min: 0.0
property double max: 100.0
property double stepSize: 1.0
property double startValue: -1000.23948
property double startValue: -1000.23948 // just start with a value that will definitely be different than initialize value. This way onValueChanged will be called
property double displayValueScale: 1
property double displayValueOffset: 0
property double displayRotation: 0
Expand Down
71 changes: 64 additions & 7 deletions backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <QThread>
#include <QObject>
#include <QVariant>
#include <QDir>
#include <QVector>

#include "miniscope.h"
#include "behaviorcam.h"
Expand All @@ -24,9 +26,12 @@ backEnd::backEnd(QObject *parent) :
behavTracker(nullptr)
{
#ifdef DEBUG
m_userConfigFileName = ":/userConfigs/UserConfigExample.json";
loadUserConfigFile();
setUserConfigOK(true);
// QString homePath = QDir::homePath();
m_userConfigFileName = "./userConfigs/UserConfigExample.json";
// loadUserConfigFile();
handleUserConfigFileNameChanged();

// setUserConfigOK(true);
#endif

// m_userConfigOK = false;
Expand All @@ -44,6 +49,7 @@ backEnd::backEnd(QObject *parent) :
ucBehaviorTracker["type"] = "None";

dataSaver = new DataSaver();
// QObject::connect(this, SIGNAL (userConfigFileNameChanged()), this, SLOT( handleUserConfigFileNameChanged() ));
}

void backEnd::setUserConfigFileName(const QString &input)
Expand All @@ -53,7 +59,7 @@ void backEnd::setUserConfigFileName(const QString &input)
//emit userConfigFileNameChanged();
}

loadUserConfigFile();
handleUserConfigFileNameChanged();
}

void backEnd::setUserConfigDisplay(const QString &input)
Expand All @@ -80,9 +86,8 @@ void backEnd::loadUserConfigFile()
void backEnd::onRunClicked()
{
// qDebug() << "Run was clicked!";
m_userConfigOK = checkUserConfigForIssues();

if (m_userConfigOK) {
parseUserConfig();

constructUserConfigGUI();

Expand All @@ -108,6 +113,13 @@ void backEnd::exitClicked()

}

void backEnd::handleUserConfigFileNameChanged()
{
loadUserConfigFile();
parseUserConfig();
checkUserConfigForIssues();
}

void backEnd::connectSnS()
{

Expand Down Expand Up @@ -185,7 +197,17 @@ void backEnd::setupDataSaver()

bool backEnd::checkUserConfigForIssues()
{
// TODO: check user config for issues
if (checkForUniqueDeviceNames() == false) {
// Need to tell user that user config has error(s)
setUserConfigOK(false);
userConfigOKChanged();
showErrorMessage();
}
else {
setUserConfigOK(true);
userConfigOKChanged();
}
// TODO: make return do something or remove
return true;
}

Expand All @@ -205,6 +227,8 @@ void backEnd::parseUserConfig()
ucMiniscopes = devices["miniscopes"].toArray();
ucBehaviorCams = devices["cameras"].toArray();
ucBehaviorTracker = m_userConfig["behaviorTracker"].toObject();


}

void backEnd::setupBehaviorTracker()
Expand All @@ -217,6 +241,39 @@ void backEnd::setupBehaviorTracker()
}
}

bool backEnd::checkForUniqueDeviceNames()
{
bool repeatingDeviceName = false;
QString tempName;
QVector<QString> deviceNames;
for (int i = 0; i < ucMiniscopes.size(); i++) {
tempName = ucMiniscopes[i].toObject()["deviceName"].toString();
if (!deviceNames.contains(tempName))
deviceNames.append(tempName);
else {
repeatingDeviceName = true;
break;
}
}
for (int i = 0; i < ucBehaviorCams.size(); i++) {
tempName = ucBehaviorCams[i].toObject()["deviceName"].toString();
if (!deviceNames.contains(tempName))
deviceNames.append(tempName);
else {
repeatingDeviceName = true;
break;
}
}

if (repeatingDeviceName == true) {
qDebug() << "Repeating Device Names!";
return false;
}
else {
return true;
}
}

void backEnd::constructUserConfigGUI()
{
int idx;
Expand Down
4 changes: 4 additions & 0 deletions backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ class backEnd : public QObject

void setupBehaviorTracker();

bool checkForUniqueDeviceNames();

signals:
void userConfigFileNameChanged();
void userConfigDisplayChanged();
void userConfigOKChanged();
void closeAll();
void showErrorMessage();

public slots:
void onRunClicked();
void onRecordClicked();
void exitClicked();
void handleUserConfigFileNameChanged();
// void onStopClicked();

private:
Expand Down
3 changes: 2 additions & 1 deletion behaviorcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ void BehaviorCam::getBehavCamConfig(QString deviceType) {
QString jsonFile;
QFile file;
m_deviceType = deviceType;
file.setFileName(":/deviceConfigs/behaviorCams.json");
// file.setFileName(":/deviceConfigs/behaviorCams.json");
file.setFileName("./deviceConfigs/behaviorCams.json");
file.open(QIODevice::ReadOnly | QIODevice::Text);
jsonFile = file.readAll();
file.close();
Expand Down
2 changes: 1 addition & 1 deletion controlpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void ControlPanel::recordTimerTick()
{
currentRecordTime++;
rootObject->setProperty("currentRecordTime", currentRecordTime);
if (currentRecordTime >= m_ucRecordLengthinSeconds) {
if (currentRecordTime >= m_ucRecordLengthinSeconds && m_ucRecordLengthinSeconds != 0) {
recordTimer->stop();
recordStop();
receiveMessage("Recording Stopped.");
Expand Down
152 changes: 110 additions & 42 deletions deviceConfigs/miniscopes.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"Miniscope_V4_BNO": {
"qmlFile": "qrc:/Miniscope_V4_BNO.qml",
"sensor": "PYTHON480",
"frameRate": 20,
"frameRate": "adjustable",
"width": 608,
"height": 608,
"headOrientation": true,
Expand Down Expand Up @@ -203,9 +204,10 @@
]
},
"Miniscope_V4": {
"qmlFile": "qrc:/Miniscope_V4_BNO.qml",
"sensor": "PYTHON480",
"frameRate": 20,
"width": 808,
"frameRate": "adjustable",
"width": 608,
"height": 608,
"headOrientation": false,
"isColor": false,
Expand All @@ -214,7 +216,7 @@
"displaySpinBoxValues":["Low", "Medium", "High"],
"displayTextValues": [1, 2, 3.5],
"outputValues":[225,228,36],
"startValue": 0,
"startValue": "Low",
"sendCommand": [
{
"protocol": "I2C",
Expand All @@ -229,13 +231,25 @@
}
]
},
"exposure": {
"startValue": 100,
"min": 1,
"max": 100,
"stepSize": 1,
"displayValueScale": 2.55,
"displayValueOffset": 0
"frameRate": {
"displaySpinBoxValues":["10FPS", "15FPS", "20FPS", "25FPS", "30FPS"],
"displayTextValues": [10, 15, 20, 25, 30],
"outputValues":[10000,6667,5000, 4000, 3300],
"startValue": "20FPS",
"sendCommand": [

{
"protocol": "I2C",
"addressW": "0b00100000",
"regLength": "1",
"reg0": "0x05",
"dataLength": "4",
"data0": "0x00",
"data1": "0xC9",
"data2": "valueH",
"data3": "valueL"
}
]
},
"led0": {
"startValue": 0,
Expand Down Expand Up @@ -280,40 +294,94 @@
"dataLength": "2",
"data0": "value",
"data1": "0x02"
},
{
"protocol": "I2C",
"addressW": "0b11101110",
"regLength": "1",
"reg0": "0x08",
"dataLength": "3",
"data0": "value",
"data1": "0x02",
"data2": "0xFF"
}
]
}
},
"initialize2": [
{
"protocol": "I2C",
"addressW": "0b11101110",
"regLength": "1",
"reg0": "0x08",
"dataLength": "2",
"data0": "0x01",
"data1": "0x02"
},
{
"protocol": "I2C",
"addressW": "0b11101010",
"regLength": "1",
"reg0": "0x08",
"dataLength": "3",
"data0": "0x03",
"data1": "0x02",
"data2": "0xFF"
}
"initialize": [
{
"description": "Speed up i2c bus timer to 50us max",
"protocol": "I2C",
"addressW": "0xC0",
"regLength": "1",
"reg0": "0x22",
"dataLength": "1",
"data0": "0b00000010"
},
{
"description": "Decrease BCC timeout, units in 2ms XX",
"protocol": "I2C",
"addressW": "0xC0",
"regLength": "1",
"reg0": "0x20",
"dataLength": "1",
"data0": "0b00001010"
},
{
"description": "Make sure DES has SER ADDR",
"protocol": "I2C",
"addressW": "0x07",
"regLength": "1",
"reg0": "0x07",
"dataLength": "1",
"data0": "0xB0"
},
{
"description": "Speed up I2c bus timer to 50u Max",
"protocol": "I2C",
"addressW": "0xB0",
"regLength": "1",
"reg0": "0x0F",
"dataLength": "1",
"data0": "0b00000010"
},
{
"description": "Decrease BCC timeout, units in 2ms",
"protocol": "I2C",
"addressW": "0xB0",
"regLength": "1",
"reg0": "0x1E",
"dataLength": "1",
"data0": "0b00001010"
},
{
"description": "sets allowable i2c addresses to send through serializer",
"protocol": "I2C",
"addressW": "0xC0",
"regLength": "1",
"reg0": "0x08",
"dataLength": "3",
"device0": "MCU",
"data0": "0b00100000",
"device1": "EWL Driver",
"data1": "0b11101110",
"device2": "Digital Pot",
"data2": "0b10100000"
},
{
"description": "sets sudo allowable i2c addresses to send through serializer",
"protocol": "I2C",
"addressW": "0xC0",
"regLength": "1",
"reg0": "0x10",
"dataLength": "3",
"device0": "MCU",
"data0": "0b00100000",
"device1": "EWL Driver",
"data1": "0b11101110",
"device2": "Digital Pot Sudo",
"data2": "0b01011000"
},
{
"description": "Enable EWL Driver",
"protocol": "I2C",
"addressW": "0b11101110",
"regLength": "1",
"reg0": "0x03",
"dataLength": "1",
"data0": "0x03"
}

]
}
}
}
Binary file modified img/MiniscopeLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3fe35ca

Please sign in to comment.