⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ss_gen.c

📁 中国石油二期加油站IC系统后台通讯软件
💻 C
📖 第 1 页 / 共 2 页
字号:
        goto cleanup2;
    }

#ifdef SS_DRVR_SUPPORT
    /* initialize driver task information */
    for (i = 0;  i < SS_MAX_DRVRTSKS;  i++)
    {
        drvrTsk = &osCp.drvrTskTbl[i];

        drvrTsk->used = FALSE;

        drvrTsk->channel = 0;
        drvrTsk->actvTsk = NULLP;
        drvrTsk->isTsk = NULLP;
        drvrTsk->low = 0;
        drvrTsk->high = 0;
    }

    osCp.numDrvrTsks = 0;

    /* implementation specific driver initialization */
    ret = ssdInitDrvr();
    if (ret != ROK)
    {
        SSLOGERROR(ERRCLS_DEBUG, ESS208, (ErrVal) ret,
                   "Could not init ssdInitDrvr");
        goto cleanup3;
    }
#endif

#ifdef SS_RTR_SUPPORT
    for (i = 0; i < SS_MAX_RTRTSKS; i++)
    {
        osCp.rtrTskTbl[i] = NULLP;
    }
#endif
    /* initialize the demand queue lookup table */
    osCp.dmndQLookupTbl[0] = 255;
    osCp.dmndQLookupTbl[1] = 0;
    osCp.dmndQLookupTbl[2] = 1;
    osCp.dmndQLookupTbl[3] = 1;
    for (i = 4;  i < 256;  i++)
    {
        if (i >= 128  &&  i <= 255)
            osCp.dmndQLookupTbl[i] = 7;
        if (i >= 64  &&  i <= 127)
            osCp.dmndQLookupTbl[i] = 6;
        if (i >= 32  &&  i <= 63)
            osCp.dmndQLookupTbl[i] = 5;
        if (i >= 16  &&  i <= 31)
            osCp.dmndQLookupTbl[i] = 4;
        if (i >= 8  &&  i <= 15)
            osCp.dmndQLookupTbl[i] = 3;
        if (i >= 4  &&  i <= 7)
            osCp.dmndQLookupTbl[i] = 2;
    }


    /* initialize timer information */
    for (i = 0;  i < SS_MAX_TMRS;  i++)
    {
        tmr = &osCp.tmrTbl[i];

        tmr->used = FALSE;
        tmr->tmrId = 0;
        tmr->ownerEnt = ENTNC;
        tmr->ownerInst = INSTNC;
        tmr->interval = 0;
        tmr->tmrActvFn = NULLP;

        tmr->nxt = i + 1;
    }

    osCp.numTmrs = 0;
    osCp.nxtTmrEntry = 0;

    ret = SInitLock(&osCp.tmrTblLock, SS_TMRTBL_LOCK);
    if (ret != ROK)
    {
        SSLOGERROR(ERRCLS_DEBUG, ESS208, (ErrVal) ret,
                   "Could not init SInitLock");
        goto cleanup4;
    }

    /* implementation specific timer initialization */
    ret = ssdInitTmr();
    if (ret != ROK)
    {
        SSLOGERROR(ERRCLS_DEBUG, ESS208, (ErrVal) ret,
                   "Could not init ssdInitTmr");
        SDestroyLock(&osCp.tmrTblLock);
        goto cleanup4;
    }


    /* implementation specific final initialization */
    ret = ssdInitFinal();
    if (ret != ROK)
    {
        SSLOGERROR(ERRCLS_DEBUG, ESS208, (ErrVal) ret,
                   "Could not init ssdInitFinal");
        goto cleanup5;
    }


    /* call init task () function */
/*   ret = ROK;
    if(NULLP != RegInit){
        ret = (*RegInit)();
    }
  
   if (ret != ROK)
   {
      goto cleanup6;
   }
*/

    /* call implementation-specific starter function */
    ssdStart();


    RETVALUE(ROK);


    /* clean up code */
    cleanup6:
    ssdDeinitFinal();

    cleanup5:
    ssdDeinitTmr();
    SDestroyLock(&osCp.tmrTblLock);

    cleanup4:
#ifdef SS_DRVR_SUPPORT
    ssdDeinitDrvr();

    cleanup3:
#endif
    ssdDeinitTsk();
    SDestroyLock(&osCp.sTskTblLock);
    ssDestroySema(&osCp.tTskTblSem);

    cleanup2:
    ssdDeinitMem();
    ssDestroySema(&osCp.regionTblSem);

    cleanup1:
    ssdDeinitGen();


    RETVALUE(RFAILED);
}


/*
*
*       Fun:   SPrint
*
*       Desc:  Print a string.
*
*              This function should be used for debugging only.
*
*       Ret:   ROK      - ok
*
*       Notes: Text buffer should be null terminated.
*
*              SDisplay will replace SPrint.
*
*              Typical usage consists of a call to sprintf to
*              format the string into a buffer followed by a
*              call to SPrint
*
*       File:  ss_gen.c
*
*/
#ifdef ANSI
PUBLIC S16 SPrint
(
Txt *buf                        /* buffer */
)
#else
PUBLIC S16 SPrint(buf)
Txt *buf;                       /* buffer */
#endif
{
    TRC1(SPrint);

    SDisplay(0, buf);

    RETVALUE(ROK);

} /* end of SPrint */


/*
*
*       Fun:   SError
*
*       Desc:  Invoked by layer when an unrecoverable
*              software error is detected. This function should
*              never return.
*
*       Ret:   None
*
*       Notes: None
*
*       File:  ss_gen.c
*
*/
#ifdef ANSI
PUBLIC S16 SError
(
Seq seq,                    /* sequence */
Reason reason               /* reason */
)
#else
PUBLIC S16 SError(seq, reason)
Seq seq;                    /* sequence */
Reason reason;              /* reason */
#endif
{
    S16 ret;
    DateTime dt;
    Txt errBuf[256];


    TRC1(SError);


    SGetDateTime(&dt);
    sprintf(errBuf, "\n\ndate: %02d/%02d/%04d time: %02d:%02d:%02d\n",
            (int)dt.month,(int)dt.day,(int)dt.year + 1900,
            (int)dt.hour,(int)dt.min,(int)dt.sec);
    SPrint(errBuf);


    ret = ssdError(seq, reason);


    RETVALUE(ret);
}


/*
*
*       Fun:   SLogError
*
*       Desc:  Invoked by layer to log an error.
*
*       Ret:   None
*
*       Notes: None
*
*       File:  ss_gen.c
*
*/
#ifdef ANSI
PUBLIC Void SLogError
(
Ent ent,                    /* Calling layer's entity id */
Inst inst,                  /* Calling layer's instance id */
ProcId procId,              /* Calling layer's processor id */
Txt *file,                  /* file name where error occured */
S32 line,                   /* line in file where error occured */
ErrCls errCls,              /* error class */
ErrCode errCode,            /* layer unique error code */
ErrVal errVal,              /* error value */
Txt *errDesc                /* description of error */
)
#else
PUBLIC Void SLogError(ent, inst, procId, file, line,
                      errCls, errCode, errVal, errDesc)
Ent ent;                    /* Calling layer's entity id */
Inst inst;                  /* Calling layer's instance id */
ProcId procId;              /* Calling layer's processor id */
Txt *file;                  /* file name where error occured */
S32 line;                   /* line in file where error occured */
ErrCls errCls;              /* error class */
ErrCode errCode;            /* layer unique error code */
ErrVal errVal;              /* error value */
Txt *errDesc;               /* description of error */
#endif
{
    DateTime dt;
    Txt errBuf[512];


    TRC1(SLogError);


    SGetDateTime(&dt);
    sprintf(errBuf, "\n\ndate: %02d/%02d/%04d time: %02d:%02d:%02d\n",
            (int)dt.month,(int)dt.day,(int)dt.year + 1900,
            (int)dt.hour,(int)dt.min,(int)dt.sec);
    SDisplay(0,errBuf);


    ssdLogError(ent, inst, procId, file, line,
                errCls, errCode, errVal, errDesc);


    RETVOID;
}


/*
*
*       Fun:   SFndProcId
*
*       Desc:  This function finds the local processor ID.
*
*       Ret:   local processor id
*
*       Notes:
*
*       File:  ss_gen.c
*
*/
#ifdef ANSI
PUBLIC ProcId SFndProcId
(
void
)
#else
PUBLIC ProcId SFndProcId()
#endif
{
    TRC1(SFndProcId);

    RETVALUE(osCp.procId);

} /* end of SFndProcId */


/*
*
*       Fun:   SSetProcId
*
*       Desc:  This function stores the local processor ID.
*
*       Ret:   Void
*
*       Notes: 
*
*       File:  ss_gen.c
*
*/
#ifdef ANSI
PUBLIC Void SSetProcId
(
ProcId procId
)
#else
PUBLIC Void SSetProcId(procId)
ProcId procId;
#endif
{
    TRC1(SSetProcId);


    osCp.procId = procId;


    RETVOID;
}




/*** add by shang, 2002-1-10 ***/

S16 ssGetEntName(Ent ent, S8 ** name)
{
    U32 i;
    for (i = 0 ; i < SS_MAX_ENT; i++)
    {
        if (g_entNameTbl[i].ent == ENTNC)
        {
            RETVALUE(RFAILED);
        }
        if (ent == g_entNameTbl[i].ent)
        {
            *name = g_entNameTbl[i].desc;
            RETVALUE(ROK);
        }
    }
    RETVALUE(RFAILED);
}


/*** add by shang is over ***/




/********************************************************************30**
  
         End of file: ss_gen.c 1.3  -  08/11/98 11:02:18
  
*********************************************************************31*/

  
/********************************************************************40**
  
        Notes: 
  
*********************************************************************41*/

/********************************************************************50**

*********************************************************************51*/

   
/********************************************************************60**
  
        Revision history:
  
*********************************************************************61*/

/********************************************************************90**
 
     ver       pat    init                  description
------------ -------- ---- ----------------------------------------------
1.1          ---      kp   1. initial release
  
1.2          ---      ag   1. Changed procId for SS to SS_PROC_ID
                              (defined by the implementation)
             ---      ag   2. Fixed a bug in function SInit
             ---      bsr  3. Changed return value for SInit and added
                              error deinit functions
             ---      kp   4. Cosmetic changes

1.3          ---      kp   1. Year display in SLogError() and SError()
                              converted into 4 digits for Y2K related
                              requirements.

*********************************************************************91*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -