LinearPathTelemetrySimulator.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include <chrono>
6 #include <memory>
7 #include <thread>
8 
9 namespace swarmio::simulator
10 {
17  {
18  private:
19 
24  std::unique_ptr<std::thread> _thread;
25 
30  std::atomic<bool> _shouldStop;
31 
37 
42  std::string _name;
43 
49 
55 
60  std::chrono::seconds _duration;
61 
66  void Worker();
67 
68  public:
69 
79  LinearPathTelemetrySimulator(services::telemetry::Service& telemetryService, const std::string& name, SimulatedLocation firstPoint, SimulatedLocation secondPoint, std::chrono::seconds duration);
80 
85  void Stop()
86  {
87  if (_thread)
88  {
89  _shouldStop = true;
90  _thread->join();
91  _thread.reset();
92  }
93  }
94 
100  {
101  Stop();
102  _telemetryService.RemoveFieldDefinitionForKey(_name);
103  _telemetryService.RemoveValue(_name);
104  }
105  };
106 }
void RemoveValue(const std::string &key)
Remove a value from the local telemetry cache.
Telemetry Service can subscribe to receive updates from remote nodes on named values.
Simulates linear back-and-forth movement between two points.
std::unique_ptr< std::thread > _thread
Worker thread.
A location described by a latitude, a longitude and an altitude.
void RemoveFieldDefinitionForKey(const std::string &key)
Remove a field from the schema.
services::telemetry::Service & _telemetryService
Telemetry service.
std::chrono::seconds _duration
Time it takes to complete one trip.
LinearPathTelemetrySimulator(services::telemetry::Service &telemetryService, const std::string &name, SimulatedLocation firstPoint, SimulatedLocation secondPoint, std::chrono::seconds duration)
Constructor.


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48