???????a?iSmart?????????? ??????????????????????????????????????AutoInit_XXXX.ba_??????????AutoInit_XXX.bat??????? ??????????????????????????????? -------????????????---------------------------- ?????? pos_ad_dll.dll------------????????????? PrintOnce.exe-------------USB????????????MT??????? printer_driver.dll--------USB????????????????MT??????? LPTPrintOnce.exe----------????????????MT??????? lptprinter_driver.dll-----?????????????????MT??????? IDNET_Service.exe---------?????????????????MT??????? VcoScale.dll--------------MT???????,???????W?????2.0 OpenCashBox.exe-----------?????????MT??????? ?????? ??????????????????USB??????(320*240)????????? ??????????????? ?? ??USB????????????????a? ????????????????????????????? SmartDisplay.exe----------?????????????????? RefreshScreen.exe---------???????????????? display_driver.dll----------?????????? ??????? VCO_Interface_test.exe----?????????????????????]?????? ------------------------------------------------- pos_ad_dll.dll????????????? #define HS_OK 0xF0 #define HS_ERROR 0xFF HS_OK????????????? HS_ERROR?????????????? ????? ??????????????????_stdcall???]????????????????????? ???????int OpenPrinter(void)??int OpenPrinter_stdcall(void)?? ??????????????????PowerBuilder?????????????????????? ??????????????????????PowerBuilder???????????????? ???u???_stdcall????????? //**********************??????************************* //?????????????????????????????W???????????????? int OpenPrinter(void) //??????????????????????????W???????????????? int ClosePrinterEx(void) //??????????????? int PrintText(char *str,int FontSize)---??????60mm?????? int PrintTextByPaperWidth(char *str,int FontSize,int PaperWidth)---???????30-80mm?????? ?????? str??????????20480 FontSize???????12-72???,??????????????????8?????f????????72?????9mm??? PaperWidth???????????30-80mm??? ??????? HS_OK HS_ERROR //?????????????????????????????????? int SetInvoiceParameter(int HeaderReserveRows,int DataRows) ?????? HeaderReserveRows,int DataRows HeaderReserveRows??//???????????????????(??)??(20~480)????????256 DataRows?????????????(20~2000)??????860??(??)??(??]????????????????????24?????? <---?????--->??) ??????? HS_OK HS_ERROR //??????????????? DllExport int SetUSBPrinterDirection(int Direction) ??????Direction 1?????? 0?????? ??????? HS_OK HS_ERROR //???????????????? DllExport int SetTakeupMotorDirection(int Direction) ??????Direction 1?????? 0?????? ??????? HS_OK HS_ERROR //?????????? DllExport int SetRealPrintHeaderWidth(int Width) ??????Width??54??56??72??80,???f???? ??????? HS_OK HS_ERROR //????????????????????????????? int SetHeaderReserveRows(int ReserveRows) ??????ReserveRows<=640?????f?? ????8??????? ??????? HS_OK HS_ERROR //?????????????????????? int SetDataRows(int DataRows) ??????DataRows <=860?????f?? ????8??????? ??????? HS_OK HS_ERROR //?????????8??? int SetPrintContrast(int Contrast) ??????Contrast?? 0--8 0???????8?????? ??????? HS_OK HS_ERROR //????????? int SetPrintSpeed(int Speed) ??????Speed 0??125mm/s 1??100mm/s 2??90mm/s 3??80mm/s 4??70mm/s 5??60mm/s ??????? HS_OK HS_ERROR //??????????????????????0-240 int SetPrintOffset(int Offset) ??????Offset:0-240 ???iSmart??????Offset=104??uc-more??????Offset=56??????? ??????? HS_OK HS_ERROR //???o????? int SetScaleType(int ScaleType) ??????ScaleType 1:iSmartP 2:iSmartS 3:iSmartEvo ?? UC-HTT-M 4:iSmartEvo_Label 5:???? 6:UC-HTT-V Other:?????? iSmartP DllExport int SetScaleType(int ScaleType) ??????? HS_OK HS_ERROR //???????????????g??????????????u???PrintText????? int SetDefaultPaperWidth(int DefaultPaperWidth) ??????DefaultPaperWidth????????Y30-80mm ??????? HS_OK HS_ERROR //??????????????????,Enable=1?????0????????????????? int SetTakeLabelSensor(int Enable); ??????Enable ???????? ??????? HS_OK HS_ERROR //???????????????????LabelAngle=0?????????????????180??? int PrintLabelImage(char *ImageData,int ImageDataBytes,int LabelPaperWidth,int LabelAngle) ?????? ImageData:??????????????? ImageDataBytes:???????????????????Y11520-172800????????160???????2400??,(???72mm??) LabelPaperWidth:??????,30-72mm?? LabelAngle=0:???????????????180?? ??????? HS_OK HS_ERROR //?f??????? int PrintBitmapFile(char *BmpFileName,int LabelAngle) ?????? BmpFileName???f??????(???24?f??????f?) LabelAngle=0:???????????????180?? ??????? HS_OK HS_ERROR //?????? int BeginPrint(int PrintType) ?????? PrintType 0??iSmartP/iSmartS/UC-HTT-M????PrintOnce.exe?????? 1??iSmartP/iSmartS/UC-HTT-M????InvoicePrintOnce.exe???????????????????????????????????????????????????????????????? 2??iSmartP/iSmartS/UC-HTT-M????LabelPrintOnce.exe????????Print.tmp????????? 3??UC-HTT-V????LPTPrintOnce.exe?????? 4????? 5??????????? 6?????????????W???--??W???????????\\SOFTWARE\\MT_RTBU??PrinterProgramNum??PrinterProgramVer 7????????????????????(pc_bPro) 80,81,82,83,90,91,92,93?????(?????????) ????: 80??90 ??????81??91 ?????????????????82??92 ?????????83??93 80--83 ??????? 90--93 ???????????USB????? ??????? HS_OK HS_ERROR ???????????? PrintText,PrintTextByPaperWidth????????????`???????????????BeginPrint?????? ???????????????????????????????????BeginPrint?????? PrintText,PrintTextByPaperWidth????????????????????????????????????????????????????40960?? //**********************???????************************* //??????????----??????????????????????????????????_????????????????????????????????????o????????? int read_baseinfo(char *buf) buf????????????65??? ??????? HS_OK HS_ERROR ????HS_OK,??????????????,????????? long max_range[3]; //?????? long min_range; //??????? long max_tare; //?????? long max_pre_tare; //????????? long resolution[3]; //??? char Weight_unit[4];//???????f char money_unit[4]; //??????f char system_version[20];//??????W //???? int send_zero(void) ??????? HS_OK??? 1 ????????????????????????? 2 ????????????Y 3 ????????????Y -1 ?? -2 ???????? -3 ??????????????/?????????????????? -8 ??IDNET_Service??????? -9 ??IDNET_Service?????????? //???????,??????????????? int send_tare(char *buf) ?????? buf??????????????10???? buf??????????????"0"??"0.000"???????????? 1????????????????=0???????????????????????0???????? 2?????????????????? buf??????????????????,??:???????????????????,??20??????????????"0.020"?? ??????? HS_OK???,???buf????????? 1 ????????????? 2 ??? 3 ????????????Y 4 ?????? 5 ????????? -1 IDNET_Service???????? -2 IDNET_Service?????????? -3 IDNET_Service?????????????/?????????????????? -8 ??IDNET_Service??????? -9 ??IDNET_Service?????????? ??????HS_OK???????????????????????????????????????????buf??????????????????20?????buf????????"00.0200"?? //??????????????????????????????? //????buf??????????????????????????????????????????10??? int send_pre_tare(char *buf) ?????? ???????????????????,??20??????????????"0.020"?? ????????????????????"0.000"????????????????? ??????? HS_OK???,???buf????????? 1 ????????????? 2 ??? 3 ????????????Y 4 ?????? 5 ????????? -1 IDNET_Service???????? -2 IDNET_Service?????????? -3 IDNET_Service?????????????/?????????????????? -8 ??IDNET_Service??????? -9 ??IDNET_Service?????????? //???????????????????????????????? //????buf?????????????????????????10??? int set_tare_bykey(char *buf) ??????? HS_OK???,???buf????????? 1 ????????????? 2 ??? 3 ????????????Y 5 ????????? -1 IDNET_Service???????? -2 IDNET_Service?????????? -3 IDNET_Service?????????????/?????????????????? -8 ??IDNET_Service??????? -9 ??IDNET_Service?????????? //?????? //????buf?????????????????????????10??? int clear_tare(char *buf) ??????? HS_OK???,???buf????????? 1 ????????????? 2 ??? 3 ????????????Y 5 ????????? -1 IDNET_Service???????? -2 IDNET_Service?????????? -3 IDNET_Service?????????????/?????????????????? -8 ??IDNET_Service??????? -9 ??IDNET_Service?????????? //??????? int read_standard(char *buf) buf????????????18??? ??????? HS_OK ??? -1 ??? -2 ???? HS_ERROR ?? ????HS_OK,??????????????,????????? char status; //status??bit0(????f)??????????????1??????? //status??bit1(????f)???????????f?????1???????f //status??bit2(?????f)???????????????1????????? char net_weight[7]; char FixSeparator;//????"P" char tare_weight[7]; ??????????????net_weight????????"?????? "????????-1 ??????????????net_weight????????"?????? "????????-2 ??????????????????1234g?????10g?????????????? status????5 net_weight ??????????"01.2340" FixSeparator???????:'P' tare_weight??????????"00.0100" C#??Delphi????????????j?????????????????????????????????????f?????????????????????????????&???f&??????? bit2~~bit0 ?????????? ????? ???f?? ????? 000 0 ????? ?????f ????? 001 1 ????? ?????f ??? 010 2 ????? ???f ????? 011 3 ????? ???f ??? 100 4 ????? ?????f ????? 101 5 ????? ?????f ??? 110 6 ????? ???f ????? 111 7 ????? ???f ??? ??status?????????????????????????????????????? ;????? int OpenCashDrawerEx(void) ***************************************************************** ??iSmartS???????????^??o???????????????ShowOrHideForm??ShowProduct??ShowDisplayText??ShowBalance ??????????? ?????????????????????????????????????????????SmartDispaly.exe??????????????????????1s????????? //******************????????????????************************* int ShowOrHideForm(int State) ????: State=1??????????? State=0???????????? ??????? HS_OK HS_ERROR //******************????????????****************************** //?????? int ShowProduct(char* plu_name,int unit_price,int price_type,int count,char * unit,int roundtype) ????: plu_name:???????????????30 unit_price:???????0-999999???(???f:??) price_type:0????????1??????? count:?????????????,???????0,??????1-1000 unit:???????????f,????????????????""?? roundtype:???????????0=???????1=??1?f?????2=??2?f?????3=???????? ??????? HS_OK HS_ERROR //???????? int ShowDisplayText(int x_pos,int y_pos,int font_size,char* Text) ????: x_pos:?????????????0-320??? y_pos:?????????????0-240??? font_size:???????????12-72??? Text:??????????????????200??? ??????? HS_OK HS_ERROR //?????????? int ShowBalance(int total_price,int charge,int change) ????: total_price:???,???????0-999999???(???f:??) charge:???,???????0-999999???(???f:??) change:????,???????0-999999???(???f:??) ??????? HS_OK HS_ERROR ??C#?????????? [DllImport("pos_ad_dll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern int read_standard_stdcall(byte[] str); private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; int li_ret = 0; byte[] p = new byte[32]; string s = ""; try { li_ret = read_standard_stdcall(p); /* * HS_OK ??? * -1 ??? * -2 ???? */ switch (li_ret) { case -1: { s = "???"; break; } case -2: { s = "????"; break; } case 0xF0: { s = "???-----"; //status??bit0(????f)??????????????1??????? //status??bit1(????f)???????????f?????1???????f //status??bit2(?????f)???????????????1????????? byte status = p[0]; if ((status & 0x01) == 0x01) { s = s + "???"; } else { s = s + "???"; } if ((status & 0x02) == 0x02) { s = s + "???f"; } else { s = s + "?????f"; } if ((status & 0x04) == 0x04) { s = s + "?????"; } else { s = s + "?????"; } s = s + Encoding.Default.GetString(p, 1, p.Length - 1); break; } default: { s = "???"; break; } } } catch (Exception ex) { s = "??" + ex.Message.ToString(); } listBox1.Items.Insert(0, s); timer1.Enabled = checkBox1.Checked; } private void checkBox1_CheckedChanged(object sender, EventArgs e) { timer1.Enabled = checkBox1.Checked; } ??????Delphi???????? function read_standard(str:Pchar):integer;cdecl;external 'pos_ad_dll.dll'; const HS_OK=$f0; const HS_ERROR=$ff; //???? type TGetWeight = packed record //????packed?????????? status:char; // bit0:???????f??????f?????1????????????????? // bit1:???????f???f???f?????1?????f??????????f?? // bit2:????????f?????f?????1?????????????????? weight:array[1..7]of char; fixchar :char;//fixed,it is "P" tare:array[1..7]of char; dummy:char; //0x00 end; procedure TForm1.Button1Click(Sender: TObject); var Ret :integer; weight : TGetWeight; status:integer; s: string; begin //????? ZeroMemory(@weight, SizeOf(weight)); Ret := read_standard(@weight);//???????????? if(Ret=HS_OK)then begin status := ord(weight.status); //bit0:????f?????????????1?????????????? if((status and $1)=$1)then begin s := '???'; end else begin s := '?????'; end; //bit1:????f??????f???????1?????f??????????f?? if((status and $2)=$2)then begin s := s+ '???f'; end else begin s := s+ '?????f'; end; //bit2:?????f?????????????1??????????????? if((status and $4)=$4)then begin s := s+ '????'; end else begin s := s+ '????'; end; s1 := ' '; s2 := s1; CopyMemory(@s1[2],@weight.weight,7); CopyMemory(@s2[2],@weight.tare,7); s1 := Trim(s1); s2 := Trim(s2); s := s+ Format(' ????%s,???%s',[s1,s2]); end else if(Ret=-1)then begin //????? end else if(Ret=-2)then begin //?????? end else begin //???????? end; end; ????? VB6????? Option Explicit Private Declare Function read_standard_stdcall Lib "pos_ad_dll.dll" (wt As Any) As Integer Private Declare Function read_baseinfo_stdcall Lib "pos_ad_dll.dll" (info As Any) As Integer Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Long) Public Function GetWeightInfo() As String Dim buf(32) As Byte Dim Ret As Integer Dim s As String Dim status As Integer Dim i As Integer For i = 1 To 10 Ret = read_standard_stdcall(buf(0)) If (Ret = 240) Then status = buf(0) buf(0) = &H30 s = StrConv(buf, vbUnicode) GetWeightInfo = s Exit Function Else If (Ret = -1) Then GetWeightInfo = "???" Exit Function End If If (Ret = -2) Then GetWeightInfo = "????" Exit Function End If Sleep (100) End If Next i GetWeightInfo = "Error" End Function