13 #include <common/include/CommandHandlerRegistry.hpp> 14 #include <common/include/Packet.hpp> 15 #include <common/include/PacketVersionResolver.hpp> 17 #include <server/include/basePipeServer/BasePipeServer.hpp> 19 #include <server/include/timelineDecoder/TimelineDecoder.hpp> 20 #include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp> 21 #include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp> 43 GatordMockService(std::unique_ptr<arm::pipe::BasePipeServer> clientConnection,
bool echoPackets)
44 : m_BasePipeServer(
std::move(clientConnection))
45 , m_EchoPackets(echoPackets)
46 , m_CloseReceivingThread(
false)
47 , m_PacketVersionResolver()
50 , m_CounterCaptureCommandHandler(
51 0, 4, m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(), !echoPackets)
52 , m_StreamMetadataCommandHandler(
53 0, 0, m_PacketVersionResolver.ResolvePacketVersion(0, 0).GetEncodedValue(), !echoPackets)
55 , m_StubCommandHandler(3, 0, m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue())
56 , m_DirectoryCaptureCommandHandler(
57 0, 2, m_PacketVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), !echoPackets)
58 , m_TimelineCaptureCommandHandler(
59 1, 1, m_PacketVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), m_TimelineDecoder)
60 , m_TimelineDirectoryCaptureCommandHandler(
61 1, 0, m_PacketVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(),
62 m_TimelineCaptureCommandHandler, !echoPackets)
64 m_TimelineDecoder.SetDefaultCallbacks();
66 m_HandlerRegistry.RegisterFunctor(&m_CounterCaptureCommandHandler);
67 m_HandlerRegistry.RegisterFunctor(&m_StreamMetadataCommandHandler);
68 m_HandlerRegistry.RegisterFunctor(&m_StubCommandHandler);
69 m_HandlerRegistry.RegisterFunctor(&m_DirectoryCaptureCommandHandler);
70 m_HandlerRegistry.RegisterFunctor(&m_TimelineDirectoryCaptureCommandHandler);
71 m_HandlerRegistry.RegisterFunctor(&m_TimelineCaptureCommandHandler);
104 return m_PacketsReceivedCount.load(std::memory_order_acquire);
114 return !m_CloseReceivingThread.load();
125 return m_DirectoryCaptureCommandHandler;
130 return m_TimelineDecoder;
135 return m_TimelineDirectoryCaptureCommandHandler;
141 std::unique_ptr<arm::pipe::BasePipeServer> m_BasePipeServer;
143 std::atomic<uint32_t> m_PacketsReceivedCount;
146 std::thread m_ListeningThread;
147 std::atomic<bool> m_CloseReceivingThread;
149 arm::pipe::PacketVersionResolver m_PacketVersionResolver;
150 arm::pipe::CommandHandlerRegistry m_HandlerRegistry;
152 arm::pipe::TimelineDecoder m_TimelineDecoder;
160 arm::pipe::TimelineCaptureCommandHandler m_TimelineCaptureCommandHandler;
161 arm::pipe::TimelineDirectoryCaptureCommandHandler m_TimelineDirectoryCaptureCommandHandler;
arm::pipe::TimelineDirectoryCaptureCommandHandler & GetTimelineDirectoryCaptureCommandHandler()
Copyright (c) 2021 ARM Limited and Contributors.
void SendDeactivateTimelinePacket()
Send a deactivate timeline packet back to the client.
void SendActivateTimelinePacket()
Send a activate timeline packet back to the client.
bool WaitForStreamMetaData()
Once the connection is open wait to receive the stream meta data packet from the client.
void SendRequestCounterDir()
Send a request counter directory packet back to the client.
bool ReceiveThreadRunning()
arm::pipe::TimelineDecoder & GetTimelineDecoder()
bool LaunchReceivingThread()
Start the thread that will receive all packets and print them nicely to stdout.
profiling::DirectoryCaptureCommandHandler & GetDirectoryCaptureCommandHandler()
A class that implements a Mock Gatord server.
uint32_t GetPacketsReceivedCount()
Return the total number of periodic counter capture packets received since the receive thread started...
void WaitCommand(uint32_t timeout)
Execute the WAIT command from the comamnd file.
void SendPeriodicCounterSelectionList(uint32_t period, std::vector< uint16_t > counters)
Send the counter list to ArmNN.
void WaitForReceivingThread()
This is a placeholder method to prevent main exiting.
GatordMockService(std::unique_ptr< arm::pipe::BasePipeServer > clientConnection, bool echoPackets)
GatordMockService & operator=(const GatordMockService &)=delete
void SendConnectionAck()
Send a connection acknowledged packet back to the client.