Changed soft events from numbers to strings.
This commit is contained in:
+3
-2
@@ -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(41)
|
||||
interest(1)
|
||||
}
|
||||
field(TSE,DBF_SHORT) {
|
||||
|
||||
@@ -266,11 +266,11 @@ static void scanpplCallFunc(const iocshArgBuf *args)
|
||||
{ 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};
|
||||
|
||||
+56
-47
@@ -101,12 +101,13 @@ static char *priorityName[NUM_CALLBACK_PRIORITIES] = {
|
||||
|
||||
/* EVENT */
|
||||
|
||||
#define MAX_EVENTS 256
|
||||
typedef struct event_scan_list {
|
||||
CALLBACK callback;
|
||||
scan_list scan_list;
|
||||
char event_name[MAX_STRING_SIZE];
|
||||
struct event_scan_list *next;
|
||||
} event_scan_list;
|
||||
static event_scan_list *pevent_list[NUM_CALLBACK_PRIORITIES][MAX_EVENTS];
|
||||
static event_scan_list *pevent_list[NUM_CALLBACK_PRIORITIES];
|
||||
|
||||
|
||||
/* IO_EVENT*/
|
||||
@@ -204,12 +205,12 @@ void scanAdd(struct dbCommon *precord)
|
||||
recGblRecordError(-1, (void *)precord,
|
||||
"scanAdd detected illegal SCAN value");
|
||||
} else if (scan == menuScanEvent) {
|
||||
int evnt;
|
||||
char* evnt;
|
||||
int prio;
|
||||
event_scan_list *pesl;
|
||||
event_scan_list **ppesl;
|
||||
|
||||
evnt = precord->evnt;
|
||||
if (evnt < 0 || evnt >= MAX_EVENTS) {
|
||||
if (*evnt == 0) {
|
||||
recGblRecordError(S_db_badField, (void *)precord,
|
||||
"scanAdd detected illegal EVNT value");
|
||||
precord->scan = menuScanPassive;
|
||||
@@ -222,17 +223,20 @@ void scanAdd(struct dbCommon *precord)
|
||||
precord->scan = menuScanPassive;
|
||||
return;
|
||||
}
|
||||
pesl = pevent_list[prio][evnt];
|
||||
if (pesl == NULL) {
|
||||
pesl = dbCalloc(1, sizeof(event_scan_list));
|
||||
pevent_list[prio][evnt] = pesl;
|
||||
pesl->scan_list.lock = epicsMutexMustCreate();
|
||||
callbackSetCallback(eventCallback, &pesl->callback);
|
||||
callbackSetPriority(prio, &pesl->callback);
|
||||
callbackSetUser(pesl, &pesl->callback);
|
||||
ellInit(&pesl->scan_list.list);
|
||||
for (ppesl = &pevent_list[prio]; *ppesl; ppesl=&(*ppesl)->next) {
|
||||
if (strcmp((*ppesl)->event_name, evnt) == 0) break;
|
||||
}
|
||||
addToList(precord, &pesl->scan_list);
|
||||
|
||||
if (*ppesl == NULL) {
|
||||
*ppesl = dbCalloc(1, sizeof(event_scan_list));
|
||||
strcpy((*ppesl)->event_name, evnt);
|
||||
(*ppesl)->scan_list.lock = epicsMutexMustCreate();
|
||||
callbackSetCallback(eventCallback, &(*ppesl)->callback);
|
||||
callbackSetPriority(prio, &(*ppesl)->callback);
|
||||
callbackSetUser(*ppesl, &(*ppesl)->callback);
|
||||
ellInit(&(*ppesl)->scan_list.list);
|
||||
}
|
||||
addToList(precord, &(*ppesl)->scan_list);
|
||||
} else if (scan == menuScanI_O_Intr) {
|
||||
io_scan_list *piosl = NULL;
|
||||
int prio;
|
||||
@@ -287,13 +291,13 @@ void scanDelete(struct dbCommon *precord)
|
||||
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) {
|
||||
if (*evnt == 0) {
|
||||
recGblRecordError(S_db_badField, (void *)precord,
|
||||
"scanAdd detected illegal EVNT value");
|
||||
precord->scan = menuScanPassive;
|
||||
@@ -306,7 +310,9 @@ void scanDelete(struct dbCommon *precord)
|
||||
precord->scan = menuScanPassive;
|
||||
return;
|
||||
}
|
||||
pesl = pevent_list[prio][evnt];
|
||||
for (pesl = pevent_list[prio]; pesl; pesl=pesl->next) {
|
||||
if (strcmp(pesl->event_name, evnt) == 0) break;
|
||||
}
|
||||
if (pesl) psl = &pesl->scan_list;
|
||||
if (!pesl || !psl)
|
||||
recGblRecordError(-1, (void *)precord,
|
||||
@@ -372,21 +378,19 @@ int scanppl(double period) /* print periodic list */
|
||||
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++) {
|
||||
for (pesl = pevent_list[prio]; 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", evnt, priorityName[prio]);
|
||||
printList(&pesl->scan_list, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -420,31 +424,36 @@ static void eventCallback(CALLBACK *pcallback)
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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++) {
|
||||
for (pesl = pevent_list[prio]; 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)
|
||||
|
||||
+9
-2
@@ -32,6 +32,11 @@ extern "C" {
|
||||
#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 long scanInit(void);
|
||||
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 scanOnceSetQueueSize(int size);
|
||||
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);
|
||||
|
||||
+6
-12
@@ -539,27 +539,21 @@ static void execOutput(calcoutRecord *prec)
|
||||
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;
|
||||
|
||||
@@ -255,7 +255,7 @@ recordtype(calcout) {
|
||||
prompt("OCAL Valid")
|
||||
interest(1)
|
||||
}
|
||||
field(OEVT,DBF_USHORT) {
|
||||
field(OEVT,DBF_STRING) {
|
||||
prompt("Event To Issue")
|
||||
promptgroup(GUI_CLOCK)
|
||||
asl(ASL0)
|
||||
|
||||
@@ -103,7 +103,7 @@ static long init_record(eventRecord *prec, int pass)
|
||||
}
|
||||
|
||||
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 @@ static long process(eventRecord *prec)
|
||||
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 process(eventRecord *prec)
|
||||
|
||||
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 @@ static long readValue(eventRecord *prec)
|
||||
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 {
|
||||
|
||||
@@ -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 @@ recordtype(event) {
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user