Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  Index 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019 
<== Date ==> <== Thread ==>

Subject: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base
From: Dirk Zimoch <dirk.zimoch@psi.ch>
To: mp+26190@code.launchpad.net
Date: Thu, 27 May 2010 15:17:25 -0000
Dirk Zimoch has proposed merging lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base.

Requested reviews:
  EPICS Core Developers (epics-core)


Soft events can be strings now.

Example:
record (event, "$(EVENTREC)") {
  field (VAL, "Injection Trigger")
}

record (ai, "$(OTHERREC)") {
  field (EVNT, "Injection Trigger")
}

record (calcout, "$(CALCREC)") {
  field (OEVT, "Injection Trigger")
}

Discussion:
Do we need hashing of the strings to speed up event triggering? Probably not when we can assume a small number of events and event names that differ early.
-- 
https://code.launchpad.net/~dirk.zimoch/epics-base/named-soft-events/+merge/26190
Your team EPICS Core Developers is requested to review the proposed merge of lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base.
=== modified file 'src/db/dbCommon.dbd'
--- src/db/dbCommon.dbd	2009-04-23 20:35:02 +0000
+++ src/db/dbCommon.dbd	2010-05-27 15:17:24 +0000
@@ -43,10 +43,11 @@
 		special(SPC_SCAN)
 		interest(1)
 	}
-	field(EVNT,DBF_SHORT) {
-		prompt("Event Number")
+	field(EVNT,DBF_STRING) {
+		prompt("Event Name")
 		promptgroup(GUI_SCAN)
 		special(SPC_SCAN)
+		size(40)
 		interest(1)
 	}
 	field(TSE,DBF_SHORT) {

=== modified file 'src/db/dbIocRegister.c'
--- src/db/dbIocRegister.c	2009-01-16 20:50:40 +0000
+++ src/db/dbIocRegister.c	2010-05-27 15:17:24 +0000
@@ -266,11 +266,11 @@
 { scanppl(args[0].dval);}
 
 /* scanpel */
-static const iocshArg scanpelArg0 = { "event number",iocshArgInt};
+static const iocshArg scanpelArg0 = { "event name",iocshArgString};
 static const iocshArg * const scanpelArgs[1] = {&scanpelArg0};
 static const iocshFuncDef scanpelFuncDef = {"scanpel",1,scanpelArgs};
 static void scanpelCallFunc(const iocshArgBuf *args)
-{ scanpel(args[0].ival);}
+{ scanpel(args[0].sval);}
 
 /* scanpiol */
 static const iocshFuncDef scanpiolFuncDef = {"scanpiol",0};

=== modified file 'src/db/dbScan.c'
--- src/db/dbScan.c	2009-04-03 17:46:26 +0000
+++ src/db/dbScan.c	2010-05-27 15:17:24 +0000
@@ -101,12 +101,14 @@
 
 /* EVENT */
 
-#define MAX_EVENTS 256
 typedef struct event_scan_list {
     CALLBACK            callback;
     scan_list           scan_list;
+    struct event_scan_list *next;
+    char                event_name[MAX_STRING_SIZE];
 } event_scan_list;
-static event_scan_list *pevent_list[NUM_CALLBACK_PRIORITIES][MAX_EVENTS];
+static event_scan_list *pevent_list[NUM_CALLBACK_PRIORITIES];
+static epicsMutexId event_list_lock[NUM_CALLBACK_PRIORITIES];
 
 
 /* IO_EVENT*/
@@ -204,34 +206,46 @@
         recGblRecordError(-1, (void *)precord,
             "scanAdd detected illegal SCAN value");
     } else if (scan == menuScanEvent) {
-        int evnt;
+        char* evnt;
         int prio;
         event_scan_list *pesl;
 
         evnt = precord->evnt;
-        if (evnt < 0 || evnt >= MAX_EVENTS) {
-            recGblRecordError(S_db_badField, (void *)precord,
-                "scanAdd detected illegal EVNT value");
-            precord->scan = menuScanPassive;
+        if (*evnt == 0) {
+            recGblRecordError(S_db_badField, (void *)precord,
+                "scanAdd: illegal empty EVNT value");
+            /*precord->scan = menuScanPassive;*/
+            return;
+        }
+        if (strlen(evnt) >= MAX_STRING_SIZE) {
+            recGblRecordError(S_db_badField, (void *)precord,
+                "scanAdd: too long EVNT value");
+            /*precord->scan = menuScanPassive;*/
             return;
         }
         prio = precord->prio;
         if (prio < 0 || prio >= NUM_CALLBACK_PRIORITIES) {
             recGblRecordError(-1, (void *)precord,
                 "scanAdd: illegal prio field");
-            precord->scan = menuScanPassive;
+            /*precord->scan = menuScanPassive;*/
             return;
         }
-        pesl = pevent_list[prio][evnt];
+        epicsMutexMustLock(event_list_lock[prio]);
+        for (pesl = pevent_list[prio]; pesl; pesl=pesl->next) {
+            if (strcmp(pesl->event_name, evnt) == 0) break;
+        }
         if (pesl == NULL) {
             pesl = dbCalloc(1, sizeof(event_scan_list));
-            pevent_list[prio][evnt] = pesl;
+            strcpy(pesl->event_name, evnt);
             pesl->scan_list.lock = epicsMutexMustCreate();
             callbackSetCallback(eventCallback, &pesl->callback);
             callbackSetPriority(prio, &pesl->callback);
             callbackSetUser(pesl, &pesl->callback);
             ellInit(&pesl->scan_list.list);
+            pesl->next=pevent_list[prio];
+            pevent_list[prio]=pesl;
         }
+        epicsMutexUnlock(event_list_lock[prio]);
         addToList(precord, &pesl->scan_list);
     } else if (scan == menuScanI_O_Intr) {
         io_scan_list *piosl = NULL;
@@ -287,31 +301,25 @@
         recGblRecordError(-1, (void *)precord,
             "scanDelete detected illegal SCAN value");
     } else if (scan == menuScanEvent) {
-        int evnt;
+        char* evnt;
         int prio;
         event_scan_list *pesl;
         scan_list *psl = 0;
 
         evnt = precord->evnt;
-        if (evnt < 0 || evnt >= MAX_EVENTS) {
-            recGblRecordError(S_db_badField, (void *)precord,
-                "scanAdd detected illegal EVNT value");
-            precord->scan = menuScanPassive;
-            return;
-        }
         prio = precord->prio;
         if (prio < 0 || prio >= NUM_CALLBACK_PRIORITIES) {
             recGblRecordError(-1, (void *)precord,
-                "scanAdd: illegal prio field");
-            precord->scan = menuScanPassive;
+                "scanDelete detected illegal PRIO field");
             return;
         }
-        pesl = pevent_list[prio][evnt];
-        if (pesl) psl = &pesl->scan_list;
-        if (!pesl || !psl) 
-            recGblRecordError(-1, (void *)precord,
-                "scanDelete for bad evnt");
-        else
+        epicsMutexMustLock(event_list_lock[prio]);
+        pesl = pevent_list[prio];
+        epicsMutexUnlock(event_list_lock[prio]);
+        for (; pesl; pesl=pesl->next) {
+            if (strcmp(pesl->event_name, evnt) == 0) break;
+        }
+        if (pesl && (psl = &pesl->scan_list))
             deleteFromList(precord, psl);
     } else if (scan == menuScanI_O_Intr) {
         io_scan_list *piosl=NULL;
@@ -372,21 +380,22 @@
     return 0;
 }
 
-int scanpel(int event_number)   /* print event list */
+int scanpel(char* evnt)   /* print event list */
 {
     char message[80];
-    int prio, evnt;
+    int prio;
     event_scan_list *pesl;
-
-    for (evnt = 0; evnt < MAX_EVENTS; evnt++) {
-        if (event_number && evnt<event_number) continue;
-        if (event_number && evnt>event_number) break;
-        for (prio = 0; prio < NUM_CALLBACK_PRIORITIES; prio++) {
-            pesl = pevent_list[prio][evnt];
-            if (!pesl) continue;
-            if (ellCount(&pesl->scan_list.list) == 0) continue;
-            sprintf(message, "Event %d Priority %s", evnt, priorityName[prio]);
-            printList(&pesl->scan_list, message);
+    
+    for (prio = 0; prio < NUM_CALLBACK_PRIORITIES; prio++) {
+        epicsMutexMustLock(event_list_lock[prio]);
+        pesl = pevent_list[prio];
+        epicsMutexUnlock(event_list_lock[prio]);
+        for (; pesl; pesl = pesl->next) {
+            if (!evnt || strcmp(pesl->event_name, evnt) == 0) {
+                if (ellCount(&pesl->scan_list.list) == 0) continue;
+                sprintf(message, "Event \"%s\" Priority %s", pesl->event_name, priorityName[prio]);
+                printList(&pesl->scan_list, message);
+            }
         }
     }
     return 0;
@@ -420,31 +429,40 @@
 
 static void initEvent(void)
 {
-    int evnt, prio;
+    int prio;
 
     for (prio = 0; prio < NUM_CALLBACK_PRIORITIES; prio++) {
-        for (evnt = 0; evnt < MAX_EVENTS; evnt++) {
-            pevent_list[prio][evnt] = NULL;
+        pevent_list[prio] = NULL;
+        event_list_lock[prio] = epicsMutexMustCreate();
+    }
+}
+
+void post_named_event(char* evnt)
+{
+    int prio;
+    event_scan_list *pesl;
+
+    if (scanCtl != ctlRun) return;
+    if (!evnt || *evnt == 0) return;
+    for (prio=0; prio<NUM_CALLBACK_PRIORITIES; prio++) {
+        epicsMutexMustLock(event_list_lock[prio]);
+        pesl = pevent_list[prio];
+        epicsMutexUnlock(event_list_lock[prio]);
+        for (; pesl; pesl=pesl->next) {
+            if (strcmp(pesl->event_name, evnt) == 0) {
+                if (ellCount(&pesl->scan_list.list) >0)
+                    callbackRequest((void *)pesl);
+            }
         }
     }
 }
 
 void post_event(int event)
 {
-    int prio;
-    event_scan_list *pesl;
-
-    if (scanCtl != ctlRun) return;
-    if (event < 0 || event >= MAX_EVENTS) {
-        errMessage(-1, "illegal event passed to post_event");
-        return;
-    }
-    for (prio=0; prio<NUM_CALLBACK_PRIORITIES; prio++) {
-        pesl = pevent_list[prio][event];
-        if (!pesl) continue;
-        if (ellCount(&pesl->scan_list.list) >0)
-            callbackRequest((void *)pesl);
-    }
+    char event_name[10];
+    
+    sprintf(event_name, "%i", event);
+    post_named_event(event_name);
 }
 
 void scanIoInit(IOSCANPVT *ppioscanpvt)

=== modified file 'src/db/dbScan.h'
--- src/db/dbScan.h	2009-04-02 14:11:27 +0000
+++ src/db/dbScan.h	2010-05-27 15:17:24 +0000
@@ -32,6 +32,11 @@
 #define MAX_PHASE           SHRT_MAX
 #define MIN_PHASE           SHRT_MIN
 
+
+#ifndef __GNUC__
+#define __attribute(dummy)
+#endif
+
 /*definitions for I/O Interrupt Scanning */
 struct io_scan_list;
 
@@ -43,7 +48,9 @@
 epicsShareFunc void scanRun(void);
 epicsShareFunc void scanPause(void);
 
-epicsShareFunc void post_event(int event);
+epicsShareFunc void post_event(int event) __attribute__ ((deprecated))
+	__attribute__ ((warning ("use post_named_event instead")));
+epicsShareFunc void post_named_event(char* event);
 epicsShareFunc void scanAdd(struct dbCommon *);
 epicsShareFunc void scanDelete(struct dbCommon *);
 epicsShareFunc double scanPeriod(int scan);
@@ -54,7 +61,7 @@
 epicsShareFunc int scanppl(double rate);
 
 /*print event lists*/
-epicsShareFunc int scanpel(int event_number);
+epicsShareFunc int scanpel(char *event_name);
 
 /*print io_event list*/
 epicsShareFunc int scanpiol(void);

=== modified file 'src/dev/softDev/devEventSoft.c'
--- src/dev/softDev/devEventSoft.c	2008-08-06 22:11:51 +0000
+++ src/dev/softDev/devEventSoft.c	2010-05-27 15:17:24 +0000
@@ -51,7 +51,7 @@
     /* INP must be CONSTANT, PV_LINK, DB_LINK or CA_LINK*/
     switch (prec->inp.type) {
     case CONSTANT:
-        if (recGblInitConstantLink(&prec->inp, DBF_USHORT, &prec->val))
+        if (recGblInitConstantLink(&prec->inp, DBF_STRING, &prec->val))
             prec->udf = FALSE;
         break;
     case PV_LINK:
@@ -70,7 +70,7 @@
 {
     long status;
 
-    status = dbGetLink(&prec->inp, DBR_USHORT, &prec->val, 0, 0);
+    status = dbGetLink(&prec->inp, DBR_STRING, prec->val, 0, 0);
     if (!status) {
         prec->udf = FALSE;
         if (prec->tsel.type == CONSTANT &&

=== modified file 'src/rec/calcoutRecord.c'
--- src/rec/calcoutRecord.c	2010-04-05 18:49:18 +0000
+++ src/rec/calcoutRecord.c	2010-05-27 15:17:24 +0000
@@ -539,27 +539,21 @@
     if (prec->nsev < INVALID_ALARM ) {
         /* Output the value */
         status = writeValue(prec);
-        /* post event if output event != 0 */
-        if (prec->oevt > 0) {
-            post_event((int)prec->oevt);
-        }
+        /* post output event if set */
+        post_named_event(prec->oevt);
     } else switch (prec->ivoa) {
         case menuIvoaContinue_normally:
             status = writeValue(prec);
-            /* post event if output event != 0 */
-            if (prec->oevt > 0) {
-                post_event((int)prec->oevt);
-            }
+            /* post output event if set */
+            post_named_event(prec->oevt);
             break;
         case menuIvoaDon_t_drive_outputs:
             break;
         case menuIvoaSet_output_to_IVOV:
             prec->oval = prec->ivov;
             status = writeValue(prec);
-            /* post event if output event != 0 */
-            if (prec->oevt > 0) {
-                post_event((int)prec->oevt);
-            }
+            /* post output event if set */
+            post_named_event(prec->oevt);
             break;
         default:
             status = -1;

=== modified file 'src/rec/calcoutRecord.dbd'
--- src/rec/calcoutRecord.dbd	2009-04-04 23:01:23 +0000
+++ src/rec/calcoutRecord.dbd	2010-05-27 15:17:24 +0000
@@ -255,10 +255,11 @@
 		prompt("OCAL Valid")
 		interest(1)
 	}
-	field(OEVT,DBF_USHORT) {
+	field(OEVT,DBF_STRING) {
 		prompt("Event To Issue")
 		promptgroup(GUI_CLOCK)
 		asl(ASL0)
+		size(40)
 	}
 	field(IVOA,DBF_MENU) {
 		prompt("INVALID output action")

=== modified file 'src/rec/eventRecord.c'
--- src/rec/eventRecord.c	2009-07-08 18:14:11 +0000
+++ src/rec/eventRecord.c	2010-05-27 15:17:24 +0000
@@ -103,7 +103,7 @@
     }
 
     if (prec->siol.type == CONSTANT) {
-	recGblInitConstantLink(&prec->siol,DBF_USHORT,&prec->sval);
+	recGblInitConstantLink(&prec->siol,DBF_STRING,&prec->sval);
     }
 
     if( (pdset=(struct eventdset *)(prec->dset)) && (pdset->init_record) ) 
@@ -123,7 +123,7 @@
 	if ( !pact && prec->pact ) return(0);
 	prec->pact = TRUE;
  
-	if(prec->val>0) post_event((int)prec->val);
+	post_named_event(prec->val);
 
 	recGblGetTimeStamp(prec);
 
@@ -140,7 +140,7 @@
 
 static long get_value(eventRecord *prec, struct valueDes *pvdes)
 {
-    pvdes->field_type = DBF_USHORT;
+    pvdes->field_type = DBF_STRING;
     pvdes->no_elements=1;
     pvdes->pvalue = (void *)(&prec->val);
     return(0);
@@ -177,10 +177,10 @@
                 return(status);
         }
         if (prec->simm == menuYesNoYES){
-                status=dbGetLink(&(prec->siol),DBR_USHORT,
+                status=dbGetLink(&(prec->siol),DBR_STRING,
 			&(prec->sval),0,0);
                 if (status==0) {
-                        prec->val=prec->sval;
+                        strcpy(prec->val, prec->sval);
                         prec->udf=FALSE;
                 }
         } else {

=== modified file 'src/rec/eventRecord.dbd'
--- src/rec/eventRecord.dbd	2002-07-12 21:35:43 +0000
+++ src/rec/eventRecord.dbd	2010-05-27 15:17:24 +0000
@@ -9,10 +9,11 @@
 #*************************************************************************
 recordtype(event) {
 	include "dbCommon.dbd" 
-	field(VAL,DBF_USHORT) {
-		prompt("Event Number To Post")
+	field(VAL,DBF_STRING) {
+		prompt("Event Name To Post")
 		promptgroup(GUI_INPUTS)
 		asl(ASL0)
+		size(40)
 	}
 	field(INP,DBF_INLINK) {
 		prompt("Input Specification")
@@ -24,8 +25,9 @@
 		promptgroup(GUI_INPUTS)
 		interest(1)
 	}
-	field(SVAL,DBF_USHORT) {
+	field(SVAL,DBF_STRING) {
 		prompt("Simulation Value")
+		size(40)
 	}
 	field(SIML,DBF_INLINK) {
 		prompt("Sim Mode Location")


Replies:
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Babak Kalantari
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Ralph Lange
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Dirk Zimoch
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Andrew Johnson
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Dirk Zimoch
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Dirk Zimoch
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Dirk Zimoch
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Dirk Zimoch
Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Dirk Zimoch

Navigate by Date:
Prev: [Merge] lp:~dirk.zimoch/epics-base/non-val-attributes into lp:epics-base Dirk Zimoch
Next: [Merge] lp:~dirk.zimoch/epics-base/fix-aai-and-aao into lp:epics-base Dirk Zimoch
Index: 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019 
Navigate by Thread:
Prev: Re: [Merge] lp:~dirk.zimoch/epics-base/non-val-attributes into lp:epics-base Dirk Zimoch
Next: Re: [Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Babak Kalantari
Index: 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019 
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 ·