restructured configuration (ofac.c)

- ofac.c contains now only the command in initialisation function list
- the other functions are moved to sicsutil.c
- moved DoubleTime and the content of access.c to sicsutil.c
- moved some initialisation code from ofac.c to the corresponding modules
This commit is contained in:
zolliker
2010-01-28 08:14:37 +00:00
parent 9b18a3bd0a
commit 4bf0c87daf
15 changed files with 199 additions and 515 deletions

View File

@ -81,7 +81,7 @@ int BackgroundAction(SConnection * pCon, SicsInterp * pSics,
}
/*--------------------------------------------------------------------------*/
void InstallBackground(SicsInterp * pSics)
void InstallBackground(void)
{
AddCommand(pSics, "bg", BackgroundAction, NULL, NULL);
AddCmd("bg", BackgroundAction);
}

View File

@ -21,6 +21,6 @@ int BackgroundCommand(SConnection * pCon, char *command);
/*
* used only once for installing Background
*/
void InstallBackground(SicsInterp * pSics);
void InstallBackground(void);
#endif /*BACKGROUND_H_ */

View File

@ -516,3 +516,8 @@ void CommandLogClose(void *pData)
if (pTail)
deleteCircular(pTail);
}
/*-------------------------------------------------------------------------*/
void CommandLogInit(void)
{
AddCommand(pServ->pSics, "commandlog", CommandLog, CommandLogClose, NULL);
}

View File

@ -1305,3 +1305,20 @@ void UnlockDeviceExecutor(pExeList self)
assert(self);
self->iLock = 0;
}
/*--------------------------------------------------------------------*/
void DevExecInit(void)
{
pExeList pExe = pServ->pExecutor;
/* commands to do with the executor. Only StopExe carries the
DeleteFunction in order to avoid double deletion. All the
other commands operate on the same datastructure.
*/
AddCommand(pServ->pSics, "StopExe", StopCommand, DeleteExeList, pExe);
AddCommand(pServ->pSics, "ListExe", ListExe, NULL, pExe);
AddCommand(pServ->pSics, "sicsidle", SicsIdle, NULL, pExe);
AddCommand(pServ->pSics, "Success", Success, NULL, pExe);
AddCommand(pServ->pSics, "pause", PauseAction, NULL, pExe);
AddCommand(pServ->pSics, "continue", ContinueAction, NULL, pExe);
AddCommand(pServ->pSics, "devexec", DevexecAction, NULL, pExe);
}

1
emon.c
View File

@ -68,6 +68,7 @@ pEnvMon CreateEnvMon(void)
free(pNew);
return NULL;
}
AddCommand(pServ->pSics, "emon", EVWrapper, DeleteEnvMon, pNew);
return pNew;
}

5
help.c
View File

@ -157,3 +157,8 @@ int SicsHelp(SConnection * pCon, SicsInterp * pSics, void *pData,
fclose(fd);
return 1;
}
/*-----------------------------------------------------------------------*/
void HelpInit(void)
{
AddCommand(pServ->pSics, "help", SicsHelp, KillHelp, NULL);
}

View File

@ -8,7 +8,7 @@
COBJ = Sclient.o network.o ifile.o intcli.o $(FORTIFYOBJ)
SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
servlog.o sicvar.o nserver.o SICSmain.o motorlist.o\
sicsexit.o costa.o task.o $(FORTIFYOBJ) access.o\
sicsexit.o costa.o task.o $(FORTIFYOBJ) \
macro.o ofac.o obpar.o obdes.o drive.o status.o intserv.o \
devexec.o mumo.o mumoconf.o selector.o selvar.o fupa.o lld.o \
lld_blob.o strrepl.o lin2ang.o fomerge.o napi5.o napi4.o\
@ -41,7 +41,7 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
sgclib.o sgfind.o sgio.o sgsi.o sghkl.o singlediff.o singlebi.o \
singlenb.o simindex.o simidx.o uselect.o singletas.o motorsec.o \
rwpuffer.o asynnet.o background.o countersec.o hdbtable.o velosec.o \
histmemsec.o sansbc.o
histmemsec.o sansbc.o sicsutil.o
MOTOROBJ = motor.o simdriv.o
COUNTEROBJ = countdriv.o simcter.o counter.o

View File

@ -20,7 +20,6 @@
#include <signal.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include "sics.h"
#include "network.h"
#include "ifile.h"
@ -525,15 +524,3 @@ int ServerIsStarting(pServer self)
{
return self->pReader == NULL;
}
/*-------------------------------------------------------------------------*/
double DoubleTime(void)
{
struct timeval now;
/* the resolution of this function is usec, if the machine supports this
and the mantissa of a double is 51 bits or more (31 for sec and 20 for mic$
*/
gettimeofday(&now, NULL);
return now.tv_sec + now.tv_usec / 1e6;
}

View File

@ -52,7 +52,4 @@ int UserWait(SConnection * pCon, SicsInterp * pSics, void *pData,
int SicsWait(long lTime);
int ServerIsStarting(pServer self);
double DoubleTime(void);
/* returns time since epoch in seconds
the resultion is machine dependent, but mostly better than msec */
#endif

606
ofac.c
View File

@ -1,439 +1,17 @@
/*--------------------------------------------------------------------------
/**
* Startup commands and definitions
*
* copyright: see file COPYRIGHT
*
* Mark Koennecke 1996 - ?
* heavy modifications to separate PSI specific commands into a
* separate library. Mark Koennecke, June 2003
*
* moved all staff except command and initialization list to sicsutil.c
* Markus Zolliker Jan 2010
*/
The ObjectFactory.
See .h file what it does.
Mark Koennecke, November 1996 -- ????
heavy modifications to separate PSI specific commands into a
separate library. Mark Koennecke, June 2003
Copyright:
Labor fuer Neutronenstreuung
Paul Scherrer Institut
CH-5423 Villigen-PSI
The authors hereby grant permission to use, copy, modify, distribute,
and license this software and its documentation for any purpose, provided
that existing copyright notices are retained in all copies and that this
notice is included verbatim in any distributions. No written agreement,
license, or royalty fee is required for any of the authorized uses.
Modifications to this software may be copyrighted by their authors
and need not follow the licensing terms described here, provided that
the new terms are clearly indicated on the first page of each file where
they apply.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
MODIFICATIONS.
-----------------------------------------------------------------------------*/
#include <stdlib.h>
#include <assert.h>
#include "fortify.h"
#include "sics.h"
#include "ifile.h"
#include "sicsexit.h"
#include "passwd.h"
#include "macro.h"
#include "splitter.h"
#include "sicsvar.h"
#include "drive.h"
#include "motor.h"
#include "servlog.h"
#include "nserver.h"
#include "status.h"
#include "statusfile.h"
#include "configfu.h"
#include "devexec.h"
#include "mumo.h"
#include "selector.h"
#include "selvar.h"
#include "countdriv.h"
#include "counter.h"
#include "scan.h"
#include "script.h"
#include "o2t.h"
#include "alias.h"
#include "stringdict.h"
#include "HistMem.h"
#include "velo.h"
#include "emon.h"
#include "evcontroller.h"
#include "danu.h"
#include "nserver.h"
#include "scan.h"
#include "fitcenter.h"
#include "token.h"
#include "hkl.h"
#include "optimise.h"
#include "commandlog.h"
#include "udpquieck.h"
#include "choco.h"
#include "chadapter.h"
#include "xytable.h"
#include "maximize.h"
#include "difrac.h"
#include "sicscron.h"
#include "lin2ang.h"
#include "synchronize.h"
#include "definealias.h"
#include "hmcontrol.h"
#include "rs232controller.h"
#include "lomax.h"
#include "anticollider.h"
#include "gpibcontroller.h"
#include "nxscript.h"
#include "tclintimpl.h"
#include "tcldrivable.h"
#include "sicsdata.h"
#include "help.h"
#include "site.h"
#include "nxupdate.h"
#include "confvirtmot.h"
#include "exeman.h"
#include "oscillate.h"
#include "diffscan.h"
#include "hklmot.h"
#include "ubcalc.h"
#include "tasub.h"
#include "tasscanub.h"
#include "mcreader.h"
#include "mccontrol.h"
#include "protocol.h"
#include "sinfox.h"
#include "sicslist.h"
#include "cone.h"
#include "sicshipadaba.h"
#include "multicounter.h"
#include "sicspoll.h"
#include "statemon.h"
#include "asyncqueue.h"
#include "asyncprotocol.h"
#include "sicsobj.h"
#include "proxy.h"
#include "reflist.h"
#include "singlex.h"
#include "motorsec.h"
#include "background.h"
#include "velosec.h"
#include "histmemsec.h"
#include "hdbtable.h"
#include "sansbc.h"
/*----------------------- Server options creation -------------------------*/
static int IFServerOption(SConnection * pCon, SicsInterp * pSics,
void *pData, int argc, char *argv[])
{
char pBueffel[512];
assert(pSics);
assert(pCon);
/* check authorisation */
if (!SCMatchRights(pCon, usMugger)) {
SCWrite(pCon, "Insufficient privilege to set options", eError);
return 0;
}
/* test if sufficient arguments */
if (argc < 3) {
snprintf(pBueffel,sizeof(pBueffel)-1, "Syntax: %s name value ", argv[0]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
/* just do it */
pSICSOptions = IFAddOption(pSICSOptions, argv[1], argv[2]);
return 1;
}
/*----------------------- Password database update -------------------------*/
static int PWSicsUser(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
char pBueffel[512];
TokenList *pList = NULL;
assert(pSics);
assert(pCon);
/* check authorisation */
if (SCGetRights(pCon) > usMugger) {
SCWrite(pCon, "Insufficient privilege to set users", eError);
return 0;
}
/* analyse commandlist */
pList = SplitArguments(argc - 1, &argv[1]);
if ((!pList) || (!pList->pNext) || (!pList->pNext->pNext)) {
snprintf(pBueffel,sizeof(pBueffel)-1, "Invalid Passwd Entry ::\n %s %s %s\n", argv[1],
argv[2], argv[3]);
SCWrite(pCon, pBueffel, eError);
DeleteTokenList(pList);
return 0;
} else {
if (pList->pNext->pNext->Type != eInt) {
SCWrite(pCon, "Need integer rights code", eError);
DeleteTokenList(pList);
return 0;
} else {
AddUser(pList->text, pList->pNext->text, pList->pNext->pNext->iVal);
}
}
DeleteTokenList(pList);
return 1;
}
/*--------------------------------------------------------------------------*/
static void InitIniCommands(SicsInterp * pInter, pTaskMan pTask)
{
pExeList pExe;
pEnvMon pEnv = NULL;
pSite site = NULL;
assert(pInter);
pExe = CreateExeList(pTask);
pServ->pExecutor = pExe;
pEnv = CreateEnvMon();
assert(pExe);
assert(pEnv);
/* permanent commands */
AddCommand(pInter, "Sics_Exitus", SicsExit, NULL, NULL);
AddCommand(pInter, "FileEval", MacroFileEval, NULL, NULL);
AddCommand(pInter, "InternEval", InternalFileEval, NULL, NULL);
AddCommand(pInter, "ClientPut", ClientPut, NULL, NULL);
AddCommand(pInter, "Capture", CaptureAction, NULL, NULL);
AddCommand(pInter, "GumPut", GumPut, NULL, NULL);
AddCommand(pInter, "broadcast", Broadcast, NULL, NULL);
AddCommand(pInter, "transact", TransactAction, NULL, NULL);
AddCommand(pInter, "fulltransact", TransactAction, NULL, NULL);
AddCommand(pInter, "sicsprompt", SicsPrompt, NULL, NULL);
AddCommand(pInter, "Publish", TclPublish, NULL, NULL);
AddCommand(pInter, "GetLog", LogCapture, NULL, NULL);
AddCommand(pInter, "config", ConfigCon, NULL, NULL);
AddCommand(pInter, "wait", UserWait, NULL, NULL);
AddCommand(pInter, "status", UserStatus, NULL, NULL);
AddCommand(pInter, "ResetServer", ResetStatus, NULL, NULL);
AddCommand(pInter, "Dir", ListObjects, NULL, NULL);
AddCommand(pInter, "SetInt", SetSICSInterrupt, NULL, NULL);
AddCommand(pInter, "GetInt", GetSICSInterrupt, NULL, NULL);
AddCommand(pInter, "SICSType", SICSType, NULL, NULL);
AddCommand(pInter, "SICSBounds", SICSBounds, NULL, NULL);
AddCommand(pInter, "SICSStatus", SICSStatus, NULL, NULL);
AddCommand(pInter, "sicstime", SICSTime, NULL, NULL);
AddCommand(pInter, "sicsdescriptor", SICSDescriptor, NULL, NULL);
AddCommand(pInter, "silent", SICSSilent, NULL, NULL);
AddCommand(pInter, "SetStatus", SetSICSStatus, NULL, NULL);
AddCommand(pInter, "db", SICSDebug, NULL, NULL);
AddCommand(pInter, "EVFactory", EVControlFactory, NULL, NULL);
AddCommand(pInter, "emon", EVWrapper, DeleteEnvMon, pEnv);
AddCommand(pInter, "commandlog", CommandLog, CommandLogClose, NULL);
AddCommand(pInter, "udpquieck", QuieckAction, KillQuieck, NULL);
AddCommand(pInter, "alias", MakeAlias, NULL, NULL);
AddCommand(pInter, "findalias", LocateAliasAction, NULL, NULL);
AddCommand(pInter, "sicscron", MakeCron, NULL, NULL);
AddCommand(pInter, "dolater", MakeCron, NULL, NULL);
AddCommand(pInter, "sicsdatafactory", SICSDataFactory, NULL, NULL);
AddCommand(pInter, "scriptcallback", CallbackScript, NULL, NULL);
AddCommand(pInter, "help", SicsHelp, KillHelp, NULL);
AddCommand(pInter, "list", SicsList, NULL, NULL);
AddCommand(pInter, "InstallHdb", InstallSICSHipadaba, NULL, NULL);
MakeProtocol(pInter);
InstallBackground(pInter);
/* commands to do with the executor. Only StopExe carries the
DeleteFunction in order to avoid double deletion. All the
other commands operate on the same datastructure.
*/
AddCommand(pInter, "StopExe", StopCommand, DeleteExeList, pExe);
AddCommand(pInter, "ListExe", ListExe, NULL, pExe);
AddCommand(pInter, "sicsidle", SicsIdle, NULL, pExe);
AddCommand(pInter, "Success", Success, NULL, pExe);
AddCommand(pInter, "pause", PauseAction, NULL, pExe);
AddCommand(pInter, "continue", ContinueAction, NULL, pExe);
AddCommand(pInter, "devexec", DevexecAction, NULL, pExe);
/* add additional object creation commands here */
AddCommand(pInter, "TokenInit", TokenInit, NULL, NULL);
AddCommand(pInter, "ServerOption", IFServerOption, NULL, NULL);
AddCommand(pInter, "SicsUser", PWSicsUser, NULL, NULL);
AddCommand(pInter, "VarMake", VarFactory, NULL, NULL);
AddCommand(pInter, "MakeDrive", MakeDrive, NULL, NULL);
AddCommand(pInter, "Motor", MotorCreate, NULL, NULL);
AddCommand(pInter, "MakeMulti", MakeMulti, NULL, NULL);
AddCommand(pInter, "MakeMono", MonoInit, NULL, NULL);
AddCommand(pInter, "MakeWaveLength", MakeWaveLengthVar, NULL, NULL);
AddCommand(pInter, "MakeEnergy", MakeEnergyVar, NULL, NULL);
AddCommand(pInter, "MakeCounter", MakeCounter, NULL, NULL);
AddCommand(pInter, "MakeSecCounter", MakeSecCter, NULL, NULL);
AddCommand(pInter, "MakeO2T", CreateO2T, NULL, NULL);
AddCommand(pInter, "SicsAlias", SicsAlias, NULL, NULL);
AddCommand(pInter, "DefineAlias", DefineAlias, NULL, NULL); /* M.Z. */
AddCommand(pInter, "MakeHM", MakeHistMemory, NULL, NULL);
AddCommand(pInter, "VelocitySelector", VelSelFactory, NULL, NULL);
AddCommand(pInter, "MakeDataNumber", DNFactory, NULL, NULL);
AddCommand(pInter, "MakeScanCommand", ScanFactory, NULL, NULL);
AddCommand(pInter, "MakePeakCenter", FitFactory, NULL, NULL);
AddCommand(pInter, "MakeHKL", HKLFactory, NULL, NULL);
AddCommand(pInter, "MakeOptimise", MakeOptimiser, NULL, NULL);
AddCommand(pInter, "kill_command", SICSKill, NULL, NULL);
AddCommand(pInter, "MakeChopper", ChocoFactory, NULL, NULL);
AddCommand(pInter, "ChopperAdapter", CHAdapterFactory, NULL, NULL);
AddCommand(pInter, "MakeXYTable", XYFactory, NULL, NULL);
AddCommand(pInter, "MakeMaximize", MaximizeFactory, NULL, NULL);
AddCommand(pInter, "MakeLin2Ang", MakeLin2Ang, NULL, NULL);
AddCommand(pInter, "MakeSync", MakeSync, NULL, NULL);
AddCommand(pInter, "MakeHMControl", MakeHMControl, NULL, NULL);
AddCommand(pInter, "MakeRS232Controller", RS232Factory, NULL, NULL);
AddCommand(pInter, "MakeMaxDetector", LoMaxFactory, NULL, NULL);
AddCommand(pInter, "AntiCollisionInstall", AntiColliderFactory, NULL,
NULL);
AddCommand(pInter, "MakeGPIB", MakeGPIB, NULL, NULL);
AddCommand(pInter, "MakeNXScript", MakeNXScript, NULL, NULL);
AddCommand(pInter, "MakeTclInt", MakeTclInt, NULL, NULL);
AddCommand(pInter, "TclReplaceDrivable", TclReplaceDrivable, NULL, NULL);
AddCommand(pInter, "DrivableInvoke", TclDrivableInvoke, NULL, NULL);
AddCommand(pInter, "UpdateFactory", UpdateFactory, NULL, NULL);
AddCommand(pInter, "allowexec", AllowExec, NULL, NULL);
AddCommand(pInter, "MakeConfigurableMotor",
MakeConfigurableVirtualMotor, NULL, NULL);
AddCommand(pInter, "MakeBatchManager", MakeExeManager, NULL, NULL);
AddCommand(pInter, "MakeOscillator", MakeOscillator, NULL, NULL);
AddCommand(pInter, "MakeDiffScan", MakeDiffScan, NULL, NULL);
AddCommand(pInter, "MakeHKLMot", HKLMotInstall, NULL, NULL);
AddCommand(pInter, "MakeUBCalc", MakeUBCalc, NULL, NULL);
AddCommand(pInter, "MakeTasUB", TasUBFactory, NULL, NULL);
AddCommand(pInter, "MakeTasScan", TASUBScanFactory, NULL, NULL);
AddCommand(pInter, "MakeMcStasReader", McStasReaderFactory, NULL, NULL);
AddCommand(pInter, "MakeMcStasController",
McStasControllerFactory, NULL, NULL);
AddCommand(pInter, "InstallSinfox", InstallSinfox, NULL, NULL);
AddCommand(pInter, "MakeCone", MakeCone, NULL, NULL);
AddCommand(pInter, "MakeMultiCounter", MakeMultiCounter, NULL, NULL);
AddCommand(pInter, "MakeSicsPoll", InstallSICSPoll, NULL, NULL);
AddCommand(pInter, "MakeStateMon", StateMonFactory, NULL, NULL);
AddCommand(pInter, "MakeAsyncProtocol", AsyncProtocolFactory, NULL,
NULL);
AddCommand(pInter, "MakeAsyncQueue", AsyncQueueFactory, NULL, NULL);
AddCommand(pInter, "MakeSicsObj", InstallSICSOBJ, NULL, NULL);
AddCommand(pInter, "DynSicsObj", InstallSICSOBJ, NULL, NULL);
AddCommand(pInter, "MakeProxy", ProxyFactory, NULL, NULL);
AddCommand(pInter, "MakeRefList", MakeReflectionList, NULL, NULL);
AddCommand(pInter, "MakeSingleX", MakeSingleX, NULL, NULL);
AddCommand(pInter, "MakeSecMotor", SecMotorFactory, NULL, NULL);
AddCommand(pInter, "MakeSecNVS", MakeSecNVS, NULL, NULL);
AddCommand(pInter, "MakeSecHM", MakeSecHM, NULL, NULL);
AddCommand(pInter, "MakeHdbTable", HdbTableFactory, NULL, NULL);
AddCommand(pInter, "MakeSansBC", SansBCFactory, NULL, NULL);
/*
install site specific commands
*/
site = getSite();
if (site != NULL) {
site->AddSiteCommands(pInter);
}
}
/*---------------------------------------------------------------------------*/
static void KillIniCommands(SicsInterp * pSics)
{
pSite site = NULL;
/* specify superfluous initialization commands here */
RemoveCommand(pSics, "TokenInit");
RemoveCommand(pSics, "ServerOption");
RemoveCommand(pSics, "SicsUser");
RemoveCommand(pSics, "VarMake");
RemoveCommand(pSics, "MakeDrive");
RemoveCommand(pSics, "Motor");
/*
RemoveCommand(pSics,"MakeMulti");
*/
RemoveCommand(pSics, "MakeMono");
RemoveCommand(pSics, "MakeWaveLength");
RemoveCommand(pSics, "MakeEnergy");
RemoveCommand(pSics, "MakeCounter");
RemoveCommand(pSics, "MakeSecCounter");
RemoveCommand(pSics, "MakeRuenBuffer");
RemoveCommand(pSics, "MakeScan");
RemoveCommand(pSics, "MakeO2T");
RemoveCommand(pSics, "SicsAlias");
RemoveCommand(pSics, "MakeHM");
RemoveCommand(pSics, "VelocitySelector");
RemoveCommand(pSics, "MakeDataNumber");
RemoveCommand(pSics, "MakeScanCommand");
RemoveCommand(pSics, "MakePeakCenter");
RemoveCommand(pSics, "MakeHKL");
RemoveCommand(pSics, "MakeOptimiser");
RemoveCommand(pSics, "MakeMesure");
RemoveCommand(pSics, "MakeChopper");
RemoveCommand(pSics, "ChopperAdapter");
RemoveCommand(pSics, "MakeHklscan");
RemoveCommand(pSics, "MakeXYTable");
RemoveCommand(pSics, "MakeMaximize");
RemoveCommand(pSics, "MakeLin2Ang");
RemoveCommand(pSics, "MakeSync");
RemoveCommand(pSics, "MakeHMControl");
RemoveCommand(pSics, "MakeRS232Controller");
RemoveCommand(pSics, "MakeMaxDetector");
RemoveCommand(pSics, "AntiColliderInstall");
RemoveCommand(pSics, "MakeGPIB");
RemoveCommand(pSics, "MakeNXScript");
RemoveCommand(pSics, "MakeTclInt");
RemoveCommand(pSics, "UpdateFactory");
RemoveCommand(pSics, "allowexec");
RemoveCommand(pSics, "MakeConfigurableMotor");
RemoveCommand(pSics, "MakeBatchManager");
RemoveCommand(pSics, "MakeOscillator");
RemoveCommand(pSics, "MakeDiffScan");
RemoveCommand(pSics, "MakeHKLMot");
RemoveCommand(pSics, "MakeUBCalc");
RemoveCommand(pSics, "MakeTasUB");
RemoveCommand(pSics, "MakeTasScan");
RemoveCommand(pSics, "MakemcStasReader");
RemoveCommand(pSics, "InstallSinfox");
RemoveCommand(pSics, "MakeCone");
RemoveCommand(pSics, "MakeMultiCounter");
RemoveCommand(pSics, "MakeStateMon");
RemoveCommand(pSics, "MakeAsyncQueue");
RemoveCommand(pSics, "MakeAsyncProtocol");
RemoveCommand(pSics, "MakeSicsObject");
RemoveCommand(pSics, "MakeGenController");
RemoveCommand(pSics, "genconfigure");
RemoveCommand(pSics, "MakeProxy");
RemoveCommand(pSics, "MakeRefList");
RemoveCommand(pSics, "MakeSingleX");
RemoveCommand(pSics, "MakeSecMotor");
RemoveCommand(pSics, "MakeSecNVS");
RemoveCommand(pSics, "MakeSecHM");
RemoveCommand(pSics, "MakeHdbTable");
RemoveCommand(pSics, "MakeSansBC");
/*
remove site specific installation commands
*/
site = getSite();
if (site != NULL) {
site->RemoveSiteCommands(pSics);
}
}
#include "ofac.h"
/*--------------------------------------------------------------------------*/
void InitGeneral(void)
@ -452,41 +30,139 @@ void InitGeneral(void)
INIT(LogReaderInit);
INIT(LogSetupInit);
INIT(StatusFileInit);
INIT(InstallBackground);
INIT(MakeProtocol);
INIT(CommandLogInit);
INIT(UdpInit);
INIT(HelpInit);
INIT(SiteInit); /* site specific initializations */
}
/*--------------------------------------------------------------------------*/
int InitObjectCommands(pServer pServ, char *file)
void InitIniCommands(SicsInterp * pInter)
{
SConnection *pCon = NULL;
char pBueffel[1024];
int iRet;
SicsInterp *pSics;
pSics = pServ->pSics;
assert(pSics);
/* declare and add permanent command */
#define PCMD(NAME, FUN) { \
int FUN(SConnection * pCon, SicsInterp * pSics, void *pData, \
int argc, char *argv[]); \
AddCommandWithFlag(pInter, NAME, FUN, NULL, NULL, 0); \
}
/* declare and add startup command */
#define SCMD(NAME, FUN) { \
int FUN(SConnection * pCon, SicsInterp * pSics, void *pData, \
int argc, char *argv[]); \
AddCommandWithFlag(pInter, NAME, FUN, NULL, NULL, 1); \
}
InitGeneral();
/* permanent commands in alphabetic order */
PCMD("alias", MakeAlias);
PCMD("broadcast", Broadcast);
PCMD("Capture", CaptureAction);
PCMD("ClientPut", ClientPut);
PCMD("config", ConfigCon);
PCMD("db", SICSDebug);
PCMD("DefineAlias", DefineAlias);
PCMD("Dir", ListObjects);
PCMD("dolater", MakeCron);
PCMD("DrivableInvoke", TclDrivableInvoke);
PCMD("DynSicsObj", InstallSICSOBJ);
PCMD("EVFactory", EVControlFactory);
PCMD("FileEval", MacroFileEval);
PCMD("findalias", LocateAliasAction);
PCMD("fulltransact", TransactAction);
PCMD("GetInt", GetSICSInterrupt);
PCMD("GetLog", LogCapture);
PCMD("GumPut", GumPut);
PCMD("InternEval", InternalFileEval);
PCMD("kill_command", SICSKill);
PCMD("list", SicsList);
PCMD("MakeMcStasController", McStasControllerFactory);
PCMD("MakeMulti", MakeMulti);
PCMD("MakeOptimise", MakeOptimiser);
PCMD("Publish", TclPublish);
PCMD("ResetServer", ResetStatus);
PCMD("scriptcallback", CallbackScript);
PCMD("SetInt", SetSICSInterrupt);
PCMD("SetStatus", SetSICSStatus);
PCMD("SICSBounds", SICSBounds);
PCMD("sicscron", MakeCron);
PCMD("sicsdatafactory", SICSDataFactory);
PCMD("sicsdescriptor", SICSDescriptor);
PCMD("sicsprompt", SicsPrompt);
PCMD("SICSStatus", SICSStatus);
PCMD("sicstime", SICSTime);
PCMD("SICSType", SICSType);
PCMD("Sics_Exitus", SicsExit);
PCMD("silent", SICSSilent);
PCMD("status", UserStatus);
PCMD("TclReplaceDrivable", TclReplaceDrivable);
PCMD("transact", TransactAction);
PCMD("wait", UserWait);
/* general initialization */
/* create a connection */
pCon = SCCreateDummyConnection(pSics);
if (!pCon) {
return 0;
}
MakeExeManager(pCon, pSics, NULL, 1, NULL);
InitIniCommands(pSics, pServ->pTasker);
InstallBckRestore(pCon, pSics);
/* evaluate the file */
snprintf(pBueffel,sizeof(pBueffel)-1, "fileeval %s", file);
iRet = InterpExecute(pSics, pCon, pBueffel);
/* done */
SCDeleteConnection(pCon);
KillIniCommands(pSics);
RemoveStartupCommands();
return 1;
/* startup commands in alphabetic order */
SCMD("allowexec", AllowExec);
SCMD("AntiCollisionInstall", AntiColliderFactory);
SCMD("ChopperAdapter", CHAdapterFactory);
SCMD("InstallHdb", InstallSICSHipadaba);
SCMD("InstallSinfox", InstallSinfox);
SCMD("MakeAsyncProtocol", AsyncProtocolFactory);
SCMD("MakeAsyncQueue", AsyncQueueFactory);
SCMD("MakeBatchManager", MakeExeManager);
SCMD("MakeChopper", ChocoFactory);
SCMD("MakeCone", MakeCone);
SCMD("MakeConfigurableMotor", MakeConfigurableVirtualMotor);
SCMD("MakeCounter", MakeCounter);
SCMD("MakeDataNumber", DNFactory);
SCMD("MakeDiffScan", MakeDiffScan);
SCMD("MakeDrive", MakeDrive);
SCMD("MakeEnergy", MakeEnergyVar);
SCMD("MakeGPIB", MakeGPIB);
SCMD("MakeHdbTable", HdbTableFactory);
SCMD("MakeHKL", HKLFactory);
SCMD("MakeHKLMot", HKLMotInstall);
SCMD("MakeHM", MakeHistMemory);
SCMD("MakeHMControl", MakeHMControl);
SCMD("MakeLin2Ang", MakeLin2Ang);
SCMD("MakeMaxDetector", LoMaxFactory);
SCMD("MakeMaximize", MaximizeFactory);
SCMD("MakeMcStasReader", McStasReaderFactory);
SCMD("MakeMono", MonoInit);
SCMD("MakeMultiCounter", MakeMultiCounter);
SCMD("MakeNXScript", MakeNXScript);
SCMD("MakeO2T", CreateO2T);
SCMD("MakeOscillator", MakeOscillator);
SCMD("MakePeakCenter", FitFactory);
SCMD("MakeProxy", ProxyFactory);
SCMD("MakeRefList", MakeReflectionList);
SCMD("MakeRS232Controller", RS232Factory);
SCMD("MakeSansBC", SansBCFactory);
SCMD("MakeScanCommand", ScanFactory);
SCMD("MakeSecCounter", MakeSecCter);
SCMD("MakeSecHM", MakeSecHM);
SCMD("MakeSecMotor", SecMotorFactory);
SCMD("MakeSecNVS", MakeSecNVS);
SCMD("MakeSicsObj", InstallSICSOBJ);
SCMD("MakeSicsPoll", InstallSICSPoll);
SCMD("MakeSingleX", MakeSingleX);
SCMD("MakeStateMon", StateMonFactory);
SCMD("MakeSync", MakeSync);
SCMD("MakeTasScan", TASUBScanFactory);
SCMD("MakeTasUB", TasUBFactory);
SCMD("MakeTclInt", MakeTclInt);
SCMD("MakeUBCalc", MakeUBCalc);
SCMD("MakeWaveLength", MakeWaveLengthVar);
SCMD("MakeXYTable", XYFactory);
SCMD("Motor", MotorCreate);
SCMD("Remob", RemobCreate);
SCMD("ServerOption", IFServerOption);
SCMD("SicsAlias", SicsAlias);
SCMD("SicsUser", PWSicsUser);
SCMD("TokenInit", TokenInit);
SCMD("UpdateFactory", UpdateFactory);
SCMD("VarMake", VarFactory);
SCMD("VelocitySelector", VelSelFactory);
}
/* all other content moved to sicsutil.c - M.Zolliker Jan 2010 */

34
ofac.h
View File

@ -1,25 +1,21 @@
/*---------------------------------------------------------------------------
/**
* Startup commands and definitions
*
* copyright: see file COPYRIGHT
*
*
* Mark Koennecke 1996 - ?
* Markus Zolliker Jan 2010
*/
ObjectFactory
SICS is a highly configurable system. This module implements
the configurable. Configuration is meant to happen via a Tcl-
configuration script. This module will initialize commands which
create SICS-objects. Than an initialization file is evaluated
via the macro facility. As most of the initialization commands
will no longer be needed after this, they will be deleted.
All this will be run with a higly privileged connection which
prints to stdout/stdin.
Mark Koennecke, November 1996
copyright: see implementation file
-----------------------------------------------------------------------------*/
#ifndef OBJECTFACTORY
#define OBJECTFACTORY
#include "sics.h"
int InitObjectCommands(pServer pServ, char *file);
/* module initialisation calls */
void InitGeneral(void);
/* module initialisation calls */
void InitIniCommands(SicsInterp * pInter);
#endif

View File

@ -220,13 +220,13 @@ int InstallProtocol(SConnection * pCon, SicsInterp * pSics, void *pData,
}
/*------------------------------------------------------------------------*/
void MakeProtocol(SicsInterp * pSics)
void MakeProtocol(void)
{
pProtocol pNew = NULL;
pNew = CreateProtocol();
if (NULL != pNew) {
AddCommand(pSics, "Protocol", ProtocolAction, DeleteProtocol, pNew);
AddCommand(pSics, "contextdo", ContextDo, NULL, NULL);
AddCommand(pServ->pSics, "Protocol", ProtocolAction, DeleteProtocol, pNew);
AddCommand(pServ->pSics, "contextdo", ContextDo, NULL, NULL);
}
}

View File

@ -19,7 +19,7 @@ static char *pProTags[3] = {
int InstallProtocol(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[]);
void DeleteProtocol(void *pSelf);
void MakeProtocol(SicsInterp * pSics);
void MakeProtocol(void);
/*--------------------- operations --------------------------------------*/
int ProtocolAction(SConnection * pCon, SicsInterp * pSics, void *pData,

7
sics.h
View File

@ -34,14 +34,9 @@ typedef enum {
#include "emon.h"
#include "nserver.h"
#include "servlog.h"
#include "sicsutil.h"
extern pServer pServ;
/**
* Decode privilege text. Implemented in access.c
* @param the text to decode
* @return -1 if code invalid, else the privilege code
*/
int decodeSICSPriv(char *privText);
#endif

View File

@ -106,3 +106,8 @@ int QuieckAction(SConnection * pCon, SicsInterp * pSics, void *pData,
SCSendOK(pCon);
return 1;
}
/*--------------------------------------------------------------------------*/
void UdpInit(void)
{
AddCommand(pServ->pSics, "udpquieck", QuieckAction, KillQuieck, NULL);
}