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

glasscore site list class More...

#include <SiteList.h>

Inheritance diagram for glasscore::CSiteList:
Inheritance graph
Collaboration diagram for glasscore::CSiteList:
Collaboration graph

Public Member Functions

 CSiteList (int numThreads=1, int sleepTime=100, int checkInterval=60)
 CSiteList constructor. More...
 
 ~CSiteList ()
 CSiteList destructor. More...
 
void clear () override
 CSiteList clear function. More...
 
bool receiveExternalMessage (std::shared_ptr< json::Object > com)
 CSiteList communication receiving function. More...
 
bool addSiteFromJSON (std::shared_ptr< json::Object > com)
 CSiteList add/update site function. More...
 
bool addListOfSitesFromJSON (std::shared_ptr< json::Object > com)
 CSiteList add list of sites function. More...
 
bool addSite (std::shared_ptr< CSite > site)
 CSiteList add/update site function. More...
 
int size () const
 CSiteList Site count function. More...
 
std::shared_ptr< CSitegetSite (std::string scnl)
 Get site by scnl. More...
 
std::shared_ptr< CSitegetSite (std::string site, std::string comp, std::string net, std::string loc)
 Get site by station, component, network, and location. More...
 
std::vector< std::shared_ptr< CSite > > getListOfSites ()
 Get current list of sites. More...
 
std::shared_ptr< json::Object > generateSiteListMessage (bool send=true)
 Generate SiteList message. More...
 
int getMaxHoursWithoutPicking () const
 Get the maximum hours without picking before a site is declared nonresponsive and unused, a -1 disables this metric. More...
 
void setMaxHoursWithoutPicking (int hoursWithoutPicking)
 Set the maximum hours without picking before a site is declared nonresponsive and unused, a -1 disables this metric. More...
 
int getHoursBeforeLookingUp () const
 Get the maximum hours between requesting site information from outside glasscore, a -1 disables this process. More...
 
void setHoursBeforeLookingUp (int hoursBeforeLookingUp)
 Set the maximum hours between requesting site information from outside glasscore, a -1 disables this process. If enabled, glass will always re-request the coordinates and properties of this station every hoursBeforeLookingUp hours, regardless if the site is currently known. More...
 
int getMaxPicksPerHour () const
 Get the maximum picks per hour before a site is declared too noisy to use, a -1 disables this metric. More...
 
void setMaxPicksPerHour (int maxPicksPerHour)
 Set the maximum picks per hour before a site is declared too noisy to use, a -1 disables this metric. More...
 
int getLastUpdated () const
 Get last time in epoch seconds the site list was modified. More...
 
glass3::util::WorkState work () override
 SiteList 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...
 

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 site list class

The CSiteList class is the class that maintains a vector and :map of all the seismic stations used by glasscore.

CSiteList also maintains a std::vector mapping the string SCNL id to CSite objects

CSiteList contains functions to support new data input and clearing the list

CSiteList uses smart pointers (std::shared_ptr).

Constructor & Destructor Documentation

glasscore::CSiteList::CSiteList ( int  numThreads = 1,
int  sleepTime = 100,
int  checkInterval = 60 
)
explicit

CSiteList constructor.

The constructor for the CSiteList class. Initializes members to default values.

glasscore::CSiteList::~CSiteList ( )

CSiteList destructor.

The destructor for the CSiteList class.

Member Function Documentation

bool glasscore::CSiteList::addListOfSitesFromJSON ( std::shared_ptr< json::Object >  com)

CSiteList add list of sites function.

The function used by CSiteList to add a whole list of sites

Parameters
com- A pointer to a json::array containing the list of sites to add
Returns
Returns true if the site was complete and added by CSiteList, false otherwise
bool glasscore::CSiteList::addSite ( std::shared_ptr< CSite site)

CSiteList add/update site function.

The function used by CSiteList to add a site to, or update a site in the vector and map.

Parameters
site- A shared pointer pointer to the site to add or update.
Returns
Returns true if the site was complete and added by CSiteList, false otherwise
bool glasscore::CSiteList::addSiteFromJSON ( std::shared_ptr< json::Object >  com)

CSiteList add/update site function.

The function used by CSiteList to add a site to, or update a site in the vector and map.

Parameters
com- A pointer to a json::object containing the site to add or update.
Returns
Returns true if the site was complete and added by CSiteList, false otherwise
void glasscore::CSiteList::clear ( )
overridevirtual

CSiteList clear function.

Reimplemented from glass3::util::BaseClass.

std::shared_ptr< json::Object > glasscore::CSiteList::generateSiteListMessage ( bool  send = true)

Generate SiteList message.

Generate a json object representing all thie sites in this SiteList in the "SiteList" format and optionally send a pointer to this object to CGlass (and out of glasscore) using the CGlass send function (pGlass->send)

Parameters
send- A boolean flag indicating that in addition to generating the "SiteList" format message, the function should also send it. Defaults to true
Returns
Returns the generated json object in the "SiteList" format.
int glasscore::CSiteList::getHoursBeforeLookingUp ( ) const

Get the maximum hours between requesting site information from outside glasscore, a -1 disables this process.

Returns
Return an integer containing the maximum hours between requesting site information
int glasscore::CSiteList::getLastUpdated ( ) const

Get last time in epoch seconds the site list was modified.

Returns
Return the last time in epoch seconds the site list was modified
std::vector< std::shared_ptr< CSite > > glasscore::CSiteList::getListOfSites ( )

Get current list of sites.

Gets the current list of sites contained within this sitelist

Returns
Returns a vector of shared_ptr's to the CSite objects contained in this list
int glasscore::CSiteList::getMaxHoursWithoutPicking ( ) const

Get the maximum hours without picking before a site is declared nonresponsive and unused, a -1 disables this metric.

Returns
Return an integer containing the maximum hours without picking allowed
int glasscore::CSiteList::getMaxPicksPerHour ( ) const

Get the maximum picks per hour before a site is declared too noisy to use, a -1 disables this metric.

Returns
Return an integer containing the maximum picks per hour allowed
std::shared_ptr< CSite > glasscore::CSiteList::getSite ( std::string  scnl)

Get site by scnl.

Gets a specific site using the given scnl id.

Parameters
scnl- A std::string containing the scnl
Returns
Returns a shared_ptr to the CSite object containing the desired site.
std::shared_ptr< CSite > glasscore::CSiteList::getSite ( std::string  site,
std::string  comp,
std::string  net,
std::string  loc 
)

Get site by station, component, network, and location.

Gets a specific site using the given station, component, network, and location

Parameters
site- A std::string containing the station
comp- A std::string containing the component
net- A std::string containing the network
loc- A std::string containing the location
Returns
Returns a shared_ptr to the CSite object containing the desired site.
bool glasscore::CSiteList::receiveExternalMessage ( std::shared_ptr< json::Object >  com)

CSiteList communication receiving function.

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

Supports Site (add site data to list) SiteUse (enable or disable a site) and ClearGlass (clear all Site data) inputs.

Parameters
com- A pointer to a json::object containing the communication.
Returns
Returns true if the communication was handled by CSiteList, false otherwise
void glasscore::CSiteList::setHoursBeforeLookingUp ( int  hoursBeforeLookingUp)

Set the maximum hours between requesting site information from outside glasscore, a -1 disables this process. If enabled, glass will always re-request the coordinates and properties of this station every hoursBeforeLookingUp hours, regardless if the site is currently known.

Parameters
hoursBeforeLookingUp- an integer containing the maximum hours between requesting site information
void glasscore::CSiteList::setMaxHoursWithoutPicking ( int  hoursWithoutPicking)

Set the maximum hours without picking before a site is declared nonresponsive and unused, a -1 disables this metric.

Parameters
hoursWithoutPicking- an integer containing the maximum hours without picking allowed
void glasscore::CSiteList::setMaxPicksPerHour ( int  maxPicksPerHour)

Set the maximum picks per hour before a site is declared too noisy to use, a -1 disables this metric.

Parameters
maxPicksPerHour- an integer containing the maximum picks per hour allowed
int glasscore::CSiteList::size ( ) const

CSiteList Site count function.

Returns
Returns an integer variable containing the number of sites in CSiteList
glass3::util::WorkState glasscore::CSiteList::work ( )
overridevirtual

SiteList work function.

checks sites

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

Implements glass3::util::ThreadBaseClass.


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