CDPUtils Class
The CDPUtils provides utility like free functions for all around use. More...
Header: | #include <Generic/CDPUtils.h> |
Public Types
typedef | ExceptionHandler |
typedef | Parameter |
Static Public Members
unsigned short | CRC16(unsigned char *puchMsg, unsigned short usDataLen) |
timeval | ConvertMsToTimeval(int ms) |
std::string | EscapeQuotation(const std::string &input) |
std::string | GetBufferDataAsHexadecimalString(const unsigned char *buffer, unsigned int len) |
std::vector<std::string> | GetCanonicalHexDump(const std::string_view &binaryString, unsigned int rowLength = 16) |
std::string | GetModelFileNameFromModelName(const std::string &modelName) |
std::string | GetTypeFromTypeName(const std::string &typeName) |
unsigned int | Hash32(const char *string, unsigned short dataLen) |
bool | IsContainedIn(std::string element, std::string container, std::string separatorChar) |
std::string | JoinParameters(const std::vector<CDPUtils::Parameter> ¶ms) |
double | NormalizedRadDegree(double degree) |
double | NormalizedRadDegreeDiff(double degreeFrom, double degreeTo) |
std::string | ReplaceAll(const std::string &stringToReplaceIn, const std::string &from, const std::string &to) |
std::string | ReplaceLessThanGreaterThan(std::string strName) |
std::string | ReplaceVariables(const std::string &input, const std::map<std::string, std::string> &vars) |
std::vector<Parameter> | SplitParameters(const std::string ¶ms, const ExceptionHandler &handler = {}) |
std::vector<Parameter> | SplitParametersFromView(const std::string_view ¶ms, const ExceptionHandler &handler = {}) |
std::vector<std::string> | SplitSemicolonSeparatedList(const std::string &list, const ExceptionHandler &handler = {}) |
std::string | StripTemplate(const std::string &name) |
Detailed Description
The CDPUtils provides utility like free functions for all around use.
Member Function Documentation
[static]
unsigned short CDPUtils::CRC16(unsigned char *puchMsg, unsigned short usDataLen)
16-bit Cyclic Redundancy Check CRC16(pmsg,nDataLen) - computes CRC of modbus serial RTU message. The function returns the CRC as a unsigned short type. CRC should be performed on the entire message (excluding the crc of course).
[static]
timeval CDPUtils::ConvertMsToTimeval(int ms)
Converts the time in milliseconds to a timeval struct.
[static]
std::string CDPUtils::EscapeQuotation(const std::string &input)
[static]
std::string CDPUtils::GetBufferDataAsHexadecimalString(const unsigned char *buffer, unsigned int len)
[static]
std::vector<std::string> CDPUtils::GetCanonicalHexDump(const std::string_view &binaryString, unsigned int rowLength = 16)
[static]
std::string CDPUtils::GetModelFileNameFromModelName(const std::string &modelName)
Returns the model filename for the model (as it is stored on disk, without .xml ending). Example:
assert( GetModelFileNameFromModelName("CDPSignal<double>")=="CDPSignal_double" ); assert( GetModelFileNameFromModelName("CDPOperator<bool>")=="CDPOperator_bool" );
[static]
std::string CDPUtils::GetTypeFromTypeName(const std::string &typeName)
[static]
unsigned int CDPUtils::Hash32(const char *string, unsigned short dataLen)
Generates a 32 bit hash from a string of characters of length dataLen with Murmur2 hash algorithm
[static]
bool CDPUtils::IsContainedIn(std::string element, std::string container, std::string separatorChar)
Finds whether an element appears within a container.
[static]
std::string CDPUtils::JoinParameters(const std::vector<CDPUtils::Parameter> ¶ms)
[static]
double CDPUtils::NormalizedRadDegree(double degree)
[static]
double CDPUtils::NormalizedRadDegreeDiff(double degreeFrom, double degreeTo)
[static]
std::string CDPUtils::ReplaceAll(const std::string &stringToReplaceIn, const std::string &from, const std::string &to)
Replaces character from with string to based on a string stringToReplaceIn. Returns new string where replacments have been done.
[static]
std::string CDPUtils::ReplaceLessThanGreaterThan(std::string strName)
Replaces < with < and > with >
[static]
std::string CDPUtils::ReplaceVariables(const std::string &input, const std::map<std::string, std::string> &vars)
Replaces variables in format %name% in input string with variable named values in vars map. If named variable is not found in the map the place holder is left in the output. Returns new string where all possible replacments have been done.
[static]
std::vector<Parameter> CDPUtils::SplitParameters(const std::string ¶ms, const ExceptionHandler &handler = {})
[static]
std::vector<Parameter> CDPUtils::SplitParametersFromView(const std::string_view ¶ms, const ExceptionHandler &handler = {})
[static]
std::vector<std::string> CDPUtils::SplitSemicolonSeparatedList(const std::string &list, const ExceptionHandler &handler = {})
[static]
std::string CDPUtils::StripTemplate(const std::string &name)
Strips the template brackets at the end of name if found. Handles both '<>' and '<>'.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.