Commit | Line | Data |
---|---|---|
9a2167bd CB |
1 | /* |
2 | * Copyright (C) 2013 Freescale Semiconductor, Inc. | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | * of this software and associated documentation files (the "Software"), to deal | |
6 | * in the Software without restriction, including without limitation the rights | |
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | * copies of the Software, and to permit persons to whom the Software is | |
9 | * furnished to do so, subject to the following conditions: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included | |
12 | * in all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
20 | * IN THE SOFTWARE. | |
21 | */ | |
22 | ||
23 | #ifndef AUXMESSAGEPROTOCOL_H | |
24 | #define AUXMESSAGEPROTOCOL_H | |
25 | ||
26 | #include "NxPacketSet.h" | |
27 | #include <inttypes.h> | |
28 | ||
29 | class MSEState; | |
30 | ||
31 | /*! | |
32 | @discussion The AUXMessageProtocol is responsible for accepting MSEO data beats | |
33 | and determining how the calling object is to disposition the MDO. | |
34 | Implements the state machine on page 91 of the IEEE-ISTO 5001-2003 specification. | |
35 | ||
36 | The AUXMessageProtocl also provides the appropriate action on the data base on the current state | |
37 | */ | |
38 | class AUXMessageProtocol | |
39 | { | |
40 | public: | |
41 | ||
42 | // all possible outcomes of the protocol | |
43 | enum Outcome | |
44 | { | |
45 | DISCARD, // MDO is invalid | |
46 | ADD_NEW_MESSAGE, // MDO begins first packet of mew message | |
47 | ADD_CURRENT, // MDO adds to current packet | |
48 | ADD_LAST_PACKET, // MDO ends the current packet | |
49 | ADD_LAST_MESSAGE // MDO ends the current message | |
50 | }; | |
51 | ||
52 | AUXMessageProtocol(); | |
53 | ~AUXMessageProtocol(); | |
54 | ||
55 | // Evaluate the correct protocol state transition based on the current state and the MSE | |
56 | // input mse - the MSE for each data beat | |
57 | // output outcome - the result of the protocol evaluation | |
58 | // return true if no processing errors | |
59 | bool evaluate(uint32_t mse, Outcome &outcome); | |
60 | ||
61 | // input mdo - the MDO for each data beat | |
62 | // input packet set - process the data into the packet set | |
63 | // return true if no processing error | |
64 | bool act(uint32_t mdo, NxPacketSet &pkt_set); | |
65 | ||
66 | // set the verbosity | |
67 | void verbose(bool verbose) | |
68 | { | |
69 | verbose_ = verbose; | |
70 | } | |
71 | ||
72 | // return text representing the outcome | |
73 | const char * outcomeText(Outcome outcome) const; | |
74 | ||
75 | private: | |
76 | ||
77 | bool verbose_; | |
78 | ||
79 | // Create all the possible protocol states | |
80 | MSEState *idle_; | |
81 | MSEState *start_message_; | |
82 | MSEState *normal_transfer_; | |
83 | MSEState *end_packet_; | |
84 | MSEState *end_message_; | |
85 | ||
86 | // current state | |
87 | MSEState *current_state_; | |
88 | ||
89 | }; | |
90 | ||
91 | #endif // AUXMESSAGEPROTOCOL_H |