Exemple #1
0
static void initPeriodic(void)
{
    dbMenu *pmenu = dbFindMenu(pdbbase, "menuScan");
    double quantum = epicsThreadSleepQuantum();
    int i;

    if (!pmenu) {
        errlogPrintf("initPeriodic: menuScan not present\n");
        return;
    }
    nPeriodic = pmenu->nChoice - SCAN_1ST_PERIODIC;
    papPeriodic = dbCalloc(nPeriodic, sizeof(periodic_scan_list*));
    periodicTaskId = dbCalloc(nPeriodic, sizeof(void *));
    for (i = 0; i < nPeriodic; i++) {
        periodic_scan_list *ppsl = dbCalloc(1, sizeof(periodic_scan_list));
        const char *choice = pmenu->papChoiceValue[i + SCAN_1ST_PERIODIC];
        double number;
        char *unit;
        int status = epicsParseDouble(choice, &number, &unit);

        ppsl->scan_list.lock = epicsMutexMustCreate();
        ellInit(&ppsl->scan_list.list);
        ppsl->name = choice;
        if (status || number == 0) {
            errlogPrintf("initPeriodic: Bad menuScan choice '%s'\n", choice);
            ppsl->period = i;
        }
        else if (!*unit ||
                 !epicsStrCaseCmp(unit, "second") ||
                 !epicsStrCaseCmp(unit, "seconds")) {
            ppsl->period = number;
        }
        else if (!epicsStrCaseCmp(unit, "minute") ||
                 !epicsStrCaseCmp(unit, "minutes")) {
            ppsl->period = number * 60;
        }
        else if (!epicsStrCaseCmp(unit, "hour") ||
                 !epicsStrCaseCmp(unit, "hours")) {
            ppsl->period = number * 60 * 60;
        }
        else if (!epicsStrCaseCmp(unit, "Hz") ||
                 !epicsStrCaseCmp(unit, "Hertz")) {
            ppsl->period = 1 / number;
        }
        else {
            errlogPrintf("initPeriodic: Bad menuScan choice '%s'\n", choice);
            ppsl->period = i;
        }
        number = ppsl->period / quantum;
        if ((ppsl->period < 2 * quantum) ||
            (number / floor(number) > 1.1)) {
            errlogPrintf("initPeriodic: Scan rate '%s' is not achievable.\n",
                choice);
        }
        ppsl->scanCtl = ctlPause;
        ppsl->loopEvent = epicsEventMustCreate(epicsEventEmpty);

        papPeriodic[i] = ppsl;
    }
}
Exemple #2
0
int callbackParallelThreads(int count, const char *prio)
{
    if (callbackIsInit) {
        fprintf(stderr, "Callback system already initialized\n");
        return -1;
    }

    if (count < 0)
        count = epicsThreadGetCPUs() + count;
    else if (count == 0)
        count = callbackParallelThreadsDefault;
    if (count < 1) count = 1;

    if (!prio || *prio == 0 || strcmp(prio, "*") == 0) {
        int i;

        for (i = 0; i < NUM_CALLBACK_PRIORITIES; i++) {
            callbackQueue[i].threadsConfigured = count;
        }
    }
    else {
        dbMenu *pdbMenu;
        int i;

        if (!pdbbase) {
            fprintf(stderr, "callbackParallelThreads: pdbbase not set\n");
            return -1;
        }

        /* Find prio in menuPriority */
        pdbMenu = dbFindMenu(pdbbase, "menuPriority");
        if (!pdbMenu) {
            fprintf(stderr, "callbackParallelThreads: No Priority menu\n");
            return -1;
        }

        for (i = 0; i < pdbMenu->nChoice; i++) {
            if (epicsStrCaseCmp(prio, pdbMenu->papChoiceValue[i]) == 0)
                goto found;
        }
        fprintf(stderr, "callbackParallelThreads: "
            "Unknown priority \"%s\"\n", prio);
        return -1;

found:
        callbackQueue[i].threadsConfigured = count;
    }
    return 0;
}
Exemple #3
0
static brkTable *findBrkTable(short linr)
{ 
    dbMenu	*pdbMenu;

    pdbMenu = dbFindMenu(pdbbase,"menuConvert");
    if (!pdbMenu) {
	epicsPrintf("findBrkTable: menuConvert not loaded!\n");
	return NULL;
    }
    if (linr < 0 || linr >= pdbMenu->nChoice) {
	epicsPrintf("findBrkTable: linr=%d but menuConvert only has %d choices\n",
	    linr,pdbMenu->nChoice);
	return NULL;
    }
    return dbFindBrkTable(pdbbase,pdbMenu->papChoiceValue[linr]);
}
Exemple #4
0
static int checkDatabase(dbBase *pdbbase)
{
    const dbMenu *pMenu;

    if (!pdbbase) {
        errlogPrintf("checkDatabase: No database definitions loaded.\n");
        return -1;
    }

    pMenu = dbFindMenu(pdbbase, "menuConvert");
    if (!pMenu) {
        errlogPrintf("checkDatabase: menuConvert not defined.\n");
        return -1;
    }
    if (pMenu->nChoice <= menuConvertLINEAR) {
        errlogPrintf("checkDatabase: menuConvert has too few choices.\n");
        return -1;
    }
    if (strcmp(pMenu->papChoiceName[menuConvertNO_CONVERSION],
               "menuConvertNO_CONVERSION")) {
        errlogPrintf("checkDatabase: menuConvertNO_CONVERSION doesn't match.\n");
        return -1;
    }
    if (strcmp(pMenu->papChoiceName[menuConvertSLOPE], "menuConvertSLOPE")) {
        errlogPrintf("checkDatabase: menuConvertSLOPE doesn't match.\n");
        return -1;
    }
    if (strcmp(pMenu->papChoiceName[menuConvertLINEAR], "menuConvertLINEAR")) {
        errlogPrintf("checkDatabase: menuConvertLINEAR doesn't match.\n");
        return -1;
    }

    pMenu = dbFindMenu(pdbbase, "menuScan");
    if (!pMenu) {
        errlogPrintf("checkDatabase: menuScan not defined.\n");
        return -1;
    }
    if (pMenu->nChoice <= menuScanI_O_Intr) {
        errlogPrintf("checkDatabase: menuScan has too few choices.\n");
        return -1;
    }
    if (strcmp(pMenu->papChoiceName[menuScanPassive],
               "menuScanPassive")) {
        errlogPrintf("checkDatabase: menuScanPassive doesn't match.\n");
        return -1;
    }
    if (strcmp(pMenu->papChoiceName[menuScanEvent],
               "menuScanEvent")) {
        errlogPrintf("checkDatabase: menuScanEvent doesn't match.\n");
        return -1;
    }
    if (strcmp(pMenu->papChoiceName[menuScanI_O_Intr],
               "menuScanI_O_Intr")) {
        errlogPrintf("checkDatabase: menuScanI_O_Intr doesn't match.\n");
        return -1;
    }
    if (pMenu->nChoice <= SCAN_1ST_PERIODIC) {
        errlogPrintf("checkDatabase: menuScan has no periodic choices.\n");
        return -1;
    }

    return 0;
}
Exemple #5
0
static void dbRecordtypeFieldItem(char *name,char *value)
{
    dbFldDes		*pdbFldDes;
    
    if(duplicate) return;
    pdbFldDes = (dbFldDes *)getLastTemp();
    if(strcmp(name,"asl")==0) {
	if(strcmp(value,"ASL0")==0) {
	    pdbFldDes->as_level = ASL0;
	} else if(strcmp(value,"ASL1")==0) {
	    pdbFldDes->as_level = ASL1;
	} else {
	    yyerror("Illegal Access Security value: Must be ASL0 or ASL1");
	}
	return;
    }
    if(strcmp(name,"initial")==0) {
	pdbFldDes->initial = epicsStrDup(value);
	return;
    }
    if(strcmp(name,"promptgroup")==0) {
	int	i;
	for(i=0; i<GUI_NTYPES; i++) {
	    if(strcmp(value,pamapguiGroup[i].strvalue)==0) {
		pdbFldDes->promptgroup = pamapguiGroup[i].value;
		return;
	    }
	}
	yyerror("Illegal promptgroup. See guigroup.h for legal values");
	return;
    }
    if(strcmp(name,"prompt")==0) {
	pdbFldDes->prompt = epicsStrDup(value);
	return;
    }
    if(strcmp(name,"special")==0) {
	int	i;
	for(i=0; i<SPC_NTYPES; i++) {
	    if(strcmp(value,pamapspcType[i].strvalue)==0) {
		pdbFldDes->special = pamapspcType[i].value;
		return;
	    }
	}
	if(sscanf(value,"%hd",&pdbFldDes->special)==1) {
	    return;
	}
	yyerror("Illegal special value.");
	return;
    }
    if(strcmp(name,"pp")==0) {
	if((strcmp(value,"YES")==0) || (strcmp(value,"TRUE")==0)) {
	    pdbFldDes->process_passive = TRUE;
	} else if((strcmp(value,"NO")==0) || (strcmp(value,"FALSE")==0)) {
	    pdbFldDes->process_passive = FALSE;
	} else {
	    yyerror("Illegal value. Must be NO or YES");
	}
	return;
    }
    if(strcmp(name,"interest")==0) {
	if(sscanf(value,"%hd",&pdbFldDes->interest)!=1) 
	    yyerror("Illegal value. Must be integer");
	return;
    }
    if(strcmp(name,"base")==0) {
	if(strcmp(value,"DECIMAL")==0) {
	    pdbFldDes->base = CT_DECIMAL;
	} else if(strcmp(value,"HEX")==0) {
	    pdbFldDes->base = CT_HEX;
	} else {
	    yyerror("Illegal value. Must be CT_DECIMAL or CT_HEX");
	}
	return;
    }
    if(strcmp(name,"size")==0) {
	if(sscanf(value,"%hd",&pdbFldDes->size)!=1) 
	    yyerror("Illegal value. Must be integer");
	return;
    }
    if(strcmp(name,"extra")==0) {
	pdbFldDes->extra = epicsStrDup(value);
	return;
    }
    if(strcmp(name,"menu")==0) {
	pdbFldDes->ftPvt = (dbMenu *)dbFindMenu(pdbbase,value);
	if(!pdbbase->ignoreMissingMenus && !pdbFldDes->ftPvt)
	    yyerrorAbort("menu not found");
	return;
    }
}