From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- ...mnn_1_1gatordmock_1_1_command_file_parser.xhtml | 172 +++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 20.02/classarmnn_1_1gatordmock_1_1_command_file_parser.xhtml (limited to '20.02/classarmnn_1_1gatordmock_1_1_command_file_parser.xhtml') diff --git a/20.02/classarmnn_1_1gatordmock_1_1_command_file_parser.xhtml b/20.02/classarmnn_1_1gatordmock_1_1_command_file_parser.xhtml new file mode 100644 index 0000000000..ae04257507 --- /dev/null +++ b/20.02/classarmnn_1_1gatordmock_1_1_command_file_parser.xhtml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + +ArmNN: CommandFileParser Class Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
CommandFileParser Class Reference
+
+
+ +

This class parses a command file for the GatordMockService. + More...

+ +

#include <CommandFileParser.hpp>

+ + + + +

+Public Member Functions

void ParseFile (std::string CommandFile, GatordMockService &mockService)
 
+

Detailed Description

+

This class parses a command file for the GatordMockService.

+

The file contains one command per line. Valid commands are: SET and WAIT.

+

SET: Will construct and send a PeriodicCounterSelection packet to enable a set of counters. WAIT: Will pause for a set period of time to allow for data to be received.

+ +

Definition at line 22 of file CommandFileParser.hpp.

+

Member Function Documentation

+ +

◆ ParseFile()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void ParseFile (std::string CommandFile,
GatordMockServicemockService 
)
+
+ +

Definition at line 19 of file CommandFileParser.cpp.

+ +

References GatordMockService::ReceiveThreadRunning(), GatordMockService::SendPeriodicCounterSelectionList(), GatordMockService::SendRequestCounterDir(), and GatordMockService::WaitCommand().

+ +

Referenced by main().

+
20 {
21  std::ifstream infile(CommandFile);
22  std::string line;
23 
24  std::cout << "Parsing command file: " << CommandFile << std::endl;
25 
26  while (mockService.ReceiveThreadRunning() && std::getline(infile, line))
27  {
28  std::istringstream iss(line);
29  std::vector<std::string> tokens;
30 
31  std::copy(std::istream_iterator<std::string>(iss), std::istream_iterator<std::string>(),
32  std::back_inserter(tokens));
33  if (tokens.size() > 0)
34  {
35  std::string command = tokens[0];
36  if (command == "LIST")
37  {
38  // Expected format for the SET command
39  //
40  // LIST
41  //
42 
43  mockService.SendRequestCounterDir();
44  }
45  if (command == "SET")
46  {
47  // Expected format for the SET command
48  //
49  // SET 500000 1 2 5 10
50  //
51  // This breaks down to:
52  // SET command
53  // 500000 polling period in micro seconds
54  // 1 2 5 10 counter list
55 
56  if (tokens.size() > 2) // minimum of 3 tokens.
57  {
58  uint32_t period = static_cast<uint32_t>(std::stoul(tokens[1]));
59 
60  std::vector<uint16_t> counters;
61 
62  std::transform(tokens.begin() + 2, tokens.end(), std::back_inserter(counters),
63  [](const std::string& str)
64  { return static_cast<uint16_t>(std::stoul(str)); });
65 
66  mockService.SendPeriodicCounterSelectionList(period, counters);
67  }
68  else
69  {
70  std::cerr << "Invalid SET command. Format is: SET <polling period> <id list>" << std::endl;
71  }
72  }
73  else if (command == "WAIT")
74  {
75  // Expected format for the SET command
76  //
77  // WAIT 11000000
78  //
79  // This breaks down to:
80  // WAIT command
81  // 11000000 timeout period in micro seconds
82  if (tokens.size() > 1) // minimum of 2 tokens.
83  {
84  uint32_t timeout = static_cast<uint32_t>(std::stoul(tokens[1]));
85  mockService.WaitCommand(timeout);
86  }
87  else
88  {
89  std::cerr << "Invalid WAIT command. Format is: WAIT <interval>" << std::endl;
90  }
91  }
92  }
93  }
94 }
+
+
+
The documentation for this class was generated from the following files: +
+
+ + + + -- cgit v1.2.1