7 #ifndef CE_DEVICE_DEVICE_H
8 #define CE_DEVICE_DEVICE_H
12 #include "ctlib/Logging.hpp"
13 #include "ctlib/Exception.h"
40 bool throwException =
true);
41 explicit Device(std::string ipAddress, uint16_t srcPort, uint16_t destPort,
int timeoutInMs, PIL::Logging *logger,
47 [[nodiscard]]
bool isOpen()
const;
51 PIL_ERROR_CODE
Exec(
const std::string& command,
ExecArgs *args =
nullptr,
char *result =
nullptr,
bool br =
true,
53 PIL_ERROR_CODE
Exec(
const std::string &command,
ExecArgs *args, std::string *result,
bool br);
62 PIL_ERROR_CODE
delay(
double delayTime);
66 const std::string& fileName,
int line, std::string formatStr, ...);
69 static PIL_ERROR_CODE
postRequest(
const std::string &url, std::string &payload);
71 static std::string
replaceAllSubstrings(std::string str,
const std::string &from,
const std::string &to);
72 static std::vector<std::string>
splitString(
const std::string &toSplit,
const std::string &delimiter);
Basic device class This class contains all basic method of all devices, like Connect,...
Definition: Device.h:30
static PIL_ERROR_CODE postRequest(const std::string &url, std::string &payload)
Sends a post request to the given url with the given payload.
Definition: Device.cpp:309
SEND_METHOD m_SendMode
Definition: Device.h:82
bool isOpen() const
Checks if the connection to the device is established.
Definition: Device.cpp:136
static std::string vectorToStringNL(std::vector< std::string > vector)
Transforms the given vector into a string. Each vector entry will be a line in the resulting string.
Definition: Device.cpp:326
bool m_EnableExceptions
Definition: Device.h:81
static std::vector< std::string > splitString(const std::string &toSplit, const std::string &delimiter)
Splits a string by the given delimiter.
Definition: Device.cpp:357
PIL_ERROR_CODE delay(double delayTime)
Stops the execution for the specified amount of time in seconds. If buffering is enabled,...
Definition: Device.cpp:265
PIL_ERROR_CODE Disconnect()
Disconnect from the device.
Definition: Device.cpp:117
PIL_ERROR_CODE Connect()
Establish a connection to the device.
Definition: Device.cpp:100
std::string m_IPAddr
Definition: Device.h:74
std::vector< std::string > m_BufferedScript
Definition: Device.h:83
PIL_ErrorHandle m_ErrorHandle
Definition: Device.h:75
int m_srcPort
Definition: Device.h:80
bool isBuffered() const
Checks if the commands sent to the device get buffered.
Definition: Device.cpp:144
PIL_ERROR_CODE handleErrorsAndLogging(PIL_ERROR_CODE errorCode, bool throwException, PIL::Level logLevel, const std::string &fileName, int line, std::string formatStr,...)
Handle logging messages, logs it based on the previously passed logging object. If exceptions are ena...
Definition: Device.cpp:76
PIL_ERROR_CODE ExecCommands(std::string &commands)
Definition: Device.cpp:242
std::string ReturnErrorMessage()
Definition: Device.cpp:255
PIL::Socket * m_SocketHandle
Definition: Device.h:77
PIL_ERROR_CODE Exec(const std::string &command, ExecArgs *args=nullptr, char *result=nullptr, bool br=true, int size=1024)
execute a (SCPI) command
Definition: Device.cpp:189
static std::string replaceAllSubstrings(std::string str, const std::string &from, const std::string &to)
Replaces all substrings in the string with the given replacement string.
Definition: Device.cpp:342
void changeSendMode(SEND_METHOD mode)
Changes the send mode of this device, i.e. whether the commands get buffered or sent directly to the ...
Definition: Device.cpp:291
~Device()
Definition: Device.cpp:59
std::string getDeviceIdentifier()
Gets the name of the currently connected device.
Definition: Device.cpp:152
PIL::Logging * m_Logger
Definition: Device.h:78
int m_destPort
Definition: Device.h:79
static bool errorOccured(PIL_ERROR_CODE errorCode)
Checks if a error occured given the error code.
Definition: Device.cpp:300
SEND_METHOD
Definition: Device.h:33
@ DIRECT_SEND
Definition: Device.h:34
@ BUFFER_ENABLED
Definition: Device.h:35
std::string m_DeviceName
Definition: Device.h:76
std::string getBufferedScript()
Transforms the current buffered script into a string and returns it.
Definition: Device.cpp:283
Device(std::string ipAddress, int timeoutInMs, SEND_METHOD mode=DIRECT_SEND, bool throwException=true)
Constructor for the Device without passing a logging object.
Definition: Device.cpp:44
ExecArgs class is used to create execution arguments based on a parameter seperator value scheme....
Definition: ExecArgs.h:15
This class contains a implementation of a command line interface. It supports various functions like ...
Definition: CommandLineInterface.h:16