Implemented epics read/write
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
* goCAConnectionCallback is called when a channel connects or disconnects.
|
||||
*/
|
||||
extern void goCAMonitorCallback(uintptr_t handle, int dbrType, long count,
|
||||
const void *dbr, int severity,
|
||||
void *dbr, int severity,
|
||||
double epicsTimeSecs);
|
||||
extern void goCAConnectionCallback(uintptr_t handle, int connected);
|
||||
|
||||
@@ -78,7 +78,7 @@ static void caMonitorCallbackShim(struct event_handler_args args) {
|
||||
}
|
||||
|
||||
goCAMonitorCallback((uintptr_t)args.usr, (int)args.type, (long)args.count,
|
||||
args.dbr, severity, timeSecs);
|
||||
(void *)args.dbr, severity, timeSecs);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -115,4 +115,29 @@ static int caAddMonitor(chid ch, short dbrType, uintptr_t userHandle,
|
||||
(void *)userHandle, pEvid);
|
||||
}
|
||||
|
||||
/* Wrappers for ca_get / ca_put, which are macros in cadef.h that expand to
|
||||
* ca_array_get / ca_array_put with count=1. CGo cannot call macros directly,
|
||||
* so we provide thin static-inline shims here. */
|
||||
|
||||
static int caGet(chtype type, chid chan, void *pValue) {
|
||||
return ca_array_get(type, 1u, chan, pValue);
|
||||
}
|
||||
|
||||
static int caPut(chtype type, chid chan, const void *pValue) {
|
||||
return ca_array_put(type, 1u, chan, pValue);
|
||||
}
|
||||
|
||||
/* Retrieve the current thread's CA context as an opaque pointer.
|
||||
* Store the result and pass it to caAttachContext() from other threads. */
|
||||
static void *caCurrentContext(void) {
|
||||
return (void *)ca_current_context();
|
||||
}
|
||||
|
||||
/* Attach an existing CA context to the calling thread. Must be called at the
|
||||
* start of every goroutine (OS thread) that makes CA calls, if that thread did
|
||||
* not call ca_context_create() itself. Returns ECA_NORMAL on success. */
|
||||
static int caAttachContext(void *ctx) {
|
||||
return ca_attach_context((struct ca_client_context *)ctx);
|
||||
}
|
||||
|
||||
#endif /* CA_WRAPPER_H */
|
||||
|
||||
Reference in New Issue
Block a user