private byte[] changeSourBt(byte[] sourBts, int index) { byte[] dataBts = new byte[16]; if (sourBts.Length < 16) { return(dataBts); } dataBts[0] = 0xfe; dataBts[1] = 0x04; dataBts[2] = sourBts[2]; dataBts[3] = sourBts[3]; dataBts[4] = sourBts[8]; dataBts[5] = sourBts[9]; dataBts[6] = sourBts[10]; dataBts[13] = (byte)(index % 0x100); if (sourBts.Length > 25) { Array.Copy(sourBts, 18, dataBts, 7, 7);//拷贝18到24的值到index中 dataBts[13] = sourBts[17]; dataBts[1] = sourBts[25]; } dataBts[14] = XWUtils.getCheckBit(dataBts); dataBts[15] = 0xfd; return(dataBts); }
private void button3_Click_1(object sender, EventArgs e) //打開串口 { label24.Visible = true; int ban = XWUtils.stringToInt1(comboBox3.Text); openCloseComm(comboBox1.Text, ban); }
private void createSocketclient() { if (socketclient != null && isOpenTCPClien) { return; } else if (socketclient != null && !isOpenTCPClien) { socketclient.Close(); } //socketclient.Close(); //socketclient = null; //isOpenTCPClien = false; string locaIp = FileModel.getFlModel().ChFlBean.ServerIP_TCP; if (locaIp == null) { locaIp = XWUtils.GetAddressIP(); } int poet = FileModel.getFlModel().ChFlBean.ServerPort_TCP; poet = poet == 0 ? 51234 : poet; string retuMsg = open(poet, locaIp); }
private void startSendListData(List <byte[]> sourBts, int index, int endIndex, string cardID) { if (endIndex < index || sourBts == null) { return; } long timeOut = long.MaxValue; byte[] zeroBt = new byte[2] { 0, 0 }; List <CardUpDataBean> cardBeans = new List <CardUpDataBean>(); for (int i = index; i <= endIndex; i++) { if (sourBts[i].Length < 16) { continue; } string sourCardID = sourBts[i][2].ToString("X2") + sourBts[i][3].ToString("X2"); if (!sourCardID.Equals(cardID) && !checkBox1.Checked) { continue; } CardUpDataBean cardBean = new CardUpDataBean(sourBts[i]); if (cardBean.FirstReceiveTime > endTime) { continue; } if (cardBean.FirstReceiveTime - timeOut > FileModel.getFlModel().ChFlBean.NoReveTime) { totalCount = 0; lostCount = 0; } if (index_card > -1) { if (index_card + 1 != cardBean.Index && index_card != 255 && cardBean.Index > index_card) { lostCount += cardBean.Index - index_card; } else if (index_card == 255 && cardBean.Index > 0) { lostCount += cardBean.Index; } } index_card = cardBean.Index; if (!XWUtils.byteBTBettow(cardBean.Port1IDHistory, zeroBt)) { totalCount += 1; } cardBean.TotalCount = totalCount; cardBean.LostCount = lostCount; cardBeans.Add(cardBean); } locaViewFrom.setHisData(cardBeans, CardUpType.HISTORY_DATA); }
public byte[] getChongZuData(byte[] cardData) { byte[] hisData = new byte[22]; Array.Copy(cardData, 0, hisData, 0, 17); Array.Copy(cardData, 18, hisData, 17, 3); hisData[20] = XWUtils.getCheckBit(hisData, 0, 21); hisData[21] = 0xfb; return(hisData); }
private void button4_Click(object sender, EventArgs e) { string beiLvTe = textBox2.Text; int bLv = XWUtils.stringToInt1(beiLvTe); if (bLv == -1) { MessageBox.Show("輸入的倍率值有誤!"); return; } BeiLv = (uint)bLv; }
/// <summary> /// 计算校验,并且发送数据 /// </summary> /// <param name="buf"></param> public void addCSAndsendData(byte[] buf) { if (buf == null || buf.Length < 2) { return; } buf[buf.Length - 2] = XWUtils.getCheckBit(buf, 0, buf.Length - 2); new Thread(sendDataModel).Start(buf); //int time = Environment.TickCount; //Console.WriteLine("sendDataModel{0},{1}", time, i_send); //i_send++; }