Datecs打印机驱动程序 [英] Datecs Printer Driver

查看:207
本文介绍了Datecs打印机驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 试图编写与第三方软件链接的datecs财务打印机的驱动程序.这个想法是从第三方软件中检索数据并将其发送到财务打印机.我无权访问第三方软件的源代码,只能从数据字典中检索数据.

我相信我需要编写打印机驱动程序,但不知道从哪里开始.我有datecs打印机的用户手册,该手册为我提供了一组命令,例如:
命令:48(30h)-用于打开财务收据

打印机具有驱动程序,但我必须发出手动命令才能进行打印.这个想法是自动将命令发送到打印机.

非常感谢您能提供的任何帮助.

干杯!

T

Hi Am attempting to write a driver for a datecs fiscal printer that is linked to a third party software. The idea is to retrieve data from the the third party software and send it to the fiscal printer. I do not have access to the source code for the third party software and can only retrieve data from the data dictionary.

I believe I need to write a printer driver but have no idea where to begin. I have the user manual for the datecs printer that gives me a set of commands for instance:
Command: 48(30h) - is used to open a fiscal receipt

The printer has a driver but I have to issue manual commands to print. The idea is to automatically send the commands to the printer.

I would really appreciate any assistance you can give me.

Cheers!

T

推荐答案

您在这里尝试过SDK吗?那不是让你按照自己的意思做吗?

http://www.datecs.bg/support.php?cat=4 [ ^ ]
Did you try the SDK here? Doesn''t that allow you to do what you say?

http://www.datecs.bg/support.php?cat=4[^]


嗨!

直接打印命令的类:



公共类DATECS
const strANS As String ="______,_,__;"

专用LDN简称为逻辑设备号
私有strLine作为字符串
私有BillCtr作为整数
Dim noNbDec作为新System.Globalization.NumberFormatInfo
昏暗的niDec作为新的System.Globalization.NumberFormatInfo
将dimDec用作新System.Globalization.NumberFormatInfo

Public Sub New(ByVal strPath为字符串,ByVal LogicalDeviceNb为短)

出错时转到errHandler

FileOpen(1,strPath,OpenMode.Output)
LDN = LogicalDeviceNb
BlockKeypad()

noNbDec.NumberDecimalDigits = 0
niDec.NumberDecimalDigits = 2
threeDec.NumberDecimalDigits = 3

退出子
errHandler:
Err.Raise(错误编号,"New DATECS",错误说明)
结束子

Public Sub BlockKeypad()
strLine ="H"& CStr(LDN)& ,______,_,__;"
PrintLine(1,strLine)
结束子

公共子UnBlockKeypad()
strLine ="F"& CStr(LDN)& ,______,_,__;"
PrintLine(1,strLine)
结束子

Public Sub AddProduct(ByVal产品名称为字符串,ByVal Qtyvar为小数,ByVal SalesValue为小数,ByVal SAIDvar为整数,ByVal CatIDvar为整数,ByVal VATGroup为短)

strLine ="S"& CStr(LDN)& ,"&和修剪(Mid(productName,1,22))& ;" & SalesValue.ToString("f",niDec)& ;" & Qtyvar.ToString("f",noNbDec)& ;" & CStr(SAIDvar)& ;" & CStr(CatIDvar)& ;" & CStr(VATGroup)& ;" & "0; 0;"
PrintLine(1,strLine)

结束子

Public Sub CashInOut(ByVal dSum as Decimal,可选ByVal bWithdraw As Boolean = False)
昏暗的iCode为整数= 1
''0-现金输入
''1-现金支出

出错时转到errHandler

如果bWithdraw然后
iCode = 1''兑现
其他
iCode = 0''现金流入
如果结束

strLine ="I"& CStr(LDN)& ,"&和iCode& ;" & dSum.ToString("f",niDec)& ";;;;"
PrintLine(1,strLine)

退出子
errHandler:
MsgBox(错误nb:"& Err.Number&,"&错误描述:"& Err.Description&,错误代码:"&"WithdrawInput")
结束子

Public Sub DiscountIncrease(ByVal dProcent为小数,可选ByVal iCode为整数= 1)
''0-增加
''1-折扣

strLine ="C"& CStr(LDN)& ,"&和iCode& ;" & dProcent.ToString("f",niDec)& ";;;;"
MsgBox(strLine)
PrintLine(1,strLine)

结束子

Public Sub AddTextLine(ByVal T1作为字符串,可选ByRef T2作为字符串=",可选ByRef T3作为字符串=",可选ByRef T4作为字符串=",可选ByRef T5作为字符串=")

strLine ="P"& CStr(LDN)& ,"&和T1& ;"
如果不是IsDBNull(T2),则strLine = strLine& T2& ;"
如果不是IsDBNull(T3),则strLine = strLine& T3& ;"
如果不是IsDBNull(T4),则strLine = strLine& T4& ;"
如果不是IsDBNull(T5),则strLine = strLine& T5& ;"

PrintLine(1,strLine)

结束子

公共小计()

PrintLine(1,"T,& CStr(LDN)&",& strANS&" 4 ;;;;;)
''0-现金
''1-ceck
''两张卡
''三张票
''4-小计

结束子

Public Sub AddPayment(ByVal pmtType为Short)
PrintLine(1,"T"& CStr(LDN)&,"& strANS& CStr(pmtType)&";;;;;")
结束子

结束类

这是您使用此类的方式:

公共函数DATECSFiscal()作为字符串
昏暗的sHeader作为字符串
将myBill设置为新的DATECS
昏暗的c()作为字符串
Dim SA As String ="
昏暗的分隔符作为新的StringBuilder()
小数的dmty数量
小数点的dPrice dPrice
昏暗的dNetAmount为小数
Dim dInitialAmount为小数
Dim dSubTotal为小数
昏暗的iDepID为整数= 1
Dim iGroupArt为整数= 1
dim dDiscount为小数

出错时转到errHandler

LDN = 1
BillCtr = CInt(dtData.Rows(0).Item(12))

myBill =新的DATECS(BillINPPath,LDN,BillCtr)
SA = dtData.Rows(0).Item(10).ToString
myBill.AddTextLine(SA&"& dtData.Rows(0).Item(11).ToString)
myBill.AddTextLine(产品数量小计")

sSeparator =新的StringBuilder
sSeparator.Append(-",pLineSize)

myBill.AddTextLine(sSeparator.ToString)

dNetAmount = CDec(dtData.Rows(0).Item(15))
dInitialAmount = CDec(dtData.Rows(0).Item(13))
dDiscount = CDec(dtData.Rows(0).Item(14))

Dim drt As System.Data.DataRow
对于dtData.Rows中的每个drt

dQty = CDec(drt.Item(1).ToString())
dPrice = CDec(drt.Item(3).ToString)
dSubTotal = CDec(drt.Item(4).ToString)

iDepID =(CDec(drt.Item(17))Mod maxDepNb)+ 1
iGroupArt =(CDec(drt.Item(18))Mod maxArtNb)+ 1

myBill.AddProduct(Mid(Trim(drt.Item(2).ToString),1,productLength),dQty,dPrice,iDepID,iGroupArt,1)
下一个

Hy!

Class for direct print commands:



Public Class DATECS
Const strANS As String = "______,_,__;"

Private LDN As Short ''Logical Device Number
Private strLine As String
Private BillCtr As Integer
Dim noNbDec As New System.Globalization.NumberFormatInfo
Dim niDec As New System.Globalization.NumberFormatInfo
Dim threeDec As New System.Globalization.NumberFormatInfo

Public Sub New(ByVal strPath As String, ByVal LogicalDeviceNb As Short)

On Error GoTo errHandler

FileOpen(1, strPath, OpenMode.Output)
LDN = LogicalDeviceNb
BlockKeypad()

noNbDec.NumberDecimalDigits = 0
niDec.NumberDecimalDigits = 2
threeDec.NumberDecimalDigits = 3

Exit Sub
errHandler:
Err.Raise(Err.Number, "New DATECS", Err.Description)
End Sub

Public Sub BlockKeypad()
strLine = "H," & CStr(LDN) & ",______,_,__;"
PrintLine(1, strLine)
End Sub

Public Sub UnBlockKeypad()
strLine = "F," & CStr(LDN) & ",______,_,__;"
PrintLine(1, strLine)
End Sub

Public Sub AddProduct(ByVal productName As String, ByVal Qtyvar As Decimal, ByVal SalesValue As Decimal, ByVal SAIDvar As Integer, ByVal CatIDvar As Integer, ByVal VATGroup As Short)

strLine = "S," & CStr(LDN) & "," & strANS & Trim(Mid(productName, 1, 22)) & ";" & SalesValue.ToString("f", niDec) & ";" & Qtyvar.ToString("f", noNbDec) & ";" & CStr(SAIDvar) & ";" & CStr(CatIDvar) & ";" & CStr(VATGroup) & ";" & "0;0;"
PrintLine(1, strLine)

End Sub

Public Sub CashInOut(ByVal dSum As Decimal, Optional ByVal bWithdraw As Boolean = False)
Dim iCode As Integer = 1
''0 - cash IN
''1- cash OUT

On Error GoTo errHandler

If bWithdraw Then
iCode = 1 ''cash out
Else
iCode = 0 ''cash in
End If

strLine = "I," & CStr(LDN) & "," & strANS & iCode & ";" & dSum.ToString("f", niDec) & ";;;;"
PrintLine(1, strLine)

Exit Sub
errHandler:
MsgBox("Error nb: " & Err.Number & ", " & "Error desc.: " & Err.Description & ", Error src.: " & " WithdrawInput")
End Sub

Public Sub DiscountIncrease(ByVal dProcent As Decimal, Optional ByVal iCode As Integer = 1)
''0 -Increase
''1- Discount

strLine = "C," & CStr(LDN) & "," & strANS & iCode & ";" & dProcent.ToString("f", niDec) & ";;;;"
MsgBox(strLine)
PrintLine(1, strLine)

End Sub

Public Sub AddTextLine(ByVal T1 As String, Optional ByRef T2 As String = "", Optional ByRef T3 As String = "", Optional ByRef T4 As String = "", Optional ByRef T5 As String = "")

strLine = "P," & CStr(LDN) & "," & strANS & T1 & ";"
If Not IsDBNull(T2) Then strLine = strLine & T2 & ";"
If Not IsDBNull(T3) Then strLine = strLine & T3 & ";"
If Not IsDBNull(T4) Then strLine = strLine & T4 & ";"
If Not IsDBNull(T5) Then strLine = strLine & T5 & ";"

PrintLine(1, strLine)

End Sub

Public Sub Subtotal()

PrintLine(1, "T," & CStr(LDN) & "," & strANS & "4;;;;;")
''0 - cash
''1-ceck
''2-card
''3-ticket
''4 -subtotal

End Sub

Public Sub AddPayment(ByVal pmtType As Short)
PrintLine(1, "T," & CStr(LDN) & "," & strANS & CStr(pmtType) & ";;;;;")
End Sub

End Class

This is how you use this class:

Public Function DATECSFiscal() As String
Dim sHeader As String
Dim myBill As New DATECS
Dim c() As String
Dim SA As String = ""
Dim sSeparator As New StringBuilder()
Dim dQty As Decimal
Dim dPrice As Decimal
Dim dNetAmount As Decimal
Dim dInitialAmount As Decimal
Dim dSubTotal As Decimal
Dim iDepID As Integer = 1
Dim iGroupArt As Integer = 1
Dim dDiscount As Decimal

On Error GoTo errHandler

LDN = 1
BillCtr = CInt(dtData.Rows(0).Item(12))

myBill = New DATECS(BillINPPath, LDN, BillCtr)
SA = dtData.Rows(0).Item(10).ToString
myBill.AddTextLine(SA & " " & dtData.Rows(0).Item(11).ToString)
myBill.AddTextLine("Product Qty SubTotal")

sSeparator = New StringBuilder
sSeparator.Append("-", pLineSize)

myBill.AddTextLine(sSeparator.ToString)

dNetAmount = CDec(dtData.Rows(0).Item(15))
dInitialAmount = CDec(dtData.Rows(0).Item(13))
dDiscount = CDec(dtData.Rows(0).Item(14))

Dim drt As System.Data.DataRow
For Each drt In dtData.Rows

dQty = CDec(drt.Item(1).ToString())
dPrice = CDec(drt.Item(3).ToString)
dSubTotal = CDec(drt.Item(4).ToString)

iDepID = (CDec(drt.Item(17)) Mod maxDepNb) + 1
iGroupArt = (CDec(drt.Item(18)) Mod maxArtNb) + 1

myBill.AddProduct(Mid(Trim(drt.Item(2).ToString), 1, productLength), dQty, dPrice, iDepID, iGroupArt, 1)
Next

myBill.Subtotal()
     
       If dDiscount > 0 Then
           DiscountRate = (dDiscount / dInitialAmount) * 100           
           myBill.DiscountIncrease(DiscountRate)
       End If

       Select Case PmtModality
           Case Is = 2 'Cash
               myBill.AddPayment(0)
           Case Is = 3 'Credit Card
               myBill.AddPayment(2)
       End Select



myBill.CloseFiscalBill()
myBill =没什么

昏暗的pResult作为字符串
pResult = RunPrinterProcess(AppDriverPath,端口&"9600"& BillINPPath&" \ Bill& CStr(BillCtr)&" .INP")

关于错误继续下一个

FileClose(1)

最终功能

私有函数RunPrinterProcess(ByVal sFileName作为字符串,ByVal sArguments作为字符串)作为String

试试

RunPrinterProcess =确定"

Dim oPro作为新工艺
使用oPro
.StartInfo.UseShellExecute = True
.StartInfo.Arguments = sArguments""COM1 9600"& InpFilePath
.StartInfo.FileName = sFileName''''"C:\ Program Files \ Datecs应用程序\ FPrintWIN \ FPrint.exe"
.Start()
结尾为

异常捕获
RunPrinterProcess =错误nb:"&错误编号和",& 错误描述:"&错误说明和",错误代码:& "RunPrinterProcess"和"FileName:"& sFileName& ",参数:& sArguments

FileClose(1)
结束尝试

最终功能

首先,您必须在软件所在的PC上安装FPrint.exe,并且打印机必须连接到此PC.
在上面的代码中,我创建一个文件"C:\ Bill1.inp",然后创建并启动该过程:

"C:\ Program Files \ Datecs应用程序\ FPrint WIN \ FPrint.exe" COM1 9600"C:\ Bill1.inp"

您的文件如下所示:

H,1,______,_,__; 1,0;
P,1,______,_,__;沙龙Sa1 ;;;;;
P,1,______,_,__;产品数量小计;;;;;
P,1,______,_,__; ---------------------- ;;;;;
S,1,______,_,__;米雷10gr; 1.00; 1; 2; 1; 1; 0; 0;
T,1,______,_,__,4 ;;;;;


我的打印机是Datecs MP55B ...但是如果您使用的是其他类型...唯一会改变的是命令(但是您可以在打印机的文档中找到此命令)

还有另一个inp文件示例(另一种打印机型号):
48,1,______,_,__; 1; 000000; 0;
49,1,______,_,__;小黄瓜; 0.05; 1.000; 5; 0; 0; 0;
49,1,______,_,__;小黄瓜; -0.05; 1.000; 5; 0; 0; 0;
49,1,______,_,__;土豆; 0.02; 1.000; 2; 0; 0; 0;
49,1,______,_,__;土豆; -0.02; 1.000; 2; 0; 0; 0;
T,1,______,_,__;

要进行测试,必须在收银机中进入编程模式.
对于Datecs MB55B,我必须输入收银机:

开启
429个
(或类似的内容...但是您也可以在收银机文档中找到它)

经过测试后,您必须回到销售模式.

CashInOut和DiscountIncrease无法正常工作...但是..我不知道为什么,因为这是正税,我仍在测试..


如果必须在C:
中包含此代码
http://www.developerfusion.com/tools/convert/vb-to-csharp/ [^ ]

祝你有美好的一天!
Alina



myBill.CloseFiscalBill()
myBill = Nothing

Dim pResult As String
pResult = RunPrinterProcess(AppDriverPath, Port & " 9600 """ & BillINPPath & "\Bill" & CStr(BillCtr) & ".INP""")

On Error Resume Next

FileClose(1)

End Function

Private Function RunPrinterProcess(ByVal sFileName As String, ByVal sArguments As String) As String

Try

RunPrinterProcess = "OK"

Dim oPro As New Process
With oPro
.StartInfo.UseShellExecute = True
.StartInfo.Arguments = sArguments ''"COM1 9600 " & InpFilePath
.StartInfo.FileName = sFileName '''' "C:\Program Files\Datecs Applications\FPrintWIN\FPrint.exe"
.Start()
End With

Catch ex As Exception
RunPrinterProcess = "Error nb: " & Err.Number & ", " & "Error desc.: " & Err.Description & ", Error src.: " & " RunPrinterProcess " & " FileName: " & sFileName & " , Arguments: " & sArguments

FileClose(1)
End Try

End Function

First you must have FPrint.exe installed on the pc where the software is, and the printer must be connected to this pc.
In the code above I create a file "C:\Bill1.inp" and then I create and start the process :

"C:\Program Files\Datecs Applications\FPrint WIN\FPrint.exe" COM1 9600"C:\Bill1.inp"

Your file looks like this:

H,1,______,_,__;1,0;
P,1,______,_,__;Salon Sa1;;;;;
P,1,______,_,__;Product Qty SubTotal;;;;;
P,1,______,_,__;----------------------;;;;;
S,1,______,_,__;Miere 10gr;1.00;1;2;1;1;0;0;
T,1,______,_,__,4;;;;;


My printer is Datecs MP55B ...but if you have another type ...the only thing that will change will be the commands (but you will find this in documentation of your printer)

There is another example of inp file (another printer model):
48,1,______,_,__;1;000000;0;
49,1,______,_,__;Gherkins;0.05;1.000;5;0;0;0;
49,1,______,_,__;Gherkins;-0.05;1.000;5;0;0;0;
49,1,______,_,__;Potatoes;0.02;1.000;2;0;0;0;
49,1,______,_,__;Potatoes;-0.02;1.000;2;0;0;0;
T,1,______,_,__;

For testing, you have to enter in programming mode in cash register.
For Datecs MB55B I had to enter to cash register this:

ON
429 TOTAL
(or something like this...but you will find this in your cash register documentation also)

After testing you have to go back to sale mode.

The CashInOut and DiscountIncrease are not working...yet..I don''t know why , because this is the sintax, I''m still testing..


If you must have this code in C:

http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]

Have a nice day!
Alina


嗨!
不客气!
我真的也很难解决这个问题..
我弄清楚了为什么折扣不起作用.
因此,Discount函数的工作方式如下(我已经对其进行了测试):

''添加产品
''S,1,______,_,__; ProductName; 18.00; 1; 1; 4; 1; 0; 0;
''小计
''T,1,______,_,__,4 ;;;;;
''折扣
''C,1,______,_,__,1; 50.00 ;;;;
总计"用于现金支付
''T,1,______,_,__,0 ;;;;

Hi!
We''re welcome!
I really had a hard time to work this out also..
I figured out why discount wasn''t working.
So the Discount function works like this (I''ve tested it):

''adding products
''S,1,______,_,__;ProductName;18.00;1;1;4;1;0;0;
''subtotal
''T,1,______,_,__,4;;;;;
''Discount
''C,1,______,_,__,1;50.00;;;;
''Total ''for cash payment
''T,1,______,_,__,0;;;;;

myBill.AddProduct(Mid(Trim(drt.Item(2).ToString), 1, productLength), dQty, dPrice, iDepID, iGroupArt, 1)
   
    myBill.Subtotal()
    If dDiscount > 0 Then
        DiscountRate = (dDiscount / dInitialAmount) * 100
        myBill.DiscountIncrease(DiscountRate)
    End If

    Select Case PmtModality
        Case Is = 2 'Cash
            myBill.AddPayment(0)
        Case Is = 3 'Credit Card
            myBill.AddPayment(2)
    End Select




现金入库,现金出库仍然无法使用...如果您找到溶蛋白,请分享;)

我也修改了我以前的帖子,添加了折扣,并修改了CashINCashOUT函数,因为我修改了参数(0值(现金输入)或1(现金输出)).在我的第一个代码中,参数被弄乱了(1 -cash in,0-cash out);)
Alina




The CASH IN , CASH OUT still doesn''t work... If you''ll find a solutin, please share it ;)

I modified my previous post also , I added the discount and I modified the CashINCashOUT function because I modified the parameters (0 value (cash in) or 1 (cash out)) . In my first code the parameters were messed up ( 1 -cash in , 0-cash out) ;)
Alina


这篇关于Datecs打印机驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆