MDF Lib 2.2
Interface against MDF 3/4 files
|
Support class for the MDF library.
#include <mdfhelper.h>
Static Public Member Functions | |
static uint64_t | NanoSecToLocal (uint64_t ns_since_1970) |
Adds the time zone offset to the time stamp. | |
static int64_t | TimeZoneOffset () |
return the time zone offset in seconds. | |
static int64_t | GmtOffsetNs () |
Returns the GMT offset in nanoseconds. | |
static int64_t | DstOffsetNs () |
Returns the daylight saving time (DST) offset in nanoseconds. | |
static std::string | NsToLocalIsoTime (uint64_t ns_since_1970) |
Converts a nanosecond since 1970 to a local ISO date and time string. | |
static std::vector< uint8_t > | NsToCanOpenDateArray (uint64_t ns_since_1970) |
Converts from nanoseconds to CANopen 7 byte Date array. | |
static std::vector< uint8_t > | NsToCanOpenTimeArray (uint64_t ns_since_1970) |
Converts from nanoseconds to CANopen 6 byte Time array. | |
static uint64_t | CanOpenDateArrayToNs (const std::vector< uint8_t > &buffer) |
Converts from a CANopen 7 byte Date array to nanoseconds since 1970. | |
static uint64_t | CanOpenTimeArrayToNs (const std::vector< uint8_t > &buffer) |
Converts from a CANopen 6 byte Time array to nanoseconds since 1970. | |
static std::string | NanoSecToDDMMYYYY (uint64_t ns_since_1970) |
Converts ns since 1970 UTC to local date DD:MM:YYYY string. | |
static std::string | NanoSecToHHMMSS (uint64_t ns_since_1970) |
Converts ns since 1970 UTC to local time HH:MM:SS string. | |
static std::string | NanoSecUtcToHHMMSS (uint64_t timestamp_ns) |
Converts ns since 1970 UTC to UTC time in 'HH:MM:SS' format. | |
static std::string | NanoSecUtcToDDMMYYYY (uint64_t timestamp_ns) |
Converts ns since 1970 UTC to UTC date in 'DD/MM/YYYY' format. | |
static std::string | NanoSecTzToHHMMSS (uint64_t timestamp_ns, int16_t tz_offset_min, int16_t dst_offset_min) |
Converts ns since 1970 UTC to a time string in 'HH:MM:SS' format in a specified timezone. | |
static std::string | NanoSecTzToDDMMYYYY (uint64_t timestamp_ns, int16_t tz_offset_min, int16_t dst_offset_min) |
Converts ns since 1970 UTC to a date string in 'DD/MM/YYYY' format in a specified timezone. | |
static void | Trim (std::string &text) |
Remove white space from string. | |
static std::string | FormatDouble (double value, uint8_t decimals, bool fixed=false, const std::string &unit={}) |
Converts a float to a string. | |
static uint64_t | NowNs () |
Return nano-seconds since 1970. | |
static std::string | Latin1ToUtf8 (const std::string &latin1) |
Converts a Latin1 string to UTF8 string. | |
static std::string | Utf16ToUtf8 (const std::wstring &utf16) |
Converts a wide UTF16 string to an UTF8 string. | |
static std::wstring | Utf8ToUtf16 (const std::string &utf8) |
Converts a wide UTF8 string to an UTF16 string. | |
static bool | ComputerUseLittleEndian () |
Returns tru if this computer uses Little Endian. | |
static std::vector< uint8_t > | TextToByteArray (const std::string &text) |
Converts a text string to a byte array. | |
|
static |
Converts from 7 byte CANopen date array to a uint64_t nanoseconds since
7-byte CANopen date format:
[in] | buffer | 7-byte CANopen date array |
|
static |
Converts from nanoseconds since 1970-01-01 to a 6-byte CANopen time array This format is used in CANopen protocol and in ASAM MDF files.
6-byte CANopen time format:
[in] | buffer | 6-byte CANopen time array |
|
static |
This function returns the current daylight saving time (DST) offset in nanoseconds.
|
static |
Converts a floating point value to a string using number of decimals.
It also fix rounding and returning a fixed decimals. Presenting fixed number of decimals means that it fills up the string with '0' characters.
Example: Value: 1.23 and decimals 3,String: (Fixed = false) "1.23" (Fixed = true) "1.230"
Optional it can append a unit to the string (Example: "1.23 m/s").
[in] | value | The floating point value. |
[in] | decimals | Max number of decimals. |
[in] | fixed | If it should show fixed number of decimals. |
[in] | unit | Appends a unit string to the output. |
|
static |
This function returns the current GMT offset in nanoseconds.
|
static |
Generates a local date string with the 'DD:MM:YYYY' format, from an UTC time stamp nanoseconds since 1970-01-01 (midnight). The nanosecond timestamp is commonly used when transfer a timestamp. Note that this may not be used as epoch in different internal clocks.
[in] | ns_since_1970 | Nanoseconds since 1970 UTC |
|
static |
Generates a local time string with the 'HH:MM:ss' format, from an UTC time stamp nanoseconds since 1970-01-01 (midnight). The nanosecond timestamp is commonly used when transfer a timestamp. Note that this may not be used as epoch in different internal clocks.
[in] | ns_since_1970 | Nanoseconds since 1970 UTC |
|
static |
Adds the time zone offset and dst to the UTC nanoseconds since 1970.
[in] | ns_since_1970 | Nano-seconds since 1970 |
|
static |
Generates a date string in the 'DD/MM/YYYY' format based on a timestamp representing nanoseconds since 1970-01-01 (midnight) UTC, adjusted for a specified timezone and daylight saving time (DST) offset. This function is useful for converting a high-precision timestamp into a human-readable date in a specific timezone.
[in] | timestamp_ns | Nanoseconds since 1970 UTC. |
[in] | tz_offset_min | Timezone offset in minutes from UTC. |
[in] | dst_offset_min | Daylight saving time (DST) offset in minutes. |
|
static |
Generates a time string in the 'HH:MM:SS' format based on a timestamp representing nanoseconds since 1970-01-01 (midnight) UTC, adjusted for a specified timezone and daylight saving time (DST) offset. This function is useful for converting a high-precision timestamp into a human-readable time in a specific timezone.
[in] | timestamp_ns | Nanoseconds since 1970 UTC. |
[in] | tz_offset_min | Timezone offset in minutes from UTC. |
[in] | dst_offset_min | Daylight saving time (DST) offset in minutes. |
|
static |
Generates a UTC date string in the 'DD/MM/YYYY' format from a timestamp representing nanoseconds since 1970-01-01 (midnight) UTC. This function is useful for converting a high-precision timestamp into a human-readable date in UTC.
[in] | timestamp_ns | Nanoseconds since 1970 UTC. |
|
static |
Generates a UTC time string in the 'HH:MM:SS' format from a timestamp representing nanoseconds since 1970-01-01 (midnight) UTC. This is useful for converting a high-precision timestamp to a human-readable time format in UTC.
[in] | timestamp_ns | Nanoseconds since 1970 UTC. |
|
static |
Converts from nanoseconds since 1970-01-01 to a 7 byte CANopen date array This format is used in CANopen protocol and in ASAM MDF files.
7-byte CANopen date format:
[in] | ns_since_1970 | Nanoseconds since 1970-01-01 |
|
static |
Converts from nanoseconds since 1970-01-01 to a 6-byte CANopen time array This format is used in CANopen protocol and in ASAM MDF files.
6-byte CANopen time format:
[in] | ns_since_1970 | Nanoseconds since 1970-01-01 |
|
static |
[in] | ns_since_1970 | Nanosecond since 1970 |
|
static |
Returns the current used time zone offset in seconds
|
static |
Removes white spaces from the begin and end of the string
text | String to trim |