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/DirectoryCaptureCommandHandler.hpp> 20 #include <server/include/timelineDecoder/TimelineDecoder.hpp> 21 #include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp> 22 #include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp> 41 GatordMockService(std::unique_ptr<arm::pipe::BasePipeServer> clientConnection,
bool echoPackets)
42 : m_BasePipeServer(
std::move(clientConnection))
43 , m_EchoPackets(echoPackets)
44 , m_CloseReceivingThread(false)
45 , m_PacketVersionResolver()
48 , m_CounterCaptureCommandHandler(
49 0, 4, m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(), !echoPackets)
50 , m_StreamMetadataCommandHandler(
51 0, 0, m_PacketVersionResolver.ResolvePacketVersion(0, 0).GetEncodedValue(), !echoPackets)
53 , m_StubCommandHandler(3, 0, m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue())
54 , m_DirectoryCaptureCommandHandler(
55 "ARMNN", 0, 2, m_PacketVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), !echoPackets)
56 , m_TimelineCaptureCommandHandler(
57 1, 1, m_PacketVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), m_TimelineDecoder)
58 , m_TimelineDirectoryCaptureCommandHandler(
59 1, 0, m_PacketVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(),
60 m_TimelineCaptureCommandHandler, !echoPackets)
62 m_TimelineDecoder.SetDefaultCallbacks();
64 m_HandlerRegistry.RegisterFunctor(&m_CounterCaptureCommandHandler);
65 m_HandlerRegistry.RegisterFunctor(&m_StreamMetadataCommandHandler);
66 m_HandlerRegistry.RegisterFunctor(&m_StubCommandHandler);
67 m_HandlerRegistry.RegisterFunctor(&m_DirectoryCaptureCommandHandler);
68 m_HandlerRegistry.RegisterFunctor(&m_TimelineDirectoryCaptureCommandHandler);
69 m_HandlerRegistry.RegisterFunctor(&m_TimelineCaptureCommandHandler);
102 return m_PacketsReceivedCount.load(std::memory_order_acquire);
112 return !m_CloseReceivingThread.load();
123 return m_DirectoryCaptureCommandHandler;
128 return m_TimelineDecoder;
133 return m_TimelineDirectoryCaptureCommandHandler;
139 std::unique_ptr<arm::pipe::BasePipeServer> m_BasePipeServer;
141 std::atomic<uint32_t> m_PacketsReceivedCount;
144 std::thread m_ListeningThread;
145 std::atomic<bool> m_CloseReceivingThread;
147 arm::pipe::PacketVersionResolver m_PacketVersionResolver;
148 arm::pipe::CommandHandlerRegistry m_HandlerRegistry;
150 arm::pipe::TimelineDecoder m_TimelineDecoder;
156 arm::pipe::DirectoryCaptureCommandHandler m_DirectoryCaptureCommandHandler;
158 arm::pipe::TimelineCaptureCommandHandler m_TimelineCaptureCommandHandler;
159 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.
arm::pipe::DirectoryCaptureCommandHandler & GetDirectoryCaptureCommandHandler()
bool ReceiveThreadRunning()
arm::pipe::TimelineDecoder & GetTimelineDecoder()
bool LaunchReceivingThread()
Start the thread that will receive all packets and print them nicely to stdout.
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.