Files
sics/intserv.c
Ferdi Franceschini 10d29d597c Cleaned up ANSTO code to merge with sinqdev.sics
This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c
Conflicts:
	.gitignore
	SICSmain.c
	asynnet.c
	confvirtualmot.c
	counter.c
	devexec.c
	drive.c
	event.h
	exebuf.c
	exeman.c
	histmem.c
	interface.h
	motor.c
	motorlist.c
	motorsec.c
	multicounter.c
	napi.c
	napi.h
	napi4.c
	network.c
	nwatch.c
	nxscript.c
	nxxml.c
	nxxml.h
	ofac.c
	reflist.c
	scan.c
	sicshipadaba.c
	sicsobj.c
	site_ansto/docs/Copyright.txt
	site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl
	site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl
	statusfile.c
	tasdrive.c
	tasub.c
	tasub.h
	tasublib.c
	tasublib.h
2015-04-23 20:49:26 +10: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;
}