EMANE  1.0.1
agent.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014,2016 - Adjacent Link LLC, Bridgewater, New
3  * Jersey
4  * Copyright (c) 2008 - DRS CenGen, LLC, Columbia, Maryland
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of DRS CenGen, LLC nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef EMANEAGENTSGPSDLOCATIONAGENT_HEADER_
36 #define EMANEAGENTSGPSDLOCATIONAGENT_HEADER_
37 
38 #include "emane/eventagent.h"
39 #include "emane/types.h"
40 
41 #include <string>
42 
43 namespace EMANE
44 {
45  namespace Agents
46  {
47  namespace GPSDLocation
48  {
54  class Agent : public EventAgent
55  {
56  public:
57  Agent(NEMId nemId,
58  PlatformServiceProvider *pPlatformService);
59 
60  ~Agent();
61 
62  void initialize(Registrar & registrar) override;
63 
64  void configure(const ConfigurationUpdate & update) override;
65 
66  void start() override;
67 
68  void stop() override;
69 
70  void destroy() throw() override;
71 
72  void processEvent(const EventId&,
73  const Serialization &) override;
74 
75  void processTimedEvent(TimerEventId eventId,
76  const TimePoint & expireTime,
77  const TimePoint & scheduleTime,
78  const TimePoint & fireTime,
79  const void * arg) override;
80 
81  private:
82  NEMId nemId_;
83  int masterPTY_;
84  int slavePTY_;
85  std::string sClientPTTYName_;
86  std::string sPseudoTerminalFile_;
87  std::string sPseudoTerminalNameFile_;
88  bool bHaveInitialPosition_;
89  bool bHaveInitialVelocity_;
90  double dLatitudeDegrees_;
91  double dLongitudeDegrees_;
92  double dAltitudeMeters_;
93  double dAzimuthDegrees_;
94  double dMagnitudeMetersPerSecond_;
95  TimerEventId timerId_;
96 
105  void sendSpoofedNMEA(double dLatitude, double dLongitude, double dAltitude);
106 
114  void sendSpoofedGPVTG(double dAzimuth, double dMagnitude);
115 
116  void doCheckSumNMEA(char *buf, size_t len);
117  };
118  }
119  }
120 }
121 
122 #endif // EMANEAGENTSGPSDLOCATIONAGENT_HEADER_
std::string Serialization
Definition: serializable.h:42
The Registrar interface provides access to all of the emulator registrars.
Definition: registrar.h:50
void initialize(Registrar &registrar) override
Definition: agent.cc:67
void processTimedEvent(TimerEventId eventId, const TimePoint &expireTime, const TimePoint &scheduleTime, const TimePoint &fireTime, const void *arg) override
Definition: agent.cc:209
std::uint16_t EventId
Definition: types.h:53
The PlatformServiceProvider interface provides access to emulator services.
Agent(NEMId nemId, PlatformServiceProvider *pPlatformService)
Definition: agent.cc:50
void processEvent(const EventId &, const Serialization &) override
Definition: agent.cc:168
Base class for all event agents.
Definition: eventagent.h:52
std::uint16_t NEMId
Definition: types.h:52
void configure(const ConfigurationUpdate &update) override
Definition: agent.cc:81
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
Agent translating location events to NMEA gpsd messages.
Definition: agent.h:54
std::size_t TimerEventId
Definition: types.h:54
Clock::time_point TimePoint
Definition: types.h:50
Definition: agent.h:43