Attached is a patch file for dbScan.c which should fix the problem and
restore backward compatibility.
I have created (and quickly tested) it with EPICS 7 but I guess it
should work with 3.16 as well.
The hack is to treat "x.000000" and "x" as the same event name if x is
an integer between 0 and 255. ("0" and "0.000000" are no event at all
now just like "").
I will create a merge request for the EPICS base repo once I have proper
tests and documentation.
Dirk
On 08.02.2018 10:08, Dirk Zimoch wrote:
This is interesting. When I wrote the "named Events" feature some years
ago, I tested with something like 2 which became "2" and all was fine.
However I never thought about generating the value from a calc. This
should be fixed, or at least "2.000000" and "2" should be treated as equal.
I will start working on it...
Dirk
On 30.01.2018 17:20, Simon Reiter wrote:
Thanks so far.
postEvent 2
works fine.
Up to now, my event record has an INP field, which links to a calc
record.
This calc record only provides the correct value under some conditions.
How can I do this without using a state machine?
record(calc,"$(BOARDNAME):ErrorFlags:calc")
{
field(INPA, "$(BOARDNAME):InitDone:S CPP")
field(CALC, "A ? 2 : 0")
}
record(event, "$(BOARDNAME):ErrorFlags:trg")
{
field(INP, "$(BOARDNAME):ErrorFlags:calc CPP")
}
This is my current code. The value of event is now 2.000000 in the
correct case.
diff --git a/src/ioc/db/dbScan.c b/src/ioc/db/dbScan.c
index 9f7df4c..ccaa831 100644
--- a/src/ioc/db/dbScan.c
+++ b/src/ioc/db/dbScan.c
@@ -112,6 +112,10 @@ typedef struct event_list {
struct event_list *next;
char event_name[MAX_STRING_SIZE];
} event_list;
+
+/* For backward compatibility with numeric events keep 255 slots.
+ Named events are in slot 0.
+*/
static event_list * volatile pevent_list[256];
static epicsMutexId event_lock;
@@ -478,10 +482,24 @@ event_list *eventNameToHandle(const char *eventname)
int prio;
event_list *pel;
static epicsThreadOnceId onceId = EPICS_THREAD_ONCE_INIT;
+ char* p;
+ long eventnumber;
if (!eventname || eventname[0] == 0)
return NULL;
+ /* Backward compatibility with numeric events:
+ Treat "x.000000" with 0<=x<=255 like "x"
+ because it is most probably a conversion from double
+ like from a calc record.
+ */
+ eventnumber = strtol(eventname, &p, 0);
+ if (eventnumber >= 0 && eventnumber <= 255
+ && (*p == 0 || strcmp(p, ".000000") == 0))
+ *p = 0; /* truncate ".000000" */
+ else
+ eventnumber = 0; /* not a numeric event */
+
epicsThreadOnce(&onceId, eventOnce, NULL);
epicsMutexMustLock(event_lock);
for (pel = pevent_list[0]; pel; pel=pel->next) {
@@ -501,12 +519,9 @@ event_list *eventNameToHandle(const char *eventname)
}
pel->next=pevent_list[0];
pevent_list[0]=pel;
- { /* backward compatibility */
- char* p;
- long e = strtol(eventname, &p, 0);
- if (*p == 0 && e > 0 && e <= 255)
- pevent_list[e] = pel;
- }
+ /* backward compatibility */
+ if (eventnumber > 0)
+ pevent_list[eventnumber] = pel;
}
done:
epicsMutexUnlock(event_lock);
- Replies:
- Re: Scanning on event number fails with EPICS 3.16 Simon Reiter
- References:
- Scanning on event number fails with EPICS 3.16 Simon Reiter
- Re: Scanning on event number fails with EPICS 3.16 Benjamin Franksen
- Re: Scanning on event number fails with EPICS 3.16 Simon Reiter
- Re: Scanning on event number fails with EPICS 3.16 Dirk Zimoch
- Navigate by Date:
- Prev:
RE: mca compilation fails on windows 7, keyword re-definition Mark Rivers
- Next:
Re: Sequencer seem to skip states with EPICS 3.16.1 Benjamin Franksen
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<2018>
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Scanning on event number fails with EPICS 3.16 Dirk Zimoch
- Next:
Re: Scanning on event number fails with EPICS 3.16 Simon Reiter
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<2018>
2019
2020
2021
2022
2023
2024
|