与this guy was having a problem大致相同,我遇到了类似的问题......
我的现金提取器通过RJ11(我认为它无论如何......)与我的打印机连接到电脑,这是Partner RP-600 Thermal Printer
。
我的打印机工作正常,但我无法打开现金抽屉。
基本上我对这应该如何运作的思考(基于我有限的理解是这样的:
我尝试了很多方法,但我得到以下错误:
OPOS_E_CLOSED = 101,但最常见的是 OPOS_E_NOEXIST = 109
如果我将其设为drawer.Open("rp-600 printer")
,我会OPOS_E_ILLEGAL = 106
我的代码如下:
using OPOSCONSTANTSLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OposPOSPrinter_CCO;
using OposCashDrawer_CCO;
namespace PosPrinterTest
{
public partial class Form1 : Form
{
private OPOSPOSPrinterClass printer = null;
private OPOSCashDrawerClass drawer = null;
public Form1()
{
InitializeComponent();
printer = new OPOSPOSPrinterClass();
drawer = new OPOSCashDrawerClass();
_IOPOSPOSPrinterEvents_StatusUpdateEventEventHandler SUEH =
new _IOPOSPOSPrinterEvents_StatusUpdateEventEventHandler(
PrinterStatusUpdateHandler);
printer.StatusUpdateEvent += SUEH;
_IOPOSCashDrawerEvents_StatusUpdateEventEventHandler DSUEH = new _IOPOSCashDrawerEvents_StatusUpdateEventEventHandler(CashDrawerStatusUpdateHandler);
drawer.StatusUpdateEvent += DSUEH;
}
private void AddList(object listline)
{
listBox1.Items.Add(listline);
listBox1.SelectedIndex = listBox1.Items.Count - 1;
}
private void OpenCashDrawer()
{
AddList("+Open drawer");
int Result = drawer.Open("rpd");
AddList(String.Format(" 1-Open drawer: RC = {0}", Result));
Result = drawer.ClaimDevice(1000);
AddList(String.Format(" 2-Claim drawer: RC = {0}", Result));
drawer.DeviceEnabled = true;
Result = drawer.ResultCode;
AddList(String.Format(" 3-Enable drawer: RC = {0}", Result));
Result = drawer.OpenDrawer();
AddList(String.Format(" 4-Open drawer: RC = {0}", Result));
AddList(String.Format("-Open drawer: {0}", ((Result == (int)OPOS_Constants.OPOS_SUCCESS) ? "Succeeded" : "Failed")));
AddList(String.Empty);
}
private void CloseCashDrawer()
{
AddList("+Close drawer");
int Result = drawer.ReleaseDevice();
AddList(String.Format(" Release drawer: RC = {0}", Result));
AddList("-Release drawer: " + ((Result == (int)OPOS_Constants.OPOS_SUCCESS) ? "Succeeded" : "Failed"));
Result = drawer.Close();
AddList(String.Format(" Close drawer: RC = {0}", Result));
AddList("-Close drawer: " + ((Result == (int)OPOS_Constants.OPOS_SUCCESS) ? "Succeeded" : "Failed"));
AddList(String.Empty);
}
private void Print()
{
AddList("+Print");
int Result = printer.PrintNormal(2, "\x1B|cA\x1B|2COPOS POSPrinter\x1B|1C\nvia Microsoft.NET\n\n");
AddList(String.Format(" Print: BC = {0}", Result));
AddList(String.Format("-Print: {0}", ((Result == (int)OPOS_Constants.OPOS_SUCCESS) ? "Succeeded" : "Failed")));
Result = printer.CutPaper(100);
AddList(String.Format(" Cut: BC = {0}", Result));
AddList(String.Format("-Cut: {0}", ((Result == (int)OPOS_Constants.OPOS_SUCCESS) ? "Succeeded" : "Failed")));
AddList(String.Empty);
}
private void OpenPrinter()
{
AddList("+Open printer");
int Result = printer.Open("rp-600 printer");
AddList(String.Format(" Open: RC = {0}", Result));
if (Result == (int)OPOS_Constants.OPOS_SUCCESS)
{
Result = printer.ClaimDevice(1000);
AddList(String.Format(" Claim printer: RC = {0}", Result));
if (Result == (int)OPOS_Constants.OPOS_SUCCESS)
{
printer.DeviceEnabled = true;
Result = printer.ResultCode;
AddList(String.Format(" Enable printer: RC = {0}>", Result));
}
}
AddList(String.Format("-Open: {0}", ((Result == (int)OPOS_Constants.OPOS_SUCCESS) ? "Succeeded" : "Failed")));
AddList(String.Empty);
}
private void ClosePrinter()
{
AddList("+Close printer");
int Result = printer.ReleaseDevice();
AddList(String.Format(" Release printer: RC = {0}", Result));
AddList("-Release printer: " + ((Result == (int)OPOS_Constants.OPOS_SUCCESS) ? "Succeeded" : "Failed"));
Result = printer.Close();
AddList(String.Format(" Close printer: RC = {0}", Result));
AddList("-Close printer: " + ((Result == (int)OPOS_Constants.OPOS_SUCCESS) ? "Succeeded" : "Failed"));
AddList(String.Empty);
}
private void PrinterStatusUpdateHandler(int nStatus)
{
AddList(" P StatusUpdate: " + nStatus);
}
private void CashDrawerStatusUpdateHandler(int nStatus)
{
AddList(String.Format(" CD Status Update: {0}", nStatus));
}
private void btnTender_Click_1(object sender, EventArgs e)
{
//OpenPrinter();
//Print();
//ClosePrinter();
OpenCashDrawer();
CloseCashDrawer();
}
}
}
如您所见,我在OpenCashDrawer()中指定的设备名称与我在opos中设置的设备名称相同。
那么我做错了什么阻止了opos找到现金抽屉?
答案 0 :(得分:0)
您的屏幕截图显示,cashdrawer LDN是" rp-cashdrawer",但您的代码正在使用" rpd"。
drawer.Open("rpd");
您应该使用配置的LDN打开设备,例如:
drawer.Open("rp-cashdrawer");