mFrame
載入中...
搜尋中...
無符合項目
SerialBusDevice.h
1
7#ifndef MFRAME_883AFE3A_63E9_470C_B1ED_2E02C0817EF2
8#define MFRAME_883AFE3A_63E9_470C_B1ED_2E02C0817EF2
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15#include "./../io/SerialBus.h"
16#include "./../lang/Object.h"
17//----------------------------------------------------------------------------------------
18
19/* ***************************************************************************************
20 * Namespace
21 */
22namespace ufm::io {
23 class SerialBusDevice;
24} // namespace ufm::io
25
26/* ***************************************************************************************
27 * Class/Interface/Struct/Enum
28 */
29
40 /* *************************************************************************************
41 * Status
42 */
43 public:
49 enum struct State : uint8_t {
50 IDLE = 0,
51 COMPLETE = 1,
52 NO_RESPONSE = 2,
53 BUS_ERROR = 3,
54 CANCEL = 4
55 };
56 /* *************************************************************************************
57 * Variable
58 */
59 private:
60 int vCompletedQuantity;
61 State vState;
63 /* *************************************************************************************
64 * Abstract Method
65 */
66
67 /* *************************************************************************************
68 * Construct Method
69 */
70 public:
77
83 virtual ~SerialBusDevice(void) override;
84
85 /* *************************************************************************************
86 * Operator Method
87 */
88
89 /* *************************************************************************************
90 * Override Method - ufm::io::SerialBus::Event
91 */
92 public:
100 virtual void onComplete(int completedQuantity) override;
101
109 virtual void onNoResponseEvent(int completedQuantity) override;
110
118 virtual void onBusErrorEvent(int completedQuantity) override;
119
127 virtual void onCancel(int completedQuantity) override;
128
129 /* *************************************************************************************
130 * Public Method
131 */
132 public:
138 void flush(void);
139
145 inline int getCompletedQuantity(void) const {
146 return this->vCompletedQuantity;
147 }
148
154 inline State getStatus(void) const {
155 return this->vState;
156 }
157
164 inline bool isIdle(void) const {
165 return (this->vState == State::IDLE);
166 }
167
174 inline bool isComplete(void) const {
175 return (this->vState == State::COMPLETE);
176 }
177
184 inline bool isNoResponse(void) const {
185 return (this->vState == State::NO_RESPONSE);
186 }
187
194 inline bool isBusError(void) const {
195 return (this->vState == State::BUS_ERROR);
196 }
197
204 inline bool isCancel(void) const {
205 return (this->vState == State::CANCEL);
206 }
207
208 /* *************************************************************************************
209 * Protected Method
210 */
211
212 /* *************************************************************************************
213 * Private Method
214 */
215
216 /* *************************************************************************************
217 * Static Variable
218 */
219
220 /* *************************************************************************************
221 * Static Method
222 */
223};
224
225/* ***************************************************************************************
226 * End of file
227 */
228
229#endif /* MFRAME_883AFE3A_63E9_470C_B1ED_2E02C0817EF2 */
序列總線裝置類別
Definition SerialBusDevice.h:39
bool isBusError(void) const
檢查是否發生總線錯誤
Definition SerialBusDevice.h:194
virtual void onComplete(int completedQuantity) override
通訊完成事件處理
bool isCancel(void) const
檢查通訊是否被取消
Definition SerialBusDevice.h:204
State getStatus(void) const
取得目前裝置狀態
Definition SerialBusDevice.h:154
virtual ~SerialBusDevice(void) override
解構序列總線裝置物件
bool isIdle(void) const
檢查裝置是否為閒置狀態
Definition SerialBusDevice.h:164
virtual void onCancel(int completedQuantity) override
取消事件處理
virtual void onNoResponseEvent(int completedQuantity) override
無回應事件處理
SerialBusDevice(void)
建構序列總線裝置物件
int getCompletedQuantity(void) const
取得已完成傳輸的資料量
Definition SerialBusDevice.h:145
bool isNoResponse(void) const
檢查是否發生無回應錯誤
Definition SerialBusDevice.h:184
void flush(void)
清除裝置狀態
virtual void onBusErrorEvent(int completedQuantity) override
總線錯誤事件處理
State
序列總線裝置狀態列舉
Definition SerialBusDevice.h:49
bool isComplete(void) const
檢查通訊是否已完成
Definition SerialBusDevice.h:174
物件基底類別
Definition Object.h:63
輸入/輸出操作命名空間
Definition Buffer.h:24
序列總線事件處理介面
Definition SerialBus.h:241