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

📄 udconfig.c

📁 工业组态软件modbus驱动源代码, 包括帮助文件.共享.
💻 C
📖 第 1 页 / 共 5 页
字号:
        /* initialize topic structure members */
        SetupDefaultTopicCfgParams (lpTopicCfg);
    } else {
        WWDisplayOutofMemory( "Topic data structure", GetAppName() );
    }

    return (lpTopicCfg);
} /* TopicCfgAlloc */

/***********************************************************************/
/* add topic configuration to list */

VOID
WINAPI
TopicCfgAddToList (LPTOPIC_CFG lpTopicCfg)
{
    AppendItemAtTail (&TopicCfgList, (LPCHAINLINK) lpTopicCfg);
} /* TopicCfgAddToList */

/***********************************************************************/
/* delete topic configuration from list */

VOID
WINAPI
TopicCfgDeleteFromList(LPTOPIC_CFG lpTopicToDelete)
{
    /* make sure pointer is valid */
    assert (lpTopicToDelete);
    /* make sure topic is in the list */
    assert (IsInChain   (&TopicCfgList, (LPCHAINLINK) lpTopicToDelete));
    /* remove the topic from the list, make sure it worked */
    assert (UnchainItem (&TopicCfgList, (LPCHAINLINK) lpTopicToDelete));
} /* TopicCfgDeleteFromList */

/***********************************************************************
 ***********************************************************************
 * Routines for managing linked list of BOARD configuration structures *
 ***********************************************************************
 ***********************************************************************/

/***********************************************************************/
/** Create new BOARD configuration structure,
    return pointer to structure, if successful **/

LPBOARD_CFG
WINAPI
BoardCfgAlloc(void)
{
    LPBOARD_CFG     lpBoardCfg;

    /* attempt to allocate memory */
    lpBoardCfg = (LPBOARD_CFG) wwHeap_AllocPtr(hHeap,
                                               GMEM_ZEROINIT | GMEM_MOVEABLE,
                                               (DWORD) sizeof(BOARD_CFG));
    if (lpBoardCfg != (LPBOARD_CFG) NULL) {
        /* initialize board structure members */
        SetupDefaultBoardCfgParams (lpBoardCfg);
    } else {
        WWDisplayOutofMemory( "Board data structure", GetAppName() );
    }

    return (lpBoardCfg);
} /* BoardCfgAlloc */

/***********************************************************************/
/* add board configuration to list */

VOID
WINAPI
BoardCfgAddToList (LPBOARD_CFG lpBoardCfg)
{
    AppendItemAtTail (&BoardCfgList, (LPCHAINLINK) lpBoardCfg);
} /* BoardCfgAddToList */

/***********************************************************************/
/* delete board configuration from list */

VOID
WINAPI
BoardCfgDeleteFromList(LPBOARD_CFG lpBoardToDelete)
{
    /* make sure pointer is valid */
    assert (lpBoardToDelete);
    /* make sure board is in the list */
    assert (IsInChain   (&BoardCfgList, (LPCHAINLINK) lpBoardToDelete));
    /* remove the board from the list, make sure it worked */
    assert (UnchainItem (&BoardCfgList, (LPCHAINLINK) lpBoardToDelete));
} /* BoardCfgDeleteFromList */

/***********************************************************************
 ***********************************************************************
 * Routines for finding Topics and Boards by ID, name, etc.            *
 ***********************************************************************
 ***********************************************************************/

/***********************************************************************/
/* check whether topic's board ID matches indicated value */

BOOL FAR TopicCfgBoardIDMatch (LPCHAINLINK chain_link, void FAR *comparisonValue)
{
    BOOL status;
    DWORD FAR *ID;
    LPTOPIC_CFG lpTopicCfg;

    status = FALSE;

    lpTopicCfg = (LPTOPIC_CFG) chain_link;
    ID = (DWORD FAR *) comparisonValue;

    if (lpTopicCfg->tc_channelID == *ID)
        status = TRUE;

    return (status);
} /* TopicCfgBoardIDMatch*/

/***********************************************************************/
/* check whether topic name matches indicated string */

BOOL FAR TopicCfgNameMatch (LPCHAINLINK chain_link, void FAR *comparisonValue)
{
    BOOL status;
    LPSTR st;
    LPTOPIC_CFG lpTopicCfg;

    /* initialize return value */
    status = FALSE;

    /* get pointers and perform string comparison */
    lpTopicCfg = (LPTOPIC_CFG) chain_link;
    st = (LPSTR) comparisonValue;

    if (lstrcmpi (lpTopicCfg->tc_name, st) == 0)
        status = TRUE;

    /* indicate whether match was found */
    return (status);
} /* TopicCfgNameMatch */

/***********************************************************************/
/* check whether board's channel ID matches indicated value */

BOOL FAR BoardCfgIDMatch (LPCHAINLINK chain_link, void FAR *comparisonValue)
{
    BOOL status;
    DWORD FAR *ID;
    LPBOARD_CFG lpBoardCfg;

    status = FALSE;

    lpBoardCfg = (LPBOARD_CFG) chain_link;
    ID = (DWORD FAR *) comparisonValue;

    if (lpBoardCfg->cp_channelID == *ID)
        status = TRUE;

    return (status);
} /* BoardCfgIDMatch*/

/***********************************************************************/
/* check whether board name matches indicated string */

BOOL FAR BoardCfgNameMatch (LPCHAINLINK chain_link, void FAR *comparisonValue)
{
    BOOL status;
    LPSTR st;
    LPBOARD_CFG lpBoardCfg;

    /* initialize return value */
    status = FALSE;

    /* get pointers and perform string comparison */
    lpBoardCfg = (LPBOARD_CFG) chain_link;
    st = (LPSTR) comparisonValue;

    if (lstrcmpi (lpBoardCfg->cp_name, st) == 0)
        status = TRUE;

    /* indicate whether match was found */
    return (status);
} /* BoardCfgNameMatch */

/***********************************************************************
 ***********************************************************************
 * Routines for handling TOPIC configuration dialogs                   *
 ***********************************************************************
 ***********************************************************************/

/***********************************************************************/
/** Start up Topic configuration dialog.
    This function is invoked by ProtDefWindowProc() when the
    "TOPIC" selection of the "Configure" menu is activated. **/

VOID
WINAPI
ConfigureTopic( HWND hWnd )
{
    WW_SELECT   wwSelect;
    FARPROC     lpprocGetHeadTopicCfg;
    FARPROC     lpprocGetNextTopicCfg;
    FARPROC     lpprocGetTopicCfgName;
    FARPROC     lpprocAddTopicCfg;
    FARPROC     lpprocConfigTopicCfg;
    FARPROC     lpprocDeleteTopicCfg;
    char        szSelectTitle[64];
    char        szGroupBoxLabel[64];
    BOOL        bAllowChanges;

    if (bUsesBoards) {
        /* check whether any boards have been defined */
        if (BoardCfgList.first_item.ptr == NULL) {
            MessageBox(hWnd,
                GetString(STRUSER+148)
                  /* "Must configure a board before configuring topics." */ ,
                GetAppName(),
                MB_OK | MB_ICONEXCLAMATION);
            return;
        }
    }

    /* if server active with allocated topics (logical devices), display read-only warning */
    if( iAllocatedDevices ) {
        WWDisplayConfigNotAllow(GetAppName());
        bAllowChanges = FALSE;
    } else {
        bAllowChanges = TRUE;
    }

    lstrcpy     (szSelectTitle, GetString(STRUSER + 140)
                        /* "Topic definition" */ );
    lstrcpy     (szGroupBoxLabel, GetString(STRUSER + 141)
                        /* "Topics" */ );
    lpprocGetHeadTopicCfg = MakeProcInstance((FARPROC)GetHeadTopicCfg, hInst);
    lpprocGetNextTopicCfg = MakeProcInstance((FARPROC)GetNextTopicCfg, hInst);
    lpprocGetTopicCfgName = MakeProcInstance((FARPROC)GetTopicCfgName, hInst);
    lpprocAddTopicCfg     = MakeProcInstance((FARPROC)AddTopicCfg, hInst);
    lpprocConfigTopicCfg  = MakeProcInstance((FARPROC)ConfigTopicCfg, hInst);
    lpprocDeleteTopicCfg  = MakeProcInstance((FARPROC)DeleteTopicCfg, hInst);
    _fmemset((LPWW_SELECT)&wwSelect, 0, sizeof(WW_SELECT));
    wwSelect.hwndOwner               = hWnd;
    wwSelect.szTitle                 = (LPSTR)szSelectTitle;
    wwSelect.szGroupBoxLabel         = (LPSTR)szGroupBoxLabel;
    wwSelect.lpfnGetListHead         = (GETLISTHEADPROC)lpprocGetHeadTopicCfg;
    wwSelect.lpfnGetNextNode         = (GETNEXTNODEPROC)lpprocGetNextTopicCfg;
    wwSelect.lpfnGetNodeName         = (GETNODENAMEPROC)lpprocGetTopicCfgName;
    wwSelect.lpfnAddNode             = (ADDNODEPROC)lpprocAddTopicCfg;
    wwSelect.lpfnConfigNode          = (CONFIGNODEPROC)lpprocConfigTopicCfg;
    wwSelect.lpfnDeleteNode          = (DELETENODEPROC)lpprocDeleteTopicCfg;
    wwSelect.bAddDeleteModifyEnabled = bAllowChanges;

    /* call the WWCOMDLG selection list function */
    WWSelect((LPWW_SELECT)&wwSelect);

#if !defined(WIN32)
    FreeProcInstance(lpprocGetHeadTopicCfg);
    FreeProcInstance(lpprocGetNextTopicCfg);
    FreeProcInstance(lpprocGetTopicCfgName);
    FreeProcInstance(lpprocAddTopicCfg);
    FreeProcInstance(lpprocConfigTopicCfg);
    FreeProcInstance(lpprocDeleteTopicCfg);
#endif
} /* ConfigureTopic */

/*************************************************************************
 * The callbacks below are called by the WWCOMDLG DLL WWSelect function. *
 *************************************************************************/

/***********************************************************************/
/** get pointer to first TOPIC configuration structure in the list **/

void far *CALLBACK
GetHeadTopicCfg(void)
{
    return (TopicCfgList.first_item.ptr);
} /* GetHeadTopicCfg */

/***********************************************************************/
/** get pointer to next TOPIC configuration structure in the list;
    this is used by the WW Common Dialogs to scan through the list
    of topic configurations for selection and modification by the user **/

void far *CALLBACK
GetNextTopicCfg( void far *lpTopicCfg )
{
    LPTOPIC_CFG lpTopicTmp;

    assert(lpTopicCfg);

    lpTopicTmp = (LPTOPIC_CFG) lpTopicCfg;
    return ( (void far *) lpTopicTmp->tc_chainLink.next_item.ptr);
} /* GetNextTopicCfg */

/***********************************************************************/
/** get pointer to name of indicated topic;
    this is used by the WW Common Dialogs to display the topic name
    in a Combo Box for selection by the user **/

char far *CALLBACK
GetTopicCfgName( void far *lpTopicCfg )
{
    char far *szTopicName;
    LPTOPIC_CFG lpTopicTmp;

    assert(lpTopicCfg);
    lpTopicTmp = (LPTOPIC_CFG) lpTopicCfg;
    szTopicName = lpTopicTmp->tc_name;

    return (szTopicName);
} /* GetTopicCfgName */

/***********************************************************************/
/** Attempt to delete the indicated topic configuration;
    this is invoked if the user clicks on the DELETE button in the dialog **/

void CALLBACK
DeleteTopicCfg( HWND hWnd, void far *lpTopicCfg )
{
    TopicCfgCheckDelete( hWnd, (LPTOPIC_CFG) lpTopicCfg);
} /* DeleteTopicCfg */

/***********************************************************************/
/** Attempt to add a new topic configuration;
    this is invoked if the user clicks on the ADD button in the dialog **/

void CALLBACK
AddTopicCfg( HWND hWnd )
{
    FARPROC     lpprocConfig;

    lpTopicCfgToEdit = NULL;
    lpprocConfig = MakeProcInstance((FARPROC)TopicDialogProc, hInst);
    DialogBoxParam( hInst,
                    "TOPIC_DEF",
                    hWnd,
                    lpprocConfig,
                    TRUE);

#ifndef WIN32
    FreeProcInstance(lpprocConfig);
#endif
} /* AddTopicCfg */

/***********************************************************************/
/** Initiate the dialog for TOPIC configuration;
    this is invoked when the user clicks the ADD or MODIFY button **/

void CALLBACK
ConfigTopicCfg( HWND hWnd, void far *lpTopicCfg, BOOL bModifyAllowed )
{
    FARPROC     lpprocConfig;

    lpTopicCfgToEdit = (LPTOPIC_CFG) lpTopicCfg;
    lpprocConfig = MakeProcInstance((FARPROC)TopicDialogProc, hInst);

⌨️ 快捷键说明

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