|
OmronPID
|
The Communication class provides an interface for communicating with he E5CC temperature controller via Modbus protocol. More...
#include <communication.h>
Data Structures | |
| class | E5CC_Address |
| The E5CC_Address nested class defines an enum class Type for ModBus addresses used for communication with the E5CC temperature controller. More... | |
Public Types | |
| enum | timing { modbus = 300 , getTempTimer = 500 , clockUpdate = 50 , timeUp = 1000 * 60 * 10 , timeOut = 700 } |
| The timing enumeration defines various timing intervals in milliseconds. More... | |
Signals | |
| void | TemperatureUpdated (double temperature) |
| This signal is emitted when the temperature value is updated. | |
| void | MVUpdated (double MV) |
| This signal is emitted when the output power value is updated. | |
| void | SVUpdated (double SV) |
| This signal is emitted when the set value is updated. | |
| void | MVupperUpdated (double MVupper) |
| This signal is emitted when the output upper value is updated. | |
| void | MVlowerUpdated (double MVlower) |
| This signal is emitted when the output lower value is updated. | |
| void | PID_PUpdated (double PID_P) |
| Emitted when the proportional (P) gain value of the PID controller is updated. | |
| void | PID_IUpdated (double PID_I) |
| Emitted when the integral (I) gain value of the PID controller is updated. | |
| void | PID_DUpdated (double PID_D) |
| Emitted when the derivative (D) gain value of the PID controller is updated. | |
| void | ATSendFinish (int atFlag) |
| Emitted when an AT command is sent to the Omron device and the send is finished. | |
| void | SVSendFinish (double SV) |
| Emitted when a set value (SV) command is sent to the Omron device and the send is finished. | |
| void | connectTimeout () |
| Emitted when a connection attempt to the Omron device times out. | |
| void | logMsg (QString string, bool newline=true) |
| Emitted when a log message is generated. | |
| void | statusUpdate () |
| Emitted when the status of the controller is updated. | |
| void | deviceConnect () |
| Emitted when a connection to the Omron device is established. | |
| void | failedConnect () |
| Emitted when a connection to the Omron device fails. | |
| void | OmronIDChanged () |
| Emitted when the Omron device ID is changed. | |
| void | serialPortRemove (QString str) |
| Emitted when a serial port is removed from the system. | |
| void | intervalUpdateChanged (int interval) |
| Emitted when the interval for updating values is changed. | |
| void | intervalConectionCheckChanged (int interval) |
| Emitted when the interval for checking the connection is changed. | |
Public Member Functions | |
| Communication (QMainWindow *parent, QStatusBar *statusBar) | |
| Constructor for Communication class. | |
| ~Communication () | |
| Destructs a Communication object. | |
| void | request (QModbusPdu::FunctionCode code, QByteArray cmd) |
| Sends a Modbus request to the Omron device. | |
| QString | formatHex (int value, int digit) |
| Formats an integer value to a hexadecimal string with the specified number of digits. | |
| QString | formatE5CCAddress (E5CC_Address::Type address, int width=4) |
| Formats an E5CC register address as a hexadecimal string with the specified width. | |
| void | askTemperature () |
| Sends a request to get the temperature from the E5CC temperature controller. | |
| void | askMV () |
| Sends a request to get the output power from the E5CC temperature controller. | |
| void | askSV () |
| Sends a request to get the set value from the E5CC temperature controller. | |
| void | askMVupper () |
| Sends a request to get the output upper limit from the E5CC temperature controller. | |
| void | askMVlower () |
| Sends a request to get the output lower limit from the E5CC temperature controller. | |
| void | askPID (QString PID) |
| Sends a request to get the specified PID parameter from the E5CC temperature controller. | |
| void | executeConnection () |
| Executes the connection to the ModBus device. | |
| void | executeRun () |
| Executes the Run command on the ModBus device. | |
| void | executeStop () |
| Executes the Stop command on the ModBus device. | |
| void | executeSendRequestSV (double SV) |
| Sends a request to set the set value (SV) of the E5CC temperature controller. | |
| void | executeSendRequestAT (int atFlag) |
| Sends a request to set the AT flag of the E5CC temperature controller. | |
| void | changeMVlowerValue (double MVlower) |
| Changes the value of the output lower limit of the E5CC temperature controller. | |
| void | changeMVupperValue (double MVupper) |
| Changes the value of the output upper limit of the E5CC temperature controller. | |
| void | changeSVValue (double SV) |
| Changes the set value (SV) of the E5CC temperature controller. This function calculates the integer value to be sent to the temperature controller based on the given set value in degrees Celsius and the temperature decimal factor of the temperature controller. It then creates a Modbus command with the calculated value and sends it to the controller to change the SV. | |
| void | read (QModbusDataUnit::RegisterType type, quint16 adress, int size) |
| Sends a Modbus request with the specified function code and command data. | |
| void | setSerialPortName (QString portName) |
| Sets the name of the serial port to use for Modbus communication. | |
| bool | isTimerUpdateRunning () const |
| Checks if the update timer is currently running. | |
| void | setTemperature (double temperature) |
| Sets the current temperature. | |
| void | setSV (double SV) |
| Sets the set value for temperature. | |
| void | setMV (double MV) |
| Sets the current output power. | |
| void | setMVupper (double MVupper) |
| Sets the upper limit for the output power. | |
| void | setMVlower (double MVlower) |
| Sets the lower limit for the output power. | |
| void | setOmronID (int omronID) |
| Sets the Omron ID for Modbus communication. | |
| void | setIntervalUpdate (int interval) |
| Sets the interval in milliseconds for updating the temperature and output power values. | |
| void | setIntervalConectionCheck (int interval) |
| Sets the interval in milliseconds for checking the Modbus connection status. | |
| QModbusRtuSerialMaster * | getOmron () const |
| Returns a pointer to the QModbusRtuSerialMaster object used for communication with the Omron PLC. | |
| QList< QSerialPortInfo > | getSerialPortDevices () const |
| Returns a list of QSerialPortInfo objects containing information about available serial port devices. | |
| QString | getPortName () const |
| Returns the name of the currently set serial port. | |
| double | getTemperature () const |
| Gets the current temperature value. | |
| double | getMV () const |
| Gets the set value. | |
| double | getSV () const |
| Gets the current output power value. | |
| double | getMVupper () const |
| Gets the output upper value. | |
| double | getMVlower () const |
| Gets the output lower value. | |
| double | getPID_P () const |
| Returns the Proportional value of the PID control for the temperature controller. | |
| double | getPID_I () const |
| Returns the Integration value of the PID control for the temperature controller. | |
| double | getPID_D () const |
| Returns the Difference value of the PID control for the temperature controller. | |
| int | getOmronID () const |
| Returns the ID of the Omron temperature controller connected to the system. | |
| int | getIntervalUpdate () const |
| Returns the interval time in seconds at which the temperature and control data are updated. | |
| int | getIntervalConectionCheck () const |
| Returns the interval time in seconds at which the connection to the Omron temperature controller is checked. | |
| QTimer * | getTimerUpdate () const |
Properties | |
| double | Temperature |
| double | SV |
| double | MV |
| double | MVupper |
| double | MVlower |
| int | OmronID |
| int | intervalUpdate |
| int | intervalConectionCheck |
The Communication class provides an interface for communicating with he E5CC temperature controller via Modbus protocol.
The timing enumeration defines various timing intervals in milliseconds.
| Enumerator | |
|---|---|
| modbus | The time in milliseconds between Modbus communication |
| getTempTimer | The time in milliseconds between requests for temperature |
| clockUpdate | The time in milliseconds between clock updates |
| timeUp | The maximum time in milliseconds before resetting the clock |
| timeOut | The time in milliseconds before a Modbus communication times out |
| Communication::Communication | ( | QMainWindow * | parent, |
| QStatusBar * | statusBar | ||
| ) |
Constructor for Communication class.
| parent | The parent window that the Communication object belongs to. |
| statusBar | The status bar of the parent window. |
| void Communication::askPID | ( | QString | PID | ) |
Sends a request to get the specified PID parameter from the E5CC temperature controller.
Asks for the PID value specified by the parameter.
| The | PID term to read. If it is not "P", "I", or "D", all three PID terms are read. |
If the input parameter is "P", it reads the value of the PID P term, emits the PID_PUpdated signal and stores the result in the variable pid_P_. If the input parameter is "I", it reads the value of the PID I term, emits the PID_IUpdated signal and stores the result in the variable pid_I_. If the input parameter is "D", it reads the value of the PID D term, emits the PID_DUpdated signal and stores the result in the variable pid_D_. If the input parameter is not "P", "I", or "D", it reads the values of all three PID terms, emits all three corresponding signals and stores the results in the corresponding variables pid_P_, pid_I_, and pid_D_.
|
signal |
Emitted when an AT command is sent to the Omron device and the send is finished.
| atFlag | The flag indicating which AT command was sent. |
| void Communication::changeMVlowerValue | ( | double | MVlower | ) |
Changes the value of the output lower limit of the E5CC temperature controller.
| MVlower | The new value of the output lower limit. |
| void Communication::changeMVupperValue | ( | double | MVupper | ) |
Changes the value of the output upper limit of the E5CC temperature controller.
| MVupper | The new value of the output upper limit. |
| void Communication::changeSVValue | ( | double | SV | ) |
Changes the set value (SV) of the E5CC temperature controller. This function calculates the integer value to be sent to the temperature controller based on the given set value in degrees Celsius and the temperature decimal factor of the temperature controller. It then creates a Modbus command with the calculated value and sends it to the controller to change the SV.
| SV | The set value to be set in degrees Celsius. |
|
inline |
Sends a request to set the AT flag of the E5CC temperature controller.
| atFlag | The value of the AT flag to set. |
|
inline |
Sends a request to set the set value (SV) of the E5CC temperature controller.
| SV | The value to set as the set value (SV). |
| QString Communication::formatE5CCAddress | ( | E5CC_Address::Type | address, |
| int | width = 4 |
||
| ) |
Formats an E5CC register address as a hexadecimal string with the specified width.
This function takes an E5CC register address as an enumeration type and formats it as a hexadecimal string with the specified width. If the resulting string is shorter than the specified width, leading zeroes are added to the beginning of the string.
| address | The E5CC register address to format. |
| width | The width of the resulting hexadecimal string. |
| QString Communication::formatHex | ( | int | value, |
| int | digit | ||
| ) |
Formats an integer value to a hexadecimal string with the specified number of digits.
This function takes an integer value and formats it as a hexadecimal string with the specified number of digits. If the resulting string is shorter than the specified width, leading zeroes are added to the beginning of the string.
| value | The integer value to format. |
| digit | The number of digits for the resulting hexadecimal string. |
| int Communication::getIntervalConectionCheck | ( | ) | const |
Returns the interval time in seconds at which the connection to the Omron temperature controller is checked.
| int Communication::getIntervalUpdate | ( | ) | const |
Returns the interval time in seconds at which the temperature and control data are updated.
| double Communication::getMV | ( | ) | const |
Gets the set value.
| double Communication::getMVlower | ( | ) | const |
Gets the output lower value.
| double Communication::getMVupper | ( | ) | const |
Gets the output upper value.
| QModbusRtuSerialMaster * Communication::getOmron | ( | ) | const |
Returns a pointer to the QModbusRtuSerialMaster object used for communication with the Omron PLC.
| int Communication::getOmronID | ( | ) | const |
Returns the ID of the Omron temperature controller connected to the system.
| double Communication::getPID_D | ( | ) | const |
Returns the Difference value of the PID control for the temperature controller.
| double Communication::getPID_I | ( | ) | const |
Returns the Integration value of the PID control for the temperature controller.
| double Communication::getPID_P | ( | ) | const |
Returns the Proportional value of the PID control for the temperature controller.
| QString Communication::getPortName | ( | ) | const |
Returns the name of the currently set serial port.
| QList< QSerialPortInfo > Communication::getSerialPortDevices | ( | ) | const |
Returns a list of QSerialPortInfo objects containing information about available serial port devices.
| double Communication::getSV | ( | ) | const |
Gets the current output power value.
| double Communication::getTemperature | ( | ) | const |
Gets the current temperature value.
|
signal |
Emitted when the interval for checking the connection is changed.
| interval | The new interval in milliseconds. |
|
signal |
Emitted when the interval for updating values is changed.
| interval | The new interval in milliseconds. |
| bool Communication::isTimerUpdateRunning | ( | ) | const |
Checks if the update timer is currently running.
|
signal |
Emitted when a log message is generated.
| string | The log message. |
| newline | True if a new line should be added to the log message, false otherwise. |
|
signal |
This signal is emitted when the output lower value is updated.
| MVlower | The new output lower value. |
|
signal |
This signal is emitted when the output power value is updated.
| MV | The new output power value. |
|
signal |
This signal is emitted when the output upper value is updated.
| MVupper | The new output upper value. |
|
signal |
Emitted when the derivative (D) gain value of the PID controller is updated.
| PID_D | The updated PID D value. |
|
signal |
Emitted when the integral (I) gain value of the PID controller is updated.
| PID_I | The updated PID I value. |
|
signal |
Emitted when the proportional (P) gain value of the PID controller is updated.
| PID_P | The updated PID P value. |
| void Communication::read | ( | QModbusDataUnit::RegisterType | type, |
| quint16 | adress, | ||
| int | size | ||
| ) |
Sends a Modbus request with the specified function code and command data.
| code | The Modbus function code. |
| cmd | The command data to be sent. This method sends a Modbus request with the specified function code and command data to the Omron device. The status bar message is cleared and the modbusReady_ flag is set to false before the request is sent. If the request is successful, the reply is checked for errors. If there is a protocol error, the error message and exception code are displayed in the status bar. If there is another type of error, the error message and error code are displayed. Once the reply has been handled, the modbusReady_ flag is set to true and the reply is deleted. If the request fails, an error message is displayed in the status bar. |
| void Communication::request | ( | QModbusPdu::FunctionCode | code, |
| QByteArray | cmd | ||
| ) |
Sends a Modbus request to the Omron device.
| code | The function code to be sent. |
| cmd | The command to be sent. This function sends a Modbus request to the Omron device. It first clears the status bar, sets the modbusReady_ flag to false, and creates a QModbusPdu object with the provided function code and data. It then creates a QModbusRequest object with the QModbusPdu, and sends it to the Omron device using the sendRawRequest() function. If successful, it connects a lambda function to the finished() signal of the QModbusReply object returned by the sendRawRequest() function. This lambda function checks for any errors in the reply and displays the appropriate message on the status bar. If the request was a broadcast, the reply is deleted immediately. Finally, the modbusReady_ flag is set to true. |
|
signal |
Emitted when a serial port is removed from the system.
| str | The name of the removed serial port. |
| void Communication::setIntervalConectionCheck | ( | int | interval | ) |
Sets the interval in milliseconds for checking the Modbus connection status.
| interval | The interval in milliseconds to set |
| void Communication::setIntervalUpdate | ( | int | interval | ) |
Sets the interval in milliseconds for updating the temperature and output power values.
| interval | The interval in milliseconds to set |
| void Communication::setMV | ( | double | MV | ) |
Sets the current output power.
| MV | The current output power to set |
| void Communication::setMVlower | ( | double | MVlower | ) |
Sets the lower limit for the output power.
| MVlower | The lower limit for the output power to set |
| void Communication::setMVupper | ( | double | MVupper | ) |
Sets the upper limit for the output power.
| MVupper | The upper limit for the output power to set |
| void Communication::setOmronID | ( | int | omronID | ) |
Sets the Omron ID for Modbus communication.
| omronID | The Omron ID to set |
| void Communication::setSerialPortName | ( | QString | portName | ) |
Sets the name of the serial port to use for Modbus communication.
| portName | The name of the serial port to use |
| void Communication::setSV | ( | double | SV | ) |
Sets the set value for temperature.
| SV | The set value to set |
| void Communication::setTemperature | ( | double | temperature | ) |
Sets the current temperature.
| temperature | The current temperature to set |
|
signal |
Emitted when a set value (SV) command is sent to the Omron device and the send is finished.
| SV | The updated SV value. |
|
signal |
This signal is emitted when the set value is updated.
| SV | The new set value. |
|
signal |
This signal is emitted when the temperature value is updated.
| temperature | The new temperature value. |