Skip to content

Commit

Permalink
Progress window on refresh, error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed Sep 6, 2024
1 parent 72dffc3 commit 342ad7b
Show file tree
Hide file tree
Showing 24 changed files with 287 additions and 162 deletions.
22 changes: 15 additions & 7 deletions Source/Basestations/OneBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "../Headstages/Headstage2.h"
#include "../Headstages/Headstage_Analog128.h"
#include "../Headstages/Headstage_Custom384.h"
#include "../Headstages/Headstage_QuadBase.h"
#include "../Probes/Neuropixels1.h"
#include "../Probes/OneBoxADC.h"
#include "../Probes/OneBoxDAC.h"
Expand Down Expand Up @@ -133,6 +134,7 @@ bool OneBox::open()
return false;
}


if (errorCode == Neuropixels::SUCCESS)
{
getInfo();
Expand All @@ -149,13 +151,17 @@ bool OneBox::open()
dacSource = std::make_unique<OneBoxDAC> (this);
}

syncFrequencies.clear();
syncFrequencies.add (1);

return true;
}

void OneBox::searchForProbes() {

probes.clear();
headstages.clear();

for (int port = 1; port <= 2; port++)
{
bool detected = false;
Expand Down Expand Up @@ -197,6 +203,11 @@ void OneBox::searchForProbes() {
LOGD (" Found 2.0 dual-dock headstage on port: ", port);
headstage = new Headstage2 (this, port);
}
else if (hsPartNumber == "NPM_HS_32") //QuadBase headstage
{
LOGC (" Found 2.0 Phase 2C dual-dock headstage on port: ", port);
headstage = new Headstage_QuadBase (this, port);
}
else
{
headstage = nullptr;
Expand Down Expand Up @@ -262,10 +273,8 @@ void OneBox::initialize (bool signalChainIsLoading)
LOGD ("Initializing ADC source on slot ", slot);
adcSource->initialize (signalChainIsLoading);

LOGD ("Neuropixels::setSWTrigger ", slot);
errorCode = Neuropixels::setSWTrigger (slot);
LOGD ("Neuropixels::arm ", slot);
errorCode = Neuropixels::arm (slot);
checkError(Neuropixels::setSWTrigger (slot), "setSWTrigger slot " + String(slot));
errorCode = checkError(Neuropixels::arm (slot), "arm slot " + String(slot));

if (errorCode != Neuropixels::SUCCESS)
{
Expand All @@ -282,12 +291,11 @@ void OneBox::close()
LOGD ("Closing OneBox on slot: ", slot);
for (auto probe : probes)
{
errorCode = Neuropixels::closeProbe (slot, probe->headstage->port, probe->dock);
checkError (Neuropixels::closeProbe (slot, probe->headstage->port, probe->dock), "closeProbe");
}

errorCode = Neuropixels::closeBS (slot);
checkError(Neuropixels::closeBS (slot), "closeBS slot " + String(slot));

LOGD ("Closed OneBox on slot: ", slot, " w/ error code: ", errorCode);
}

void OneBox::setSyncAsInput()
Expand Down
2 changes: 0 additions & 2 deletions Source/Basestations/OneBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class OneBox : public Basestation
/** Triggers the Waveplayer output */
void triggerWaveplayer (bool shouldStart);

Neuropixels::NP_ErrorCode errorCode;

static Array<int> existing_oneboxes;
int serial_number = -1;

Expand Down
2 changes: 0 additions & 2 deletions Source/Basestations/PxiBasestation.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ class PxiBasestation : public Basestation

std::unique_ptr<ArmBasestation> armBasestation;

Neuropixels::NP_ErrorCode errorCode;

bool invertOutput;
};

Expand Down
38 changes: 32 additions & 6 deletions Source/Headstages/Headstage1.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,43 @@

#include "../NeuropixComponents.h"

/**
Connects to a Neuropixels 1.0 probe
*/
class Headstage1 : public Headstage
{
public:
/** Constructor */
Headstage1::Headstage1 (Basestation*, int port);

/** Reads headstage part number and serial number */
void getInfo() override;

/** Returns true if headstage tester is connected */
bool hasTestModule() override;
void runTestModule() override;

Neuropixels::NP_ErrorCode errorCode;
/** Runs the headstage tests */
void runTestModule() override;
};

/**
Represents a Neuropixels 1.0 flex cable
*/
class Flex1 : public Flex
{
public:
/** Constructor */
Flex1::Flex1 (Headstage*);
void getInfo() override;

Neuropixels::NP_ErrorCode errorCode;
/** Reads flex part number */
void getInfo() override;
};

/** Test module status codes */
typedef struct HST_Status
{
Neuropixels::NP_ErrorCode VDD_A1V2;
Expand All @@ -61,14 +78,25 @@ typedef struct HST_Status
Neuropixels::NP_ErrorCode SIGNAL;
};

/**
Interface to headstage test module
*/
class HeadstageTestModule_v3 : public HeadstageTestModule
{
public:

/** Constructor */
HeadstageTestModule_v3::HeadstageTestModule_v3 (Basestation* bs, Headstage* hs);

/** Gets part info */
void getInfo() override;

/** Runs all tests */
void runAll() override;

/** Shows test results */
void showResults() override;

private:
Expand All @@ -90,8 +118,6 @@ class HeadstageTestModule_v3 : public HeadstageTestModule

std::vector<std::string> tests;

Neuropixels::NP_ErrorCode errorCode;

std::unique_ptr<HST_Status> status;
};

Expand Down
26 changes: 22 additions & 4 deletions Source/Headstages/Headstage2.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,42 @@ Copyright (C) 2020 Allen Institute for Brain Science and Open Ephys

#include "../NeuropixComponents.h"

/**
Connects to a Neuropixels 2.0 probe
*/
class Headstage2 : public Headstage
{
public:

/** Constructor */
Headstage2::Headstage2 (Basestation*, int port);

/** Gets headstage info */
void getInfo() override;

/** No test module available for 2.0 probes, so this is always false */
bool hasTestModule() override { return false; }
void runTestModule() override {}

Neuropixels::NP_ErrorCode errorCode;
/** No tests can be run */
void runTestModule() override {}
};

/**
Represents a Neuropixels 2.0 probe flex cable
*/
class Flex2 : public Flex
{
public:

/** Constructor */
Flex2::Flex2 (Headstage*, int dock);
void getInfo() override;

Neuropixels::NP_ErrorCode errorCode;
/** Gets flex info */
void getInfo() override;
};

#endif // __NEUROPIXHS2_H_2C4C2D67__
4 changes: 0 additions & 4 deletions Source/Headstages/Headstage_Analog128.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ class Headstage_Analog128 : public Headstage
void getInfo() override;
bool hasTestModule() override { return false; }
void runTestModule() override {}

Neuropixels::NP_ErrorCode errorCode;
};

class Flex1_NHP : public Flex
{
public:
Flex1_NHP::Flex1_NHP (Headstage*);
void getInfo() override;

Neuropixels::NP_ErrorCode errorCode;
};

#endif // __NEUROPIXHSNP1V1_H_2C4C2D67__
4 changes: 0 additions & 4 deletions Source/Headstages/Headstage_Custom384.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class Headstage_Custom384 : public Headstage

/** No test module available*/
void runTestModule() override {}

Neuropixels::NP_ErrorCode errorCode;
};

/**
Expand All @@ -61,8 +59,6 @@ class Flex1_Custom : public Flex

/** Get part number */
void getInfo() override;

Neuropixels::NP_ErrorCode errorCode;
};

#endif // __NEUROPIXHSNP1V1_H_2C4C2D67__
4 changes: 0 additions & 4 deletions Source/Headstages/Headstage_QuadBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ class Headstage_QuadBase : public Headstage
void getInfo() override;
bool hasTestModule() override { return false; }
void runTestModule() override {}

Neuropixels::NP_ErrorCode errorCode;
};

class Flex_QuadBase : public Flex
{
public:
Flex_QuadBase::Flex_QuadBase (Headstage*, int dock);
void getInfo() override;

Neuropixels::NP_ErrorCode errorCode;
};

#endif // __NEUROPIXHSP2C_H_2C4C2D67__
21 changes: 20 additions & 1 deletion Source/NeuropixComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,30 @@ struct ProbeSettings
class NeuropixComponent
{
public:

/** Constructor */
NeuropixComponent() {}

/** Pure virtual method for getting component info */
virtual void getInfo() = 0;

/** Holds component info */
ComponentInfo info;

virtual void getInfo() = 0;
/** Checks error messages */
Neuropixels::NP_ErrorCode checkError (Neuropixels::NP_ErrorCode error, const String& function = "")
{
if (error != Neuropixels::SUCCESS)
{
LOGE (function, " Error: ", Neuropixels::getErrorMessage (error));
}

return error;
}

/** Holds error codes*/
Neuropixels::NP_ErrorCode errorCode;

};

/** Holds info about APIv3, as well as a boolean value to indicate whether or not it is being used*/
Expand Down
Loading

0 comments on commit 342ad7b

Please sign in to comment.