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

📄 engine.c

📁 vt6528芯片交换机API函数和文档运行程序
💻 C
字号:
/*
 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
 * All rights reserved.
 *
 * This software is copyrighted by and is the sole property of
 * VIA Networking Technologies, Inc. This software may only be used
 * in accordance with the corresponding license agreement. Any unauthorized
 * use, duplication, transmission, distribution, or disclosure of this
 * software is expressly forbidden.
 *
 * This software is provided by VIA Networking Technologies, Inc. "as is"
 * and any express or implied warranties, including, but not limited to, the
 * implied warranties of merchantability and fitness for a particular purpose
 * are disclaimed. In no event shall VIA Networking Technologies, Inc.
 * be liable for any direct, indirect, incidental, special, exemplary, or
 * consequential damages.
 *
 *
 * File:    engine.c
 *
 * Purpose: UI engine main body
 *
 * Author:  Jenda Jao
 *
 * Date:    Jan 08, 2002
 *
 * Functions:
 *
 * Revision History:
 *
 */


#if !defined(__KEY_H__)
#include "key.h"
#endif
#if !defined(__ANSIKEY_H__)
#include "ansikey.h"
#endif
#include "str.h"
#include "tty.h"
#if !defined(__SWSRAM_H__)
#include "swsram.h"
#endif
#include "allpages.h"
#include "engine.h"
#include "eng_io.h"
#include "eng_move.h"
#include "eng_act.h"
#include "dbgmenu.h"

#ifdef __ADD_ANLZ
#include "anlzmain.h"
#endif




/*---------------------  Static Definitions  ------------------------*/

/*---------------------  Static Types  ------------------------------*/

/*---------------------  Static Macros  -----------------------------*/

/*---------------------  Static Classes  ----------------------------*/

/*---------------------  Static Variables  --------------------------*/

/*---------------------  Static Functions  --------------------------*/

/*---------------------  Export Variables  --------------------------*/
UINT8 g_byRootPageID;
UINT8 g_byCurPageID;
UINT16 g_wTotalLineNum;
UINT16 g_wCurLineID;
UINT16 g_wCurItemID;
BOOL g_bDataDirty;
UINT8 g_byCurKey;

UINT8 g_byMultiPageNo;

volatile BOOL    g_bSemaphoreTtyLogout;




void ENGvEnterPage(void)
{
    g_byCurPageID = g_byRootPageID;

    while (g_byCurPageID != PAGE_LOGIN) {
        g_wTotalLineNum = 0;

        // The returned main menu page is always PAGE_MAIN_MENU, defined in g_abyPreviousPageID,
        // but the root page may be PAGE_MAIN_MENU or PAGE_MAIN_MENU_NOLOGOUT
        if (g_byCurPageID == PAGE_MAIN_MENU)
            g_byCurPageID = g_byRootPageID;

        if (g_pSCurPage->bLoadPage)
            if (g_pSCurPage->bLoadPage())
                continue;

        //// if item page
        if (g_pSCurPage->byActItemNum) {
            g_bDataDirty = FALSE;
            g_wCurLineID = 0;   // g_wCurLineID should be zero before print page
            ENGvPrintPage();

            ENGvRunActionBar();
        }   // end if item page
        //// menu page (ITEM_MENU_PAGESEL)
        else {
            g_wCurLineID = g_wCurItemID = 0;
            g_byMultiPageNo = 0;
            ENGvPrintPage();

            ENGvItemSelect();

            if (g_byCurPageID == PAGE_LOGIN)    // for disconnection (auto logout)
                return;

            if (g_byCurKey == MK_ESCAPE) // goto previous page
                g_byCurPageID = g_abyPreviousPageID[g_byCurPageID];
            else                                            // goto selected page
                g_byCurPageID = ((SItemPageSel*)(g_SCurItem.pvItem))->byPageID;
        }   // end if menu page
    }   // end while
}


// select a var item, return the array index of aSVarItem
void ENGvItemSelect(void)
{
    BOOL bRtnKey = FALSE;
    UINT8   u8Tmp;


    g_byCurKey = 1;     // print the first item at first time

    // To generate msg bar
    ENGvClearMsgBar();

    while (1) {
        if (g_byCurKey)
            ENGvPrintItem(g_wCurLineID, g_wCurItemID, PRINT_ITEM_HIGHLIGHT);

        if (bRtnKey)
            bRtnKey = FALSE;
        else
            g_byCurKey = TTY_cGetChar();

        // for auto-logout
        if (g_bSemaphoreTtyLogout) {
            g_byCurPageID = PAGE_LOGIN;
            g_bSemaphoreTtyLogout = FALSE;
            return;
        }
        // for debug menu
        else if (g_byCurKey == AK_UDLINE) {
            DBGvMainMenu();
            ENGvPrintPage();
        }
#ifdef __ADD_ANLZ
        // for analyzer menu
        else if (g_byCurKey == '}') {
            ANLZ_vMainMenu();
            ENGvPrintPage();
        }
#endif
        // move item
        else if ((MK_V_UP <= g_byCurKey && g_byCurKey <= MK_V_LEFT) ||
                (g_byCurKey == MK_TAB) || (g_byCurKey == MK_BACKSPACE) ) {
            ENGvPrintItem(g_wCurLineID, g_wCurItemID, PRINT_ITEM_NORMAL);
            ENGvMoveItem();
        }
        // for listbox only
        else if ((g_byCurKey == MK_SPACE)&&(g_SCurItem.f4DataType == ITEM_LISTBOX)) {
            SItemListbox* pSIListbox = (SItemListbox*)(g_SCurItem.pvItem);
            UINT8 byValue, byStartBit, byEndBit;
            byStartBit = pSIListbox->byStartBit;
            byEndBit = pSIListbox->byEndBit;
            
            SWSRAM_vExtractBitsByByte(pSIListbox->pbyIndex + (pSIListbox->byVarBitOffset>>3) * g_wCurLineID,
                            byStartBit + (pSIListbox->byVarBitOffset&0x07) * g_wCurLineID,
                            byEndBit + (pSIListbox->byVarBitOffset&0x07) * g_wCurLineID,
                            &byValue);

            byValue = (byValue + 1) % pSIListbox->byListNum;

            SWSRAM_vModifyBitsByByte(pSIListbox->pbyIndex + (pSIListbox->byVarBitOffset>>3) * g_wCurLineID,
                           byStartBit + (pSIListbox->byVarBitOffset&0x07) * g_wCurLineID,
                           byEndBit + (pSIListbox->byVarBitOffset&0x07) * g_wCurLineID,
                           &byValue);

            g_bDataDirty = TRUE;
        }
        // for var-listbox only
        else if ((g_byCurKey == MK_SPACE)&&(g_SCurItem.f4DataType == ITEM_VAR_LISTBOX)) {
            SItemVarListbox* pSIListbox = (SItemVarListbox*)(g_SCurItem.pvItem);
            UINT8 byValue, byStartBit, byEndBit;
            byStartBit = pSIListbox->byStartBit;
            byEndBit = pSIListbox->byEndBit;

            if (! pSIListbox->pSStrTblMap->byListNum)
                continue;

            // The ITEM_VAR_LISTBOX item does not support repeat-type in this smart version
            SWSRAM_vExtractBitsByByte(pSIListbox->pbyIndex,
                            byStartBit,
                            byEndBit,
                            &byValue);

            byValue = (byValue + 1) % (pSIListbox->pSStrTblMap->byListNum);

            SWSRAM_vModifyBitsByByte(pSIListbox->pbyIndex,
                           byStartBit,
                           byEndBit,
                           &byValue);
            g_bDataDirty = TRUE;
        }
        // jump to action bar or goto selected page (LINK_TYPE_EDITPAGE includes ITEM_MENU_PAGESEL)
        else if ((g_byCurKey == MK_ENTER && (g_SCurItem.f2LinkType == LINK_TYPE_LISTBOX || g_SCurItem.f2LinkType == LINK_TYPE_EDITPAGE))
              || (g_byCurKey == MK_ESCAPE)) {
            ENGvPrintItem(g_wCurLineID, g_wCurItemID, PRINT_ITEM_NORMAL);
            return;
        }
        // deal with hotkey for ITEM_MENU_PAGESEL, support hot key
        else if (g_SCurItem.f4DataType == ITEM_MENU_PAGESEL) {
            if (g_byCurKey >= '0' && g_byCurKey <= '9')
            {
                if ((g_byCurPageID == PAGE_MAIN_MENU_NOLOGOUT) &&
                    (('0' <= g_byCurKey) && (g_byCurKey < '1'+g_pSCurPage->wVarItemNum)))
                {
                    /* type key 1~9 and passwd disable; key 0 is not valid */
                    if (g_byCurKey == '0')
                        g_byCurKey = 0;
                    else{
                        g_wCurItemID = g_byCurKey-'1';
                        return;
                    }
                }
                
                if (('0' <= g_byCurKey) && (g_byCurKey < '0'+g_pSCurPage->wVarItemNum)) {
                    if (g_byCurKey == '0')
                        g_wCurItemID = g_pSCurPage->wVarItemNum-1;
                    else
                        g_wCurItemID = g_byCurKey-'1';
                    return;
                }
            }
            // A~Z
            else
            {
                u8Tmp = 10; //10 means Item10 print ItemA
                if (g_byCurPageID == PAGE_MAIN_MENU_NOLOGOUT)
                    u8Tmp -= 1; //-1 because g_pSCurPage->wVarItemNum will decrease 1

                if ((g_byCurKey >= 'A' && g_byCurKey <= 'Z') && 
                    (g_byCurKey < 'A'+g_pSCurPage->wVarItemNum-u8Tmp) )
                {
                    g_wCurItemID = g_byCurKey- 'A' + 9;
                    return;
                }

                if ((g_byCurKey >= 'a' && g_byCurKey <= 'z') && 
                    (g_byCurKey < 'a'+g_pSCurPage->wVarItemNum-u8Tmp) )
                {
                    g_wCurItemID = g_byCurKey- 'a' + 9;
                    return;
                }
            }
            g_byCurKey = 0; // input key not valid

        }
        // accept user input for ITEM_DECNUM, ITEM_HEXNUM, ITEM_STRING, ITEM_PASSWORD
        else if (g_SCurItem.f4DataType < ITEM_LISTBOX && g_SCurItem.f2LinkType == LINK_TYPE_NONE) {
            ENGvInputItem(&(g_SCurItem));
            g_bDataDirty = TRUE;
            bRtnKey = g_byCurKey;
        }
        // input key not valid
        else {
            g_byCurKey = 0;
        }
    }
}


⌨️ 快捷键说明

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