neic-glass3  1.4.6
Public Member Functions | Static Public Attributes | List of all members
glasscore::CHypoList Class Reference

glasscore hypocenter list class More...

#include <HypoList.h>

Inheritance diagram for glasscore::CHypoList:
Inheritance graph
Collaboration diagram for glasscore::CHypoList:
Collaboration graph

Public Member Functions

 CHypoList (int numThreads=1, int sleepTime=50, int checkInterval=300)
 CHypoList constructor. More...
 
 ~CHypoList ()
 CHypoList destructor. More...
 
bool addHypo (std::shared_ptr< CHypo > hypo, bool scheduleProcessing=true, CPickList *parentThread=NULL)
 Add hypo to list. More...
 
bool associateData (std::shared_ptr< CPick > pk)
 Try to associate pick to a hypo in the list. More...
 
bool fitData (std::shared_ptr< CPick > pk)
 Try to fit pick to a hypo in the list. More...
 
bool associateData (std::shared_ptr< CCorrelation > corr)
 Try to associate correlation to a hypo in the list. More...
 
void clear () override
 CHypoList clear function. More...
 
bool receiveExternalMessage (std::shared_ptr< json::Object > com)
 CHypoList communication receiving function. More...
 
bool processHypo (std::shared_ptr< CHypo > hyp)
 Process provided hypocenter. More...
 
int getHypoProcessingQueueLength ()
 Get the current length of the hypocenter processing queue. More...
 
std::vector< std::weak_ptr< CHypo > > getHypos (double t1, double t2)
 Get list of CHypos in given time range. More...
 
int getMaxAllowableHypoCount () const
 Gets the maximum number of hypocenters this list will hold. More...
 
int getCountOfTotalHyposProcessed () const
 Get the total number of hypos processed by this list. More...
 
int length () const
 Get the current number of hypos contained in this list. More...
 
bool findAndMergeMatchingHypos (std::shared_ptr< CHypo > hyp)
 Merge hypos close in space time. More...
 
int appendToHypoProcessingQueue (std::shared_ptr< CHypo > hyp)
 Append hypo to processing queue. More...
 
std::shared_ptr< CHypogetNextHypoFromProcessingQueue ()
 Get first hypo from processing queue. More...
 
void removeHypo (std::shared_ptr< CHypo > hypo, bool reportCancel=true)
 Remove hypo from list. More...
 
bool requestHypo (std::shared_ptr< json::Object > com)
 Cause CHypoList to generate a Hypo message for a hypocenter. More...
 
bool resolveData (std::shared_ptr< CHypo > hypo, bool allowStealing=true)
 Ensure all supporting belong to hypo. More...
 
void setMaxAllowableHypoCount (int hypoMax)
 Set the maximum number of hypos that this list will support. More...
 
glass3::util::WorkState work () override
 Hypolist work function. More...
 
- Public Member Functions inherited from glass3::util::ThreadBaseClass
 ThreadBaseClass ()
 ThreadBaseClass constructor. More...
 
 ThreadBaseClass (std::string threadName, int sleepTimeMS=100, int numThreads=1, int checkInterval=300)
 An advanced constructor that sets up the ThreadBaseClass with a provided thread name, sleep between work time duration, number of threads, and statsus check interval. More...
 
 ~ThreadBaseClass ()
 ThreadBaseClass destructor. More...
 
virtual bool start ()
 work thread start function More...
 
virtual bool stop ()
 work thread stop function More...
 
int getNumThreads ()
 Retrieves the number of work threads. More...
 
void setNumThreads (int numThreads)
 Sets the number of work threads. More...
 
void setThreadHealth (bool health=true)
 Function to set thread health. More...
 
virtual bool healthCheck ()
 work threads check function More...
 
void setSleepTime (int sleepTimeMS)
 Sets the time to sleep between work() calls. More...
 
int getSleepTime ()
 Retrieves the time to sleep between work() calls. More...
 
glass3::util::ThreadState getWorkThreadsState ()
 Function to get the work threads state. More...
 
void setHealthCheckInterval (int interval)
 Function to set work threads health check interval. More...
 
int getHealthCheckInterval ()
 Function to retrieve the work threads health check interval. More...
 
bool getTerminate ()
 Function to retrieve whether the thread should terminate. More...
 
const std::string & getThreadName ()
 Function to retrieve the name of the work threads. More...
 
std::time_t getAllLastHealthy (size_t *pThreadId)
 Function to retrieve the oldest time any of the work threads last updated their health status as healthy. More...
 
- Public Member Functions inherited from glass3::util::BaseClass
 BaseClass ()
 BaseClass constructor. More...
 
virtual ~BaseClass ()
 BaseClass destructor. More...
 
virtual bool setup (std::shared_ptr< const json::Object > config)
 BaseClass configuration function. More...
 
const std::shared_ptr< const json::Object > getConfig ()
 
bool getSetup ()
 Retrieves the class member boolean flag indicating whether the class has been setup, set to true if setup was successful. More...
 
const std::string & getDefaultAgencyId ()
 Function to retrieve the name of the default agency id. More...
 
void setDefaultAgencyId (const std::string &id)
 Function to set the name of the default agency id. More...
 
const std::string & getDefaultAuthor ()
 Function to retrieve the name of the default author. More...
 
void setDefaultAuthor (const std::string &author)
 Function to set the name of the default author. More...
 

Static Public Attributes

static constexpr double k_nHypoSearchPastDurationForPick = 3600
 The duration in seconds to search into the past for hypos matching a pick. More...
 

Additional Inherited Members

- Protected Member Functions inherited from glass3::util::ThreadBaseClass
void setWorkThreadsState (glass3::util::ThreadState state)
 Function to set threads state. More...
 
void workLoop ()
 ThreadBaseClass work loop function. More...
 
void setLastHealthy (std::time_t now)
 Function to set the last time the work thread was healthy. More...
 
- Protected Attributes inherited from glass3::util::ThreadBaseClass
std::vector< std::thread > m_WorkThreads
 the std::vector that contains the work std::thread objects More...
 
std::map< std::thread::id, std::atomic< int > > m_ThreadHealthMap
 A std::map containing the epoch times as std::atomic<double>> that each work thread was last marked as healthy, identified by the thread id. More...
 
- Protected Attributes inherited from glass3::util::BaseClass
std::shared_ptr< const json::Object > m_Config
 A shared pointer to the json::Object that holds the configuration. More...
 
std::atomic< bool > m_bIsSetup
 the boolean flag indicating whether the class has been setup, set to true if setup was successful. More...
 
std::string m_DefaultAgencyID
 A std::string containing the default agency id to use in parsing if one is not provided. More...
 
std::string m_DefaultAuthor
 A std::string containing the default author to use in parsing if one is not provided. More...
 

Detailed Description

glasscore hypocenter list class

The CHypoList class is the class that maintains a std::map of all the earthquake hypocenters being considered by glasscore.

CHypoList also maintains a std::vector mapping the double hypo origin time (in Gregorian seconds) to the std::string hypo id

CHypoList also maintains a std::vector of std::string ids of hypos to be processed

CHypoList contains functions to support hypocenter refinement, new data association, and requesting output data.

CHypoList uses smart pointers (std::shared_ptr).

Constructor & Destructor Documentation

glasscore::CHypoList::CHypoList ( int  numThreads = 1,
int  sleepTime = 50,
int  checkInterval = 300 
)
explicit

CHypoList constructor.

The constructor for the CHypoList class.

Parameters
numThreads- An integer containing the number of threads in the pool. Default 1
sleepTime- An integer containing the amount of time to sleep in milliseconds between jobs. Default 50
checkInterval- An integer containing the amount of time in seconds between status checks. -1 to disable status checks. Default 300.
glasscore::CHypoList::~CHypoList ( )

CHypoList destructor.

The destructor for the CHypoList class.

Member Function Documentation

bool glasscore::CHypoList::addHypo ( std::shared_ptr< CHypo hypo,
bool  scheduleProcessing = true,
CPickList parentThread = NULL 
)

Add hypo to list.

Add the given hypocenter to the vector and map, if the new hypocenter causes the number of hypocenters in the vector/map to exceed the configured maximum, remove the oldest hypocenter from the list/map.

Adds the hypocenter to the processing queue, and optionally schedules it for processing

Parameters
hypo- A std::shared_ptr to the hypocenter to add
scheduleProcessing- A boolean flag indicating whether to automatically schedule processing when the hypo is added, defaults to true
parentThread- A pointer to a CPickList parent to write thread status to
Returns
Returns true if the hypo was added, false otherwise.
int glasscore::CHypoList::appendToHypoProcessingQueue ( std::shared_ptr< CHypo hyp)

Append hypo to processing queue.

Append the given hypocenter to the processing queue if it is not already in the queue.

Parameters
hyp- A std::shared_ptr to the hypocenter to add
Returns
Returns the current size of the processing queue
bool glasscore::CHypoList::associateData ( std::shared_ptr< CPick pk)

Try to associate pick to a hypo in the list.

Attempt to associate the given pick to a hypocenter in the list

Adds the hypocenter to the processing queue if a pick was associated.

Parameters
pk- A std::shared_ptr to the pick to associate.
Returns
Returns true if the pick associated with a hypo, false otherwise
bool glasscore::CHypoList::associateData ( std::shared_ptr< CCorrelation corr)

Try to associate correlation to a hypo in the list.

Attempt to associate the given correlation to a hypocenter in the list

Adds the hypocenter to the processing queue if a correlation was associated.

Parameters
corr- A std::shared_ptr to the correlation to associate.
Returns
Returns true if the correlation associated with a hypo, false otherwise
void glasscore::CHypoList::clear ( )
overridevirtual

CHypoList clear function.

Reimplemented from glass3::util::BaseClass.

bool glasscore::CHypoList::findAndMergeMatchingHypos ( std::shared_ptr< CHypo hyp)

Merge hypos close in space time.

This function attempts to merge the picks of the given hypo and other hypos within a time/distance range into a target hypo. This function prefers a reported hypo over an unreported hypo when selecting the merge target. If the targeted hypo's resultant stack value is high enough then the target hypo keeps the picks, and the donor hypo(s) are canceled / removed.

Parameters
hyp- a shared_ptr to the CHypo to start the merge process with
Returns
Returns true if hypos were merged, false otherwise
bool glasscore::CHypoList::fitData ( std::shared_ptr< CPick pk)

Try to fit pick to a hypo in the list.

Attempt to fit the given pick to a hypocenter in the list

Parameters
pk- A std::shared_ptr to the pick to associate.
Returns
Returns true if the pick fit with a hypo, false otherwise
int glasscore::CHypoList::getCountOfTotalHyposProcessed ( ) const

Get the total number of hypos processed by this list.

Returns
Return an integer containing the total number of hypos processed by this list
int glasscore::CHypoList::getHypoProcessingQueueLength ( )

Get the current length of the hypocenter processing queue.

Returns
Returns an integer value containing the current length of the processing queue
std::vector< std::weak_ptr< CHypo > > glasscore::CHypoList::getHypos ( double  t1,
double  t2 
)

Get list of CHypos in given time range.

Get a list of hypocenters in vHypo with origin time within given range

Parameters
t1- Starting time of selection range
t2- Ending time of selection range
Returns
A vector of std::weak_ptr to CHypos withing range, or empty list if none fit in the time range.
int glasscore::CHypoList::getMaxAllowableHypoCount ( ) const

Gets the maximum number of hypocenters this list will hold.

Returns
Returns an integer containing the maximum number of hypocenters this list will hold
std::shared_ptr< CHypo > glasscore::CHypoList::getNextHypoFromProcessingQueue ( )

Get first hypo from processing queue.

Get the first valid hypocenter from the processing queue.

Returns
Returns a std::shared_ptr to the hypocenter retrieved from the queue.
int glasscore::CHypoList::length ( ) const

Get the current number of hypos contained in this list.

Returns
Return an integer containing the current number of hypos contained in this list
bool glasscore::CHypoList::processHypo ( std::shared_ptr< CHypo hyp)

Process provided hypocenter.

Process the provided hypocenter by localizing, scavenging, pruning, performing cancel checks, and output message generation. The hypocenter is put back on the processing queue if the hypo is changed and not canceled.

Parameters
hyp- A std::shared_ptr to the hypocenter to have its pick assocations resolved.
Returns
Returns true if hypocenter survives
bool glasscore::CHypoList::receiveExternalMessage ( std::shared_ptr< json::Object >  com)

CHypoList communication receiving function.

The function used by CHypoList to receive communication (such as configuration or input data), from outside the glasscore library, or it's parent CGlass.

Supports the ReqHypo (generate output hypocenter message) input.

Parameters
com- A pointer to a json::object containing the communication.
Returns
Returns true if the communication was handled by CGlass, false otherwise
void glasscore::CHypoList::removeHypo ( std::shared_ptr< CHypo hypo,
bool  reportCancel = true 
)

Remove hypo from list.

Remove given hypocenter from the underlying multiset. Also, unlink any associated data, and optionally generate a cancelation message.

Parameters
hypo- A std::shared_ptr to the hypocenter to remove
reportCancelA boolean flag indicating whether to report a cancel message when the hypo is removed
bool glasscore::CHypoList::requestHypo ( std::shared_ptr< json::Object >  com)

Cause CHypoList to generate a Hypo message for a hypocenter.

Causes CHypoList to generate a json formatted hypocenter message for the id in the given ReqHypo message and send a pointer to this object to CGlass (and out of glasscore) by calling the hypo's Hypo() function

Parameters
com- A pointer to a json::object containing the id of the hypocenter to use
Returns
Returns true if the Hypo message was generated, false otherwise
bool glasscore::CHypoList::resolveData ( std::shared_ptr< CHypo hypo,
bool  allowStealing = true 
)

Ensure all supporting belong to hypo.

Search through all supporting data in the given hypocenter's lists, using the hypo affinity functions to determine whether the data best fits the hypocenter or not.

Note that this function is in hypolist for threading deadlock reasons

Parameters
hypo- A shared_ptr to a CHypo to resolve
allowStealing- A boolean flag indicating whether to allow resolveData to steal data, defaults to true
Returns
Returns true if the hypocenter's pick list was changed, false otherwise.
void glasscore::CHypoList::setMaxAllowableHypoCount ( int  hypoMax)

Set the maximum number of hypos that this list will support.

Parameters
hypoMax- an integer containing the maximum number of hypos that this list will support
glass3::util::WorkState glasscore::CHypoList::work ( )
overridevirtual

Hypolist work function.

Process the next hypo on the processing queue. Typically hypocenters are added to the processing queue because they are either new, or have been modified by another part of glasscore.

A process count is set when a hypocenter is first scheduled (by addHypo() or associate()) for processing. Hypocenters are only processed a limited number of times, up to the overall glasscore process limit. Any additional after this requires that new supporting data be added to the hypo via associateData()

Returns
returns glass3::util::WorkState::OK if work was successful, glass3::util::WorkState::Error if not.

Implements glass3::util::ThreadBaseClass.

Member Data Documentation

constexpr double glasscore::CHypoList::k_nHypoSearchPastDurationForPick = 3600
static

The duration in seconds to search into the past for hypos matching a pick.


The documentation for this class was generated from the following files: