12 #include <plugin_api.h>
18 #include <plugin_exception.h>
23 #include <simple_https.h>
24 #include <simple_http.h>
25 #include <config_category.h>
26 #include "rapidjson/writer.h"
27 #include "rapidjson/stringbuffer.h"
28 #include "json_utils.h"
29 #include "libcurl_https.h"
31 #include "string_utils.h"
33 #include <linkedlookup.h>
37 #define PLUGIN_NAME "OMF"
38 #define TYPE_ID_KEY "type-id"
39 #define SENT_TYPES_KEY "sentDataTypes"
40 #define DATA_KEY "dataTypes"
41 #define DATA_KEY_SHORT "dataTypesShort"
42 #define DATA_KEY_HINT "hintChecksum"
43 #define NAMING_SCHEME "namingScheme"
44 #define AFH_HASH "afhHash"
45 #define AF_HIERARCHY "afHierarchy"
46 #define AF_HIERARCHY_ORIG "afHierarchyOrig"
49 #define PROPERTY_TYPE "type"
50 #define PROPERTY_NUMBER "number"
51 #define PROPERTY_STRING "string"
53 #define ENDPOINT_URL_PI_WEB_API "https://HOST_PLACEHOLDER:PORT_PLACEHOLDER/piwebapi/omf"
54 #define ENDPOINT_URL_CR "https://HOST_PLACEHOLDER:PORT_PLACEHOLDER/ingress/messages"
55 #define ENDPOINT_URL_OCS "https://REGION_PLACEHOLDER.osisoft.com:PORT_PLACEHOLDER/api/v1/tenants/TENANT_ID_PLACEHOLDER/Namespaces/NAMESPACE_ID_PLACEHOLDER/omf"
56 #define ENDPOINT_URL_ADH "https://REGION_PLACEHOLDER.datahub.connect.aveva.com:PORT_PLACEHOLDER/api/v1/Tenants/TENANT_ID_PLACEHOLDER/Namespaces/NAMESPACE_ID_PLACEHOLDER/omf"
58 #define ENDPOINT_URL_EDS "http://localhost:PORT_PLACEHOLDER/api/v1/tenants/default/namespaces/default/omf"
60 #define AUTHORIZATION_URL_ADH "REGION_PLACEHOLDER.datahub.connect.aveva.com"
61 #define AUTHORIZATION_URL_OCS "REGION_PLACEHOLDER.osisoft.com:443"
63 enum OMF_ENDPOINT_PORT {
64 ENDPOINT_PORT_PIWEB_API=443,
65 ENDPOINT_PORT_CR=5460,
66 ENDPOINT_PORT_OCS=443,
67 ENDPOINT_PORT_EDS=5590,
75 #define NOT_BLOCKING_ERRORS_DEFAULT QUOTE( \
78 "Redefinition of the type with the same ID is not allowed", \
79 "Invalid value type for the property", \
80 "Property does not exist in the type definition", \
81 "Container is not defined", \
82 "Unable to find the property of the container of type" \
87 #define NOT_BLOCKING_ERRORS_DEFAULT_PI_WEB_API QUOTE( \
90 "The specified value is outside the allowable range" \
95 #define AF_HIERARCHY_RULES QUOTE( \
110 void start(
const std::string& storedData);
111 uint32_t
send(
const vector<Reading *>& readings);
114 void loadSentDataTypes(rapidjson::Document& JSONData);
116 int PIWebAPIGetVersion(
bool logMessage =
true);
117 int EDSGetVersion(
bool logMessage =
true);
118 int IsADHConnected(
bool logMessage =
true);
119 void SetOMFVersion();
120 void CheckDataActionCode();
121 OMF_ENDPOINT identifyPIServerEndpoint();
122 std::string saveSentDataTypes();
123 unsigned long calcTypeShort(
const std::string& dataTypes);
124 void ParseProductVersion(std::string &versionString,
int *major,
int *minor);
125 std::string ParseEDSProductInformation(std::string json);
126 std::string AuthBasicCredentialsGenerate(std::string& userId, std::string& password);
127 void AuthKerberosSetup(std::string& keytabEnv, std::string& keytabFileName);
128 double GetElapsedTime(
struct timeval *startTime);
129 bool IsDataArchiveConnected();
130 void handleOMFTracing();
137 bool m_sendFullStructure;
140 string m_hostAndPort;
141 unsigned int m_retrySleepTime;
142 unsigned int m_maxRetry;
143 unsigned int m_timeout;
146 string m_dataActionCode;
148 string m_producerToken;
149 string m_formatNumber;
150 string m_formatInteger;
151 OMF_ENDPOINT m_PIServerEndpoint;
152 NAMINGSCHEME_ENDPOINT
154 string m_DefaultAFLocation;
158 string m_prefixAFAsset;
159 string m_PIWebAPIProductTitle;
160 string m_RestServerVersion;
161 string m_PIWebAPIAuthMethod;
162 string m_PIWebAPICredentials;
163 string m_KerberosKeytab;
172 string m_OCSNamespace;
173 string m_OCSTenantId;
174 string m_OCSClientId;
175 string m_OCSClientSecret;
179 vector<pair<string, string>>
182 std::vector<std::string>
185 std::map<std::string, OMFDataTypes>
191 bool m_tracingEnabled;
192 std::size_t m_numBlocks;