fe_gps_port_impl.h
Go to the documentation of this file.
1 /*
2  * This file is protected by Copyright. Please refer to the COPYRIGHT file
3  * distributed with this source distribution.
4  *
5  * This file is part of REDHAWK frontendInterfaces.
6  *
7  * REDHAWK frontendInterfaces is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * REDHAWK frontendInterfaces is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program. If not, see http://www.gnu.org/licenses/.
19  */
20 #ifndef FE_GPS_PORT_H
21 #define FE_GPS_PORT_H
22 
23 #include "fe_port_impl.h"
24 
25 #include <redhawk/FRONTEND/GPS.h>
26 
27 namespace frontend {
28 
30  public:
31  virtual frontend::GPSInfo get_gps_info(const std::string& port_name) {
32  return frontend::GPSInfo();
33  }
34  virtual void set_gps_info(const std::string& port_name, const frontend::GPSInfo &gps_info) {
35  }
36  virtual frontend::GpsTimePos get_gps_time_pos(const std::string& port_name) {
37  return frontend::GpsTimePos();
38  }
39  virtual void set_gps_time_pos(const std::string& port_name, const frontend::GpsTimePos &gps_time_pos) {
40  }
41  };
42  // ----------------------------------------------------------------------------------------
43  // InGPSPort declaration
44  // ----------------------------------------------------------------------------------------
45  class InGPSPort : public POA_FRONTEND::GPS, public Port_Provides_base_impl
46  {
47  public:
48  InGPSPort(std::string port_name, gps_delegation *_parent) :
49  Port_Provides_base_impl(port_name)
50  {
51  parent = _parent;
52  };
53  ~InGPSPort() {};
54 
55  FRONTEND::GPSInfo* gps_info() {
56  boost::mutex::scoped_lock lock(portAccess);
57  frontend::GPSInfo retval = this->parent->get_gps_info(this->name);
58  FRONTEND::GPSInfo* tmpVal = frontend::returnGPSInfo(retval);
59  return tmpVal;
60  };
61  void gps_info(const FRONTEND::GPSInfo &gps) {
62  boost::mutex::scoped_lock lock(portAccess);
63  frontend::GPSInfo input = frontend::returnGPSInfo(gps);
64  this->parent->set_gps_info(this->name, input);
65  return;
66  };
67  FRONTEND::GpsTimePos* gps_time_pos() {
68  boost::mutex::scoped_lock lock(portAccess);
69  frontend::GpsTimePos retval = this->parent->get_gps_time_pos(this->name);
70  FRONTEND::GpsTimePos* tmpVal = frontend::returnGpsTimePos(retval);
71  return tmpVal;
72  };
73  void gps_time_pos(const FRONTEND::GpsTimePos& gps_time_pos) {
74  boost::mutex::scoped_lock lock(portAccess);
75  frontend::GpsTimePos input = frontend::returnGpsTimePos(gps_time_pos);
76  this->parent->set_gps_time_pos(this->name, input);
77  return;
78  };
79  std::string getRepid() const {
80  return "IDL:FRONTEND/GPS:1.0";
81  };
82 
83  protected:
85  boost::mutex portAccess;
86  };
87 
88  // ----------------------------------------------------------------------------------------
89  // OutGPSPort declaration
90  // ----------------------------------------------------------------------------------------
91  template<typename PortType_var, typename PortType>
92  class OutGPSPortT : public OutFrontendPort<PortType_var,PortType>
93  {
94  public:
95  OutGPSPortT(std::string port_name) : OutFrontendPort<PortType_var, PortType>(port_name)
96  {};
98 
99  frontend::GPSInfo gps_info() {
100  frontend::GPSInfo retval;
101  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
102  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
103  if (this->active) {
104  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
105  try {
106  const FRONTEND::GPSInfo_var tmp = ((*i).first)->gps_info();
107  retval = frontend::returnGPSInfo(tmp);
108  } catch(...) {
109  }
110  }
111  }
112  return retval;
113  };
114  void gps_info(const frontend::GPSInfo &gps) {
115  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
116  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
117  if (this->active) {
118  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
119  try {
120  const FRONTEND::GPSInfo_var tmp = frontend::returnGPSInfo(gps);
121  ((*i).first)->gps_info(tmp);
122  } catch(...) {
123  }
124  }
125  }
126  return;
127  };
128  frontend::GpsTimePos gps_time_pos() {
129  frontend::RFInfoPkt retval;
130  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
131  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
132  if (this->active) {
133  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
134  try {
135  const FRONTEND::GpsTimePos_var tmp = ((*i).first)->gps_time_pos();
136  retval = frontend::returnGpsTimePos(tmp);
137  } catch(...) {
138  }
139  }
140  }
141  return retval;
142  };
143  void gps_time_pos(frontend::GpsTimePos gps_time_pos) {
144  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
145  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
146  if (this->active) {
147  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
148  try {
149  const FRONTEND::GpsTimePos_var tmp = frontend::returnGpsTimePos(gps_time_pos);
150  ((*i).first)->gps_time_pos(tmp);
151  } catch(...) {
152  }
153  }
154  }
155  return;
156  };
157 
158  };
159  class OutGPSPort : public OutGPSPortT<FRONTEND::GPS_var,FRONTEND::GPS> {
160  public:
161  OutGPSPort(std::string port_name) : OutGPSPortT<FRONTEND::GPS_var,FRONTEND::GPS>(port_name)
162  {};
163  };
164 
165 } // end of frontend namespace
166 
167 
168 #endif
std::string name
Definition: Port_impl.h:316
virtual frontend::GpsTimePos get_gps_time_pos(const std::string &port_name)
Definition: fe_gps_port_impl.h:36
FRONTEND::GPSInfo * returnGPSInfo(const frontend::GPSInfo &val)
Definition: fe_port_impl.h:107
OutGPSPort(std::string port_name)
Definition: fe_gps_port_impl.h:161
boost::mutex updatingPortsLock
Definition: Port_impl.h:360
std::string getRepid() const
Definition: fe_gps_port_impl.h:79
Definition: fe_tuner_device.h:37
virtual void set_gps_info(const std::string &port_name, const frontend::GPSInfo &gps_info)
Definition: fe_gps_port_impl.h:34
~OutGPSPortT()
Definition: fe_gps_port_impl.h:97
Definition: Port_impl.h:364
~InGPSPort()
Definition: fe_gps_port_impl.h:53
std::vector< std::pair< PortType_var, std::string > > outConnections
Definition: fe_port_impl.h:298
frontend::GPSInfo gps_info()
Definition: fe_gps_port_impl.h:99
frontend::GpsTimePos gps_time_pos()
Definition: fe_gps_port_impl.h:128
boost::mutex portAccess
Definition: fe_gps_port_impl.h:85
InGPSPort(std::string port_name, gps_delegation *_parent)
Definition: fe_gps_port_impl.h:48
Definition: fe_gps_port_impl.h:159
gps_delegation * parent
Definition: fe_gps_port_impl.h:81
Definition: fe_gps_port_impl.h:45
FRONTEND::GpsTimePos * returnGpsTimePos(const frontend::GpsTimePos &val)
Definition: fe_port_impl.h:146
OutGPSPortT(std::string port_name)
Definition: fe_gps_port_impl.h:95
void gps_info(const frontend::GPSInfo &gps)
Definition: fe_gps_port_impl.h:114
virtual frontend::GPSInfo get_gps_info(const std::string &port_name)
Definition: fe_gps_port_impl.h:31
FRONTEND::GpsTimePos * gps_time_pos()
Definition: fe_gps_port_impl.h:67
Definition: fe_gps_port_impl.h:92
void gps_time_pos(frontend::GpsTimePos gps_time_pos)
Definition: fe_gps_port_impl.h:143
bool active
Definition: Port_impl.h:359
virtual void set_gps_time_pos(const std::string &port_name, const frontend::GpsTimePos &gps_time_pos)
Definition: fe_gps_port_impl.h:39
void gps_info(const FRONTEND::GPSInfo &gps)
Definition: fe_gps_port_impl.h:61
Definition: fe_gps_port_impl.h:29
void gps_time_pos(const FRONTEND::GpsTimePos &gps_time_pos)
Definition: fe_gps_port_impl.h:73
FRONTEND::GPSInfo * gps_info()
Definition: fe_gps_port_impl.h:55
Definition: fe_port_impl.h:238