COSMOS core
1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
|
Classes | |
struct | filestruc |
Macros | |
#define | DATA_LOG_TYPE_SOH 0 |
#define | DATA_LOG_TYPE_EVENT 1 |
#define | DATA_LOG_TYPE_BEACON 2 |
#define | DATA_LOG_TYPE_PROGRAM 3 |
Functions | |
void | log_write (string node, string agent, double utc, string extra, string type, string record, string location) |
Write log entry - full. More... | |
void | log_write (string node, string agent, double utc, string type, const char *record) |
Write log entry - fixed location. More... | |
void | log_write (string node, int type, double utc, const char *record, string directory) |
Write log entry - fixed location, no extra, integer type and agent. More... | |
void | log_move (string oldpath, string newpath, bool compress) |
Move log file - path version. More... | |
void | log_move (string node, string agent, string srclocation, string dstlocation, bool compress) |
Move log file - full version. More... | |
void | log_move (string node, string agent) |
Move log file - short version. More... | |
vector< double > | data_list_archive_days (string node, string agent) |
Get a list of days in a Node archive. More... | |
string | log_read (gzFile &file, int num) |
log_reads Loop until the newline character is seen. Append it to a string and return the line once the newline is met. More... | |
vector< filestruc > | data_list_archive (string node, string agent, double utc, string type) |
Get a list of files in a Node archive. More... | |
vector< filestruc > | data_list_archive (string node, string agent, double utc) |
vector< filestruc > | data_list_files (string directory) |
Get list of files in a directory, directly. More... | |
size_t | data_list_files (string directory, vector< filestruc > &files) |
Get list of files in a directory, indirectly. More... | |
vector< filestruc > | data_list_files (string node, string location, string agent) |
Get list of files in a Node, directly. More... | |
size_t | data_list_files (string node, string location, string agent, vector< filestruc > &files) |
Get list of files in a Node, indirectly. More... | |
vector< string > | data_list_nodes () |
Get list of Nodes, directly. More... | |
int32_t | data_list_nodes (vector< string > &nodes) |
Get list of Nodes, indirectly. More... | |
int32_t | data_get_nodes (vector< cosmosstruc > &node) |
Get vector of Node structures. More... | |
string | data_name (string node, double mjd, string extra, string type) |
Create data file name. More... | |
string | data_name (string node, double mjd, string type) |
int32_t | data_name_date (string node, string filename, uint16_t &year, uint16_t &jday, uint32_t &seconds) |
Get date from file name. More... | |
int32_t | data_name_date (string node, string filename, double &utc) |
Get date from file name. More... | |
string | data_base_path (string node, string location, string agent, string filename) |
Create data file path. More... | |
string | data_base_path (string node, string location, string agent) |
string | data_base_path (string node, string location) |
string | data_base_path (string node) |
string | data_archive_path (string node, string agent, double mjd) |
string | data_type_path (string node, string location, string agent, double mjd, string type) |
Create data file path. More... | |
string | data_type_path (string node, string location, string agent, double mjd, string extra, string type) |
Create data file path. More... | |
string | data_name_path (string node, string location, string agent, double mjd, string name) |
Create data file path. More... | |
string | data_resource_path (string name) |
Create resource file path. More... | |
bool | data_exists (string &path) |
Check existence of path. More... | |
FILE * | data_open (string path, const char *mode) |
Open file from path. More... | |
int32_t | set_cosmosroot (string name, bool create_flag) |
Set Root Directory. More... | |
int32_t | set_cosmosroot (bool create_flag) |
Find Root Directory. More... | |
string | get_cosmosroot (bool create_flag) |
Return COSMOS Root Directory. More... | |
int32_t | get_cosmosroot (string &result, bool create_flag) |
Return COSMOS Root Directory. More... | |
int32_t | set_cosmosresources (string name, bool create_flag) |
Set Resources Directory. More... | |
int32_t | set_cosmosresources (bool create_flag) |
Find Resources Directory. More... | |
string | get_cosmosresources (bool create_flag) |
Return COSMOS Resources Directory. More... | |
int32_t | get_cosmosresources (string &result, bool create_flag) |
Return COSMOS Resources Directory. More... | |
int32_t | setEnvCosmosResources (string path) |
Set Environment Variable for COSMOS resources. More... | |
int32_t | setEnvCosmosNodes (string path) |
Set Environment Variable for COSMOS nodes. More... | |
int32_t | setEnv (string var, string path) |
Set Environment Variable for COSMOS. More... | |
int32_t | setEnvCosmos (string path) |
int32_t | set_cosmosnodes (string name, bool create_flag) |
Set Nodes Directory. More... | |
int32_t | set_cosmosnodes (bool create_flag) |
Find COSMOS Nodes Directory on Windows, Linux or MacOS. More... | |
string | get_cosmosnodes (bool create_flag) |
Return COSMOS Nodes Directory. More... | |
int32_t | get_cosmosnodes (string &result, bool create_flag) |
Get COSMOS Nodes Directory. More... | |
string | get_nodedir (string node, bool create_flag) |
Get Current Node Directory. More... | |
int32_t | data_load_archive (string node, string agent, double utcbegin, double utcend, string type, vector< string > &result) |
Load data from archive. More... | |
int32_t | data_load_archive (string node, string agent, double mjd, string type, vector< string > &result) |
int32_t | data_load_archive (double mjd, vector< string > &telem, vector< string > &event, cosmosstruc *cinfo) |
double | findlastday (string name) |
Find last day in archive. More... | |
double | findfirstday (string name) |
Find first day in archive. More... | |
int32_t | kml_write (cosmosstruc *cinfo) |
Add to KML path. More... | |
bool | data_isdir (string path) |
bool | data_ischardev (string path) |
bool | data_isfile (string path, off_t size) |
double | data_ctime (string path) |
off_t | data_size (string path) |
int32_t | data_execute (string cmd, string &result, string shell) |
void | log_reopen () |
int | check_events (eventstruc *events, int max, cosmosstruc *data) |
#define DATA_LOG_TYPE_SOH 0 |
#define DATA_LOG_TYPE_EVENT 1 |
#define DATA_LOG_TYPE_BEACON 2 |
#define DATA_LOG_TYPE_PROGRAM 3 |
void log_write | ( | string | node, |
string | agent, | ||
double | utc, | ||
string | extra, | ||
string | type, | ||
string | record, | ||
string | location | ||
) |
Write log entry - full.
Append the provided string to a file in the {node}/{location}/{agent} directory. The file name is created as {node}_yyyyjjjsssss_{extra}.{type}
node | Node name. |
location | Location name. |
agent | Agent name. |
utc | UTC to be converted to year (yyyy), julian day (jjj) and seconds (sssss). |
extra | Extra part of name. |
type | Type part of name. |
record | String to be appended to file. |
void log_write | ( | string | node, |
string | agent, | ||
double | utc, | ||
string | type, | ||
const char * | record | ||
) |
Write log entry - fixed location.
Append the provided string to a file in the {node}/temp/{agent} directory. The file name is created as {node}_yyyyjjjsssss_{extra}.{type}
node | Node name. |
agent | Agent name. |
utc | UTC to be converted to year (yyyy), julian day (jjj) and seconds (sssss). |
extra | Extra part of name. |
type | Type part of name. |
record | String to be appended to file.Write log entry - fixed location, no extra |
Append the provided string to a file in the {node}/temp/{agent} directory. The file name is created as {node}_yyyyjjjsssss.{type}
node | Node name. |
agent | Agent name. |
utc | UTC to be converted to year (yyyy), julian day (jjj) and seconds (sssss). |
type | Type part of name. |
record | String to be appended to file. |
void log_write | ( | string | node, |
int | type, | ||
double | utc, | ||
const char * | record, | ||
string | directory | ||
) |
Write log entry - fixed location, no extra, integer type and agent.
Append the provided string to a file in the {node}/temp/{agent_name} directory. The file name is created as {node}_yyyyjjjsssss.{type_name}
node | Node name. |
type | Integer specifying what type and agent of file. |
utc | UTC to be converted to year (yyyy), julian day (jjj) and seconds (sssss). |
record | String to be appended to file. |
void log_move | ( | string | oldpath, |
string | newpath, | ||
bool | compress | ||
) |
Move log file - path version.
Move files previously created with log_write to their final location, optionally compressing with gzip. The path version accepts only specific paths, from and to, and whether compression should be used.
oldpath | Path to move from. |
newpath | Path to move to. |
compress | Wether or not to compress with gzip. |
void log_move | ( | string | node, |
string | agent, | ||
string | srclocation, | ||
string | dstlocation, | ||
bool | compress | ||
) |
Move log file - full version.
Move files previously created with log_write to their final location, optionally compressing with gzip. The full version allows for specification of the source and destination locations, and whether compression should be used. The routine will find all files currently in {node}/{srclocation}/{agent} and move them to {node}/{dstlocation}/{agent}.
node | Node name. |
agent | Agent name. |
srclocation | Source location name. |
dstlocation | Destination location name. |
compress | Wether or not to compress with gzip. |
void log_move | ( | string | node, |
string | agent | ||
) |
Move log file - short version.
Move files previously created with log_write to their final location. The short version assumes a source location of "temp" and a destination locations of "outgoing". The routine will find all files currently in {node}/temp/{agent} and move them to {node}/outgoing/{agent}.
node | Node name. |
agent | Agent name. |
vector< double > data_list_archive_days | ( | string | node, |
string | agent | ||
) |
Get a list of days in a Node archive.
Generate a list of days available in the archive of the indicated Node and Agent. The result is returned as a vector of Modified Julian Days.
string log_read | ( | gzFile & | file, |
int | num | ||
) |
log_reads Loop until the newline character is seen. Append it to a string and return the line once the newline is met.
Use this function to loop through the gzfile until eof is reached. It returns each string line by line in the log file.
file | The file to be read. |
num | The maximum number of characters to be written to the buffer. |
vector< filestruc > data_list_archive | ( | string | node, |
string | agent, | ||
double | utc, | ||
string | type | ||
) |
Get a list of files in a Node archive.
Generate a list of archived files for the indicated Node, Agent, and UTC. The result is returned as a vector of filestruc, one entry for each file found.
node | Node to search. |
agent | Subdirectory of location to search. |
utc | Day in archive as MJD. |
type | File extension. |
vector< filestruc > data_list_archive | ( | string | node, |
string | agent, | ||
double | utc | ||
) |
vector< filestruc > data_list_files | ( | string | directory | ) |
Get list of files in a directory, directly.
Generate a list of files for the indicated directory. The result is returned as a vector of filestruc, one entry for each file found.
directory | Directory to search. |
size_t data_list_files | ( | string | directory, |
vector< filestruc > & | files | ||
) |
Get list of files in a directory, indirectly.
Generate a list of files for the indicated directory. The result is returned as a vector of filestruc, one entry for each file found. Repeated calls to this function will append entries.
directory | Directory to search. |
vector< filestruc > data_list_files | ( | string | node, |
string | location, | ||
string | agent | ||
) |
Get list of files in a Node, directly.
Generate a list of files for the indicated Node, location (eg. incoming, outgoing, ...), and Agent. The result is returned as a vector of filestruc, one entry for each file found.
node | Node to search. |
location | Subdirectory of Node to search. |
agent | Subdirectory of location to search. |
size_t data_list_files | ( | string | node, |
string | location, | ||
string | agent, | ||
vector< filestruc > & | files | ||
) |
Get list of files in a Node, indirectly.
Generate a list of files for the indicated Node, location (eg. incoming, outgoing, ...), and Agent. The result is returned as a vector of filestruc, one entry for each file found. Repeated calls to this function will append entries.
node | Node to search. |
location | Subdirectory of Node to search. |
agent | Subdirectory of location to search. |
files | List of filestruc. |
vector< string > data_list_nodes | ( | ) |
Get list of Nodes, directly.
Scan the COSMOS root directory and return the name of each Node that is found.
int32_t data_list_nodes | ( | vector< string > & | nodes | ) |
Get list of Nodes, indirectly.
Scan the COSMOS root directory and return the name of each Node that is found. Repeated calls to this function will append entries.
nodes | Vector of strings with Node names. |
int32_t data_get_nodes | ( | vector< cosmosstruc > & | node | ) |
Get vector of Node structures.
Scan the COSMOS root directory and return a cosmosstruc for each Node that is found.
node | Vector of cosmosstruc for each Node. |
string data_name | ( | string | node, |
double | mjd, | ||
string | extra, | ||
string | type | ||
) |
Create data file name.
Builds a filename up from the date of creation and its type. Format is: yyyyjjjsssss_extra.type, where yyyy is the Year, jjj is the Julian Day, sssss is the Seconds, and type is any accepted COSMOS file type (eg. log, event, telemetry, message, command.)
node | Node name. |
mjd | UTC of creation date in Modified Julian Day |
extra | Extra part of file name. |
type | Any valid extension type |
string data_name | ( | string | node, |
double | mjd, | ||
string | type | ||
) |
int32_t data_name_date | ( | string | node, |
string | filename, | ||
uint16_t & | year, | ||
uint16_t & | jday, | ||
uint32_t & | seconds | ||
) |
Get date from file name.
Assuming the COSMOS standard filename format from data_name, extract the date portion and return it as year, julian day and seconds.
node | Name of Node. |
filename | Name of File. |
year | Holder for integer year. |
jday | Holder for integer julian day. |
seconds | Holder for integer julian seconds. |
int32_t data_name_date | ( | string | node, |
string | filename, | ||
double & | utc | ||
) |
Get date from file name.
Assuming the COSMOS standard filename format from data_name, extract the date portion and return it as a Modified Julian Day.
node | Name of Node. |
filename | Name of File. |
utc | Holder for returned utc. |
string data_base_path | ( | string | node, |
string | location, | ||
string | agent, | ||
string | filename | ||
) |
Create data file path.
Create a full path to the named file based on the provided information. The path will be of the form {cosmosnodes}/{node}/{location}/{agent}/{filename}, or in the case of a "data" location, {cosmosnodes}/{node}/{location}/{agent}/{yyyy}/{jjj}/{filename}. If {cosmosnodes} is not defined, or cannot be found, it will be left blank.
string data_base_path | ( | string | node, |
string | location, | ||
string | agent | ||
) |
string data_base_path | ( | string | node, |
string | location | ||
) |
string data_base_path | ( | string | node | ) |
string data_archive_path | ( | string | node, |
string | agent, | ||
double | mjd | ||
) |
string data_type_path | ( | string | node, |
string | location, | ||
string | agent, | ||
double | mjd, | ||
string | type | ||
) |
Create data file path.
Build a path to a data file using its filename and the current Node directory.
node | Node directory in cosmosroot. |
location | Subfolder in Node directory (outgoing, incoming, data, temp). |
agent | Task specific subfolder of location, if relevant |
mjd | UTC of creation date in Modified Julian Day |
type | Any valid extension type |
string data_type_path | ( | string | node, |
string | location, | ||
string | agent, | ||
double | mjd, | ||
string | extra, | ||
string | type | ||
) |
Create data file path.
Build a path to a data file using its filename and the current Node directory.
node | Node directory in cosmosroot. |
location | Subfolder in Node directory (outgoing, incoming, data, temp). |
agent | Task specific subfolder of location, if relevant |
mjd | UTC of creation date in Modified Julian Day |
extra | Extra text to add to the full name. |
type | Any valid extension type |
string data_name_path | ( | string | node, |
string | location, | ||
string | agent, | ||
double | mjd, | ||
string | name | ||
) |
Create data file path.
Build a path to a data file using its filename and the current Node directory.
node | Node directory in cosmosroot. |
location | Subfolder in Node directory (outgoing, incoming, data, temp). |
agent | Task specific subfolder of location, if relevant |
mjd | UTC of creation date in Modified Julian Day |
name | File name. |
string data_resource_path | ( | string | name | ) |
Create resource file path.
Build a path to a resource file using its filename and the current resource directory.
name | File name. |
bool data_exists | ( | string & | path | ) |
Check existence of path.
Check whether a path exists, within the limits of permissions.
path | string containing full path. |
FILE * data_open | ( | string | path, |
const char * | mode | ||
) |
Open file from path.
Attempt to open a file with an optional path. If a path is included, each directory element will be created if it is missing. The final file will be opened with the requested mode.
path | Full path to file, absolute or relative. |
mode | fopen style mode. |
int32_t set_cosmosroot | ( | string | name, |
bool | create_flag | ||
) |
Set Root Directory.
Set the internal variable that points to where all COSMOS files are stored.
name | Absolute or relative pathname of directory. |
create_flag | Create directory if not already present. |
int32_t set_cosmosroot | ( | bool | create_flag | ) |
Find Root Directory.
Set the internal variable that points to where all COSMOS resource files are stored. This checks, in succession:
string get_cosmosroot | ( | bool | create_flag | ) |
Return COSMOS Root Directory.
Get the internal variable that points to where all COSMOS Resource files are stored. Initialize variable if this is the first call to the function.
create_flag | Create directory if not already present. |
int32_t get_cosmosroot | ( | string & | result, |
bool | create_flag | ||
) |
Return COSMOS Root Directory.
Get the internal variable that points to where all COSMOS Resource files are stored. Initialize variable if this is the first call to the function.
result | Full path to Root directory. |
create_flag | Create directory if not already present. |
int32_t set_cosmosresources | ( | string | name, |
bool | create_flag | ||
) |
Set Resources Directory.
Set the internal variable that points to where all COSMOS resource files are stored.
name | Absolute or relative pathname of directory. |
create_flag | Create directory if not already present. |
int32_t set_cosmosresources | ( | bool | create_flag | ) |
Find Resources Directory.
Set the internal variable that points to where all COSMOS resource files are stored. This checks, in succession:
string get_cosmosresources | ( | bool | create_flag | ) |
Return COSMOS Resources Directory.
Get the internal variable that points to where all COSMOS Resource files are stored. Initialize variable if this is the first call to the function.
create_flag | Create directory if not already present. |
int32_t get_cosmosresources | ( | string & | result, |
bool | create_flag | ||
) |
Return COSMOS Resources Directory.
Get the internal variable that points to where all COSMOS Resource files are stored. Initialize variable if this is the first call to the function.
result | Full path to Resources directory. |
create_flag | Create directory if not already present. |
int32_t setEnvCosmosResources | ( | string | path | ) |
Set Environment Variable for COSMOS resources.
path | Full path of the COSMOS resources folder. |
int32_t setEnvCosmosNodes | ( | string | path | ) |
int32_t setEnv | ( | string | var, |
string | path | ||
) |
Set Environment Variable for COSMOS.
var | environment variable to set (ex. COSMOSRESOURCES) |
path | Full path of the COSMOS variable folder. |
int32_t setEnvCosmos | ( | string | path | ) |
Set Environment Variable for COSMOS Automatically These variables are just temporarily created while the program runs.
path | full path of the COSMOS variable folder. |
int32_t set_cosmosnodes | ( | string | name, |
bool | create_flag | ||
) |
Set Nodes Directory.
Set the internal variable that points to where all COSMOS resource files are stored.
name | Absolute or relative pathname of directory. |
create_flag | Create directory if not already present. |
int32_t set_cosmosnodes | ( | bool | create_flag | ) |
Find COSMOS Nodes Directory on Windows, Linux or MacOS.
Set the internal variable that points to where all COSMOS node files are stored. This either uses the value in COSMOSNODES, or looks for the directory up to 6 levels above the current directory, first in "cosmosnodes", and then in "nodes".
string get_cosmosnodes | ( | bool | create_flag | ) |
Return COSMOS Nodes Directory.
Get the internal variable that points to where all COSMOS Node files are stored. Initialize variable if this is the first call to the function.
create_flag | Create directory if not already present. |
int32_t get_cosmosnodes | ( | string & | result, |
bool | create_flag | ||
) |
Get COSMOS Nodes Directory.
Get the internal variable that points to where all COSMOS files are stored.
result | String to place path in. |
create_flag | Create directory if not already present. |
string get_nodedir | ( | string | node, |
bool | create_flag | ||
) |
Get Current Node Directory.
Get the internal variable that points to where node files are stored for the current Node.
node | Name of current Node |
create_flag | Whether or not to create node directory if it doesn't already exist. |
int32_t data_load_archive | ( | string | node, |
string | agent, | ||
double | utcbegin, | ||
double | utcend, | ||
string | type, | ||
vector< string > & | result | ||
) |
Load data from archive.
Load JSON entries of specified type from data archive for specified Node and Agent. Will return all data that is available within specified date range, in files {COSMOSNODES}/{Node}/date/{Agent}/{yyyy}/{ddd}/{*}.type.
node | Name of Node. |
agent | Name of Agent. |
utcbegin | Starting UTC. |
utcend | Ending UTC. |
type | Type extension. |
result | Vector of JSON strings. |
int32_t data_load_archive | ( | string | node, |
string | agent, | ||
double | mjd, | ||
string | type, | ||
vector< string > & | result | ||
) |
int32_t data_load_archive | ( | double | mjd, |
vector< string > & | telem, | ||
vector< string > & | event, | ||
cosmosstruc * | cinfo | ||
) |
double findlastday | ( | string | name | ) |
Find last day in archive.
Searches through data archives for this Node to find most recent day for which data is available. This is then stored in lastday.
double findfirstday | ( | string | name | ) |
Find first day in archive.
Searches through data archives for this Node to find oldest day for which data is available. This is then stored in firstday.
int32_t kml_write | ( | cosmosstruc * | cinfo | ) |
Add to KML path.
Write a KML file to keep track of the path the node is following. Create the file if it doesn't alreay exist. Append to it if it already exists.
cinfo | Pointer to cosmosstruc to use. |
bool data_isdir | ( | string | path | ) |
bool data_ischardev | ( | string | path | ) |
bool data_isfile | ( | string | path, |
off_t | size | ||
) |
double data_ctime | ( | string | path | ) |
off_t data_size | ( | string | path | ) |
int32_t data_execute | ( | string | cmd, |
string & | result, | ||
string | shell | ||
) |
void log_reopen | ( | ) |
int check_events | ( | eventstruc * | events, |
int | max, | ||
cosmosstruc * | data | ||
) |