Separate library that holds helper functions for the main OMF code.
Diff: osisoft-omf.h
- Revision:
- 8:e5fe40b77f8f
- Parent:
- 1:1c31b413ba0c
- Child:
- 10:844e209f1d79
--- a/osisoft-omf.h Fri Feb 16 00:34:16 2018 +0000 +++ b/osisoft-omf.h Wed Mar 14 14:14:51 2018 +0000 @@ -17,6 +17,7 @@ #include "mbed.h" #include "https_request.h" +#include "config.deviceID.h" // ************************************************************************ // Helper function that casts floats into strings @@ -53,5 +54,65 @@ // ************************************************************************ void OMFLib_syncClockViaNTP(NetworkInterface* network); - + +// ------------------------------------------------------------------------ + +// Automatically generated OMF-SPECIFIC CONSTANTS +// Similarly, specify the name of for the data values type; this should likewise be unique +// for each general class of IoT device--for example, if you were running this script on two different devices, +// each with different numbers and kinds of sensors, you would specify a different data values message type name +// when running the script on each device. If both devices were the same, you could use the same data_values_message_type_name +const string DATA_VALUES_MESSAGE_TYPE_NAME = DEVICE_TYPE + "_data_values_type"; + +// The unique device name will also be used as part of the container id used to send live data values +const string DATA_VALUES_CONTAINER_ID = DEVICE_NAME + "_data_values_container"; + +// The device type will also be used for the asset type constant as well +const string ASSETS_MESSAGE_TYPE_NAME = DEVICE_TYPE + "_asset_type"; + +// The containers message JSON requires both of the above constants; it is also a constant +const string CONTAINERS_MESSAGE_JSON = "[" + "{" + "\"id\": \"" + DATA_VALUES_CONTAINER_ID + "\"," + "\"typeid\": \"" + DATA_VALUES_MESSAGE_TYPE_NAME + "\"" + "}" +"]"; + +// A JSON packet to containing linking data for the PI AF asset that will be made +const string LINKS_MESSAGE_JSON = "[" + "{" + "\"typeid\": \"__Link\"" "," + "\"values\": [" + // This first link will locate such a newly created AF Element under the root PI element targeted by the PI Connector in your target AF database + // This was specfied in the Connector Relay Admin page; note that a new parent element, with the same name as the producer_token, will also be made + "{" + "\"Source\": {" + "\"typeid\": \"" + ASSETS_MESSAGE_TYPE_NAME + "\"," + "\"index\": \"_ROOT\"" + "}," + "\"Target\": {" + "\"typeid\": \"" + ASSETS_MESSAGE_TYPE_NAME + "\"," + "\"index\": \"" + DEVICE_NAME + "\"" + "}" + "}," + // This second link will map new PI Points (created by messages sent to the data values container) to a newly create element + "{" + "\"Source\": {" + "\"typeid\": \"" + ASSETS_MESSAGE_TYPE_NAME + "\"," + "\"index\": \"" + DEVICE_NAME + + "\"" + "}," + "\"Target\": {" + "\"containerid\": \"" + DATA_VALUES_CONTAINER_ID + "\"" + "}" + "}" + "]" + "}" +"]"; + +// ------------------------------------------------------------------------ + +// Constants used for setting headers when sending OMF messages +const string OMF_VERSION = "1.0"; +const string OMF_MESSAGE_FORMAT = "JSON"; +const string CONTENT_TYPE = "application/json"; #endif \ No newline at end of file