第二家公司Get技能总结

一,连接硬件设备

     1,网口连接

          使用IP和端口建立通信一端,使用socket连接,连接的时候,同步Connect连接超时过长的话,应该先用异步方式建立以个连接,确认连接是否可用,然后报错或者关闭后,重新建立一个同步连接  

          

                this.mClientSockets = new Dictionary<string,Socket>();
                //初始化IP终端
                this.ipEndPoint = new IPEndPoint(IPAddress.Any, serverPort);
                //初始化服务端Socket
                this.mServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                //端口绑定
                this.mServerSocket.Bind(this.ipEndPoint);
                //设置监听数目
                this.mServerSocket.Listen(maxClientCount);
                try
                {
                    report = new PosReport.PosReportBC();
                    temRetailListProdView = new PosTrade.View.RetailListProdView();
                    posTableBc = new PosTableView.PosTableBc();
                    currTrade = new CurrTradeInfo();
                    currRetailpro = new List<RetailProdInfo>();
                }
                catch (Exception ex)
                {
                }

  

     2,串口连接  

         使用System.IO.Ports.SerialPort连接串口,设置波特率等信息,进行数据发送,写入,不同型号打印机对应的打印指令基本相同

 //打印头移动到下一行
byte[] temp = new byte[] { 0x0A };
 Write(temp);

  

     3,驱动连接

        使用System.Drawing.Printing.PrintDocument进行打印,设置他相应的属性,使用printd_pos.Print();进行打印

二,   

System.Drawing.Printing.PrintDocument 

原文地址:https://www.cnblogs.com/janeaiai/p/8901015.html