2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include "ConnectionAcknowledgedCommandHandler.hpp"
8 #include <armnn/Exceptions.hpp>
10 #include <boost/format.hpp>
18 void ConnectionAcknowledgedCommandHandler::operator()(const Packet& packet)
20 ProfilingState currentState = m_StateMachine.GetCurrentState();
23 case ProfilingState::Uninitialised:
24 case ProfilingState::NotConnected:
25 throw RuntimeException(boost::str(boost::format("Connection Acknowledged Command Handler invoked while in an "
27 % GetProfilingStateName(currentState)));
28 case ProfilingState::WaitingForAck:
30 if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 1u))
32 throw armnn::InvalidArgumentException(boost::str(boost::format("Expected Packet family = 0, id = 1 but "
33 "received family = %1%, id = %2%")
34 % packet.GetPacketFamily()
35 % packet.GetPacketId()));
38 // Once a Connection Acknowledged packet has been received, move to the Active state immediately
39 m_StateMachine.TransitionToState(ProfilingState::Active);
41 m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory);
43 // Notify the Send Thread that new data is available in the Counter Stream Buffer
44 m_SendCounterPacket.SetReadyToRead();
47 case ProfilingState::Active:
50 throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
51 % static_cast<int>(currentState)));
55 } // namespace profiling