ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcbIFC2.hpp
Go to the documentation of this file.
1
7#ifndef ngcbIFC2_H
8#define ngcbIFC2_H
9
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
15#include <ngc/core/ngcb.h>
16#include <ngc/core/ngcbSocket.h>
17#include <ngc/core/ngcbSched.h>
18#include <ngc/core/ngcbIFC.hpp>
19
23#define ngcbIFC2_DEFAULT_PORT 8010
24
25
29class ngcbIFC2: public ngcbIFC
30{
31public:
33 int fdPipe[2];
34
36 char keeperMsg[256];
37
40
42 ngcbIFC2();
43
45 explicit ngcbIFC2(const char *name);
46
48 virtual ~ngcbIFC2();
49
50 /*
51 * Client interface
52 */
53
55 int Fd();
56
58 int Sim(int level);
59
61 int Open(const char *name);
62
64 int Close();
65
67 void Keeper(int seconds);
68
70 int Reset();
71
73 int Ping();
74
76 int Timeout(int seconds);
77
79 int SetTime(uint64_t sec, uint64_t nsec);
80
82 int RPC(int mod, int target, int req, void *payload, unsigned int size,
83 unsigned int *status);
84
86 int ReadAddr(ngcb_route_t route, int addr, int *buffer, int size,
87 int *result);
88
90 int WriteAddr(ngcb_route_t route, int addr, const int *buffer, int size,
91 int *result);
92
94 int Status(int *devStatus);
95
97 int Connect();
98
100 int Disconnect();
101
103 int Connected();
104
105 /***
106 * Start TSU trigger at given absolute time
107 * (seconds + fractional nanoseconds)
108 */
109 int TsuStartAt(uint64_t sec, uint64_t nsec);
110
112 int TsuStart();
113
115 int TsuStop();
116
118 int TsuTrigger();
119
121 int TsuSnapshot();
122
124 int TsuStatus(int *value);
125
127 int TsuConfig(ngcb_tsu_t *cfg);
128
129 /***
130 * The function checks the TSU running status. If the status cannot be
131 * read -1 is returned and ErrMsg() contains the detailed error message.
132 * Otherwise 1 is returned if the TSU is running or zero is returned if
133 * the TSU is not running.
134 */
135 int TsuRunning();
136
137 /*
138 * Bottom end i/o
139 */
140
142 void Lock();
143
145 void Unlock();
146
148 int _ReadAddr(ngcb_route_t route, int addr, int *buffer, int size,
149 int *result);
150
152 int _WriteAddr(ngcb_route_t route, int addr, const int *buffer,
153 int size, int *result);
154
156 int _Ping(char *erms);
157
158protected:
159
160private:
162 int fdCmd_;
163
165 unsigned int requestId_;
166
168 ngcb_sema_t semLock_;
169
171 int thr_;
172
174 ngcb_thread_t thid_;
175
177 ngcbIFC *simulator_;
178
180 void Init_();
181
183 int RPC_(int mod, int target, int req, void *payload, unsigned int size,
184 unsigned int *status);
185
187 int DevRead_(int fd, void *buffer, size_t size, char *erms);
188
190 int DevWrite_(int fd, const void *buffer, size_t size, char *erms);
191
193 void StartKeeper_();
194
196 void StopKeeper_();
197};
198
199#endif
int _WriteAddr(ngcb_route_t route, int addr, const int *buffer, int size, int *result)
Write to address.
Definition ngcbIFC2.cpp:1158
int TsuStop()
Stop TSU trigger.
Definition ngcbIFC2.cpp:551
int TsuRunning()
Definition ngcbIFC2.cpp:759
void Unlock()
Unlock device access.
Definition ngcbIFC2.cpp:92
int SetTime(uint64_t sec, uint64_t nsec)
Set device time (seconds and nanoseconds since UNIX epoch)
Definition ngcbIFC2.cpp:397
int keeperFailure
Line keeper failure flag.
Definition ngcbIFC2.hpp:39
ngcbIFC2()
Constructor without name.
Definition ngcbIFC2.cpp:63
int Connected()
Connected to device.
Definition ngcbIFC2.cpp:336
int _ReadAddr(ngcb_route_t route, int addr, int *buffer, int size, int *result)
Read from address.
Definition ngcbIFC2.cpp:980
int Ping()
Ping device.
Definition ngcbIFC2.cpp:923
int Close()
Close interface.
Definition ngcbIFC2.cpp:277
int TsuStatus(int *value)
Get TSU status.
Definition ngcbIFC2.cpp:597
int Disconnect()
Disconnect from device.
Definition ngcbIFC2.cpp:324
int TsuStart()
Start TSU trigger immediately.
Definition ngcbIFC2.cpp:486
int fdPipe[2]
Timer thread pipe.
Definition ngcbIFC2.hpp:33
int WriteAddr(ngcb_route_t route, int addr, const int *buffer, int size, int *result)
Write to address.
Definition ngcbIFC2.cpp:887
char keeperMsg[256]
Line keeper error message.
Definition ngcbIFC2.hpp:36
int Sim(int level)
Set simulation level.
Definition ngcbIFC2.cpp:131
virtual ~ngcbIFC2()
Destructor.
Definition ngcbIFC2.cpp:75
int TsuSnapshot()
Take TSU snapshot.
Definition ngcbIFC2.cpp:801
int ReadAddr(ngcb_route_t route, int addr, int *buffer, int size, int *result)
Read from address.
Definition ngcbIFC2.cpp:848
int TsuTrigger()
Manual TSU trigger.
Definition ngcbIFC2.cpp:575
int TsuConfig(ngcb_tsu_t *cfg)
Get TSU configuration.
Definition ngcbIFC2.cpp:658
int _Ping(char *erms)
Ping protocol.
Definition ngcbIFC2.cpp:1317
int Connect()
Connect through to device.
Definition ngcbIFC2.cpp:312
int TsuStartAt(uint64_t sec, uint64_t nsec)
Definition ngcbIFC2.cpp:443
int Reset()
Reset device.
Definition ngcbIFC2.cpp:341
int Fd()
Return device file descriptor.
Definition ngcbIFC2.cpp:126
int RPC(int mod, int target, int req, void *payload, unsigned int size, unsigned int *status)
RPC.
Definition ngcbIFC2.cpp:834
int Status(int *devStatus)
Get last communication status.
Definition ngcbIFC2.cpp:404
void Lock()
Lock device access.
Definition ngcbIFC2.cpp:86
void Keeper(int seconds)
Set line keeper interval (seconds)
Definition ngcbIFC2.cpp:417
virtual int Timeout()
Get timeout.
Definition ngcbIFC.cpp:585
int Open()
Open interface with current name.
Definition ngcbIFC.cpp:316
ngcbIFC()
Constructor without device name.
Definition ngcbIFC.cpp:33
pthread_t ngcb_thread_t
Definition ngcbSched.h:52
Definition ngcbIFC.hpp:72
Definition ngcbSched.h:77
Definition ngcbIFC.hpp:460