API
 
Loading...
Searching...
No Matches
modbus_exception.hpp
Go to the documentation of this file.
1/** \file modbus_exception.hpp
2 * \brief Exception types for the MagAO-X Modbus client.
3 *
4 * \author Jared R. Males (jaredmales@gmail.com)
5 */
6
7#ifndef MODBUSPP_MODBUS_EXCEPTION_H
8#define MODBUSPP_MODBUS_EXCEPTION_H
9
10#include <exception>
11#include <string>
12
13/// Modbus Exception Class
14/**
15 * Modbus Exeception Super Class
16 *
17 * Throwed when a exception or errors happens in modbus protocol
18 */
19class modbus_exception : public std::exception
20{
21 public:
22 std::string msg;
23 virtual const char *what() const throw()
24 {
25 return "A Error In Modbus Happened!";
26 }
27};
28
29/// Modbus Connect Exception
30/**
31 * Connection Issue
32 *
33 * Throwed when a connection issues happens between modbus client and server
34 */
36{
37 public:
38 virtual const char *what() const throw()
39 {
40 if( !msg.empty() )
41 {
42 return msg.c_str();
43 }
44
45 return "Having Modbus Connection Problem";
46 }
47};
48
49/// Modbus Illgal Function Exception
50/**
51 * Illegal Function
52 *
53 * Throwed when modbus server return error response function 0x01
54 */
56{
57 public:
58 virtual const char *what() const throw()
59 {
60 return "Illegal Function";
61 }
62};
63
64/// Modbus Illegal Address Exception
65/**
66 * Illegal Address
67 *
68 * Throwed when modbus server return error response function 0x02
69 */
71{
72 public:
74 {
75 msg = "test";
76 }
77
78 const char *what() const throw()
79 {
80 return "Illegal Address";
81 }
82};
83
84/// Modbus Illegal Data Value Exception
85/**
86 * Illegal Data Vlaue
87 *
88 * Throwed when modbus server return error response function 0x03
89 */
91{
92 public:
93 virtual const char *what() const throw()
94 {
95 return "Illegal Data Value";
96 }
97};
98
99/// Modbus Server Failure Exception
100/**
101 * Server Failure
102 *
103 * Throwed when modbus server return error response function 0x04
104 */
106{
107 public:
108 virtual const char *what() const throw()
109 {
110 return "Server Failure";
111 }
112};
113
114/// Modbus Acknowledge Exception
115/**
116 * Acknowledge
117 *
118 * Throwed when modbus server return error response function 0x05
119 */
121{
122 public:
123 virtual const char *what() const throw()
124 {
125 return "Acknowledge";
126 }
127};
128
129/// Modbus Server Busy Exception
130/**
131 * Server Busy
132 *
133 * Throwed when modbus server return error response function 0x06
134 */
136{
137 public:
138 virtual const char *what() const throw()
139 {
140 return "Server Busy";
141 }
142};
143
144/// Modbus Gate Way Problem Exception
145/**
146 * Gate Way Problem
147 *
148 * Throwed when modbus server return error response function 0x0A and 0x0B
149 */
151{
152 public:
153 virtual const char *what() const throw()
154 {
155 return "Gateway Problem";
156 }
157};
158
159/// Modbus Buffer Exception
160/**
161 * Buffer Exception
162 *
163 * Throwed when buffer is too small for the data to be storaged.
164 */
166{
167 public:
168 virtual const char *what() const throw()
169 {
170 return "Size of Buffer Is too Small!";
171 }
172};
173
174/// Modbus Amount Exception
175/**
176 * Amount Exception
177 *
178 * Throwed when the address or amount input is mismatching.
179 */
181{
182 public:
183 virtual const char *what() const throw()
184 {
185 return "Too many Data!";
186 }
187};
188
189#endif // MODBUSPP_MODBUS_EXCEPTION_H
Modbus Acknowledge Exception.
virtual const char * what() const
Modbus Amount Exception.
virtual const char * what() const
Modbus Buffer Exception.
virtual const char * what() const
Modbus Connect Exception.
virtual const char * what() const
Modbus Exception Class.
virtual const char * what() const
Modbus Gate Way Problem Exception.
virtual const char * what() const
Modbus Illegal Address Exception.
Modbus Illegal Data Value Exception.
virtual const char * what() const
Modbus Illgal Function Exception.
virtual const char * what() const
Modbus Server Busy Exception.
virtual const char * what() const
Modbus Server Failure Exception.
virtual const char * what() const