ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbIFC2.hpp
Go to the documentation of this file.
1
8#ifndef ngcbIFC2_H
9#define ngcbIFC2_H
10
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16#include <ngc/core/ngcb.h>
17#include <ngc/core/ngcbSocket.h>
18#include <ngc/core/ngcbSched.h>
19#include <ngc/core/ngcbIFC.hpp>
20
24#define ngcbIFC2_DEFAULT_PORT 2635
25
26
30class ngcbIFC2: public ngcbIFC
31{
32public:
34 int fdPipe[2];
35
37 char keeperMsg[256];
38
41
43 ngcbIFC2();
44
46 explicit ngcbIFC2(const char *name);
47
49 virtual ~ngcbIFC2();
50
51 /*
52 * Client interface
53 */
54
56 int Fd();
57
59 int Sim(int level);
60
62 int Open(const char *name);
63
65 int Close();
66
68 void Keeper(int seconds);
69
71 int Reset();
72
74 int Ping();
75
77 int Timeout(int seconds);
78
80 int SetTime(uint64_t sec, uint64_t nsec);
81
83 int RPC(int mod, int target, int req, void *payload, unsigned int size,
84 unsigned int *status);
85
87 int ReadAddr(ngcb_route_t route, int addr, int *buffer, int size,
88 int *result);
89
91 int WriteAddr(ngcb_route_t route, int addr, const int *buffer, int size,
92 int *result);
93
95 int Status(int *devStatus);
96
98 int Connect();
99
101 int Disconnect();
102
104 int Connected();
105
106 /***
107 * Start TSU trigger at given absolute time
108 * (seconds + fractional nanoseconds)
109 */
110 int TsuStartAt(uint64_t sec, uint64_t nsec);
111
113 int TsuStart();
114
116 int TsuStop();
117
119 int TsuTrigger();
120
122 int TsuSnapshot();
123
125 int TsuStatus(int *value);
126
128 int TsuConfig(ngcb_tsu_t *cfg);
129
130 /***
131 * The function checks the TSU running status. If the status cannot be
132 * read -1 is returned and ErrMsg() contains the detailed error message.
133 * Otherwise 1 is returned if the TSU is running or zero is returned if
134 * the TSU is not running.
135 */
136 int TsuRunning();
137
138 /*
139 * Bottom end i/o
140 */
141
143 void Lock();
144
146 void Unlock();
147
149 int _ReadAddr(ngcb_route_t route, int addr, int *buffer, int size,
150 int *result);
151
153 int _WriteAddr(ngcb_route_t route, int addr, const int *buffer,
154 int size, int *result);
155
157 int _Ping(char *erms);
158
159protected:
160
161private:
163 int fdCmd_;
164
166 unsigned int requestId_;
167
169 ngcb_sema_t semLock_;
170
172 int thr_;
173
175 ngcb_thread_t thid_;
176
178 ngcbIFC *simulator_;
179
181 void Init_();
182
184 int RPC_(int mod, int target, int req, void *payload, unsigned int size,
185 unsigned int *status);
186
188 int DevRead_(int fd, void *buffer, size_t size, char *erms);
189
191 int DevWrite_(int fd, const void *buffer, size_t size, char *erms);
192
194 void StartKeeper_();
195
197 void StopKeeper_();
198
199
206 void SeqConfig(int mod, int word);
207
214 unsigned int SeqStatus(int mod);
215
221 void SeqStart(int mod);
222
228 void SeqStopAndReset(int mod);
229
235 void SeqBreak(int mod);
236
242 void SeqTrigger(int mod);
243
252 void SetPatRamLow(int mod, unsigned int offset, const int *ram, unsigned int size);
253
262 void GetPatRamLow(int mod, unsigned int offset, int *ram, unsigned int size);
263
272 void SetPatRamHigh(int mod, unsigned int offset, const int *ram, unsigned int size);
273
282 void GetPatRamHigh(int mod, unsigned int offset, int *ram, unsigned int size);
283
292 void SetSeqRam(int mod, unsigned int offset, const int *ram, unsigned int size);
293
302 void GetSeqRam(int mod, unsigned int offset, int *ram, unsigned int size);
303
304};
305
306#endif
int _WriteAddr(ngcb_route_t route, int addr, const int *buffer, int size, int *result)
Write to address.
Definition ngcbIFC2.cpp:1279
int TsuStop()
Stop TSU trigger.
Definition ngcbIFC2.cpp:554
int TsuRunning()
Definition ngcbIFC2.cpp:762
void Unlock()
Unlock device access.
Definition ngcbIFC2.cpp:95
int SetTime(uint64_t sec, uint64_t nsec)
Set device time (seconds and nanoseconds since UNIX epoch)
Definition ngcbIFC2.cpp:400
int keeperFailure
Line keeper failure flag.
Definition ngcbIFC2.hpp:40
ngcbIFC2()
Constructor without name.
Definition ngcbIFC2.cpp:66
int Connected()
Connected to device.
Definition ngcbIFC2.cpp:339
int _ReadAddr(ngcb_route_t route, int addr, int *buffer, int size, int *result)
Read from address.
Definition ngcbIFC2.cpp:997
int Ping()
Ping device.
Definition ngcbIFC2.cpp:940
int Close()
Close interface.
Definition ngcbIFC2.cpp:280
int TsuStatus(int *value)
Get TSU status.
Definition ngcbIFC2.cpp:600
int Disconnect()
Disconnect from device.
Definition ngcbIFC2.cpp:327
int TsuStart()
Start TSU trigger immediately.
Definition ngcbIFC2.cpp:489
int fdPipe[2]
Timer thread pipe.
Definition ngcbIFC2.hpp:34
int WriteAddr(ngcb_route_t route, int addr, const int *buffer, int size, int *result)
Write to address.
Definition ngcbIFC2.cpp:897
char keeperMsg[256]
Line keeper error message.
Definition ngcbIFC2.hpp:37
int Sim(int level)
Set simulation level.
Definition ngcbIFC2.cpp:134
virtual ~ngcbIFC2()
Destructor.
Definition ngcbIFC2.cpp:78
int TsuSnapshot()
Take TSU snapshot.
Definition ngcbIFC2.cpp:804
int ReadAddr(ngcb_route_t route, int addr, int *buffer, int size, int *result)
Read from address.
Definition ngcbIFC2.cpp:851
int TsuTrigger()
Manual TSU trigger.
Definition ngcbIFC2.cpp:578
int TsuConfig(ngcb_tsu_t *cfg)
Get TSU configuration.
Definition ngcbIFC2.cpp:661
int _Ping(char *erms)
Ping protocol.
Definition ngcbIFC2.cpp:1562
int Connect()
Connect through to device.
Definition ngcbIFC2.cpp:315
int TsuStartAt(uint64_t sec, uint64_t nsec)
Definition ngcbIFC2.cpp:446
int Reset()
Reset device.
Definition ngcbIFC2.cpp:344
int Fd()
Return device file descriptor.
Definition ngcbIFC2.cpp:129
int RPC(int mod, int target, int req, void *payload, unsigned int size, unsigned int *status)
RPC.
Definition ngcbIFC2.cpp:837
int Status(int *devStatus)
Get last communication status.
Definition ngcbIFC2.cpp:407
void Lock()
Lock device access.
Definition ngcbIFC2.cpp:89
void Keeper(int seconds)
Set line keeper interval (seconds)
Definition ngcbIFC2.cpp:420
virtual int Timeout()
Get timeout.
Definition ngcbIFC.cpp:588
int Open()
Open interface with current name.
Definition ngcbIFC.cpp:319
ngcbIFC()
Constructor without device name.
Definition ngcbIFC.cpp:36
pthread_t ngcb_thread_t
Definition ngcbSched.h:53
Definition ngcbIFC.hpp:78
Definition ngcbSched.h:78
Definition ngcbIFC.hpp:466