EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Redundancy Patch: db
From: Andrew Johnson <[email protected]>
To: EPICS core-talk <[email protected]>
Date: Thu, 15 Nov 2007 17:36:44 -0600
**************
Modified
**************

# source files
(1) base-3.14.9/src/db/dbAccess.c
    dbPutSpecial() is added for CCE. This function is just a pipe to
    call the static function putSpecial(). dbPutSpecial() is written
    by John L. Dalesio and Bernd Schoeneburg originally.

(2) base-3.14.9/src/db/dbScan.c
    Register periodic scan tasks at RMT. When the IOC is SLAVE, these
    tasks are changed to be inactive.

(3) base-3.14.9/src/dbStatic/dbBase.h
    enum type "redUp" and the element of struct dbFldDes "red_update"
    are added for CCE. They are added by Bernd Schoeneburg originally.

(4) base-3.14.9/src/dbStatic/dbLexRoutines.c
    Deal with pdbFldDes->red_update for CCE, by Bernd Schoeneburg
    originally.


**************
Added
**************
(1) base-3.14.9/src/db/rmtDrvIf.h
    The head file for RMT driver interface.

Index: src/db/dbAccess.c
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/db/dbAccess.c,v
retrieving revision 1.116.2.11
diff -u -b -r1.116.2.11 dbAccess.c
--- src/db/dbAccess.c	19 Dec 2006 16:20:47 -0000	1.116.2.11
+++ src/db/dbAccess.c	12 Nov 2007 18:22:33 -0000
@@ -15,6 +15,15 @@
  *      Date:            11-7-90
 */
 
+/************************************************************************
+modification history
+----------------------
+Oct.16,2007,Gongfa Liu  dbPutSpecial() is added for CCE. This function is
+                        just a pipe to call the static function putSpecial().
+                        dbPutSpecial() is written by John L. Dalesio
+                        and Bernd Schoeneburg originally.
+************************************************************************/
+
 
 #include <stddef.h>
 #include <stdlib.h>
@@ -117,6 +126,19 @@
     return(0);
 }
 
+/* dbPutSpecial() is added for CCE. This function is just a pipe */
+/* to call the static function putSpecial().                     */
+/* Originally by John L. Dalesio and Bernd Schoeneburg.          */
+/*---------------------------------------------------------------*/
+long epicsShareAPI dbPutSpecial(DBADDR *paddr,int pass)
+{
+    long        status;
+
+    status = putSpecial(paddr,pass);
+    return status;
+}
+/*---------------------------------------------------------------*/
+
 static void get_enum_strs(DBADDR *paddr, char **ppbuffer,
 	struct rset *prset,long	*options)
 {
Index: src/db/dbScan.c
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/db/dbScan.c,v
retrieving revision 1.74.2.3
diff -u -b -r1.74.2.3 dbScan.c
--- src/db/dbScan.c	25 Aug 2005 13:04:51 -0000	1.74.2.3
+++ src/db/dbScan.c	12 Nov 2007 18:22:33 -0000
@@ -15,6 +15,13 @@
  *      Date:   	        07/18/91
  */
 
+/************************************************************************
+modification history
+----------------------
+Oct.16,2007,Gongfa Liu  register periodic scan tasks at RMT. When the IOC
+                        is SLAVE, these tasks are changed to be inactive.  
+************************************************************************/
+
 #include <epicsStdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -48,6 +55,31 @@
 #include "recGbl.h"
 #include "dbScan.h"
 
+/* added by Gongfa Liu */
+/* -------------------------------------------------------------*/
+#include "epicsFindSymbol.h"
+#include "rmtDrvIf.h" 
+
+#ifndef vxWorks 
+#define BOOL int  
+#define LOCAL static
+#define IMPORT extern
+#define TRUE 1
+#define FALSE 0
+#endif
+
+typedef struct {
+        BOOL            run;            /* scan task is running */
+        BOOL            activeFlag;     /* flag to check if loop is running */
+        const char*     instanceName;
+        epicsThreadId   tid;            /* task id of driver instance */
+} scanPrivateType;
+
+static STATUS scanStart(scanPrivateType *ppvt);
+static STATUS scanStop(scanPrivateType *ppvt);
+static STATUS scanGetStatus(scanPrivateType *ppvt, drvStatusType *pstatus);
+static STATUS scanGetInfo(scanPrivateType *ppvt, char *pString, short *psize, char *prequestString);
+/* -------------------------------------------------------------*/
 
 /* SCAN ONCE */
 int onceQueueSize = 1000;
@@ -483,10 +515,58 @@
     double	diff;
     double	delay;
 
+    /* added by Gongfa Liu                               */
+    /* register the periodicTask at RMT                  */
+    /* --------------------------------------------------*/
+    rmtEntryTabType   scanRegistry;
+    scanPrivateType   scanPvt;
+
+    const rmtInfoTabType  *prmtInfoTab;
+    STATUS (*prmtRegister)() = NULL;
+    long status;
+
+    scanRegistry.type                = "ScanPeriodic";
+    scanRegistry.instanceName        = epicsThreadGetNameSelf();
+    scanRegistry.testTimeTypical     = 0;
+    scanRegistry.pPrvt               = (void *)&scanPvt;
+    scanRegistry.pStart              = (RMTSUPFUN)scanStart;
+    scanRegistry.pStop               = (RMTSUPFUN)scanStop;
+    scanRegistry.pTestIO             = NULL;
+    scanRegistry.pGetStatus          = (RMTSUPFUN)scanGetStatus;
+    scanRegistry.pShutdown           = NULL;
+    scanRegistry.pGetInfo            = (RMTSUPFUN)scanGetInfo;
+    scanRegistry.pGetUpdate          = NULL;
+    scanRegistry.pStartUpdate        = NULL;
+    scanRegistry.pStopUpdate         = NULL;
+
+    scanPvt.instanceName   = scanRegistry.instanceName;
+    scanPvt.tid            = epicsThreadGetIdSelf();
+    scanPvt.run            = FALSE;
+    scanPvt.activeFlag     = TRUE; /* always TRUE when no testIO */
+
+    prmtRegister = (RMTSUPFUN)epicsFindSymbol("rmtRegister");
+    if(prmtRegister == NULL)
+    {
+      printf("Non redundant IOC!!!\n");
+      scanPvt.run = TRUE; /* let scan task be active */
+    }
+    else 
+    {
+      status = (*prmtRegister)(&scanRegistry, &prmtInfoTab);
+    }
+    /* ---------------------------------------------------*/
+
     taskwdInsert ( epicsThreadGetIdSelf(), NULL, NULL );
     epicsTimeGetCurrent(&start_time);
     while(TRUE) {
-	if(interruptAccept)scanList(psl);
+	/* if(interruptAccept)scanList(psl); */
+	/* changed by sbg and Gongfa Liu     */
+        /* when the IOC is MASTER, scanPvt.run is TRUE *
+        /*------------------------------------------*/
+	if(interruptAccept && scanPvt.run == TRUE)
+	    scanList(psl);
+        /*------------------------------------------*/
+
         epicsTimeGetCurrent(&end_time);
         diff = epicsTimeDiffInSeconds(&end_time,&start_time);
 	delay = psl->period - diff;
@@ -690,3 +770,68 @@
 	epicsMutexUnlock(psl->lock);
 	return;
 }
+
+/* added by Gongfa Liu                                                                   */
+/* some functions for RMT driver interface.                                              */
+/* --------------------------------------------------------------------------------------*/
+static STATUS scanStart(scanPrivateType *ppvt)
+{
+        ppvt->run = TRUE;
+        printf("scanStart: ppvt->run=%d\n", ppvt->run);
+        return (OK);
+}
+
+static STATUS scanStop(scanPrivateType *ppvt)
+{
+        ppvt->run=FALSE;
+        printf("scanStop: ppvt->run=%d\n", ppvt->run);
+        return (OK);
+}
+
+static STATUS scanGetStatus(scanPrivateType *ppvt, drvStatusType *pstatus)
+{
+        pstatus->mode = ppvt->run ? MODE_run : MODE_stop;
+        pstatus->testResult = TEST_undefined;
+
+        if ( epicsThreadIsSuspended(ppvt->tid) )
+        {
+            pstatus->error = INVALID_ERROR;
+            /*pstatus->mode = MODE_stop;* set again when the task is suspended */
+        }
+        else
+            pstatus->error = NO_ERROR;
+
+        pstatus->updateBusy = FALSE;
+        pstatus->inSync = TRUE;
+        pstatus->activeFlag = ppvt->activeFlag;
+        /* ppvt->activeFlag = FALSE;  */ /* activeFlag shuold be kept TRUE when no TestIO */
+
+        return OK;
+}
+
+static STATUS scanGetInfo(scanPrivateType *ppvt, char *pString, short *psize, char *prequestString)
+{
+        char scanTaskInfo[100];
+
+        sprintf(scanTaskInfo,"<XML><NAME>%s</NAME><STATUS>%s</STATUS></XML>",
+                ppvt->instanceName, ppvt->run ? "active" : "inactive");
+
+        if(prequestString && strlen(prequestString))
+                printf("%s: scanGetInfo with request\n", ppvt->instanceName);
+        else
+                printf("%s: scanGetInfo without request\n", ppvt->instanceName);
+
+        if (psize != NULL && pString != NULL)
+        {
+                if (*psize > sizeof(scanTaskInfo))
+                        strcpy (pString, scanTaskInfo);
+                else
+                        *psize = sizeof(scanTaskInfo)+1;
+
+                printf("%s\n", scanTaskInfo);
+                return OK;
+        }
+        else
+                return ERROR;
+}
+/* --------------------------------------------------------------------------------------*/
Index: src/db/rmtDrvIf.h
===================================================================
--- /dev/null	2007-11-05 13:05:14.280278523 -0600
+++ src/db/rmtDrvIf.h	2007-11-01 08:20:40.000000000 -0500
@@ -0,0 +1,63 @@
+/*****************************************************************************\
+* Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchrotron,
+* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
+* Redundancy IOC codes are distributed subject to a Software License Agreement
+* found in file LICENSE.txt that is included with this distribution.
+\*****************************************************************************/
+
+#ifndef INCLrmtDrvIfh  /* Include-file already inserted ?  */
+#define INCLrmtDrvIfh  /* defined macro flags insertion    */
+
+#ifndef vxWorks
+#define OK	0
+#define ERROR	-1
+typedef long	STATUS;
+#endif
+
+typedef enum {UPDATE_full, UPDATE_data} updateMode;
+
+typedef enum {MODE_stop, MODE_run, MODE_standby, MODE_test} modeType;
+typedef enum {TEST_undefined, TEST_ok, TEST_error, TEST_timeout, TEST_aborted} testResultType;
+typedef enum {NO_ERROR, WARNING_ERROR, INVALID_ERROR} errorType;
+
+typedef struct {
+	modeType mode;
+	testResultType testResult;
+	errorType error;
+	int updateBusy;	/* single update running */
+	int inSync;	/* 1 == up-to-date with updates */
+	int activeFlag;	/* set to TRUE by activity, cleared by getStatus() */
+} drvStatusType;
+
+/* special driver type for watchdog */
+#define               WATCHDOG        "WATCHDOG"
+
+typedef STATUS	(*RMTSUPFUN)();
+typedef void	(*RMTCALLBACK)(int, testResultType);
+
+typedef struct {
+	const char		*type;
+	const char		*instanceName;
+	unsigned short		testTimeTypical;
+	void			*pPrvt;
+	RMTSUPFUN		pStart;
+	RMTSUPFUN		pStop;
+	RMTSUPFUN		pTestIO;
+	RMTSUPFUN		pGetStatus;
+	RMTSUPFUN		pShutdown;
+	RMTSUPFUN		pGetInfo;
+	RMTSUPFUN		pGetUpdate;
+	RMTSUPFUN		pStartUpdate;
+	RMTSUPFUN		pStopUpdate;
+
+} rmtEntryTabType;
+
+typedef struct {
+	const char		*partnerIPPrivate;
+	short			preferredMaster;
+} rmtInfoTabType;
+
+STATUS  rmtRegister(rmtEntryTabType *prmtEntryTab,
+	const rmtInfoTabType **pprmtInfoTab);
+
+#endif			 /* end of insertions	*/
Index: src/dbStatic/dbBase.h
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/dbStatic/dbBase.h,v
retrieving revision 1.12.2.5
diff -u -b -r1.12.2.5 dbBase.h
--- src/dbStatic/dbBase.h	26 Oct 2006 16:05:23 -0000	1.12.2.5
+++ src/dbStatic/dbBase.h	12 Nov 2007 18:22:33 -0000
@@ -13,6 +13,14 @@
  *      Date:                   03-19-92
  */
 
+/************************************************************************
+modification history
+----------------------
+Oct.16,2007,Gongfa Liu  enum type "redUp" and the element of struct
+                        dbFldDes "red_update" are added for CCE. 
+                        They are added by Bernd Schoeneburg originally.
+************************************************************************/
+
 #ifndef INCdbBaseh
 #define INCdbBaseh 1
 
@@ -53,6 +61,8 @@
 typedef enum {CT_DECIMAL,CT_HEX} ctType;
 /* access level types */
 typedef enum {ASL0,ASL1} asLevel;
+/* redundant ioc update mode, for CCE. Originally by Bernd Schoeneburg */ 
+typedef enum {RED_NO_UPDATE,RED_INIT_COPY,RED_CONT_UPDATE} redUp;
 
 /*Breakpoint Tables */
 typedef struct brkInt{ /* breakpoint interval */
@@ -81,6 +91,8 @@
 	short	promptgroup;	/*prompt, i.e. gui group		*/
 	short   interest;	/*interest level			*/
 	asLevel	as_level;	/*access security level			*/
+	redUp	red_update;	/*redundant ioc update mode, for CCE    */
+                                /*Originally by Bernd Schoeneburg       */
 	char	*initial;	/*initial value				*/
 	/*If (DBF_MENU,DBF_DEVICE) ftPvt is (pdbMenu,pdbDeviceMenu)	*/
 	void	*ftPvt;
Index: src/dbStatic/dbLexRoutines.c
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/dbStatic/dbLexRoutines.c,v
retrieving revision 1.27.2.14
diff -u -b -r1.27.2.14 dbLexRoutines.c
--- src/dbStatic/dbLexRoutines.c	15 Nov 2006 23:33:31 -0000	1.27.2.14
+++ src/dbStatic/dbLexRoutines.c	12 Nov 2007 18:22:33 -0000
@@ -12,6 +12,15 @@
 
 /*The routines in this module are serially reusable NOT reentrant*/
 
+/************************************************************************
+modification history
+----------------------
+Oct.16,2007,Gongfa Liu  deal with pdbFldDes->red_update for CCE.
+                        by Bernd Schoeneburg originally.
+************************************************************************/
+
+
+
 #include <epicsStdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -481,6 +490,7 @@
     allocTemp(pdbFldDes);
     pdbFldDes->name = epicsStrDup(name);
     pdbFldDes->as_level = ASL1;
+    pdbFldDes->red_update = RED_CONT_UPDATE;  /* for CCE, by Bernd Schoeneburg originally. */
     for(i=0; i<DBF_NTYPES; i++) {
 	if(strcmp(type,pamapdbfType[i].strvalue)==0) {
 	    pdbFldDes->field_type = pamapdbfType[i].value;
@@ -579,6 +589,18 @@
 	    yyerrorAbort("menu not found");
 	return;
     }
+    /* for CCE, by Bernd Schoeneburg originally. */
+    if(strcmp(name,"red_update")==0) {
+        if(strcmp(value,"NO_UPDATE")==0) {
+            pdbFldDes->red_update = RED_NO_UPDATE;
+        } else if(strcmp(value,"INIT_COPY")==0) {
+            pdbFldDes->red_update = RED_INIT_COPY;
+        } else if(strcmp(value,"CONT_UPDATE")==0) {
+            pdbFldDes->red_update = RED_CONT_UPDATE;
+        } else {
+            yyerror("Illegal value. Must be NO_UPDATE, INIT_COPY or CONT_UPDATE");
+        }
+    }
 }
 
 static void dbRecordtypeCdef(char *text) {

Replies:
Re: Redundancy Patch: db Andrew Johnson

Navigate by Date:
Prev: Redundancy Patch: libCom Andrew Johnson
Next: Redundancy Patch: iocsh Andrew Johnson
Index: 2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Redundancy Patch: libCom Andrew Johnson
Next: Re: Redundancy Patch: db Andrew Johnson
Index: 2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·