![]() |
Fledge
An open source edge computing platform for industrial users
|
#include <omf.h>
Public Member Functions | |
| OMF (const std::string &name, HttpSender &sender, const std::string &path, const long typeId, const std::string &producerToken) | |
| Constructor: pass server URL path, OMF_type_id and producerToken. | |
| OMF (const std::string &name, HttpSender &sender, const std::string &path, std::map< std::string, OMFDataTypes > &types, const std::string &producerToken) | |
| void | setOMFVersion (std::string &omfversion) |
| void | setSender (HttpSender &sender) |
| uint32_t | sendToServer (const std::vector< Reading > &readings, bool skipSentDataTypes=true) |
| Send data to PI Server passing a vector of readings. More... | |
| uint32_t | sendToServer (const std::vector< Reading * > &readings, bool compression, bool skipSentDataTypes=true) |
| Send all the readings to the PI Server. More... | |
| uint32_t | sendToServer (const Reading &reading, bool skipSentDataTypes=true) |
| Send a single reading to the PI Server. More... | |
| uint32_t | sendToServer (const Reading *reading, bool skipSentDataTypes=true) |
| Send a single reading pointer to the PI Server. More... | |
| void | setFormatType (const std::string &key, std::string &value) |
| Add the key (OMF type + OMF format) into a map. More... | |
| void | setPIServerEndpoint (const OMF_ENDPOINT PIServerEndpoint) |
| Set which PIServer component should be used for the communication. | |
| void | setNamingScheme (const NAMINGSCHEME_ENDPOINT namingScheme) |
| std::string | generateMeasurementId (const string &assetName) |
| Generate the container id for the given asset. More... | |
| std::string | generateSuffixType (string &assetName, long typeId) |
| Generate a suffix for the given asset in relation to the selected naming schema and the value of the type id. More... | |
| long | getNamingScheme (const string &assetName) |
| Retrieve the naming scheme for the given asset in relation to the end point selected the default naming scheme selected and the naming scheme of the asset itself. More... | |
| string | getHashStored (const string &assetName) |
| Retrieve the hash for the given asset in relation to the end point selected. More... | |
| string | getPathStored (const string &assetName) |
| Retrieve the current AF hierarchy for the given asset. More... | |
| string | getPathOrigStored (const string &assetName) |
| Retrieve the AF hierarchy in which given asset was created. More... | |
| bool | setPathStored (const string &assetName, string &afHierarchy) |
| Stores the current AF hierarchy for the given asset. More... | |
| bool | deleteAssetAFH (const string &assetName, string &path) |
| AFHierarchy - delete the link between 2 elements in the AF hierarchy. More... | |
| bool | createAssetAFH (const string &assetName, string &path) |
| AFHierarchy - create the link between 2 elements in the AF hierarchy. More... | |
| void | setDefaultAFLocation (const std::string &DefaultAFLocation) |
| Set the first level of hierarchy in Asset Framework in which the assets will be created, PI Web API only. | |
| bool | setAFMap (const std::string &AFMap) |
| Set the Names and Metadata rules to address where assets should be placed in the AF hierarchy. | |
| void | setSendFullStructure (const bool sendFullStructure) |
| void | setPrefixAFAsset (const std::string &prefixAFAsset) |
| Set the first level of hierarchy in Asset Framework in which the assets will be created, PI Web API only. | |
| void | setDelimiter (const std::string &delimiter) |
| void | setDataActionCode (const std::string &actionCode) |
| std::string | getFormatType (const std::string &key) const |
| Get from m_formatTypes map the key (OMF type + OMF format) More... | |
| void | setNotBlockingErrors (std::vector< std::string > &) |
| Set the list of errors considered not blocking in the communication with the PI Server. | |
| std::string | compress_string (const std::string &str, int compressionlevel=Z_DEFAULT_COMPRESSION) |
| Compress a string. More... | |
| const long | getTypeId () const |
| bool | isDataTypeError (const char *message) |
| Check for invalid/redefinition data type error. More... | |
| bool | isPIstable () |
| bool | isPIconnected () |
| void | setPIconnected (bool connectionStatus) |
| std::size_t | getNumBlocks () |
| void | setNumBlocks (std::size_t numBlocks) |
| void | setMapObjectTypes (const std::vector< Reading * > &data, std::map< std::string, Reading * > &dataSuperSet) |
| Create a superset data map for each reading and found datapoints. More... | |
| void | unsetMapObjectTypes (std::map< std::string, Reading * > &dataSuperSet) const |
| Cleanup the mapped object types for input data. More... | |
| void | setStaticData (std::vector< std::pair< std::string, std::string >> *staticData) |
| void | generateAFHierarchyPrefixLevel (string &path, string &prefix, string &AFHierarchyLevel) |
| Calculate the prefix to be used for AF objects and the last level of the hierarchies from a given AF path. More... | |
| map< std::string, std::string > | getNamesRules () const |
| map< std::string, std::string > | getMetadataRulesExist () const |
| bool | getAFMapEmptyNames () const |
| bool | getAFMapEmptyMetadata () const |
| void | setLegacyMode (bool legacy) |
Static Public Member Functions | |
| static std::string | ApplyPIServerNamingRulesObj (const std::string &objName, bool *changed) |
| Check a PI Server object name and returns the proper name to use following the naming rules: More... | |
| static std::string | ApplyPIServerNamingRulesPath (const std::string &objName, bool *changed) |
| Check a PI Server path name and returns the proper name to use following the naming rules: More... | |
| static std::string | ApplyPIServerNamingRulesInvalidChars (const std::string &objName, bool *changed) |
| Check a PI Server name and returns the proper name to use following the naming rules. More... | |
| static std::string | variableValueHandle (const Reading &reading, std::string &AFHierarchy) |
| Evaluate the AF hierarchy provided and expand the variables in the form ${room:unknown}. More... | |
| static bool | extractVariable (string &strToHandle, string &variable, string &value, string &defaultValue) |
| Extracts a variable and its elements from a string, the variable will have the shape ${room:unknown}. More... | |
| static void | reportAsset (const string &asset, const string &level, const string &msg) |
| Report an error related to an asset if the asset has not already been reported. More... | |
|
static |
Check a PI Server name and returns the proper name to use following the naming rules.
Invalid chars: Control characters plus: * ? ; { } [ ] | \ ‘ ’ "
| objName | The object name to verify |
| changed | if not null, it is set to true if a change occurred |
|
static |
Check a PI Server object name and returns the proper name to use following the naming rules:
Note: Names on PI-Server side are not case sensitive
| objName | The object name to verify |
| changed | if not null, it is set to true if a change occur |
Names cannot begin with '__'. These are reserved for system use.
|
static |
Check a PI Server path name and returns the proper name to use following the naming rules:
Names on PI-Server side are not case sensitive
| objName | The object name to verify |
| changed | if not null, it is set to true if a change occurred |
Names cannot begin with '__'. These are reserved for system use.
| std::string OMF::compress_string | ( | const std::string & | str, |
| int | compressionlevel = Z_DEFAULT_COMPRESSION |
||
| ) |
Compress a string.
| str | Input STL string that is to be compressed |
| compressionlevel | zlib/gzip Compression level |
| bool OMF::createAssetAFH | ( | const string & | assetName, |
| string & | path | ||
| ) |
AFHierarchy - create the link between 2 elements in the AF hierarchy.
| bool OMF::deleteAssetAFH | ( | const string & | assetName, |
| string & | path | ||
| ) |
AFHierarchy - delete the link between 2 elements in the AF hierarchy.
|
static |
Extracts a variable and its elements from a string, the variable will have the shape ${room:unknown}.
| strToHandle | Source string from which the variable should be extracted |
| variable | Variable found in the form ${room:unknown} |
| value | Value of the variable, left part , room in this case ${room:unknown} |
| defaultValue | Default value of the variable, right part , unknown in this case ${room:unknown} |
| void OMF::generateAFHierarchyPrefixLevel | ( | string & | path, |
| string & | prefix, | ||
| string & | AFHierarchyLevel | ||
| ) |
Calculate the prefix to be used for AF objects and the last level of the hierarchies from a given AF path.
| path | Path to evaluate |
| out/prefix | Calculated prefix |
| out/AFHierarchyLevel | last level of the hierarchies evaluated form the path |
| std::string OMF::generateMeasurementId | ( | const string & | assetName | ) |
Generate the container id for the given asset.
| assetName | Asset for which the container id should be generated |
| std::string OMF::generateSuffixType | ( | string & | assetName, |
| long | typeId | ||
| ) |
Generate a suffix for the given asset in relation to the selected naming schema and the value of the type id.
| assetName | Asset for which the suffix should be generated |
| typeId | Type id of the asset |
| std::string OMF::getFormatType | ( | const std::string & | key | ) | const |
| string OMF::getHashStored | ( | const string & | assetName | ) |
Retrieve the hash for the given asset in relation to the end point selected.
| assetName | Asset for which the hash should be retrieved |
| long OMF::getNamingScheme | ( | const string & | assetName | ) |
Retrieve the naming scheme for the given asset in relation to the end point selected the default naming scheme selected and the naming scheme of the asset itself.
| assetName | Asset for which the naming schema should be retrieved |
| string OMF::getPathOrigStored | ( | const string & | assetName | ) |
Retrieve the AF hierarchy in which given asset was created.
| assetName | Asset for which the path should be retrieved |
| string OMF::getPathStored | ( | const string & | assetName | ) |
Retrieve the current AF hierarchy for the given asset.
| assetName | Asset for which the path should be retrieved |
| bool OMF::isDataTypeError | ( | const char * | message | ) |
Check for invalid/redefinition data type error.
| message | Server reply message for data type creation |
|
static |
Report an error related to an asset if the asset has not already been reported.
| asset | The asset name |
| level | The level to log the message at |
| msg | The message to log |
| uint32_t OMF::sendToServer | ( | const Reading & | reading, |
| bool | skipSentDataTypes = true |
||
| ) |
Send a single reading to the PI Server.
Note: this overload is never called.
| reading | A reading to send |
| uint32_t OMF::sendToServer | ( | const Reading * | reading, |
| bool | skipSentDataTypes = true |
||
| ) |
Send a single reading pointer to the PI Server.
Note: this overload is never called.
| reading | A reading pointer to send |
| uint32_t OMF::sendToServer | ( | const std::vector< Reading * > & | readings, |
| bool | compression, | ||
| bool | skipSentDataTypes = true |
||
| ) |
Send all the readings to the PI Server.
| readings | A vector of readings data pointers |
| skipSendDataTypes | Send datatypes only once (default is true) |
| compression | If true, compress JSON payload before sending to PI |
Types messages sent, now transform each reading to OMF format.
After formatting the new vector of data can be sent with one message only
| uint32_t OMF::sendToServer | ( | const std::vector< Reading > & | readings, |
| bool | skipSentDataTypes = true |
||
| ) |
Send data to PI Server passing a vector of readings.
Send all the readings to the PI Server.
Data sending is composed by a few phases handled by private methods.
Note: DataTypes are sent only once by using an in memory key map, being the key = assetName + typeId. Passing false to skipSentDataTypes changes the logic.
Returns the number of processed readings.
Note: this overload is never called.
| readings | A vector of readings data |
| skipSendDataTypes | Send datatypes only once (default is true) |
| void OMF::setFormatType | ( | const std::string & | key, |
| std::string & | value | ||
| ) |
| void OMF::setMapObjectTypes | ( | const std::vector< Reading * > & | data, |
| std::map< std::string, Reading * > & | dataSuperSet | ||
| ) |
Create a superset data map for each reading and found datapoints.
The output map is filled with a Reading object containing all the datapoints found for each asset in the input reading set. The datapoints have a fake value based on the datapoint type
| readings | Current input readings data |
| dataSuperSet | Map to store all datapoints for an assetname |
| bool OMF::setPathStored | ( | const string & | assetName, |
| string & | afHierarchy | ||
| ) |
Stores the current AF hierarchy for the given asset.
| assetName | Asset for which the path should be retrieved |
| afHierarchy | Current AF hierarchy of the asset |
| void OMF::unsetMapObjectTypes | ( | std::map< std::string, Reading * > & | dataSuperSet | ) | const |
Cleanup the mapped object types for input data.
| dataSuperSet | The mapped object to cleanup |
|
static |
Evaluate the AF hierarchy provided and expand the variables in the form ${room:unknown}.
| reading | Asset reading that should be considered from which to extract the metadata values |
| AFHierarchy | AF hierarchy containing the variable to be expanded |