C# 如何将plu发送到条形码ACLASS&;使用c语言的罗金塔秤#

C# 如何将plu发送到条形码ACLASS&;使用c语言的罗金塔秤#,c#,scale,C#,Scale,我有许多类型的条形码秤,所以我想通过POS程序发送项目数据,但当我搜索更多内容时,我知道我应该使用这个PBusDrv.dll,并在尝试了我知道的所有事情后遵循下面的文档,我得到的PBusTransferPLUCluster函数不起作用,给我{参数不正确。(HRESULT的异常:0x80070057(E_INVALIDARG))} 那么有人能帮我解决这个问题吗 这是密码 // using System; using System.Runtime.InteropServices; using

我有许多类型的条形码秤,所以我想通过POS程序发送项目数据,但当我搜索更多内容时,我知道我应该使用这个PBusDrv.dll,并在尝试了我知道的所有事情后遵循下面的文档,我得到的PBusTransferPLUCluster函数不起作用,给我{参数不正确。(HRESULT的异常:0x80070057(E_INVALIDARG))} 那么有人能帮我解决这个问题吗

这是密码

   //
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        private TPlu ONEPLU;


        [DllImport("PBusDrv.dll", CharSet = CharSet.Ansi)]

        private static extern int PBusConnect(string RefLFZKFileName, string RefCFGFileName, string SerialNO, string CommName, int BaudRate);
        [DllImport("PBusDrv.dll", CharSet = CharSet.Ansi)]
        private static extern int PBusConnectEx(string RefLFZKFileName, string RefCFGFileName, string IPAddr);

        [DllImport("PBusDrv.dll", CharSet = CharSet.Ansi)]
        private static extern int PBusDisConnect(string SerialNO);

        [DllImport("PBusDrv.dll", CharSet = CharSet.Ansi)]
        private static extern int PBusTransferPLUCluster(ref PPLUCluster PPC);
        public struct TPLUCluster
        {
            public TPlu[] PLU;

        }
        public struct PPLUCluster
        {
            public TPLUCluster[] TPLUCluster;

        }
        public struct TPlu
        {
            //    TPlu=record           //PLU data structure
            public string Name;  //product name, 36 characters
            public int LFCode; //Lfcode,1-999999,only way to identify each kind of product 
            public int Hotkey;
            public string Code;  //product code,10 digit, used to form barcode
            public int BarCode;    //barcode type,0-99
            public int UnitPrice;    //unit price, did not have decimal mode, 0-9999999
            public int WeightUnit;    //weight unit 0-12
            public int Deptment; //department,2 number, used to form barcode 
            public double Tare;  //tare weight, it should within 15Kg after logic conversion 
            public int ShlefTime;  //shelf time,0-365
            public int PackageType;    //package type,0:normal/ limitative weight mode,1:weight fixed,2:price fixed,3:barcode printer mode
            public Double PackageWeight;    //package weight/limitative weight, it should within 15Kg after logic conversion
            public int Tolerance;  //package error tolerance,0-20
            public byte Message1;   //message 1,0-197
            public byte Reserved;   //reserved
            public string Reserved1;    //reserved
            public byte Message2;   //message 2,0-197
            public byte Reserved2;  //reserved
            public byte MultiLabel; //multi-label,0-255,8 Bit corresponding to A0-D1 respectively
            public short Rebate;  //rebate,0-99
            public int Account; //enter an item in an account, reserved
        }
        public Form1()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Int64 aa = 1;
                string IP = "192.168.1.87"; //lfzkfull.DAT
                aa = PBusDisConnect(IP);
                aa = PBusConnectEx("C:\\Users\\Royal\\source\\repos\\WindowsFormsApp1\\WindowsFormsApp1\\bin\\Debug\\lfzk.DAT", "C:\\Users\\Royal\\source\\repos\\WindowsFormsApp1\\WindowsFormsApp1\\bin\\Debug\\SYSTEM.CFG", IP);

                ONEPLU.Name = "TahaYOU";
                ONEPLU.LFCode = 2;
                ONEPLU.Code = "10001";// IP;
                ONEPLU.BarCode = 7;
                ONEPLU.UnitPrice = 60000;
                ONEPLU.WeightUnit = 4;
                ONEPLU.Deptment = 21;
                ONEPLU.Tare = 0;
                ONEPLU.ShlefTime = 15;
                ONEPLU.PackageType = 0;
                ONEPLU.PackageWeight = 0;
                ONEPLU.Tolerance = 5;
                ONEPLU.Reserved = 0;
                ONEPLU.Reserved1 = "";
                ONEPLU.Message1 = 0;
                ONEPLU.Message2 = 0;
                ONEPLU.MultiLabel = 0;
                ONEPLU.Rebate = 0;
                ONEPLU.Account = 0;
                ONEPLU.Hotkey = 2;



                TPLUCluster TPLUCluster = new TPLUCluster();
                TPLUCluster.PLU = new TPlu[4];
                TPLUCluster.PLU[0] = ONEPLU;
                ONEPLU.Hotkey = 3;
                ONEPLU.LFCode = 3;
                TPLUCluster.PLU[1] = ONEPLU;
                ONEPLU.Hotkey = 4;
                ONEPLU.LFCode = 4;
                TPLUCluster.PLU[2] = ONEPLU;
                ONEPLU.Hotkey = 5;
                ONEPLU.LFCode = 5;
                TPLUCluster.PLU[3] = ONEPLU;

                TPLUCluster[] TPLUClusterA = new TPLUCluster[1];
                TPLUClusterA = new TPLUCluster[1];
                TPLUClusterA[0] = TPLUCluster;


                PPLUCluster ppc = new PPLUCluster();
                ppc.TPLUCluster = TPLUClusterA;
                aa = PBusTransferPLUCluster(ref ppc);
                aa = PBusDisConnect(IP);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
这是文档

PBusDrv.DLL use explanation 

PBusDrv.DLL is a 32 digit dynamic link libraries, mostly is used to download PLU data to Pinncale label scale. 
Main Data structure and function: (Delphi syntax. For other languages, please refer to use):

1.Data structure
TPlu=record         //PLU data structure
     Name:         PChar;   //product name, 36 characters
     LFCode:       Longint; //Lfcode,1-999999,only way to identify each kind of product 
     Code:         PChar;   //product code,10 digit, used to form barcode
     BarCode:      Longint; //barcode type,0-99
     UnitPrice:    Longint; //unit price, did not have decimal mode, 0-9999999
     WeightUnit:   Longint; //weight unit 0-12
     Deptment:     Longint; //department,2 number, used to form barcode 
     Tare:         Double;  //tare weight, it should within 15Kg after logic conversion 
     ShlefTime:    Longint; //shelf time,0-365
     PackageType:  Longint; //package type,0:normal/ limitative weight mode,1:weight fixed,
                             //2:price fixed,3:barcode printer mode
     PackageWeight:Double;  //package weight/limitative weight, it should within 15Kg after logic conversion
     Tolerance:    Longint; //package error tolerance,0-20
     Message1:     Byte;    //message 1,0-197
     Reserved:     Byte;    //reserved
     Reserved1:    Word;    //reserved
     Message2:     Byte;    //message 2,0-197
     Reserved2:    Byte;    //reserved
     MultiLabel:   Byte;    //multi-label,0-255,8 Bit corresponding to A0-D1 respectively
     Rebate:       ShortInt;    //rebate,0-99
     Account:      LongInt; //enter an item in an account, reserved
   end;
   PPLU=^TPLU;
   TPLUCluster=Array[0..3]of TPLU;  //one PLU cluster including 4 pcs PLU
   PPLUCluster=^TPLUCluster;
   THotkeyTable=Array[0..83]of LongInt; //each array element is a PLU lfcode,
                        //84 pcs element corresponding to 84 pcs PLU
   PHotkeyTable=^THotkeyTable;

   For detailed explanation, please refer to user manual’s program interface part.

2.Function(suppose label scale sw (LBMNC) is installed under XX directory)
Connect function
Function PBusConnect(RefLFZKFileName:PChar;//lf font list file name,including path,
                        //usually point to XX\bin\lfzk.dat
                                            //if used character set,point to XX\bin\lfzkfull.dat
RefCFGFileName:PChar;   //configuration file name, including path, usually point to //XX\bin\system.cfg
SerialNO:DWord;     //label scale serial number, if is Ethernet, please transfer IP address as
//DWord,such as 192.168.0.1 transfer to $C0A80001
                     CommName:PChar;        //equipment name, such as:COM1,COM2,if is Ethernet, it is:IP
                     BaudRate:Integer   //communication speed, set as 0
                     ):Integer;far; external 'PbusDrv.dll';

Function PBusConnectEx(RefLFZKFileName:PChar;// lf font list file name, including path,
                        //usually point to XX\bin\lfzk.dat
                                            //if use character set,point to XX\bin\lfzkfull.dat
RefCFGFileName:PChar;   //configuration file name, including path, usually point to //XX\bin\system.cfg
                     IPAddr: PChar;     //label scale IP address, such as:192.168.0.1
                     ):Integer;far; external 'PbusDrv.dll';

Disconnect function
Function PBusDisConnect(SerialNO: DWord //label scale serial no.
                        ):Integer;far; external 'PbusDrv.dll';

Function PBusDisConnectEx(IPAddr: PChar;    //label scale IP address,such as:192.168.0.1
                        ):Integer;far; external 'PbusDrv.dll';

send PLU function
Function PBusTransferPLUCluster(PPC:PPLUCluster //PLU cluster
                                ):Integer;far; external 'PbusDrv.dll';

send Hotkey function
Function PBusTransferHotkey(HotkeyTable:PHotkeyTable; //hotkey list
                            TableIndex:Integer  //hotkey list no., total two list,0 and 1
                            ):Integer;far; external 'PbusDrv.dll';

send message function
Function PBusTransferMessage(Id:Integer; //info code,1~197
                               PMessage:PChar; //information text
                               DataLen:Integer //information text length
                               ):Integer;far; external 'PBusDrv.DLL';

transform PLU to character string
Function PBusPLUToStr(LPPLU:PPLU;       //PLU data
              LPStr:PChar       //character string(one line of TXP file), this finger must distribute space.
              ):Integer;Stdcall;far; external 'PbusDrv.dll';

transform character string to PLU
Function PBusStrToPLU(LPStr:PChar;      //character string(one line to TXP file)
              LPPLU:PPLU        //PLU data
              ):Integer;Stdcall;far; external 'PbusDrv.dll';
clear all PLU
Function PBusClearPLUData:Integer;Stdcall;far; external 'PBusDrv.dll';

3.Flow
(1) PBusConnect if returned value<0, jump out
        |
(2) PBusTransferPLUCluster/PBusTransferHotkey   if returned value<0, jump to (4)
        |
(3) PBusTransferPLUCluster/PBusTransferHotkey   if returned value<0, jump to (4)
        |
        .   if returned value<0, jump to (4)    
        .
        .
(4)     PBusDisConnect

4.Examples
  Example under Delphi60 catalog is writen with Delphi, could pass test under Delphi6.0.  Example under VB60 catalog is written with Visual Basic, could pass test under VB6.0.
  Example under VC60 catalog is written with Visual C++, could pass test under VC6.0.
  Example under PB65 catalog is written with PowerBuilder, could pass test under PB6.5.

Remarks:
1.Explanation of lf font bank and system parameter
PbusConnect connect function cites two file: lfzk.dat and system.cfg, lfzk.dat is lf font bank character list,store some system setting in system.cfg . We intensively suggest to cite corresponding file under link32 install catalog,to make sure that when Link32 sw modifying system parameter, it could reflect to dynamic link libraries in time。For example:There is a option “lf common font bank usage character set” of link32 system option,after modification of it, this parameter setting will be stored in system.cfg,if PbusConnect connect function cites system.cfg of link32 setting catalog ,the dynamic link libraries will download using new configure, or it will confuse the font bank. Of course, you could place these two file on other places, but must make sure update these two file in time and in-phase.
2.Setting of data align mode of delphi 6 and Delphi 7.
Set delphi6 and delphi7 as below,
Project->Options->Code generation->Record field alignment select 4
If do not want to change default setting (default value is 8) of Delphi data align mode or use Delphi5,could use PBusDrv.DLL of other catalog.
PBusDrv.DLL使用说明
PBusDrv.DLL是一个32位的动态链接库,主要用于将PLU数据下载到Pinncale label scale。
主要数据结构和功能:(Delphi语法,其他语言请参考使用):
1.数据结构
TPlu=记录//PLU数据结构
名称:PChar;//产品名称,36个字符
LFCode:Longint;//LFCode,1-999999,识别每种产品的唯一方法
代码:PChar;//产品代码,10位,用于形成条形码
条码:Longint;//条码类型,0-99
单价:Longint;//单价,没有十进制模式,0-9999999
权重单位:Longint;//权重单位0-12
部门:Longint;//部门,2号,用于形成条形码
皮重:加倍;//皮重,逻辑转换后在15Kg以内
ShlefTime:Longint;//保存时间,0-365
PackageType:Longint;//包类型,0:正常/限制重量模式,1:重量固定,
//2:价格固定,3:条形码打印机模式
包装重量:双倍;//包装重量/限制重量,逻辑转换后应在15Kg以内
容差:Longint;//包错误容差,0-20
Message1:Byte;//消息1,0-197
保留:字节;//保留
Reserved1:Word;//保留
Message2:Byte;//消息2,0-197
Reserved2:Byte;//保留
多标签:字节;//多标签,0-255,8位分别对应于A0-D1
返利:ShortInt;//返利,0-99
帐户:LongInt;//在帐户中输入项目,保留
结束;
PPLU=^TPLU;
TPLUCluster=TPLU的数组[0..3];//一个PLU集群,包括4个pcs PLU
PPLUCluster=^TPLUCluster;
THotkeyTable=LongInt的数组[0..83];//每个数组元素都是一个PLU lfcode,
//84个元件对应84个PLU
PHotkeyTable=^THotkeyTable;
详细说明请参见用户手册的程序接口部分。
2.功能(假设标签秤sw(LBMNC)安装在XX目录下)
连接函数
函数PBusConnect(RefLFZKFileName:PChar;//lf字体列表文件名,包括路径,
//通常指向XX\bin\lfzk.dat
//如果使用字符集,请指向XX\bin\lfzkfull.dat
RefCFGFileName:PChar;//配置文件名,包括路径,通常指向//XX\bin\system.cfg
SerialNO:DWord;//标签刻度序列号,如果是以太网,请将IP地址传输为
//DWord,例如192.168.0.1转换为$C0A80001
CommName:PChar;//设备名称,如:COM1、COM2,如果是以太网,则为:IP
波特率:整数//通信速度,设置为0
):整数;far;外部“PbusDrv.dll”;
函数PBusConnectEx(RefLFZKFileName:PChar;//lf字体列表文件名,包括路径,
//通常指向XX\bin\lfzk.dat
//如果使用字符集,请指向XX\bin\lfzkfull.dat
RefCFGFileName:PChar;//配置文件名,包括路径,通常指向//XX\bin\system.cfg
IPAddr:PChar;//标签缩放IP地址,例如:192.168.0.1
):整数;far;外部“PbusDrv.dll”;
断开功能
功能PBusDisConnect(序列号:DWord//标签刻度序列号。
):整数;far;外部“PbusDrv.dll”;
函数PBusDisConnectEx(IPAddr:PChar;//标签规模IP地址,如:192.168.0.1
):整数;far;外部“PbusDrv.dll”;
发送PLU函数
函数PBusTransferPLUCluster(PPC:PPLUCluster//plucluster
):整数;far;外部“PbusDrv.dll”;
发送热键功能
函数PBusTransferHotkey(HotkeyTable:PHotkeyTable;//热键列表
TableIndex:Integer//热键列表编号,共两个列表,0和1
):整数;far;外部“PbusDrv.dll”;
发送消息功能
函数PBusTransferMessage(Id:Integer;//信息代码,1~197
PMessage:PChar;//信息文本
DataLen:Integer//信息文本长度
):整数;far;外部“PBusDrv.DLL”;
将PLU转换为字符串
函数PBusPLUToStr(LPPLU:PPLU;//PLU数据
LPStr:PChar//字符串(TXP文件的一行),此手指必须分配空间。
):整数;Stdcall;far;外部“PbusDrv.dll”;
将字符串转换为PLU
函数PBusStrToPLU(LPStr:PChar;//字符串(到TXP文件的一行)
LPPLU:PPLU//PLU数据
):整数;Stdcall;far;外部“PbusDrv.dll”;
清除所有PLU
函数PBusClearPLUData:Integer;Stdcall;far;外部“PBusDrv.dll”;
3.流动

(1)如果PBESCONT返回ValueI不理解问题,请考虑添加一些标点符号和代码标记(@)此外,看起来你可以从代码中删除无关的线条。让你的问题轻松有趣,是吸引潜在答案的关键。我的问题是错误在哪里。这个代码不起作用,它只是连接和断开连接,而不是发送DATAI,不理解这个问题。考虑添加一些标点符号和代码。标记(``)。此外,看起来您可以从您的应用程序中删除不相关的行