diff --git a/Installer/phoBehavioralBoxLabjackController.nsi b/Installer/phoBehavioralBoxLabjackController.nsi index 7eac3c8..e8171d9 100644 --- a/Installer/phoBehavioralBoxLabjackController.nsi +++ b/Installer/phoBehavioralBoxLabjackController.nsi @@ -4,8 +4,8 @@ ; ------------------------------- ; Start - !define PRODUCT_VERSION "1.0.1.3" - !define VERSION "1.0.1.3" + !define PRODUCT_VERSION "1.0.1.5" + !define VERSION "1.0.1.5" !define MUI_PRODUCT "phoBehavioralBoxLabjackController" !define MUI_FILE "phoBehavioralBoxLabjackController" @@ -27,8 +27,8 @@ ;!define PHO_BUILD_PATH "../x64/Release" ; !define PHO_BUILD_PATH "C:\Common\repo\phoBehavioralBoxLabjackController\x64\Release" ; !define PHO_BUILD_PATH "C:\Users\Pho\repos\phoBehavioralBoxLabjackController\x64\Release" - !define PHO_BUILD_PATH "C:\Users\Pho\repos\phoBehavioralBoxLabjackController\builds\x64\Release" -; !define PHO_BUILD_PATH "C:\Users\watsonlab\Desktop\phoTempRepo\phoBehavioralBoxLabjackController\builds\x64\Release" + ; !define PHO_BUILD_PATH "C:\Users\Pho\repos\phoBehavioralBoxLabjackController\builds\x64\Release" + !define PHO_BUILD_PATH "C:\Users\WatsonLab\source\repos\phoBehavioralBoxLabjackController\builds\x64\Release" CRCCheck On diff --git a/ProgramVersion.h b/ProgramVersion.h index 0189634..bb6c012 100644 --- a/ProgramVersion.h +++ b/ProgramVersion.h @@ -1,2 +1,2 @@ #pragma once -#define SOFTWARE_VERSION "1.0.1.4" \ No newline at end of file +#define SOFTWARE_VERSION "1.0.1.6" \ No newline at end of file diff --git a/READMEPLEASE.txt b/READMEPLEASE.txt new file mode 100644 index 0000000..f56dc5b --- /dev/null +++ b/READMEPLEASE.txt @@ -0,0 +1,10 @@ +As of right now, this is the fully functional piece of software that will run the Labjacks in the behavioral boxes. + +Issues addressed: + Analog signal continuous outputs from small changes + Duplicate digital lines output + +This has yet to be tested. Josh, Deniz, and I will most likely go in and manually test the functionalities. + +signed +-David Kim (your friendly neighborhood lab tech-research assistant-employee guy) diff --git a/device_info.vcxproj.filters b/device_info.vcxproj.filters.txt similarity index 100% rename from device_info.vcxproj.filters rename to device_info.vcxproj.filters.txt diff --git a/src/BehavioralBoxLabjack.cpp b/src/BehavioralBoxLabjack.cpp index 941e850..266ac5b 100644 --- a/src/BehavioralBoxLabjack.cpp +++ b/src/BehavioralBoxLabjack.cpp @@ -51,6 +51,8 @@ BehavioralBoxLabjack::BehavioralBoxLabjack(int uniqueIdentifier, const char * de //this->testBuildLogicalInputChannels(); this->LoadActiveLogicalInputChannelsConfig(); + + lastReadExpandedPortValues = new double[8]; //DAVID CONTROL YOURSALF this->serialNumber = serialNumber; char iden[256]; sprintf(iden, "%d", this->serialNumber); @@ -198,6 +200,7 @@ BehavioralBoxLabjack::~BehavioralBoxLabjack() this->shouldStop = true; //Read the values and save them one more time, so we know when the end of data collection occured. this->readSensorValues(); + delete[] lastReadExpandedPortValues; // TODO: see if the stream version needs to do anything special here // Probably need to do something with To stop stream, use LJM_eStreamStop. printf("Stopping stream...\n"); @@ -871,7 +874,7 @@ void BehavioralBoxLabjack::SetupStream() WriteNameOrDie(this->handle, "AIN_ALL_NEGATIVE_CH", AIN_ALL_NEGATIVE_CH); // Build the stream object: - const double stream_scan_rate_Hz = 240.0; + const double stream_scan_rate_Hz = 100.0; auto currChannelNames = this->getInputPortNames(PortEnumerationMode::portNames, true, true); this->ljStreamInfo.build(currChannelNames, stream_scan_rate_Hz); @@ -1004,8 +1007,8 @@ void BehavioralBoxLabjack::readSensorValues() auto expandedPortNames = this->getInputPortNames(PortEnumerationMode::expandedPortNames, true, true); - double* lastReadExpandedPortValues = nullptr; - lastReadExpandedPortValues = new double[expandedPortNames.size()]; + //double* lastReadExpandedPortValues = nullptr; // David's edit. This fixes continuous analog outputs + //lastReadExpandedPortValues = new double[expandedPortNames.size()]; std::vector lastReadExpandedPortValuesVector (expandedPortNames.size(), 0.0); //lastReadExpandedPortValuesVector.reserve(expandedPortNames.size()); @@ -1053,8 +1056,10 @@ void BehavioralBoxLabjack::readSensorValues() double* last_expanded_value_pointer = lastReadExpandedPortValues + (currWithinScanExpandedPortLinearOffset); double* curr_expanded_value_pointer = curr_got_expanded_values.data(); - auto didAnyChange = currChannel->fn_generic_get_didValueChange(currChannelNumExpandedValues, last_expanded_value_pointer, curr_expanded_value_pointer); - + //std::cout << scanIndex << ' '; + //std::cout << "lastReadExpandedPortValues: " << *lastReadExpandedPortValues << " currWithinScanExpandedPortLinearOffset " << currWithinScanExpandedPortLinearOffset << std::endl; + std::vector didExpandedPortChange = currChannel->fn_generic_get_didValueChange(currChannelNumExpandedValues, last_expanded_value_pointer, curr_expanded_value_pointer); + //channelExpandedPortValues[logicalChannelIndex] = std::vector(currChannelNumExpandedValues); currChannelExpandedPortValues[logicalChannelIndex] = curr_got_expanded_values; //TODO: validate that this works @@ -1066,7 +1071,7 @@ void BehavioralBoxLabjack::readSensorValues() { // Loop through and update the individual expanded port values: if (currChannel->isLoggedToCSV() || currChannel->isLoggedToConsole()) { - currDidChange = didAnyChange[i]; + currDidChange = didExpandedPortChange[i]; if (currDidChange) { if (currChannel->getReturnsContinuousValue()) @@ -1129,8 +1134,8 @@ void BehavioralBoxLabjack::readSensorValues() delete[] lastReadValues; lastReadValues = nullptr; - delete[] lastReadExpandedPortValues; - lastReadExpandedPortValues = nullptr; + //delete[] lastReadExpandedPortValues; + //lastReadExpandedPortValues = nullptr; streamRead++; } @@ -1205,7 +1210,13 @@ void BehavioralBoxLabjack::performPersistValues(unsigned long long estimated_sca if (did_anyAnalogPortChange) { // If an analog port changed, write out to the digital line - newCSVLine_analogOnly.writeToFile(this->fileFullPath_analog, true); //TODO: relies on CSV object's internal buffering and writes out to the file each time. + // DavidsAnalogWriterBlock = !DavidsAnalogWriterBlock; + if (analogWriterCounter == 2) { + std::cout << "Written to file "; + newCSVLine_analogOnly.writeToFile(this->fileFullPath_analog, true); //TODO: relies on CSV object's internal buffering and writes out to the file each time. + analogWriterCounter = 0; + } + ++analogWriterCounter; } if (did_anyDigitalPortChange) { diff --git a/src/BehavioralBoxLabjack.h b/src/BehavioralBoxLabjack.h index 68dcd71..20626d8 100644 --- a/src/BehavioralBoxLabjack.h +++ b/src/BehavioralBoxLabjack.h @@ -43,6 +43,8 @@ class BehavioralBoxLabjack BehavioralBoxLabjack& operator=(const BehavioralBoxLabjack&) = delete; // non copyable ~BehavioralBoxLabjack(); + double* lastReadExpandedPortValues = nullptr;// David trying to make a global ass pointer with the worst coding background ever seen to mankind + enum class PortEnumerationMode { logicalChannelOnly, portNames, expandedPortNames }; /* * logicalChannelOnly: only the logical channel name, like {"DISPENSE_SIGNALS"} @@ -127,6 +129,8 @@ class BehavioralBoxLabjack int err; int handle; bool shouldStop = false; + //bool DavidsAnalogWriterBlock = true; // this is to control the write speed of the analog data. It makes performPersistValues function only write half the speed of the sampling frequency + int analogWriterCounter = 0; // Override Values: bool isOverrideActive_VisibleLED = false; diff --git a/src/External/C_C++_LJM/visual_studio_2008/more/stream/stream_basic/stream_basic.vcxproj.filters b/src/External/C_C++_LJM/visual_studio_2008/more/stream/stream_basic/stream_basic.vcxproj.filters.txt similarity index 100% rename from src/External/C_C++_LJM/visual_studio_2008/more/stream/stream_basic/stream_basic.vcxproj.filters rename to src/External/C_C++_LJM/visual_studio_2008/more/stream/stream_basic/stream_basic.vcxproj.filters.txt diff --git a/src/External/C_C++_LJM/visual_studio_2008/more/stream/stream_burst/stream_burst.vcxproj.filters b/src/External/C_C++_LJM/visual_studio_2008/more/stream/stream_burst/stream_burst.vcxproj.filters.txt similarity index 100% rename from src/External/C_C++_LJM/visual_studio_2008/more/stream/stream_burst/stream_burst.vcxproj.filters rename to src/External/C_C++_LJM/visual_studio_2008/more/stream/stream_burst/stream_burst.vcxproj.filters.txt diff --git a/src/External/C_C++_LJM/visual_studio_2008/more/utilities/raw_bytes/raw_bytes.vcxproj.filters b/src/External/C_C++_LJM/visual_studio_2008/more/utilities/raw_bytes/raw_bytes.vcxproj.filters.txt similarity index 100% rename from src/External/C_C++_LJM/visual_studio_2008/more/utilities/raw_bytes/raw_bytes.vcxproj.filters rename to src/External/C_C++_LJM/visual_studio_2008/more/utilities/raw_bytes/raw_bytes.vcxproj.filters.txt diff --git a/src/Main.cpp b/src/Main.cpp index 19c63f1..554e08f 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -148,6 +148,105 @@ int main(int argc, char** argv) } std::cout << "\t done." << std::endl; } + + + + + + + + + + + + + else if (character == 'F') { + // Show the data files: + std::cout << "Showing current output directory..." << std::endl; + // Iterate through all found Labjacks + auto loaded_config = configMan->getLoadedConfig(); + std::string fullOutputDirectoryPathString = configMan->getGeneratedActiveOutputDirectory(); + std::cout << "\t Showing output file directory at " << fullOutputDirectoryPathString << std::endl; + LabjackHelpers::showInExplorer(fullOutputDirectoryPathString); + std::cout << "\t done." << std::endl; + } + else if (character == 'P') { + // Prints the current data + std::cout << "Printing current data..." << std::endl; + // Iterate through all found Labjacks + for (int i = 0; i < controller->getActiveLabjacks().size(); i++) { + //controller->getActiveLabjacks()[i]->diagnosticPrintLastValues(); + } + std::cout << "\t done." << std::endl; + } + else if (character == 'R') { + std::cout << "Refreshing Labjacks..." << std::endl; + controller->scanForNewLabjacks(); + //if (shouldStartWebServer) { + // Refresh the webserver + //WServer::instance()->postAll(&LabjackControllerWebApplication::staticUpdateActiveLabjacks); + //} + std::cout << "\t done." << std::endl; + } + else if (character == 'L') { + std::cout << "Toggling visible LED Light mode on all labjacks..." << std::endl; + // Iterate through all found Labjacks + for (int i = 0; i < controller->getActiveLabjacks().size(); i++) { + controller->getActiveLabjacks()[i]->toggleOverrideMode_VisibleLED(); + } + std::cout << "\t done." << std::endl; + } + else if (character == 'A') { + std::cout << "Toggling attract mode on all Labjacks..." << std::endl; + // Iterate through all found Labjacks + for (int i = 0; i < controller->getActiveLabjacks().size(); i++) { + controller->getActiveLabjacks()[i]->toggleOverrideMode_AttractModeLEDs(); + } + std::cout << "\t done." << std::endl; + } + else if (character == 'U') { + std::cout << "Utility mode:" << std::endl; + //TODO: utility mode. + // Export data as CSV + std::vector exportPaths = controller->exportHistoricalDataAsCSV("C:/Common/data/", "export-HistoricalData"); + if (exportPaths.empty()) { + std::cout << "Tried to export CSV files but had no historical data." << std::endl; + } + else { + int numExportPaths = exportPaths.size(); + std::cout << "Export " << numExportPaths << " historical data .CSV files:" << std::endl; + for (size_t i = 0; i < numExportPaths; i++) + { + std::cout << "\t" << exportPaths[i] << std::endl; + } + } + std::cout << "\t done." << std::endl; + } + + + + + + + + + + + + + + + + + + + + + + + + + else { printCommandsMenu(); } @@ -217,10 +316,10 @@ void printCommandsMenu() { std::cout << "\t Press [p] at any time to print the most recently read values for all labjacks." << std::endl; std::cout << "\t Press [f] at any time to show the current output file directory." << std::endl; std::cout << "\t Press [s] at any time to show the current log files for all labjacks." << std::endl; - /*std::cout << "\t Press [r] at any time to refresh and scan for more labjacks." << std::endl; + std::cout << "\t Press [r] at any time to refresh and scan for more labjacks." << std::endl; std::cout << "\t Press [l] at any time to toggle visible LED Light mode for all labjacks." << std::endl; std::cout << "\t Press [a] at any time to toggle Attract mode for all labjacks." <