8 #include <g3log/g3log.hpp> 9 #include <g3log/logworker.hpp> 15 int main(
int argc,
const char *argv[])
20 char *hostname = zsys_hostname();
25 auto worker = g3::LogWorker::createLogWorker();
26 worker->addDefaultLogger(
"swarmio-simulator",
".");
27 initializeLogging(worker.get());
28 std::string configFilePath =
"";
29 for (
int i = 1; i < argc; ++i)
31 const char *current = argv[i];
32 if (current[0] ==
'-')
34 if (current[1] ==
'C')
37 configFilePath = current + 2;
42 LOG(FATAL) <<
"Command line argument " << i <<
" is unknown";
48 LOG(FATAL) <<
"Command line argument " << i <<
" cannot be processed";
54 std::cout <<
"Local node started with UUID: " << endpoint.
GetUUID() <<
"\n";
61 value.set_string_value(
"This won't ever change.");
65 value.set_string_value(
"And neither will this.");
70 auto &pairs = *value.mutable_map_value()->mutable_pairs();
71 pairs[
"key1"].set_string_value(
"value1");
72 pairs[
"key2"].set_uint_value(2);
73 pairs[
"key3"].set_int_value(-3);
74 auto &pairs2 = *pairs[
"key4"].mutable_map_value()->mutable_pairs();
75 pairs2[
"embedded1"].set_string_value(
"subvalue1");
76 pairs2[
"embedded2"].set_uint_value(2);
81 auto &elements = *value.mutable_int_array();
82 elements.add_elements(30);
83 elements.add_elements(55);
84 elements.add_elements(0);
85 elements.add_elements(-45);
86 elements.add_elements(900);
104 e1.
AddParameter(
"severity", data::discovery::Type::INT);
117 std::cout <<
"Press ENTER to stop the simulator." 124 pathSimulator.Stop();
A special event handler that serves discovery information and ignores the event itself.
virtual void Stop() override
Send a termination signal and wait until the endpoint finished processing messages.
Simulates linear back-and-forth movement between two points.
void SetConfig(std::string cfg)
Set the config file path.
virtual const std::string & GetUUID() override
Get the UUID of the local node.
A strongly typed in-memory parameter target that can be made read-only.
void AddFauxEventHandler(FauxEventHandler *eventHandler)
Add an event handler and register it.
void AddInMemoryParameter(InMemoryParameter *parameter)
Add an In-Memory Parameter and register it.
A location described by a latitude, a longitude and an altitude.
swarmio::services::telemetry::Service & GetTelemetryService()
Get a reference for the Telemetry service.
void AddParameter(const std::string &key, data::discovery::Type type)
Add a new parameter to serve for discovery.
An Endpoint implementation using the Zyre protocol.
int main(int argc, const char *argv[])
Represents a collection of standard services that can be used to simulate an ordinary device...
virtual void Start() override
Start the background thread, announce the Zyre node and start processing messages.
void AddConstantTelemetryValue(const std::string &key, const data::Variant &value, bool includeInStatus=false)
Add a constant telemetry value.