1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 18:28:52 -05:00

Added in flexible board channel count to both online and offline CoMPASS sources. Started process of adding in scaler support (maybe graphs?)

This commit is contained in:
Gordon McCann 2022-06-15 00:21:57 -04:00
parent 29433be65a
commit e1b56dd1c3
15 changed files with 85 additions and 23 deletions

View File

@ -3,7 +3,7 @@
An example of what a user created layer might look like. This is how one would extend the base editor to have more
functionality, specific to their experiment/setup. In this case, we provide inputs for reaction information so that
the kinematic shift of the SE-SPS focal plane can be calculated, and weights for tracing particle trajectories are
produced for use in analysis (as NavVariables).
produced for use in analysis (as Variables).
A reminder that these layers should not be that intense. The more work that is shoved into the UI, the less responsive
and more sluggish overall the UI will become. The vast bulk of the analysis work should be left to the PhysicsLayer which has its own

View File

@ -61,4 +61,36 @@ namespace Navigator {
}
Variable::~Variable() {}
void Variable::SetName(const std::string& name)
{
if (m_name != "")
{
NAV_ERROR("Attempting to change the name of an already bound Variable! Set name: {0} New name: {1}", m_name, name);
return;
}
m_name = name;
}
Scaler::Scaler() :
m_pdata(nullptr), m_name("")
{
}
Scaler::Scaler(const std::string& name) :
m_pdata(nullptr), m_name(name)
{
}
Scaler::~Scaler() {}
void Scaler::SetName(const std::string& name)
{
if (m_name != "")
{
NAV_ERROR("Attempting to change the name of an already bound Scaler! Set name: {0} New name: {1}", m_name, name);
return;
}
m_name = name;
}
}

View File

@ -74,6 +74,7 @@ namespace Navigator {
inline void SetValue(double value) { *(m_pdata) = value; }
inline double GetValue() { return *(m_pdata); }
inline const std::string& GetName() { return m_name; }
void SetName(const std::string& name);
friend class SpectrumManager;
private:
@ -81,6 +82,25 @@ namespace Navigator {
std::string m_name;
};
class Scaler
{
public:
Scaler();
Scaler(const std::string& name);
~Scaler();
inline void Increment() { ++(*m_pdata); }
inline const std::string& GetName() { return m_name; }
inline uint64_t GetCounts() { return *m_pdata; }
void SetName(const std::string& name);
friend class SpectrumManager;
private:
std::shared_ptr<std::atomic<uint64_t>> m_pdata;
std::string m_name;
};
}
#endif

View File

@ -43,6 +43,7 @@ namespace Navigator {
m_chosenPort = "51489";
m_chosenWindow = 3000000;
m_bitflags = 0;
m_channels_per_board = 16;
ImGui::OpenPopup(ICON_FA_LINK " Attach Source");
}
if (ImGui::BeginPopupModal(ICON_FA_LINK " Attach Source"))
@ -77,6 +78,7 @@ namespace Navigator {
{
m_bitflags = m_bitflags ^ CompassHeaders::EnergyCalibrated;
}
ImGui::InputInt("Channels Per Digitizer Board", &m_channels_per_board);
}
else if (m_chosenType == DataSource::SourceType::CompassOffline)
{
@ -88,6 +90,7 @@ namespace Navigator {
auto temp = m_fileDialog.RenderFileDialog();
if (!temp.first.empty() && temp.second == FileDialog::Type::OpenDir)
m_chosenLocation = temp.first;
ImGui::InputInt("Channels Per Digitizer Board", &m_channels_per_board);
}
ImGui::InputInt("Coinc. Window (ps)", &m_chosenWindow);
@ -96,12 +99,12 @@ namespace Navigator {
{
if (m_chosenType == DataSource::SourceType::CompassOffline)
{
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort);
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, false, 0U, m_channels_per_board);
Application::Get().OnEvent(event);
}
else if (m_chosenType == DataSource::SourceType::CompassOnline)
{
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, true, m_bitflags);
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, true, m_bitflags, m_channels_per_board);
Application::Get().OnEvent(event);
}
ImGui::CloseCurrentPopup();

View File

@ -30,6 +30,7 @@ namespace Navigator {
FileDialog m_fileDialog;
uint16_t m_bitflags;
int m_chosenWindow;
int m_channels_per_board;
};
}

View File

@ -21,15 +21,18 @@ namespace Navigator {
{
public:
//Bitflags is a final option for random crap needed for a source. Currently used for compass online to indicate header state.
PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window, const std::string& port = "51489", bool sortFlag=false, uint16_t bitflags = 0) :
m_sourceLocation(loc), m_port(port), m_sourceType(type), m_coincidenceWindow(window), m_sortFlag(sortFlag), m_bitflags(bitflags)
PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window, const std::string& port = "51489", bool sortFlag=false, uint16_t bitflags = 0,
int channels_per_board=16) :
m_sourceLocation(loc), m_port(port), m_sourceType(type), m_coincidenceWindow(window), m_sortFlag(sortFlag), m_bitflags(bitflags), m_channels_per_board(channels_per_board)
{}
inline std::string GetSourceLocation() { return m_sourceLocation; }
inline std::string GetSourcePort() { return m_port; }
inline DataSource::SourceType GetSourceType() { return m_sourceType; }
inline uint64_t GetCoincidenceWindow() { return m_coincidenceWindow; }
inline bool GetSortFlag() { return m_sortFlag; }
inline const std::string GetSourceLocation() const { return m_sourceLocation; }
inline const std::string GetSourcePort() const { return m_port; }
inline const DataSource::SourceType GetSourceType() const { return m_sourceType; }
inline const uint64_t GetCoincidenceWindow() const { return m_coincidenceWindow; }
inline const bool GetSortFlag() const { return m_sortFlag; }
inline const int GetChannelsPerBoard() const { return m_channels_per_board; }
inline const uint16_t GetBitFlags() const { return m_bitflags; }
std::string ToString() const override
{
@ -46,6 +49,7 @@ namespace Navigator {
uint64_t m_coincidenceWindow;
bool m_sortFlag;
uint16_t m_bitflags;
int m_channels_per_board;
};
class NAV_API PhysicsStopEvent : public Event

View File

@ -25,8 +25,8 @@
namespace Navigator {
CompassOnlineSource::CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header) :
DataSource(), m_bufferIter(nullptr), m_bufferEnd(nullptr), m_header(header)
CompassOnlineSource::CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header, int channels_per_board) :
DataSource(), m_bufferIter(nullptr), m_bufferEnd(nullptr), m_header(header), m_nchannels_per_board(channels_per_board)
{
InitConnection(hostname, port);
}

View File

@ -39,7 +39,7 @@ namespace Navigator {
class CompassOnlineSource : public DataSource
{
public:
CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header);
CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header, int channels_per_board=16);
virtual ~CompassOnlineSource() override;
virtual const NavData& GetData() override;

View File

@ -23,12 +23,12 @@
namespace Navigator {
CompassRun::CompassRun() :
DataSource(), m_directory(""), m_startIndex(0)
DataSource(), m_directory(""), m_startIndex(0), m_nchannels_per_board(16)
{
}
CompassRun::CompassRun(const std::string& dir) :
DataSource(), m_directory(dir), m_startIndex(0)
CompassRun::CompassRun(const std::string& dir, int channels_per_board) :
DataSource(), m_directory(dir), m_startIndex(0), m_nchannels_per_board(channels_per_board)
{
CollectFiles();
}

View File

@ -36,7 +36,7 @@ namespace Navigator {
public:
CompassRun();
CompassRun(const std::string& dir);
CompassRun(const std::string& dir, int channels_per_board=16);
virtual ~CompassRun();
virtual const NavData& GetData() override;
inline void SetDirectory(const std::string& dir) { m_directory = dir; CollectFiles(); }
@ -52,7 +52,7 @@ namespace Navigator {
std::vector<CompassFile> m_datafiles;
unsigned int m_startIndex; //this is the file we start looking at; increases as we finish files.
const int m_nchannels_per_board = 16; //IMPORTANT: Used for ID'ing channels uniquely. If you use boards with 32 or 8 or 64 channels you must change this! If you mix boards with
int m_nchannels_per_board; //IMPORTANT: Used for ID'ing channels uniquely. If you use boards with 32 or 8 or 64 channels you must change this! If you mix boards with
//different numbers of channels, you will have to find a different id solution.
ShiftMap m_smap;

View File

@ -13,12 +13,12 @@
namespace Navigator {
//loc=either an ip address or a file location, port=address port, or unused in case of file
DataSource* CreateDataSource(const std::string& loc, const std::string& port, DataSource::SourceType type, uint16_t bitflags)
DataSource* CreateDataSource(const std::string& location, const std::string& port, uint16_t header, int channels_per_board, DataSource::SourceType type)
{
switch(type)
{
case DataSource::SourceType::CompassOffline : return new CompassRun(loc);
case DataSource::SourceType::CompassOnline : return new CompassOnlineSource(loc, port, bitflags);
case DataSource::SourceType::CompassOffline : return new CompassRun(location, channels_per_board);
case DataSource::SourceType::CompassOnline : return new CompassOnlineSource(location, port, header, channels_per_board);
case DataSource::SourceType::None : return nullptr;
}
NAV_WARN("Invalid DataSourceType at CreateDataSource!");

View File

@ -38,7 +38,7 @@ namespace Navigator {
NavData m_datum;
};
NAV_API DataSource* CreateDataSource(const std::string& loc, const std::string& port, DataSource::SourceType type, uint16_t bitflags = 0);
NAV_API DataSource* CreateDataSource(const std::string& location, const std::string& port, uint16_t bitflags, int channels_per_board, DataSource::SourceType type);
NAV_API std::string ConvertDataSourceTypeToString(DataSource::SourceType type);
}

View File

@ -114,7 +114,7 @@ namespace Navigator {
{
NAV_PROFILE_FUNCTION();
std::scoped_lock<std::mutex> guard(m_sourceMutex); //Shouldn't matter for this, but safety first
m_source.reset(CreateDataSource(event.GetSourceLocation(), event.GetSourcePort(), event.GetSourceType()));
m_source.reset(CreateDataSource(event.GetSourceLocation(), event.GetSourcePort(), event.GetBitFlags(), event.GetChannelsPerBoard(), event.GetSourceType()));
m_eventBuilder.SetCoincidenceWindow(event.GetCoincidenceWindow());
m_eventBuilder.SetSortFlag(event.GetSortFlag());
m_eventBuilder.ClearAll(); //Protect against stopping mid-event

View File

@ -20,6 +20,7 @@ namespace Navigator {
void OpenGLContext::Init()
{
NAV_PROFILE_FUNCTION();
glfwMakeContextCurrent(m_windowHandle);
int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);

View File

@ -35,6 +35,7 @@ namespace Navigator {
void OpenGLWindow::Init(const WindowProperties& props)
{
NAV_PROFILE_FUNCTION();
m_data.width = props.width;
m_data.height = props.height;
m_data.name = props.name;