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

📄 win_ss.c

📁 中国石油二期加油站IC系统后台通讯软件
💻 C
📖 第 1 页 / 共 5 页
字号:
    localtime_r(&tt, &tme);
    dt->month = (U8) tme.tm_mon + 1;
    dt->day = (U8) tme.tm_mday;
    dt->year = (U8) tme.tm_year;
    dt->hour = (U8) tme.tm_hour;
    dt->min = (U8) tme.tm_min;
    dt->sec = (U8) tme.tm_sec;
    dt->tenths = 0;
    */
    GetLocalTime(&date);

    dt->month = (U8) date.wMonth;
    dt->day = (U8) date.wDay;
    dt->year = (U8) (date.wYear - 2000 );
    dt->hour = (U8) date.wHour;
    dt->min = (U8) date.wMinute;
    dt->sec = (U8) date.wSecond;
    dt->tenths = 0;

    RETVALUE(ROK);
}


/*
*
*       Fun:   Get system time
*
*       Desc:  This function is used to determine the system time.
*
*       Ret:   ROK      - ok
*
*       Notes: osCp.dep.sysTicks is updated by the timer thread.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SGetSysTime
(
Ticks *sysTime              /* system time */
)
#else
PUBLIC S16 SGetSysTime(sysTime)
Ticks *sysTime;             /* system time */
#endif
{
    TRC1(SGetSysTime);


#if (ERRCLASS & ERRCLS_INT_PAR)      
    if ( sysTime == NULLP )
    {
        WINLOGERROR(ERRCLS_INT_PAR, EMT021, ERRZERO, "Null pointer");
        RETVALUE(RFAILED);
    }
#endif


    *sysTime = osCp.dep.sysTicks;


    RETVALUE(ROK);
}

  
/*
*
*       Fun:   Get Random Number
*
*       Desc:  Invoked by layer when a pseudorandom number is required.
*
*       Ret:   ROK      - ok
*
*       Notes: Suggested approach uses shuffled Linear Congruential
*              Operators as described in Byte magazine October
*              1984; "Generating and Testing Pseudorandom Numbers"
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SRandom
(
Random *value               /* random number */
)
#else
PUBLIC S16 SRandom(value)
Random *value;              /* random number */
#endif
{
    TRC1(SRandom);


#if (ERRCLASS & ERRCLS_INT_PAR)
    if ( value == NULLP )
    {
        WINLOGERROR(ERRCLS_INT_PAR, EMT022, value, "Null pointer");
        RETVALUE(RFAILED);
    }
#endif


    *value = (Random) rand();


    RETVALUE(ROK);
}


/*
*
*       Fun:   Exit Task
*
*       Desc:  This function exits from a task.
*
*       Ret:   ROK      - ok
*
*       Notes: Currently does nothing.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SExitTsk
(
void
)
#else
PUBLIC S16 SExitTsk()
#endif
{
    TRC1(SExitTsk);


    RETVALUE(ROK);
}


/*
*
*       Fun:   Exit Interrupt
*
*       Desc:  This function exits from an interrupt.
*
*       Ret:   ROK      - ok
*
*       Notes: Currently does nothing.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SExitInt
(
void
)
#else
PUBLIC S16 SExitInt()
#endif
{
    TRC1(SExitInt);


    RETVALUE(ROK);
}

  
/*
*
*       Fun:   Hold Interrupt
*
*       Desc:  This function prohibits interrupts from being enabled until
*              release interrupt. This function should be called when
*              interrupts are disabled and prior to any call to system
*              services either by entry to an interrupt service routine or
*              by explicit call to disable interrupt.
*
*       Ret:   ROK      - ok
*
*       Notes: Currently does nothing
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SHoldInt
(
void
)
#else
PUBLIC S16 SHoldInt()
#endif
{
    TRC1(SHoldInt);


    RETVALUE(ROK);
}


/*
*
*       Fun:   Release Interrupt
*
*       Desc:  This function allows interrupts to be enabled.
*
*       Ret:   ROK      - ok
*
*       Notes: Currently does nothing.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SRelInt
(
void
)
#else
PUBLIC S16 SRelInt()
#endif
{
    TRC1(SRelInt);


    RETVALUE(ROK);
}


/*
*
*       Fun:   SEnbInt
*
*       Desc:  Enable interrupts
*
*       Ret:   ROK on success
*              RFAILED on error
*
*       Notes: Currently does nothing.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC INLINE S16 SEnbInt
(
void
)
#else
PUBLIC INLINE S16 SEnbInt()
#endif
{
    TRC1(SEnbInt);
/*
	_enable();
*/
    RETVALUE(ROK);
}


/*
*
*       Fun:   SDisInt
*
*       Desc:  Disable interrupts
*
*       Ret:   ROK on success
*              RFAILED on error
*
*       Notes: Currently does nothing.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC INLINE S16 SDisInt
(
void
)
#else
PUBLIC INLINE S16 SDisInt()
#endif
{
    TRC1(SDisInt);
/*
	_disable();
*/
    RETVALUE(ROK);
}


/*
*
*       Fun:   Get Vector
*
*       Desc:  This function gets the function address stored at the
*              specified interrupt vector.
*
*       Ret:   ROK      - ok
*
*       Notes: Currently does nothing.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SGetVect
(
VectNmb vectNmb,                /* vector number */
PIF *vectFnct                   /* vector function */
)
#else
PUBLIC S16 SGetVect(vectNmb, vectFnct)
VectNmb vectNmb;                /* vector number */
PIF *vectFnct;                  /* vector function */
#endif
{
    TRC1(SGetVect);


    UNUSED(vectNmb);
    UNUSED(vectFnct);


    RETVALUE(ROK);
}


/*
*
*       Fun:   Put Vector
*
*       Desc:  This function installs the specified function at the
*              specified interrupt vector.
*
*       Ret:   ROK      - ok
*
*       Notes: Currently does nothing.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SPutVect
(
VectNmb vectNmb,                /* vector number */
PIF vectFnct                    /* vector function */
)
#else
PUBLIC S16 SPutVect(vectNmb, vectFnct)
VectNmb vectNmb;                /* vector number */
PIF vectFnct;                   /* vector function */
#endif
{
    TRC1(SPutVect);


    UNUSED(vectNmb);
    UNUSED(vectFnct);


    RETVALUE(ROK);
}


/*
*
*       Fun:   SGetEntInst
*
*       Desc:  This function gets the current entity and instance.
*
*       Ret:   ROK      - ok
*              RFAILED  - failed, general (optional)
*
*       Notes: This function may be called by the OS or Layer 1
*              hardware drivers.
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SGetEntInst
(
Ent *ent,                       /* entity */
Inst *inst                      /* instance */
)
#else
PUBLIC S16 SGetEntInst(ent, inst)
Ent *ent;                       /* entity */
Inst *inst;                     /* instance */
#endif
{
    S16 i;
    S16 ret;
    DWORD tId;
    SsSTskEntry *sTsk;


    TRC1(SGetEntInst);


#if (ERRCLASS & ERRCLS_INT_PAR)

    /* check pointers */
    if ( ent == NULLP  ||  inst == NULLP )
    {
        WINLOGERROR(ERRCLS_INT_PAR, EMT023, ERRZERO, "Null pointer");
        RETVALUE(RFAILED);
    }
#endif


    /* get the thread id */
    /*
    tId = taskIdSelf();
    */
    tId = GetCurrentThreadId();

    /* find the system task in whose context we're running */
    sTsk = NULLP;
    ret = SLock(&osCp.sTskTblLock);
    if ( ret != ROK )
    {
        RETVALUE(RFAILED);
    }
    for ( i = 0;  i < SS_MAX_STSKS;  i++ )
    {
        if ( osCp.sTskTbl[i].dep.tId == tId )
        {
            sTsk = &osCp.sTskTbl[i];
            break;
        }
    }
    if ( sTsk != NULLP )
    {
        ret = SLock(&sTsk->dep.lock);
        if ( ret == ROK )
        {
            *ent = sTsk->dep.ent;
            *inst = sTsk->dep.inst;
            SUnlock(&sTsk->dep.lock);
        }
    }
    SUnlock(&osCp.sTskTblLock);


    RETVALUE(ret == ROK ? ROK : RFAILED);
}

  
/*
*
*       Fun:   SSetEntInst
*
*       Desc:  This function sets the current entity and instance.
*
*       Ret:   ROK      - ok
*
*       Notes:
*
*       File:  win_ss.c
*
*/
#ifdef ANSI
PUBLIC S16 SSetEntInst
(
Ent ent,                    /* entity */
Inst inst                   /* instance */
)
#else
PUBLIC S16 SSetEntInst(ent, inst)
Ent ent;                    /* entity */
Inst inst;                  /* instance */
#endif
{
    S16 i;
    S16 ret;
    DWORD tId;
    SsSTskEntry *sTsk;


    TRC1(SSetEntInst);


#if (ERRCLASS & ERRCLS_INT_PAR)

    /* check entity and instance IDs */
    if ( ent >= ENTNC  ||  inst >= INSTNC )
    {
        WINLOGERROR(ERRCLS_INT_PAR, EMT024, ERRZERO, "Invalid entity/instance");
        RETVALUE(RFAILED);
    }
#endif


    /* get the thread id */
    /*
    tId = taskIdSelf();
    */
    tId = GetCurrentThreadId();

    /* find the system task in whose context we're running */
    sTsk = NULLP;
    ret = SLock(&osCp.sTskTblLock);
    if ( ret != ROK )
    {
        RETVALUE(RFAILED);
    }
    for ( i = 0;  i < SS_MAX_STSKS;  i++ )
    {
        if ( osCp.sTskTbl[i].dep.tId == tId )
        {
            sTsk = &osCp.sTskTbl[i];
            break;
        }
    }
    if ( sTsk != NULLP )
    {
        ret = SLock(&sTsk->dep.lock);
        if ( ret == ROK )
        {
            sTsk->dep.ent = ent;
            sTsk->dep.inst = inst;
            SUnlock(&sTsk->dep.lock);
        }
    }
    SUnlock(&osCp.sTskTblLock);


    RETVALUE(ret == ROK ? ROK : RFAILED);
}

#ifdef SS_DRVR_SUPPORT

/*
*
*       Fun:   SSetIntPend
*
*       Desc:  Set interrupt pending flag
*
*       Ret:   ROK on success
*              RFAILED on error
*
*       Notes:
*
*       File:  win_ss.c
*
*/
    #ifdef ANSI
PUBLIC INLINE S16 SSetIntPend
(
U16 id,                         /* driver task identifier */
Bool flag                       /* flag */
)
    #else
PUBLIC INLINE S16 SSetIntPend(id, flag)
U16 id;                         /* driver task identifier */
Bool flag;                      /* flag */
    #endif
{
    WinIsFlag isFlag;


    TRC1(SSetIntPend);


#if (ERRCLASS & ERRCLS_INT_PAR)
    if ( id >= SS_MAX_DRVRTSKS  ||  osCp.drvrTskTbl[id].used == FALSE )
    {
        WINLOGERROR(ERRCLS_INT_PAR, EMT025, id, "Invalid instance");
        RETVALUE(RFAILED);
    }
#endif


    isFlag.id = id;
    isFlag.action = (flag ? WIN_IS_SET : WIN_IS_UNSET);

    if ( _write(osCp.dep.isFildes[WRITE], (char *)&isFlag, sizeof(isFlag)) != sizeof(isFlag) )
    {
        RETVALUE(RFAILED);
    }


    RETVALUE(ROK);
}
#endif  /* SS_DRVR_SUPPORT */


/********************************************************************30**
  
         End of file: win_ss.c 1.1  -  10/15/98 10:33:04
  
*********************************************************************31*/


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

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

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

   
/********************************************************************60**
  
        Revison history:
  
*********************************************************************61*/

/********************************************************************90**

     ver       pat    init                  description
------------ -------- ---- ----------------------------------------------
1.1          ---      kp   1. MTSS-Solaris release 2.1

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

⌨️ 快捷键说明

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