stec-platform
gds_codex.h
1 /***************************************************************************
2  * Copyright (C) 2009,2011 by VremSoft *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18  ***************************************************************************/
19 
20 /*
21 *
22 * $LastChangedDate: 2016-04-28 11:12:16 -0400 (Thu, 28 Apr 2016) $
23 * $LastChangedBy: ed $
24 * $Revision: 690 $
25 * $Author: ed $
26 * $URL: svn+ssh://svn.vremsoft.com/var/share/svn/tags/platfom3.4.3/platformlib/qnxtalk/gds_codex.h $
27 * $Id: gds_codex.h 690 2016-04-28 15:12:16Z ed $
28 * edc@vremsoft.com
29 *
30 * 19
31 *
32 * *** 2014<c> ***
33 *
34 *
35 */
36 
37 #ifndef GDS_CODEX_H
38 #define GDS_CODEX_H
39 
40 #include <QtCore>
41 #include <QTcpSocket>
42 #include <publicationregistration.h>
43 #include <publication.h>
44 
45 
46 
47 #include "pdscmsg.h"
48 #include "vqsubscriber.h"
49 #include "vqpublisher.h"
50 #include "vqdefines.h"
51 #include "qnxsprur.h"
52 
53 
54 // #define HOLD_PUBLICATION_NAMES
55 
56 namespace QXX {
57 
58 class PLATFORMSHARED_EXPORT gds_codex : public QTcpSocket
59 {
60  Q_OBJECT
61 
62 private :
63 
65  QMutex creationLock;
66 
67  QnxSprur &plugin;
68 
69  qint32 blockSize;
70 
72  QString routerVersion;
73 
75  bool valid;
76 
78  PblHdr NULL_hdr;
79 
81  QMutex idLock;
82 
84  long ID;
85 
87  DLock < int > Socket;
88 
90  DLock < long > heartbeats;
91 
93  QMutex ourGdsSubscribersLock;
94  VASubscriberMap ourGdsSubscribers;
95  VASubscriberNamesMap ourGdsSubscribersbNames;
96 
98  VQSubscriber *findSubscriber ( long id );
99 
101  QMutex ourGdsPublishersLock;
102  VAPublisherMap ourGdsPublishers;
103 
105  QMutex RequestUpdateLock;
106 
108  VQPublisher *findPublisher ( long id );
109 
111  void UpDatePDS (
112  long id,
113  PblId pb,
114  void *data,
115  int index,
116  int count,
117  ArticleType type,
118  size_t ArticleSize );
119 
120 
121  int uniqueID;
122  int socketD;
123  bool aquiredConnection;
124 
125  QMap<QString,char> flashOffCopyNames;
126  QMap<QString,char> flashOffCopyRemoteNames;
127 
128 public :
130  gds_codex (QnxSprur &Plugin, int UniqueID, QObject *parent = 0 );
131 
133  virtual ~gds_codex();
134 
136  const QString GetVersion ( void ) const { return routerVersion; }
137 
139  int RegisterSubscriber ( long id, VQSubscriber *sub );
140 
142  int UnRegisterSubscriber(long id);
143 
145  int RegisterPublisher ( long id, VQPublisher *pub );
146 
148  int UnRegisterPublisher ( long id );
149 
151  virtual void UserSendMessage ( int length, void *msg );
152 
154  long getGdsId ( void );
155 
157  void DataFromGds ( VQSubscriber *sub, void *data, int index, int count, ArticleType type, size_t articleSize );
158 
160  void DataFromGds ( VQPublisher *sub, void *data, int index, int count, ArticleType type, size_t articleSize );
161 
163  void RequestUpdate ( long id, PblId pb, ArticleType type, VremVArray &values, int index );
164 
166  void CreationLock ( void )
167  {
168  creationLock.lock();
169  } // CreationLock
170 
172  void CreationUnlock ( void )
173  {
174  creationLock.unlock();
175  } // CreationUnlock
176 
177 
178  virtual void NameFound( QString &name, PblHdr *hdr);
179 
180 
181 private slots :
183  void codex ( QByteArray message );
184 
185  void slot_connected();
186  void slot_disconnected();
187  void slot_readyRead();
188 
189 signals :
191  void sigSendingData ( int, QByteArray );
192 
193 public slots :
194 
195  void slot_newpublication(QString newPub);
196  void slot_lostpublication(QString Pub);
197 
198 signals :
200  void sigNameFound ( QString name, PblHdr hdr );
201 
203  void sigNameLost ( QString name, PblHdr hdr );
204 
206  void sigRouterVersion ( QString version );
207 
209  void sigRouterVersionHeartBeat ( QString beat );
210 
213 
214 
216  void sigMessageError ( QString err );
217 
219  void sigSocketState ( bool );
220 
222  void sigLibError ( QString err );
223 
226  void SignalLostRemotePublication(int,QString);
227  void SignalNewRemotePublication(int,QString);
228 
229 
230 
231 
232 }; // gds_codex
233 
234 }
235 
236 #if 0
237 namespace Ui
238 {
239  class codexClass : public gds_codex
240  {
241  }; // codexClass
242 
243 } // namespace Ui
244 
245 #endif
246 
247 #endif // GDS_CODEX_H
Definition: qnxsprur.h:39
Definition: vqpublisher.h:60
Definition: vqsubscriber.h:73
Definition: gds_codex.h:59
void CreationUnlock(void)
Unlocks when a creation of a publication or subscription.
Definition: gds_codex.h:172
void sigMessageError(QString err)
User can catch messages from qnx error here.
void SignalLostRemoteDescriptor(int)
new only when needed
void sigLibError(QString err)
Internal lib error.
const QString GetVersion(void) const
Gets the version of the gdsbridge on the other side.
Definition: gds_codex.h:136
void sigNameLost(QString name, PblHdr hdr)
User should connect to this for names lost.
void sigSendingData(int, QByteArray)
Sending data to xmitter.
void sigRouterVersionHeartBeat(QString beat)
Heart beat pumps since connection.
void sigSocketState(bool)
Socket closed error, connection lost.
void sigRouterVersion(QString version)
User should connect to this to receive the router version when it comes in.
void sigNameFound(QString name, PblHdr hdr)
Users should connect to this for new names.
void sigRouterReceived()
Message Received.
void CreationLock(void)
Locks when a creation of a publication or subscription.
Definition: gds_codex.h:166
Definition: pdscmsg.h:41