2 * Copyright (C) 2013 Freescale Semiconductor, Inc.
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:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
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
27 #include "AUXMessageProtocol.h"
28 #include "NxPacketSet.h"
33 // Abstract MSEState to contain the transition tables
34 // and the state specific outcomes.
39 // Constructor to allow initialization of the state information
40 MSEState(AUXMessageProtocol::Outcome outcome
, const char *name
) :
41 outcome_(outcome
), state_name_(name
)
48 // update to the next state
49 virtual MSEState
*nextState(uint32_t mse
);
51 // return the outcome for this state
52 virtual AUXMessageProtocol::Outcome
outcome() const
57 // perform the action on the MDO for this state
58 virtual bool act(uint32_t mdo
, NxPacketSet
&pkt_set
) = 0;
60 // initialize the state transition table
61 void initialize_transitions(MSEState
*new_state_00
,
62 MSEState
*new_state_01
, MSEState
*new_state_10
,
63 MSEState
*new_state_11
);
66 const char* name() const
68 return state_name_
.c_str();
71 // indicates if an optimized single beat message is being processed
72 // shared across all states
73 static bool start_optimized_message_
;
76 // Number of possible transitions from every state
77 static const uint32_t MAX_STATE_TRANSITIONS
= 4;
79 // table of next states based on MSE value
80 MSEState
*next_state_
[MAX_STATE_TRANSITIONS
];
82 // The result of being in a state
83 AUXMessageProtocol::Outcome outcome_
;
86 const string state_name_
;
90 class MSEIdle
: public MSEState
95 MSEState(AUXMessageProtocol::DISCARD
, "IDLE")
102 // update to the next state
103 virtual MSEState
*nextState(uint32_t mse
);
105 // perform the action on the MDO for this state
106 virtual bool act(uint32_t mdo
, NxPacketSet
&pkt_set
);
111 class MSEStartMessage
: public MSEState
116 MSEState(AUXMessageProtocol::ADD_NEW_MESSAGE
, "START_MESSAGE")
119 virtual ~MSEStartMessage()
123 // perform the action on the MDO for this state
124 virtual bool act(uint32_t mdo
, NxPacketSet
&pkt_set
);
128 class MSENormalTransfer
: public MSEState
132 MSENormalTransfer() :
133 MSEState(AUXMessageProtocol::ADD_CURRENT
, "NORMAL_TRANSFER")
136 virtual ~MSENormalTransfer()
140 // perform the action on the MDO for this state
141 virtual bool act(uint32_t mdo
, NxPacketSet
&pkt_set
);
145 class MSEEndPacket
: public MSEState
150 MSEState(AUXMessageProtocol::ADD_LAST_PACKET
, "END_PACKET")
153 virtual ~MSEEndPacket()
157 // perform the action on the MDO for this state
158 virtual bool act(uint32_t mdo
, NxPacketSet
&pkt_set
);
162 class MSEEndMessage
: public MSEState
167 MSEState(AUXMessageProtocol::ADD_LAST_MESSAGE
, "END_MESSAGE")
170 virtual ~MSEEndMessage()
174 // update to the next state
175 virtual MSEState
*nextState(uint32_t mse
);
177 // perform the action on the MDO for this state
178 virtual bool act(uint32_t mdo
, NxPacketSet
&pkt_set
);
This page took 0.039184 seconds and 4 git commands to generate.