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

📄 udmain.c

📁 工业组态软件modbus驱动源代码, 包括帮助文件.共享.
💻 C
📖 第 1 页 / 共 4 页
字号:
        return FALSE;
    }
	
	// 3/4/2000  modify by Chen jun,将不可写的Item取消写命令
	// skip, if READ only tag
	switch (lpSymEnt->msPlcDataType) {
		case	ITEM_INPUT_COIL:
		case	ITEM_INPUT_REG:
			return FALSE;
	}

    /*
     * Build a message to write the new data value.
     * Schedule it to be written as soon as possible.
     * It should have higher priority than regular poll messages.
     */

    Ok = UdprotPrepareWriteMsg(lpTopic, lpSymEnt, ptValue);

#ifdef DEBUG_CALL_TRAFFIC
    if (Verbose)
        debug("ProtNewValueForDevice( %8lX, %8lX, %8lX ) => %d",
              hLogDev, hProt, ptValue, (int) Ok);
#endif

    /* indicate TRUE if success */
    return Ok;
} /* ProtNewValueForDevice */

/***********************************************************************/
/** Deactivate a point.
    Called when no active requests for the point remain.
    The data structures representing the point must be deleted. **/

BOOL
WINAPI
ProtDeactivatePoint(HLOGDEV hLogDev,    /* Identifies the topic */
                    HPROT hProt)        /* Identifies the item  */
{
    unsigned long   SymIndex;
    BOOL            success = TRUE;
    LPSTAT          lpTopic;
    SYMPTR          lpSymEnt;

#ifdef DEBUG_CALL_TRAFFIC
    if (Verbose)
        debug("ProtDeactivatePoint( %8lX, %8lX )", hLogDev, hProt);
#endif

    /* indicate error if either logical device or handle is NULL */
    assert(hLogDev);
    assert(hProt);

    /* get pointer to station structure */
    lpTopic = (LPSTAT) hLogDev;
    if (lpTopic == (LPSTAT) NULL) {
        /* unable to access structure, indicate error */
        return FALSE;
    }

    /* Check whether this is the reserved point STATUS */
    if (hProt == HPROT_STATUS) {
        /* STATUS point, deactivate it */
        lpTopic->statStatusActive = FALSE;
        lpTopic->statStatusDue = FALSE;
        return TRUE;
    }

    /* not STATUS, check for valid handle */
    if (hProt < SYM_OFFSET) {
        /* invalid handle, indicate error */
        return FALSE;
    }

    /* get symbol table index based on handle */
    SymIndex = (unsigned long) (hProt - SYM_OFFSET);

    /* get pointer to point's symbol table entry */
    lpSymEnt = (SYMPTR) GetExtArrayMemberPtr (&lpTopic->statSymTab, SymIndex);
    if (lpSymEnt == (SYMPTR) NULL) {
        /* indicate error if no symbol table or out of range */
        return FALSE;
    } else {
        /* check whether point is active */
        if (lpSymEnt->msActive) {
            /* Mark the point as deactivated in the symbol table */
            lpSymEnt->msActive = FALSE;
            /*
             * Remove it from the poll message that encompasses it
             * Perhaps delete the message if no other points remain.
             */
            success = UdprotDelPoll(lpTopic, lpSymEnt);
            /* indicate error if cannot remove from poll message */
            assert(success);
        }
    }

    /* update the screen */
    DumpScreen();
    /* indicate success if TRUE */
    return (success);
} /* ProtDeactivatePoint */

/***********************************************************************/
/** Delete a point.
    Called when it's time to remove a point from the symbol table. **/

BOOL
WINAPI
ProtDeletePoint(HLOGDEV hLogDev,   /* Identifies the topic */
                HPROT hProt)       /* Identifies the item  */
{
    unsigned long   SymIndex;
    LPSTAT          lpTopic;
    SYMPTR          lpSymEnt;
    BOOL            Ok = FALSE;

#ifdef DEBUG_CALL_TRAFFIC
    if (Verbose)
        debug("ProtDeletePoint( %8lX, %8lX )", hLogDev, hProt);
#endif

    /* indicate error if either logical device or handle is NULL */
    assert(hLogDev);
    assert(hProt);

    /* get pointer to station data structure */
    lpTopic = (LPSTAT) hLogDev;
    if (lpTopic == (LPSTAT) NULL) {
        /* unable to access structure, indicate error */
        return FALSE;
    }

    /* First check whether this is the reserved point STATUS */
    if (hProt == HPROT_STATUS) {
        /* STATUS point, clear DB pointer and deactivate point */
        lpTopic->statHdbStatus = (HDB) NULL;
        lpTopic->statStatusActive = FALSE;
        lpTopic->statStatusDue = FALSE;
        /* indicate success */
        return TRUE;
    }

    /* not STATUS, check for valid handle */
    if (hProt < SYM_OFFSET) {
        /* invalid handle, indicate error */
        return FALSE;
    }

    /* get symbol table index based on handle */
    SymIndex = (unsigned long) (hProt - SYM_OFFSET);

    /* get pointer to point's symbol table entry */
    lpSymEnt = (SYMPTR) GetExtArrayMemberPtr (&lpTopic->statSymTab, SymIndex);
    if (lpSymEnt == (SYMPTR) NULL) {
        /* indicate error if no symbol table or out of range */
        return FALSE;
    }

    /* remove the point's symbol table entry */
    if (UdprotUnchainSymEnt(lpTopic, lpSymEnt)) {
        /* Return the entry to the free list */
        if (UdprotFreeSymEnt(lpTopic, lpSymEnt)) {
            /* point freed, indicate success */
            Ok = TRUE;
        }
    }
    /* indicate success if TRUE */
    return Ok;
} /* ProtDeletePoint */

/***********************************************************************/
/** Place the driver in the suspended state
    and update the menu to reflect it. **/

void
WINAPI
UdprotSuspend()
{
    HANDLE          hMenu;

    ProtocolSuspended = TRUE;

    hMenu = GetSystemMenu(hWndParent, FALSE);
    EnableMenuItem(hMenu, MENU_SUSPEND, MF_GRAYED);
    EnableMenuItem(hMenu, MENU_RESUME, MF_ENABLED);
} /* UdprotSuspend */

/***********************************************************************/
/** Return the driver to the active state
    and update the menu to reflect it. **/

void
WINAPI
UdprotResume()
{
    HANDLE          hMenu;

    ProtocolSuspended = FALSE;

    hMenu = GetSystemMenu(hWndParent, FALSE);
    EnableMenuItem(hMenu, MENU_SUSPEND, MF_ENABLED);
    EnableMenuItem(hMenu, MENU_RESUME, MF_GRAYED);
} /* UdprotResume */

/***********************************************************************/
/** Dump status information to the screen.
    Called to update the status information
    which is displayed in the client area. **/

VOID
WINAPI
DumpScreen()
{

    if (!IsIconic(hWndParent)) {
        InvalidateRect(hWndParent, (LPRECT)NULL, TRUE);
    }
} /* DumpScreen */

/***********************************************************************/
/** get difference between time marks, handling wrap-around **/

static
DWORD
WINAPI
TickDiff (DWORD dwFrom, DWORD dwTo)
{
    if (dwTo >= dwFrom)
    {
        return (dwTo - dwFrom);
    }
    else
    {
        /* wrap-around */
        return ((((DWORD) 0xFFFFFFFFL) - dwFrom) + dwTo);
    }
} /* TickDiff */

/***********************************************************************/
/** get difference between current time and last timer **/

DWORD
WINAPI
GetDeltaTime (VOID)
{
    return (TickDiff (lastTimer, GetCurrentTime ()));
} /* GetDeltaTime */

/***********************************************************************/
/* respond to ABOUT menu item */

void WINAPI
UdDisplayAbout (HWND hWnd)
{
#if ((defined(USING_WW_COMMONUI) && defined(WIN32)) || defined(USING_WW_ABOUT))
    /* use Wonderware about box */
 #ifdef USING_WW_COMMONUI
    /* display Wonderware Common UI About Box */
    Common_SetAppInstance(hInst);
    Common_ShowAboutBox (COMMON_IOSERVER32ID, szServerIDstring);
 #else
    /* display Wonderware Common Dialog About Box */
    WW_AB_INFO    AboutBoxInfo;
    HICON         hIcon;

    memset (&AboutBoxInfo, 0, sizeof(AboutBoxInfo));
    hIcon = LoadIcon(hInst, "Udprot");

    AboutBoxInfo.hwndOwner    = hWnd;
    AboutBoxInfo.szDriverName = GetAppName();
    AboutBoxInfo.szId         = GetString(STRUSER + 142);

    // DV - FS2000 porting changes
    // remove all refrences to the hardcoded version number. Pick up the version number from the RC file.
    //AboutBoxInfo.szVersion    = GetString(STRUSER + 0);

    AboutBoxInfo.szVersion    = NULL;
    AboutBoxInfo.szCopyright  = GetString(STRUSER + 143);
    AboutBoxInfo.hIcon        = hIcon;
    AboutBoxInfo.szComment    = GetString(STRUSER + 149);

    WWDisplayAboutBoxEx((LPWW_AB_INFO) &AboutBoxInfo, COMMON_IOSERVER32ID, (LPSTR)"");
    DestroyIcon (hIcon);
 #endif
#else
    /* use privately-defined about box */
    FARPROC       lpprocAbout;

    lpprocAbout = MakeProcInstance((FARPROC) UdPrivateAbout, hInst);
    DialogBox(hInst, GetString(STRUSER + 75) /* "ABOUT_BOX" */ ,
               hWnd, lpprocAbout);
 #ifndef WIN32
    FreeProcInstance(lpprocAbout);
 #endif
#endif
} /* UdDisplayAbout */

/***********************************************************************/
/* display privately-defined ABOUT box */

BOOL
WINAPI
UdPrivateAbout (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {

    case WM_INITDIALOG:
        WWCenterDialog( hDlg );

		// DV - porting to FS2000
        //SetDlgItemText(hDlg, CI_VERSION, GetString(STRUSER+0));
        SetFocus(GetDlgItem(hDlg, IDOK));

        return FALSE;

    case WM_COMMAND:
        EndDialog(hDlg, TRUE);
        return TRUE;

    default:
        return FALSE;
    }
} /* UdPrivateAbout */

/***********************************************************************/
/* this routine is here to supercede one in the toolkit */

BOOL WINAPI ProcessDlgMessages(LPMSG);

BOOL
WINAPI
ProcessDlgMessages (LPMSG lpMsg)
{
    return (FALSE);
} /* ProcessDlgMessages */

/***********************************************************************/
/** The following cures a Microsoft C7 linking anomaly, do not remove.
    Otherwise, you will get a message indicating no main procedure. **/

int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
int (PASCAL *zzyzx)(HANDLE, HANDLE, LPSTR, int) = WinMain;

⌨️ 快捷键说明

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