Files
sics/intserv.c
koennecke 1afe142812 - Removed old code
- Extended tasker to support task groups
- Added task functions for motors and counters
- Modifed devexec to use the new task functions
- Modified TAS to treat the monochromator separatly
- Coded a EIGER monochromator module to reflect even more new
  requirements
- Added EPICS counters and motors
- Modified multicounter to be better performing


SKIPPED:
	psi/eigermono.c
	psi/make_gen
	psi/makefile_linux
	psi/psi.c
	psi/sinqhttp.c
2013-04-02 15:13:35 +00:00

90 lines
2.0 KiB
C

/*--------------------------------------------------------------------------
The server side implementation of the Interrupt module.
As future version of this module may support adding interrupt
handlers, the necessary precautions are made, by keeping the
interrupt handlers in an array of function pointers. Is
quick as well.
Mark Koennecke, November 1996
Revised: Mark Koennecke, September 1997
Removed unused UDP interrupt port stuff
Mark Koennecke, February 2013
Copyright: see copyright.h
Labor fuer Neutronenstreuung
Paul Scherrer Institut
CH-5423 Villigen-PSI
-----------------------------------------------------------------------------*/
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <strlutil.h>
#include "fortify.h"
#include "sics.h"
#include "network.h"
#include "interrupt.h"
#include "status.h"
#include "splitter.h"
#include "configfu.h"
#include "devexec.h"
#include "servlog.h"
#include "nread.h"
#include "task.h"
#include "event.h"
#define MAXINTERRUPT 7
#define INTERUPTWAIT 5
/*----------------------------------------------------------------------------*/
static char *pIntText[] = {
"continue",
"abortop",
"abortscan",
"abortbatch",
"halt",
"free",
"end",
NULL
};
/*-------------------------------------------------------------------------*/
void SetInterrupt(int iCode)
{
int iInt;
iInt = iCode;
TaskSignal(pServ->pTasker, SICSINT, &iInt);
}
/*--------------------------------------------------------------------------*/
int Interrupt2Text(int iInterrupt, char *text, int iTextLen)
{
if ((iInterrupt < 0) || (iInterrupt > MAXINTERRUPT)) {
return 0;
}
strlcpy(text, pIntText[iInterrupt], iTextLen - 1);
return 1;
}
/*-------------------------------------------------------------------------*/
int Text2Interrupt(char *text)
{
int i = 0;
while (pIntText[i] != NULL) {
if (strcmp(pIntText[i], text) == 0) {
break;
}
i++;
}
if (i >= MAXINTERRUPT) {
return -1;
}
return i;
}