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

Finished adding in initial comments

This commit is contained in:
Gordon McCann 2022-03-06 15:17:54 -05:00
parent 060183e26f
commit 2c4af3a0e0
47 changed files with 411 additions and 42 deletions

View File

@ -1,7 +1,14 @@
/*
SPSAnalysisStage.cpp
Example of a user AnalysisStage. This one is based around the SE-SPS detector system in FoxLab at FSU.
GWM -- Feb 2022
*/
#include "SPSAnalysisStage.h"
namespace Navigator {
//Construct each NavParameter with their unique name. Then bind them to the SpectrumManager.
SPSAnalysisStage::SPSAnalysisStage() :
AnalysisStage("SPSAnalysis"), delayFLTime("delayFLTime"), delayFRTime("delayFRTime"), delayBLTime("delayBLTime"), delayBRTime("delayBRTime"), x1("x1"), x2("x2"), xavg("xavg"),
scintLeft("scintLeft"), anodeBack("anodeBack")
@ -20,10 +27,13 @@ namespace Navigator {
SPSAnalysisStage::~SPSAnalysisStage() {}
//Do some physics!
void SPSAnalysisStage::AnalyzePhysicsEvent(const NavEvent& event)
{
//Most analysis stages will start kinda like this. Take the raw event data and
//put it into NavParameters using the hit id. Switches are perfect for this. Can also
//create mapping classes to use text-file-based id association (commonly called channel maps).
for(auto& hit : event)
{
switch (hit.id)
@ -49,6 +59,8 @@ namespace Navigator {
}
}
//If you want to use parameters to calculate another parameter, you
//need to check that the parameter is valid (set in this event)!
if(delayFLTime.IsValid() && delayFRTime.IsValid())
x1.SetValue((delayFLTime.GetValue() - delayFRTime.GetValue())*0.5);

View File

@ -1,3 +1,9 @@
/*
SPSAnalysisStage.h
Example of a user AnalysisStage. This one is based around the SE-SPS detector system in FoxLab at FSU.
GWM -- Feb 2022
*/
#include "Navigator.h"
namespace Navigator {
@ -11,6 +17,7 @@ namespace Navigator {
virtual void AnalyzePhysicsEvent(const NavEvent& event) override;
private:
//Create a bunch of parameters
NavParameter delayFLTime;
NavParameter delayFRTime;
NavParameter delayBLTime;
@ -21,6 +28,7 @@ namespace Navigator {
NavParameter scintLeft;
NavParameter anodeBack;
//some variables.
double weight1 = 1.7;
double weight2 = -0.7;
};

View File

@ -1,6 +1,13 @@
/*
main.cpp
Entry point for the example NavProject. Also contains example of a simple user Navigator::Application.
GWM -- Feb 2022
*/
#include "Navigator.h"
#include "SPSAnalysisStage.h"
//User application class. Pushes user analysis stages.
class SPSApp : public Navigator::Application
{
public:
@ -11,8 +18,10 @@ public:
}
};
//Define the creation function to make our user application
Navigator::Application* Navigator::CreateApplication() { return new SPSApp(); }
//Make sure to initialize log BEFORE creating application.
int main(int argc, const char** argv)
{
Navigator::Logger::Init();

View File

@ -1,3 +1,10 @@
/*
EditorLayer.cpp
Application layer encapsulating the editor for Navigator. Written using the Dear ImGui library. Setup based off of @TheCherno's Hazel game engine.
EditorLayer essentially controls the state for UI related actions.
GWM -- Feb 2022
*/
#include "EditorLayer.h"
#include "imgui.h"
#include "misc/cpp/imgui_stdlib.h"
@ -34,6 +41,7 @@ namespace Navigator {
{
}
//These updates are used whenever a new object is added to the manager.
void EditorLayer::UpdateHistogramList()
{
m_histoList = SpectrumManager::GetInstance().GetListOfHistograms();
@ -49,6 +57,7 @@ namespace Navigator {
m_paramList = SpectrumManager::GetInstance().GetListOfParameters();
}
//The main function
void EditorLayer::OnImGuiRender()
{
static bool startFlag = true; //first render retrieve base
@ -164,7 +173,7 @@ namespace Navigator {
ImGui::EndMenuBar();
}
//Render all of our sub-windows, dialogs, panels, etc
std::string open_file_result = m_fileDialog.ImGuiRenderOpenFile(".nav");
std::string save_file_result = m_fileDialog.ImGuiRenderSaveFile(".nav");
if (!open_file_result.empty())
@ -247,6 +256,8 @@ namespace Navigator {
ImGui::End();
}
//Simple dialogs, no need for separate class
void EditorLayer::RemoveHistogramDialog()
{
static std::string selectedGram = "";

View File

@ -1,3 +1,10 @@
/*
EditorLayer.h
Application layer encapsulating the editor for Navigator. Written using the Dear ImGui library. Setup based off of @TheCherno's Hazel game engine.
EditorLayer essentially controls the state for UI related actions.
GWM -- Feb 2022
*/
#ifndef EDITOR_LAYER_H
#define EDITOR_LAYER_H

View File

@ -1,9 +1,23 @@
/*
FileDialog.cpp
File dialog window in ImGui using std::filesystem. This is slightly complicated, as file dialogs change function
based on the type of action one wants to perform. In our case we have OpenFile, SaveFile, and OpenDirectory. One can also
specify the kind of file (extension). Use FontAwesome icons.
Use style:
if(ImGui::Button())
Set...FileDialog(true);
std::string value = ImGuiRender...(extension);
GWM -- Feb 2022
*/
#include "FileDialog.h"
#include "misc/cpp/imgui_stdlib.h"
#include "IconsFontAwesome5.h"
namespace Navigator {
//Helper function to handle file size printing
std::string ConvertFileSystemSizeToString(std::uintmax_t value)
{
int i = 0;
@ -24,6 +38,8 @@ namespace Navigator {
FileDialog::~FileDialog() {}
//Each type of action has its own render function
std::string FileDialog::ImGuiRenderOpenFile(const std::string& ext)
{
if (m_openFileFlag)

View File

@ -1,3 +1,16 @@
/*
FileDialog.h
File dialog window in ImGui using std::filesystem. This is slightly complicated, as file dialogs change function
based on the type of action one wants to perform. In our case we have OpenFile, SaveFile, and OpenDirectory. One can also
specify the kind of file (extension). Use FontAwesome icons.
Use style:
if(ImGui::Button())
Set...FileDialog(true);
std::string value = ImGuiRender...(extension);
GWM -- Feb 2022
*/
#ifndef FILE_DIALOG_H
#define FILE_DIALOG_H

View File

@ -1,3 +1,10 @@
/*
SourceDialog.cpp
Handles selection of data source type and location specification. Needs to be updated when new source
types are added to Navigator.
GWM -- Feb 2022
*/
#include "SourceDialog.h"
#include "Navigator/Events/PhysicsEvent.h"
#include "Navigator/Events/Event.h"

View File

@ -1,3 +1,10 @@
/*
SourceDialog.h
Handles selection of data source type and location specification. Needs to be updated when new source
types are added to Navigator.
GWM -- Feb 2022
*/
#ifndef SOURCE_DIALOG_H
#define SOURCE_DIALOG_H

View File

@ -1,3 +1,9 @@
/*
SpectrumDialog.h
Handles creation of new spectra. Pretty much that simple.
GWM -- Feb 2022
*/
#include "SpectrumDialog.h"
#include "Navigator/SpectrumManager.h"

View File

@ -1,3 +1,9 @@
/*
SpectrumDialog.h
Handles creation of new spectra. Pretty much that simple.
GWM -- Feb 2022
*/
#ifndef SPECTRUM_DIALOG_H
#define SPECTRUM_DIALOG_H

View File

@ -1,3 +1,10 @@
/*
SpectrumPanel.cpp
This is the big boi. Renders a panel holding all of the drawn plots. Good news is that in general only a few things really require
any modification if new types of plots are to be rendered, basically just the zoomed in spectrum rendering.
GWM -- Feb 2022
*/
#include "SpectrumPanel.h"
#include "Navigator/SpectrumManager.h"
#include "misc/cpp/imgui_stdlib.h"
@ -5,6 +12,7 @@
namespace Navigator {
//Convert a StatResults struct from analysis to a std::string helper function
std::string GenerateStatString(const std::string& name, const StatResults& results, bool is2D = true)
{
std::stringstream stream;
@ -25,6 +33,7 @@ namespace Navigator {
SpectrumPanel::~SpectrumPanel() {}
//Main render function. Handles generating subplot regions as well as the zoomed in region
bool SpectrumPanel::OnImGuiRender(const std::vector<HistogramParameters>& histoList, const std::vector<CutParams>& cutList, const std::vector<std::string>& paramList)
{
static bool acceptCutFlag = false;
@ -214,6 +223,7 @@ namespace Navigator {
return result;
}
//Renders Cut button as well as dialog for creating cuts.
void SpectrumPanel::RenderCutButton()
{
if (ImGui::Button(ICON_FA_CUT " Draw Cut"))
@ -244,6 +254,7 @@ namespace Navigator {
}
}
//Simple button/dialog for removing integration regions
void SpectrumPanel::RenderRemoveRegionButton()
{
static std::string selectedRegion = "";

View File

@ -1,3 +1,10 @@
/*
SpectrumPanel.h
This is the big boi. Renders a panel holding all of the drawn plots. Good news is that in general only a few things really require
any modification if new types of plots are to be rendered, basically just the zoomed in spectrum rendering.
GWM -- Feb 2022
*/
#ifndef SPECTRUM_PANEL_H
#define SPECTRUM_PANEL_H
@ -8,6 +15,7 @@
namespace Navigator {
//Simple struct for holding a region of interest
struct NAV_API IntegrationRegion
{
IntegrationRegion(const ImPlotRect& rect, const std::string& n, const std::string& hist_n) :

View File

@ -1,3 +1,9 @@
/*
AppEvent.h
Events related to the main application (window events mostly). Again, based on @TheCherno's work.
GWM -- Feb 2022
*/
#ifndef APP_EVENT_H
#define APP_EVENT_H
@ -6,6 +12,7 @@
namespace Navigator {
// Window closing is pure event (no data)
class NAV_API WindowCloseEvent : public Event
{
public:

View File

@ -1,3 +1,11 @@
/*
Event.h
Event system for Navigator. Based entirely upon the work of @TheCherno in his game engine series, with additons specific to
Navigator. Abstract Event class and an EventDispatcher. EventDispatcher links a function to the event for handling. See Application::OnEvent for
an example of use.
GWM -- Feb 2022
*/
#ifndef EVENT_H
#define EVENT_H
@ -71,6 +79,7 @@ namespace Navigator {
Event& m_event;
};
//For easy printing
NAV_API inline std::ostream& operator<<(std::ostream& os, const Event& e)
{
return os << e.ToString();

View File

@ -1,3 +1,9 @@
/*
KeyEvent.h
Events related to key presses. Again, based on @TheCherno's work.
GWM -- Feb 2022
*/
#ifndef KEY_EVENT_H
#define KEY_EVENT_H
@ -6,6 +12,7 @@
namespace Navigator {
//Since so many key related events, have a base
class NAV_API KeyEvent : public Event
{
public:

View File

@ -1,3 +1,9 @@
/*
KeyEvent.h
Events related to mouse. Again, based on @TheCherno's work.
GWM -- Feb 2022
*/
#ifndef MOUSE_EVENT_H
#define MOUSE_EVENT_H

View File

@ -1,3 +1,9 @@
/*
KeyEvent.h
Events related to physics processes. Again, based on @TheCherno's work.
GWM -- Feb 2022
*/
#ifndef PHYSICS_EVENT_H
#define PHYSICS_EVENT_H
@ -7,6 +13,7 @@
namespace Navigator {
//When we start physics, need info for what kind of source we make
class NAV_API PhysicsStartEvent : public Event
{
public:
@ -48,6 +55,7 @@ namespace Navigator {
EVENT_TYPE_SETUP(PhysicsStop);
};
//Unused. Exists as a potential path of upgrade
class NAV_API PhysicsParamEvent : public Event
{
public:

View File

@ -1,3 +1,8 @@
/*
ImGuiBuild.cpp
Here we link to the approprate ImGui backend implementaions.
If we want cases other than OpenGL, use switches on Metal,
DirectX, etc.
*/
#include "backends/imgui_impl_opengl3.cpp"
#include "backends/imgui_impl_glfw.cpp"

View File

@ -1,3 +1,8 @@
/*
ImGuiExtensions.cpp
Compile this to enable std library extensions for ImGui,
in particular using std::string with ImGui::InputText
GWM -- Feb 2022
*/
#include "misc/cpp/imgui_stdlib.cpp"

View File

@ -1,3 +1,11 @@
/*
ImGuiLayer.h
The layer containing all of the ImGui related setup and calls. Based on the work by @TheCherno in his game engine series.
Should always exist as an overlay in the Application LayerStack. Note that it currently is OpenGL specific based on
ImGui implementation/backends.
GWM -- Feb 2022
*/
#include "ImGuiLayer.h"
#include "Navigator/Application.h"
#include "Navigator/NavCore.h"
@ -38,7 +46,7 @@ namespace Navigator {
//Can currently cause assertion failure on checking number of monitors in ImGui sanity checks.
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
ImGui::StyleColorsDark();
ImGui::StyleColorsDark(); //Hacker mode
ImPlot::StyleColorsDark();
ImGuiStyle& style = ImGui::GetStyle();
@ -49,6 +57,9 @@ namespace Navigator {
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
//Setup our fonts. We have Roboto for text and FontAwesome for our icons.
//Note the .ttf files are found in NavProject, or in the bin dir. This is because
//the actual program (NavProject) is launched from either the bin/ ... /NaProject or the NavProject directory
//io.Fonts->AddFontDefault();
ImFontConfig latin_config;
latin_config.RasterizerMultiply = 1.3f;
@ -64,7 +75,7 @@ namespace Navigator {
GLFWwindow* window = static_cast<GLFWwindow*>(app.GetWindow().GetNativeWindow());
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 410");
ImGui_ImplOpenGL3_Init("#version 410"); //GLSL version
NAV_INFO("ImGui Finished initializing.");
}
@ -107,6 +118,9 @@ namespace Navigator {
void ImGuiLayer::OnImGuiRender()
{
//Demo's used to figure out how to do things.
//Should not be on for actual NavProject for
//real use
//static bool show = true;
//ImGui::ShowDemoWindow(&show);
//ImPlot::ShowDemoWindow();

View File

@ -1,3 +1,11 @@
/*
ImGuiLayer.h
The layer containing all of the ImGui related setup and calls. Based on the work by @TheCherno in his game engine series.
Should always exist as an overlay in the Application LayerStack. Note that it currently is OpenGL specific based on
ImGui implementation/backends.
GWM -- Feb 2022
*/
#ifndef IMGUI_LAYER_H
#define IMGUI_LAYER_H

View File

@ -1,10 +1,9 @@
//
// AnalysisStack.cpp
// Navigator
//
// Created by Gordon McCann on 12/26/21.
//
/*
AnalysisStack.cpp
Container for the analyses in the PhysicsLayer. Really just a specialized wrapper around std::vector.
GWM -- Feb 2022
*/
#include "AnalysisStack.h"
namespace Navigator {

View File

@ -1,9 +1,9 @@
//
// AnalysisStack.h
// Navigator
//
// Created by Gordon McCann on 12/26/21.
//
/*
AnalysisStack.h
Container for the analyses in the PhysicsLayer. Really just a specialized wrapper around std::vector.
GWM -- Feb 2022
*/
#ifndef ANALYSIS_STACK_H
#define ANALYSIS_STACK_H
@ -32,4 +32,4 @@ namespace Navigator {
}
#endif /* AnalysisStack_h */
#endif

View File

@ -1,3 +1,10 @@
/*
AnalysisStage.h
Represents a step in a chain of analyses that are run on a NavEvent. These stages are where NavParameters are set and validated. Users should use this base class
to create their own analyses and inject them into their project. See template NavProject for an example of use.
GWM -- Feb 2022
*/
#include "AnalysisStage.h"
namespace Navigator {

View File

@ -1,3 +1,10 @@
/*
AnalysisStage.h
Represents a step in a chain of analyses that are run on a NavEvent. These stages are where NavParameters are set and validated. Users should use this base class
to create their own analyses and inject them into their project. See template NavProject for an example of use.
GWM -- Feb 2022
*/
#ifndef ANALYSIS_STAGE_H
#define ANALYSIS_STAGE_H

View File

@ -7,6 +7,10 @@
in the future.
Written by G.W. McCann Oct. 2020
Modified for Navigator; not really any significant changes. Just some simple changes, removal of unused data.
GWM -- Feb 2022
*/
#include "CompassFile.h"

View File

@ -7,6 +7,10 @@
in the future.
Written by G.W. McCann Oct. 2020
Modified for Navigator; not really any significant changes. Just some simple changes, removal of unused data.
GWM -- Feb 2022
*/
#ifndef COMPASSFILE_H
#define COMPASSFILE_H

View File

@ -1,3 +1,9 @@
/*
CompassHit.h
Simple struct representing data from the CAEN CoMPASS DAQ. Note here I do not have any of the non-standard data available (calibrated energy, waveform data, etc.)
GWM -- Feb 2022
*/
#ifndef COMPASS_HIT_H
#define COMPASS_HIT_H

View File

@ -1,3 +1,17 @@
/*
CompassOnlineSource.cpp
A data source for online CAEN CoMPASS Data. Creates a tcp socket, connects to the remote source, and pulls data to a buffer. Data is then converted
from the CAEN CoMPASS format to the native NavData format. Uses asio as the networking library (see asio docs).
IMPORTANT
Navigator wants a unqiue ID on each hit. To do this we use the idiom:
id = board_number * nchannels_per_board + channel_number
This requires two things: that the class variable m_nchannels_per_board be set to match your physical digitizers, and that ALL of your
digitizers have the SAME number of channels. By default CompassRun assumes 16 channels per board, as this is what is used with the SE-SPS setup at FoxLab.
If you use a different set of boards, CHANGE THIS VALUE! If you use mixed boards, you will need to invent a new id scheme altogether.
GWM -- Feb 2022
*/
#include "CompassOnlineSource.h"
namespace Navigator {
@ -14,6 +28,8 @@ namespace Navigator {
void CompassOnlineSource::InitSocket(const std::string& hostname, const std::string& port)
{
m_validFlag = false;
//asio tends to work in terms of exceptions, which we avoid in the rest of this project.
//If the connection is unsuccessful, an exception is thrown, which we parse and print to the terminal.
try
{
asio::ip::tcp::resolver resolver(m_socketContext);
@ -54,7 +70,7 @@ namespace Navigator {
m_datum.longEnergy = m_currentHit.lgate;
m_datum.shortEnergy = m_currentHit.sgate;
m_datum.timestamp = m_currentHit.timestamp;
m_datum.id = m_currentHit.board * 16 + m_currentHit.channel;
m_datum.id = m_currentHit.board * m_nchannels_per_board + m_currentHit.channel;
return m_datum;
}

View File

@ -1,3 +1,17 @@
/*
CompassOnlineSource.h
A data source for online CAEN CoMPASS Data. Creates a tcp socket, connects to the remote source, and pulls data to a buffer. Data is then converted
from the CAEN CoMPASS format to the native NavData format. Uses asio as the networking library (see asio docs).
IMPORTANT
Navigator wants a unqiue ID on each hit. To do this we use the idiom:
id = board_number * nchannels_per_board + channel_number
This requires two things: that the class variable m_nchannels_per_board be set to match your physical digitizers, and that ALL of your
digitizers have the SAME number of channels. By default CompassRun assumes 16 channels per board, as this is what is used with the SE-SPS setup at FoxLab.
If you use a different set of boards, CHANGE THIS VALUE! If you use mixed boards, you will need to invent a new id scheme altogether.
GWM -- Feb 2022
*/
#ifndef COMPASS_ONLINE_SOURCE_H
#define COMPASS_ONLINE_SOURCE_H
@ -20,7 +34,9 @@ namespace Navigator {
void FillBuffer();
void GetHit();
std::vector<char> m_buffer;
static constexpr size_t m_bufferSize = 1000000;
static constexpr size_t m_bufferSize = 1000000; //Max amount of data we allow the source to buffer in. I don't think this should ever be maxed?
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
//different numbers of channels, you will have to find a different id solution.
char* m_bufferIter;
char* m_bufferEnd;
CompassHit m_currentHit;

View File

@ -8,6 +8,11 @@
Written by G.W. McCann Oct. 2020
Updated to also handle scaler data. -- GWM Oct. 2020
Modifed and updated for use in Navigator. Obviously stripped out any ROOT code. Also, now uses the very nice std::filesystem
library to handle filepathing. Also, removed scalers (for now).
GWM -- Feb 2022
*/
#include "CompassRun.h"
@ -131,10 +136,11 @@ namespace Navigator {
}
else
{
//Convert data from CoMPASS format to universal Navigator format.
m_datum.longEnergy = m_hit.lgate;
m_datum.shortEnergy = m_hit.sgate;
m_datum.timestamp = m_hit.timestamp;
m_datum.id = m_hit.board * 16 + m_hit.channel;
m_datum.id = m_hit.board * m_nchannels_per_board + m_hit.channel;
}
return m_datum;

View File

@ -6,6 +6,15 @@
and writes to a ROOT file for further processing.
Written by G.W. McCann Oct. 2020
Modifed and updated for use in Navigator. Obviously stripped out any ROOT code. Also, now uses the very nice std::filesystem
library to handle filepathing. One change of great import: Navigator wants a unqiue ID on each hit. To do this we use the idiom:
id = board_number * nchannels_per_board + channel_number
This requires two things: that the class variable m_nchannels_per_board be set to match your physical digitizers, and that ALL of your
digitizers have the SAME number of channels. By default CompassRun assumes 16 channels per board, as this is what is used with the SE-SPS setup at FoxLab.
If you use a different set of boards, CHANGE THIS VALUE! If you use mixed boards, you will need to invent a new id scheme altogether.
GWM -- Feb 2022
*/
#ifndef COMPASSRUN_H
#define COMPASSRUN_H
@ -39,7 +48,8 @@ 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
//different numbers of channels, you will have to find a different id solution.
ShiftMap m_smap;
CompassHit m_hit;

View File

@ -1,9 +1,18 @@
/*
DataSource.cpp
Abstract data source class. In Navigator a DataSource can be either an online (live) source or an offline (file) source. By default,
Navigator has classes to handle CAEN CoMPASS data sources (files and online); other sources may be implemented as more use cases for Navigator become
apparent.
GWM -- Feb 2022
*/
#include "DataSource.h"
#include "Caen/CompassRun.h"
#include "Caen/CompassOnlineSource.h"
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)
{
switch(type)

View File

@ -1,3 +1,11 @@
/*
DataSource.h
Abstract data source class. In Navigator a DataSource can be either an online (live) source or an offline (file) source. By default,
Navigator has classes to handle CAEN CoMPASS data sources (files and online); other sources may be implemented as more use cases for Navigator become
apparent.
GWM -- Feb 2022
*/
#ifndef DATA_SOURCE_H
#define DATA_SOURCE_H
@ -9,7 +17,7 @@ namespace Navigator {
class NAV_API DataSource
{
public:
enum class SourceType
enum class SourceType //Need to know what kind of sources are available.
{
None,
CompassOnline,

View File

@ -1,3 +1,11 @@
/*
NavData.h
Simple data structures for the event building process in Navigator. Way to create uniform data from different sources. Note that the current paradigm
is very heavily tied to digital data aquisition systems. Any attempt to use Navigator for analog systems would require a deep overhaul of the event processing.
Most likely link to something like nscldaq.
GWM -- Feb 2022
*/
#ifndef NAVDATA_H
#define NAVDATA_H

View File

@ -1,3 +1,13 @@
/*
PhysicsEventBuilder.h
Class for taking in raw NavData and converting into a NavEvent. NavEvent is just a std::vector of NavData, where
the held NavData all falls within a time window called the coincidence window. As soon as a NavData is given that falls outside
of this window, the current event is shifted to the ready event and the AddDatumToEvent function returns true. The ready event can
then be retrieved. The hit that triggered the end of event then is used to start the new event. The current pattern is strongly associated
with digital electronics concepts for nuclear data aquisition systems.
GWM -- Feb 2022
*/
#include "PhysicsEventBuilder.h"
namespace Navigator {
@ -13,18 +23,18 @@ namespace Navigator {
bool PhysicsEventBuilder::AddDatumToEvent(const NavData& datum)
{
if (m_eventStartTime == 0)
if (m_eventStartTime == 0) //first ever event
{
m_eventStartTime = datum.timestamp;
m_event.push_back(datum);
return false;
}
else if (datum.timestamp - m_eventStartTime < m_coincWindow)
else if (datum.timestamp - m_eventStartTime < m_coincWindow) //are we within active window
{
m_event.push_back(datum);
return false;
}
else
else // found one that falls outside
{
m_readyEvent = m_event;
m_event.clear();

View File

@ -1,3 +1,13 @@
/*
PhysicsEventBuilder.h
Class for taking in raw NavData and converting into a NavEvent. NavEvent is just a std::vector of NavData, where
the held NavData all falls within a time window called the coincidence window. As soon as a NavData is given that falls outside
of this window, the current event is shifted to the ready event and the AddDatumToEvent function returns true. The ready event can
then be retrieved. The hit that triggered the end of event then is used to start the new event. The current pattern is strongly associated
with digital electronics concepts for nuclear data aquisition systems.
GWM -- Feb 2022
*/
#ifndef PHYSICS_EVENT_BUILDER_H
#define PHYSICS_EVENT_BUILDER_H
@ -11,7 +21,7 @@ namespace Navigator {
PhysicsEventBuilder(uint64_t windowSize);
~PhysicsEventBuilder();
inline void SetCoincidenceWindow(uint64_t windowSize) { m_coincWindow = windowSize; }
inline void ClearAll()
inline void ClearAll() // reset all internal structures
{
m_event.clear();
m_readyEvent.clear();

View File

@ -1,3 +1,12 @@
/*
PhysicsLayer.cpp
The layer of the application representing all physics. This includes the data source and the thread upon which data is piped, event built, and analyzed.
PhysicsLayer receives a PhysicsStartEvent or PhysicsStopEvent to handle changes to the state of the secondary thread. As it handles the thread, it must have synchronization.
This is handled on two levels. The first is a mutex that synchronizes access to the DataSource. The second is an atomic boolean flag which is used to control the state of the physics thread.
PhysicsLayer also owns the AnalysisStack for the application.
GWM -- Feb 2022
*/
#include "PhysicsLayer.h"
#include "Navigator/SpectrumManager.h"
#include "NavData.h"
@ -38,6 +47,7 @@ namespace Navigator {
bool PhysicsLayer::OnPhysicsStartEvent(PhysicsStartEvent& event)
{
//If the Physics thread is active, kill it
if(m_activeFlag)
{
DetachDataSource();
@ -46,6 +56,7 @@ namespace Navigator {
AttachDataSource(event);
//If we succesfully attached, fire up a new phys thread
if(m_activeFlag)
{
NAV_INFO("Starting new analysis thread...");
@ -61,8 +72,6 @@ namespace Navigator {
return true;
}
void PhysicsLayer::PushStage(AnalysisStage* stage)
{
m_physStack.PushStage(stage);
@ -70,17 +79,18 @@ namespace Navigator {
void PhysicsLayer::OnUpdate() {}
/*Threaded functions*/
void PhysicsLayer::DestroyPhysThread()
{
NAV_INFO("Destroying the analysis thread...");
//Join the thread back to the parent (finish up the thread)
if(m_physThread != nullptr && m_physThread->joinable())
{
m_physThread->join();
}
//Free the thread memory
if(m_physThread != nullptr)
{
delete m_physThread;
@ -91,10 +101,10 @@ namespace Navigator {
void PhysicsLayer::AttachDataSource(PhysicsStartEvent& event)
{
std::lock_guard<std::mutex> guard(m_sourceMutex);
std::lock_guard<std::mutex> guard(m_sourceMutex); //Shouldn't matter for this, but safety first
m_source.reset(CreateDataSource(event.GetSourceLocation(), event.GetSourcePort(), event.GetSourceType()));
m_eventBuilder.SetCoincidenceWindow(event.GetCoincidenceWindow());
m_eventBuilder.ClearAll();
m_eventBuilder.ClearAll(); //Protect against stopping mid-event
if (m_source->IsValid())
{
NAV_INFO("Attach successful. Enabling data pull...");
@ -124,6 +134,7 @@ namespace Navigator {
NavData datum;
while(m_activeFlag)
{
//Scope to encapsulate access to the data source
{
std::lock_guard<std::mutex> guard(m_sourceMutex);
if (m_source == nullptr || !m_source->IsValid())
@ -144,13 +155,16 @@ namespace Navigator {
}
}
//Pass data from source to event builder. True from AddDatumToEvent indicates event is ready
if (m_eventBuilder.AddDatumToEvent(datum))
{
event = m_eventBuilder.GetReadyEvent();
for (auto& stage : m_physStack)
stage->AnalyzePhysicsEvent(event);
//Now that the analysis stack has filled all our NavParameters with data, update the histogram counts
manager.UpdateHistograms();
//Invalidate all parameters to get ready for next event
manager.InvalidateParameters();
}
}

View File

@ -1,3 +1,12 @@
/*
PhysicsLayer.h
The layer of the application representing all physics. This includes the data source and the thread upon which data is piped, event built, and analyzed.
PhysicsLayer receives a PhysicsStartEvent or PhysicsStopEvent to handle changes to the state of the secondary thread. As it handles the thread, it must have synchronization.
This is handled on two levels. The first is a mutex that synchronizes access to the DataSource. The second is an atomic boolean flag which is used to control the state of the physics thread.
PhysicsLayer also owns the AnalysisStack for the application.
GWM -- Feb 2022
*/
#ifndef PHYSICS_LAYER_H
#define PHYSICS_LAYER_H
@ -32,7 +41,6 @@ namespace Navigator {
void PushStage(AnalysisStage* stage);
private:
void DestroyPhysThread();
void AttachDataSource(PhysicsStartEvent& event);
@ -40,7 +48,7 @@ namespace Navigator {
void RunSource();
AnalysisStack m_physStack;
std::atomic<bool> m_activeFlag;
std::atomic<bool> m_activeFlag; //safe read/write across thread, but more expensive
std::mutex m_sourceMutex;

View File

@ -4,10 +4,11 @@
formated file containing data for shifts and then stores them in an unordered_map.
Key is a global compass channel (board#*16 + channel). Shifts in ps.
Note: Timestamps are now shifted in binary conversion. This means that shifts *MUST*
be stored as Long64_t types. No decimals!
Written by G.W. McCann Oct. 2020
Not currently implemented for Navigator though it could still be useful. Leave this here as a maybe upgrade path.
GWM -- Feb 2022
*/
#include "ShiftMap.h"

View File

@ -4,10 +4,11 @@
formated file containing data for shifts and then stores them in an unordered_map.
Key is a global compass channel (board#*16 + channel). Shifts in ps.
Note: Timestamps are now shifted in binary conversion. This means that shifts *MUST*
be stored as Long64_t types. No decimals!
Written by G.W. McCann Oct. 2020
Not currently implemented for Navigator though it could still be useful. Leave this here as a maybe upgrade path.
GWM -- Feb 2022
*/
#ifndef SHIFTMAP_H
#define SHIFTMAP_H

View File

@ -1,3 +1,10 @@
/*
GraphicsContext.h
Abstraction of graphical rendering context. Exists to allow Navigator the felxibility to be backend api agnostic, though currently
only OpenGL is implemented. Entirely based upon the work done by @TheCherno in his game engine series. See his content for more details.
GWM -- Feb 2022
*/
#ifndef GRAPHICS_CONTEXT_H
#define GRAPHICS_CONTEXT_H

View File

@ -1,3 +1,10 @@
/*
RenderCommand.cpp
Render call abstraction. Exists to allow Navigator the felxibility to be backend api agnostic, though currently
only OpenGL is implemented. Entirely based upon the work done by @TheCherno in his game engine series. See his content for more details.
GWM -- Feb 2022
*/
#include "RenderCommand.h"
#include "Platform/OpenGL/OpenGLRendererAPI.h"

View File

@ -1,3 +1,10 @@
/*
RenderCommand.h
Render call abstraction. Exists to allow Navigator the felxibility to be backend api agnostic, though currently
only OpenGL is implemented. Entirely based upon the work done by @TheCherno in his game engine series. See his content for more details.
GWM -- Feb 2022
*/
#ifndef RENDER_COMMAND_H
#define RENDER_COMMAND_H

View File

@ -1,3 +1,10 @@
/*
RenderAPI.h
Render API abstraction. Exists to allow Navigator the felxibility to be backend api agnostic, though currently
only OpenGL is implemented. Entirely based upon the work done by @TheCherno in his game engine series. See his content for more details.
GWM -- Feb 2022
*/
#include "RendererAPI.h"
namespace Navigator {

View File

@ -1,3 +1,10 @@
/*
RenderAPI.h
Render API abstraction. Exists to allow Navigator the felxibility to be backend api agnostic, though currently
only OpenGL is implemented. Entirely based upon the work done by @TheCherno in his game engine series. See his content for more details.
GWM -- Feb 2022
*/
#ifndef RENDERER_API_H
#define RENDERER_API_H
@ -12,7 +19,7 @@ namespace Navigator {
enum class API
{
None = 0,
OpenGL = 1
OpenGL = 1 //Currently only have OpenGL
};
virtual void Clear() = 0;