请问哪位有用JavaWeb接过思达的TCP410打印机?

TcStudio
  • 134

我这边安装了他们官网下载的ocx控件,但是js调用的时候提示找不到函数!

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<LINK rel="stylesheet" type="text/css" href="/css/sample.css">
</head>
<body>
    <p>
        <OBJECT id="VisualCard" border="0" classid="clsid:F2F7F2A4-E582-11D1-89AC-00C04FCAF6E3" width="50" align="baseline" height="50">
            <PARAM NAME="_Version" VALUE="65536">
            <PARAM NAME="_ExtentX" VALUE="1322">
            <PARAM NAME="_ExtentY" VALUE="1322">
            <PARAM NAME="_StockProps" VALUE="0">
        </OBJECT>
    </p>
    <script language="JScript" type="text/jscript">
        
    
    ////////////////////////////////////////////////////////////////////////
    //"State" Property Constants.
    ////////////////////////////////////////////////////////////////////////
    
    SMJ_S_CLOSED                      = 1;
    SMJ_S_IDLE                        = 2;
    SMJ_S_BUSY                        = 3;
    SMJ_S_ERROR                       = 4;
    SMJ_S_CLEAR                       = 5;
    SMJ_S_TIMEOUT                     = 6;
    
    ////////////////////////////////////////////////////////////////////////
    //"ResultCode" Property Constants.
    ////////////////////////////////////////////////////////////////////////
    
    SMJ_ERROR                         = 100;
    
    SMJ_SUCCESS                       = 0;
    SMJ_E_CLOSED                      = 101;
    SMJ_E_NOTCLAIMED                  = 102;
    SMJ_E_ILLEGAL                     = 103;
    SMJ_E_NOCONTROL                   = 104;
    SMJ_E_NOHARDWARE                  = 105;
    SMJ_E_CLEAR                       = 106;
    SMJ_E_TIMEOUT                     = 107;
    SMJ_E_BUSY                        = 108;
    SMJ_E_NOBUSY                      = 109;
    SMJ_E_DSR_BUSY                    = 110;
    
    ////////////////////////////////////////////////////////////////////////
    //"Open" Parameter Constants.
    ////////////////////////////////////////////////////////////////////////
    
    SMJ_VISUALCARD_PORTCOM1           = 1;
    SMJ_VISUALCARD_PORTCOM2           = 2;
    SMJ_VISUALCARD_PORTCOM3           = 3;
    SMJ_VISUALCARD_PORTCOM4           = 4;
    SMJ_VISUALCARD_PORTCOM5           = 5;
    SMJ_VISUALCARD_PORTCOM6           = 6;
    SMJ_VISUALCARD_PORTCOM7           = 7;
    SMJ_VISUALCARD_PORTCOM8           = 8;
    SMJ_VISUALCARD_PORTCOM9           = 9;
    SMJ_VISUALCARD_PORTCOM10          = 10;
    
    SMJ_VISUALCARD_BAUDRATE19200BPS   = 1;
    SMJ_VISUALCARD_BAUDRATE9600BPS    = 2;
    SMJ_VISUALCARD_BAUDRATE4800BPS    = 3;
    SMJ_VISUALCARD_BAUDRATE2400BPS    = 4;
    SMJ_VISUALCARD_BAUDRATE38400BPS   = 5;
    
    SMJ_VISUALCARD_BYTESIZE8BIT       = 1;
    SMJ_VISUALCARD_BYTESIZE7BIT       = 2;
    
    SMJ_VISUALCARD_PARITYNONE         = 1;
    SMJ_VISUALCARD_PARITYODD          = 2;
    SMJ_VISUALCARD_PARITYEVEN         = 3;
    
    
    
    var writeMessage
    var accessType
    var CardPosition
    var DoubleWid
    
    function OutputOnClick()     // Ejecting
    {
        accessType = "outputcard";
        VisualCard_open();
    }
    
    function SetClick()
    {
        accessType = "setmem";
        VisualCard_open();
    }
    
    function PrintOnClick()     // Execute printing
    {
        accessType = "printcard";
        VisualCard_open();
    }
    
    function ReadOnClick()     // Read Mg stripe
    {
        accessType = "readcard";
        VisualCard_open();
    }
    
    function ReadStatusOnClick()
    {
        accessType = "readstatus";
        VisualCard_open();
    }
    
    function Prepairprinting()
    {
        DoubleWid = "\x1be12A倍宽字ABC"+"\x1be11\n"+    document.Form.writemessage.value;
        document.Form.writemessage.value = DoubleWid;
    }
    
    function SetMag()
    {
        DoubleWid = "C7";
        document.Form.writemessage.value = DoubleWid;
    }
    
    function DisplayPosition()
    {
        //简单处理,需要更改    
        if(CardPosition=="200000"){
            document.Form.readstatus.value  = CardPosition + "卡片待取走"
        }else if(CardPosition=="100000"){
            document.Form.readstatus.value  = CardPosition + "卡片在前部卡口处"
        }else if(CardPosition=="010000"){
            document.Form.readstatus.value  = CardPosition + "卡片在前部待卡"
        }else if(CardPosition=="001000"){
            document.Form.readstatus.value  =CardPosition +  "卡片在前部"
        }else if(CardPosition=="000100"){
            document.Form.readstatus.value  =CardPosition +  "卡片在后部"
        }else if(CardPosition=="000010"){
            document.Form.readstatus.value  = CardPosition + "上盖打开"
        }else if(CardPosition=="000000"){
            document.Form.readstatus.value  = CardPosition + "机器内无卡"
        }else{
            document.Form.readstatus.value  = CardPosition + "复合状态"
        }
    }
    
    function WriteOnClick()     // Write to Mg stripe
    {
        accessType = "writecard";
        VisualCard_open();
    }
    
    function VisualCard_open()     // Start Communication
    {
        console.log(VisualCard);
        console.log("document.Form.portnum.value>>"+document.Form.portnum.value);
        console.log("SMJ_VISUALCARD_BAUDRATE9600BPS>>"+SMJ_VISUALCARD_BAUDRATE9600BPS);
        console.log("SMJ_VISUALCARD_BYTESIZE8BIT>>"+SMJ_VISUALCARD_BYTESIZE8BIT);
        console.log("SMJ_VISUALCARD_PARITYNONE>>"+SMJ_VISUALCARD_PARITYNONE);
        nResult = VisualCard.Open(document.Form.portnum.value, SMJ_VISUALCARD_BAUDRATE9600BPS, SMJ_VISUALCARD_BYTESIZE8BIT, SMJ_VISUALCARD_PARITYNONE);
        if(VisualCard.State == SMJ_S_IDLE)
        {
            nResult = VisualCard.Claim(0);
            if(VisualCard.Result == SMJ_E_NOHARDWARE)
            {
                alert("SMJ_E_NOHARDWARE !!!");
                nResult = VisualCard.ClearCommunication();
                nResult = VisualCard.Release();
                nResult = VisualCard.Close();
            }
            else
            {
                nResult = VisualCard.Communication(0x59, "", 0, true);
            }
        }else{
            if(VisualCard.State == SMJ_S_BUSY)
            {
                nResult = VisualCard.ClearCommunication();
                nResult = VisualCard.Release();
                nResult = VisualCard.Close();
            }
            else
            {
                alert("VistualState !?");
            }
        }
    }
    </script>
    <script language="JScript" for="VisualCard" event="CommunicationEvent(nResult,nCommunicationID)">
        
    switch(nResult)
    {
        case SMJ_SUCCESS:
            if((nCommunicationID == 1) && (accessType == "outputcard"))     // execute ejecting
            {
                nResult = VisualCard.Communication(0x50, "1", 0, true);
                accessType = "end";
            }
            else if((nCommunicationID == 1) && (accessType == "printcard"))     // execute printing
            {
                nResult = VisualCard.Communication(0x40, "", 0, true);
            }
            else if((nCommunicationID == 2) && (accessType == "printcard"))
            {
                Prepairprinting();
                nResult = VisualCard.Communication(0x41, document.Form.writemessage.value, 0, true);
            }
            else if((nCommunicationID == 3) && (accessType == "printcard"))
            {
                nResult = VisualCard.Communication(0x46, "1", 0, true);
                accessType ="end";
            }
            else if((nCommunicationID == 1) && (accessType == "readcard"))     // execute reading
            {
                if(document.Form.Rtripnum.value == 1)
                    nResult = VisualCard.Communication(0x25, "", 0, true);
                else if(document.Form.Rtripnum.value == 2)
                    nResult = VisualCard.Communication(0x26, "", 0, true);
                else if(document.Form.Rtripnum.value == 3)
                    nResult = VisualCard.Communication(0x27, "", 0, true);
                else
                    nResult = VisualCard.Communication(0x26, "", 0, true);
            }
            else if((nCommunicationID == 2) && (accessType == "readcard"))
            {
                document.Form.readcardmes.value = VisualCard.RxString;
                nResult = VisualCard.Communication(0x59, "", 0, true);
                accessType = "end";
            }
            else if((nCommunicationID == 1) && (accessType == "readstatus"))     // execute read status
            {
                nResult = VisualCard.Communication(0x59, "", 0, true);
            }
            else if((nCommunicationID == 2) && (accessType == "readstatus"))
            {
                //   document.Form.readstatus.value  = VisualCard.RxString;
                CardPosition  = VisualCard.RxString;
                DisplayPosition();
                nResult = VisualCard.Communication(0x59, "", 0, true);
                accessType = "end";
            }
            else if((nCommunicationID == 1) && (accessType == "writecard"))     // execute writing
            {
                if(document.Form.Wtripnum.value == 1)
                    nResult = VisualCard.Communication(0x3b, document.Form.writecardmes.value, 0, true);
                else if(document.Form.Wtripnum.value == 2)
                    nResult = VisualCard.Communication(0x3c, document.Form.writecardmes.value, 0, true);
                else if(document.Form.Wtripnum.value == 3)
                    nResult = VisualCard.Communication(0x3d, document.Form.writecardmes.value, 0, true);
                else
                    nResult = VisualCard.Communication(0x3c, document.Form.writecardmes.value, 0, true);
            }
            else if((nCommunicationID == 2) && (accessType == "writecard"))
            {
                if(document.Form.Wtripnum.value == 1)
                nResult = VisualCard.Communication(0x32, "1", 0, true);
                else if(document.Form.Wtripnum.value == 2)
                nResult = VisualCard.Communication(0x32, "2", 0, true);
                else if(document.Form.Wtripnum.value == 3)
                nResult = VisualCard.Communication(0x32, "4", 0, true);
                  else
                nResult = VisualCard.Communication(0x32, "3", 0, true);
            }
            else if((nCommunicationID == 3) && (accessType == "writecard"))
            {
                nResult = VisualCard.Communication(0x59, "", 0, true);

                accessType = "end";
            }
            else if((nCommunicationID == 1) && (accessType == "setmem"))
            {
                SetMag();
                nResult = VisualCard.Communication(0x91, document.Form.writemessage.value,0, true);
                accessType = "end";
            }
            else if(accessType == "end")     // Quit communication
            {
                nResult = VisualCard.ClearCommunication();
                nResult = VisualCard.Release();
                nResult = VisualCard.Close();
            }
            break;
        case SMJ_E_NOHARDWARE:
            alert("SMJ_E_NOHARDWARE !!!");
            //硬件不存在.
            nResult = VisualCard.ClearCommunication();
            nResult = VisualCard.Release();
            nResult = VisualCard.Close();
            break;
        case SMJ_E_BUSY:
            alert("SMJ_E_BUSY !!!");
            //忙
            break;
        case SMJ_E_DSR_BUSY:
            alert("SMJ_E_DSR_BUSY !!!");
            nResult = VisualCard.ClearCommunication();
            nResult = VisualCard.Release();
            nResult = VisualCard.Close();
            break;
        default:
            alert("Illegal !?"+ nResult);            //非法命令或参数
            nResult = VisualCard.ClearCommunication();
            nResult = VisualCard.Release();
            nResult = VisualCard.Close();
            break;
    }

    
    </script>
    <form style="Z-INDEX: 0" name="Form">
        <table border="0" height="372">
            <tr>
                <th><FONT face="宋体">选择端口</FONT></th>
                <td><FONT size="3" face="GulimChe"><STRONG>串口选择</STRONG></FONT>
                    <select size="1" name="portnum">
                        <option selected value="1">COM1</option>
                        <option value="2">COM2</option>
                        <option value="3">COM3</option>
                        <option value="4">COM4</option>
                        <option value="5">COM5</option>
                        <option value="6">COM6</option>
                        <option value="7">COM7</option>
                        <option value="8">COM8</option>
                        <option value="9">COM9</option>
                        <option value="10">COM10</option>
                </select></td>
            </tr>

            <TR>
                <TD height="37">
                    <P align="center">
                        <FONT style="Z-INDEX: 0" face="宋体">读取状态字</FONT>
                    </P>
                </TD>
                <TD height="37" colSpan="2"><INPUT style="Z-INDEX: 0"
                    id="Text1" size="43" name="readstatus"> <INPUT
                    style="Z-INDEX: 0" id="Button2" onclick="ReadStatusOnClick()"
                    value="读状态" type="button" name="readcard"></TD>
            </TR>
            <tr>
                <th height="39"><FONT size="3" face="GulimChe"><STRONG>读取磁轨选择</STRONG></FONT>
                    <select size="1" name="Rtripnum">
                        <option selected value="1">第一磁轨</option>
                        <option value="2">第二磁轨</option>
                        <option value="3">第三磁轨</option>
                </select></th>

                <td height="39" colSpan="2">
                    <P>
                        <input size="50" name="readcardmes"><input
                            onclick="ReadOnClick()" value="读卡" type="button" name="readcard">
                    </P>
                </td>
            </tr>
            <tr>
                <th height="40"><FONT size="3" face="GulimChe"><STRONG>写入磁轨选择</STRONG></FONT>
                    <select size="1" name="Wtripnum">
                        <option selected value="1">第一磁轨</option>
                        <option value="2">第二磁轨</option>
                        <option value="3">第三磁轨</option>
                </select></th>
                <td height="39" colSpan="2">
                    <P>
                        <input size="50" name="writecardmes"><input id="Button1"
                            onclick="WriteOnClick()" value="写卡" type="button"
                            name="writecard"><FONT face="宋体"></FONT>
                    </P>
                </td>
            </tr>
            <tr>
                <th>Print</th>
                <td colSpan="2">每行打印24个字母/数字或12个汉字<br> <textarea rows="6"
                        cols="34" name="writemessage"></textarea> <input
                    onclick="PrintOnClick()" value="打印卡" type="button" name="printcard">
                </td>
            </tr>
            <tr>
                <td colSpan="2" align="left">
                    <P>
                        <input onclick="SetClick()" value="设置三轨有效" type="button"
                            name="Set3Trip">
                </td>
            </tr>
            <tr>
                <td colSpan="2" align="middle">
                    <P>
                        <input onclick="OutputOnClick()" value="退卡" type="button"
                            name="outputcard">
                </td>
            </tr>
        </table>
    </form>
    <p></p>
</body>
</html>
回复
阅读 1.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏