Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  Index 2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018 
<== Date ==> <== Thread ==>

Subject: Patch: Enhancement to asTrapWrite?
From: Andrew Johnson <anj@aps.anl.gov>
To: EPICS core-talk <core-talk@aps.anl.gov>
Cc: Eric Berryman <eric.berryman@gmail.com>
Date: Thu, 27 Sep 2007 12:21:50 -0500
I received the attached patch from Eric Berryman, which I'm posting here for additional comments. The change should not break existing asTrapWrite plug-ins since it merely adds fields to the message structure that contains all of the information about the write being performed — the fields it adds contain the new data and metadata from the put. However it does increase the size of the asTrapWriteMessage structure from 4 to 7 pointers.

I can see that it simplifies the use of the asTrapWrite API, but I am not convinced that it is strictly necessary. The existing API does not provide the put data & metadata directly, but this information can be obtained from the record field by the 'after' call to the registered plug-in. This would not be true if the put causes record processing which modifies the value of the field before the 'after' call, but by forcing users to fetch the 'after' data they also find out what the real effect was of that put, not just what the client tried to do (if you rely only on what was in the put buffer as provided by this patch you can't be 100% sure what value actually ended up in the field).

Comments, positive or negative?

- Andrew
--
When a distinguished but elderly scientist states that something is
possible, he is almost certainly right.  When he states that something
is impossible, he is very probably wrong.  -- Arthur C. Clarke
--- /opt/epicsB/base_old/src/as/asLib.h	2007-09-24 13:11:43.000000000 -0400
+++ /opt/epicsB/base/src/as/asLib.h	2007-09-24 13:28:44.969781176 -0400
@@ -42,9 +42,9 @@
 	(asActive \
 	? ((asClientPvt)->access>=asWRITE ? TRUE : FALSE)\
 	: TRUE)
-#define asTrapWriteBefore(asClientPvt,user,host,addr) \
+#define asTrapWriteBefore(asClientPvt,user,host,addr,dtype,dptr,dcnt) \
     (((asActive) && (asClientPvt)->trapMask) \
-    ? asTrapWriteBeforeWrite((user),(host),(addr)) \
+    ? asTrapWriteBeforeWrite((user),(host),(addr),(dtype),(dptr),(dcnt)) \
     : 0)
 
 #define asTrapWriteAfter(pvt) if((pvt)) asTrapWriteAfterWrite((pvt))
@@ -101,7 +101,7 @@
 epicsShareFunc int epicsShareAPI asDumpHashFP(FILE *fp);
 
 epicsShareFunc void * epicsShareAPI asTrapWriteBeforeWrite(
-    const char *userid,const char *hostid,void *addr);
+    const char *userid,const char *hostid,void *addr,unsigned short dataType,void *dataptr,unsigned long count);
 
 epicsShareFunc void epicsShareAPI asTrapWriteAfterWrite(void *pvt);
 
--- /opt/epicsB/base_old/src/as/asTrapWrite.h	2007-09-24 13:11:43.000000000 -0400
+++ /opt/epicsB/base/src/as/asTrapWrite.h	2007-09-24 13:24:48.000000000 -0400
@@ -24,6 +24,9 @@
     const char *hostid;
     void *serverSpecific;
     void *userPvt;
+    unsigned short *dataType;
+    void *dataptr;
+    unsigned long *count;
 } asTrapWriteMessage;
 
 
--- /opt/epicsB/base_old/src/as/asTrapWrite.c	2007-09-24 13:57:45.117261852 -0400
+++ /opt/epicsB/base/src/as/asTrapWrite.c	2007-09-24 13:21:17.000000000 -0400
@@ -112,7 +112,7 @@
 }
 
 void * epicsShareAPI asTrapWriteBeforeWrite(
-    const char *userid,const char *hostid,void *addr)
+    const char *userid,const char *hostid,void *addr,unsigned short dataType,void *dataptr,unsigned long count)
 {
     writeMessage *pwriteMessage;
     listener *plistener;
@@ -125,6 +125,9 @@
     pwriteMessage->message.userid = userid;
     pwriteMessage->message.hostid = hostid;
     pwriteMessage->message.serverSpecific = addr;
+    pwriteMessage->message.dataType = dataType;
+    pwriteMessage->message.dataptr = dataptr;
+    pwriteMessage->message.count = count;
     ellInit(&pwriteMessage->listenerPvtList);
     epicsMutexMustLock(pasTrapWritePvt->lock);
     ellAdd(&pasTrapWritePvt->writeMessageList,&pwriteMessage->node);
--- /opt/epicsB/base_old/src/rsrv/camessage.c	2007-09-24 13:59:25.992793308 -0400
+++ /opt/epicsB/base/src/rsrv/camessage.c	2007-09-24 13:45:17.414564490 -0400
@@ -791,7 +791,10 @@
     asWritePvt = asTrapWriteBefore ( pciu->asClientPVT,
         pciu->client->pUserName ? pciu->client->pUserName : "",
         pciu->client->pHostName ? pciu->client->pHostName : "",
-        (void *) &pciu->addr );
+        (void *) &pciu->addr,
+		mp->m_dataType,
+		pPayload,
+		mp->m_count);
 
     dbStatus = db_put_field(
                   &pciu->addr,
@@ -1774,7 +1777,10 @@
         pciu->asClientPVT,
         pciu->client->pUserName ? pciu->client->pUserName : "",
         pciu->client->pHostName ? pciu->client->pHostName : "",
-        (void *) &pciu->addr );
+        (void *) &pciu->addr,
+		mp->m_dataType,
+		pPayload,
+		mp->m_count);
 
     dbPutNotify(&pciu->pPutNotify->dbPutNotify);
 

Replies:
RE: Patch: Enhancement to asTrapWrite? Jeff Hill

Navigate by Date:
Prev: RE: DA property hierarchy for interfacing to the DBR_XXXX types Jeff Hill
Next: Attention EPICS Core Developers! Andrew Johnson
Index: 2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018 
Navigate by Thread:
Prev: RE: DA property hierarchy for interfacing to the DBR_XXXX types Jeff Hill
Next: RE: Patch: Enhancement to asTrapWrite? Jeff Hill
Index: 2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·