/// <summary> ///格口状态改变发送 WCS->WMS /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void MouthState() { try { //查询格口号状态为 1或0的格口 DataTable tbProt = createdata.GetProtSend(); if (tbProt != null) { if (tbProt.Rows.Count > 0) { string seqId = string.Empty; List <byte> wmsSeq = new List <byte>(); foreach (DataRow row in tbProt.Rows) { wmsSeq.Clear(); //清空byte集合 byte stsPort = 0X01; //锁定 if (row["sts"].ToString() == "0") { stsPort = 0X02;///解锁 } short prot = short.Parse(row["prot"].ToString()); byte[] array = BitConverter.GetBytes(prot); //以字节数组的形式返回返回指定的 16 位有符号整数值 wmsSeq.Add(array[1]); wmsSeq.Add(array[0]); wmsSeq.Add(stsPort); bool sendSts = WmsCommon.Instance().ErrWmsSendData(0X86, 0X08, wmsSeq, ref seqId); //bool 布尔类型 if (sendSts) { createdata.UpDataWcsWms(prot.ToString()); if (stsPort == 0x01) { Log.WriteLog2(prot + "发送格口状态成功: 锁定"); } else { Log.WriteLog2(prot + "发送格口状态成功: 解锁"); } tb_message.AppendText("格口 " + prot + " 发送状态成功\r\n"); } //发送给WMS 要求WMS打印 if (stsPort == 0X01) { wmsSeq.Clear(); array = BitConverter.GetBytes(1); wmsSeq.Add(array[1]); wmsSeq.Add(array[0]); WmsCommon.Instance().ErrWmsSendData(0X85, 0X07, wmsSeq, ref seqId); } } } } } catch (Exception ex) { Log.WriteLog("发送WMS格口状态 ex" + ex.Message); } }