API Documentation

Core

The Core API provides access to commonly used functions and data types for PolySync applications. This API defines a set of globally unique parameters and Diagnostic Trouble Codes (DTCs) that enable applications to communicate their runtime status. This API also provides the PolySync Core enumerations, types, and variables.

Usage #include <PolySyncCore.hpp>

Macros

polySyncLogDebug ( … )

The PolySync debug log function.

This is a wrapper to polysync::log, using log level LOG_LEVEL_DEBUG.

Example:

  polySyncLogDebug( "It's time to debug." );

polySyncLogError ( … )

The PolySync error log function.

This is a wrapper to polysync::log, using log level LOG_LEVEL_ERROR.

Example:

  polySyncLogError( "Oh no! An error occurred!" );

polySyncLogInfo ( … )

The PolySync info log function.

This is a wrapper to polysync::log, using log level LOG_LEVEL_INFO.

Example:

  polySyncLogInfo( "Here is some useful information." );

PolySyncLogWarning ( … )

The PolySync warning log function.

This is a wrapper to polysync::log, using log level LOG_LEVEL_WARN.

Example:

  PolySyncLogWarning( "Useful information." );

Version

The Version class is a convenience class for storing PolySync Core Module version information. This is useful to verify that an application supports the installed PolySync version.

Version::Version ( )

This constructor will gather PolySync version data.

Version::getBuildDate ( )

getBuildDate will get the date that indicates when the PolySync version was built.

Returns
  • Build date for the core module [UTC microseconds]

Version::getMajor ( )

getMajor will get the digit that represents the PolySync major version for the release. The major digit will increase with stable changes without full backwards compatibility.

Returns
  • Major build digit for the PolySync release

Version::getMinor ( )

getMinor will get the digit that represents the PolySync minor version for the release. The minor digit will increase with the release of stable feature additions.

Returns
  • Minor build digit for the PolySync release

Version::getSubMinor ( )

getSubMinor will get the digit that represents the PolySync subminor version for the release.

The subminor digit will increase with the release of stable bug fixes.

Returns
  • Subminor build digit for the PolySync release

getBuildVersion ( )

Get the PolySync API build version information, including: the major, minor, and subminor digits, as well as the UTC build-date variables.

Returns
  • Object containing the version information for the PolySync release

std::vector< uchar > getFileHash ( … )

This will get the MD5 hash of the provided file.

Parameters
in/out type name description
in std::string file_path A pointer to a char buffer that specifies the file path.
Returns
  • String representation of the MD5 hash value for a file
Exceptions
  • polysync::DTCException on failure

getMonotonicTimestamp ( )

This will get the current monotonically increasing timestamp relative to system start up. This is useful for calculating the delta of time during application processing.

Returns
  • Timestamp at this moment in time [UTC microseconds]

getNodeID ( … )

This will extract the global node ID from the node GUID.

The node ID is a useful tool when identifying a node on the PolySync bus and filtering data sources.

Parameters
in/out type name description
in ps_guid guid GUID to parse node ID from.
Returns
  • Unique node ID represented by the given ps_guid
Exceptions
  • polysync::DTCException on failure

getNodeType ( … )

This will extract the node type from the node GUID.

The node type is useful when performing high-level node filtering. For example, identifying all hardware and algorithm nodes on the bus.

Parameters
in/out type name description
in ps_guid guid GUID to parse node type from.
Returns
  • Type of node represented by ps_guid
Exceptions
  • polysync::DTCException on failure

Node Types: ( Compile-time constants )

Name Value
PSYNC_NODE_TYPE_INVALID 0U.
PSYNC_NODE_TYPE_ALL 65535U.
PSYNC_NODE_TYPE_API_USER 1U.
PSYNC_NODE_TYPE_MANAGER 2U.
PSYNC_NODE_TYPE_STUDIO 3U.
PSYNC_NODE_TYPE_STUDIO_PLUGIN 4U.
PSYNC_NODE_TYPE_HARDWARE_DRIVER 6U.
PSYNC_NODE_TYPE_SOFTWARE_DRIVER 7U.
PSYNC_NODE_TYPE_SOFTWARE_ALGORITHM 8U.

getTimestamp ( )

This will get the current timestamp, which is synchronized across PolySync hosts. [UTC microseconds]

Host synchronization requires that the PolySync PTP service is active.

https://support.harbrick.com/hc/en-us/articles/217713947

Returns
  • ps_timestamp at the time of the function call [UTC microseconds]

interfaceAddressStringToValue ( … )

This will convert the PolySync interface address string to the equivalent ulong value.

It will expect the format to match a valid IP address “X.X.X.X,” or value “AUTO.”

Parameters
in/out type name description
in std::string address The string representing the interface address, as shown above.
Returns
  • Converted value of the address represented by a string
Exceptions
  • polysync::DTCException on failure

std::string interfaceAddressValueToString ( … )

interfaceAddressValueToString will convert the PolySync interface address ulong value to the equivalent string.

It expects a buffer of at least PSYNC_MODULE_VERIFY_HASH_LEN bytes. Example:

[in] 0xA0B0C0D0 -> [out] “160.176.192.208”

Parameters
in/out type name description
in ps_interface_address addressvalue Interface address value to convert.
Returns
  • PolySync address represented in string format
Exceptions
  • polysync::DTCException on failure

sleepMicro ( … )

This will sleep for a given amount of time. [microseconds]

Parameters
in/out type name description
in ps_timestamp interval Duration of time to sleep for.