/// <summary> /// 获取账号字节码或者关闭连接字节码 /// </summary> /// <returns></returns> private byte[] getCountBt() { if (PeoplePowerModel.getPeoplePowerModel().Jurisdiction != PeoplePowerModel.getPeoplePowerModel().CongjiValue) { return(null); } if (PeoplePowerModel.getPeoplePowerModel().IsConnect) //关闭 { byte[] errValue = new byte[8] { 0xff, 0xfd, 0xff, 0x00, 0x00, 0xfd, 0xff, 0xfd }; return(errValue); } string count = PeoplePowerModel.getPeoplePowerModel().Count; string power = PeoplePowerModel.getPeoplePowerModel().Password; byte[] countBt = Encoding.UTF8.GetBytes(count); //Encoding.UTF8.GetString(arrRecvmsg, 0, length); byte[] powerBt = Encoding.UTF8.GetBytes(power); byte[] bufs = new byte[6 + countBt.Length + powerBt.Length]; // { 0xff, 0xfd, 0xff, 0x00, 0, 0, 0, 0xfd, 0xff, 0xfd };//发一个身份验证 bufs[0] = 0xff; bufs[1] = 0xfd; bufs[2] = 0xff; Array.Copy(countBt, 0, bufs, 3, countBt.Length); Array.Copy(powerBt, 0, bufs, 3 + countBt.Length, powerBt.Length); bufs[bufs.Length - 3] = 0xfd; bufs[bufs.Length - 2] = 0xff; bufs[bufs.Length - 1] = 0xfd; return(bufs); }
/// <summary> /// 发送同步命令 /// </summary> public void sendConjiTongBu() { if (PeoplePowerModel.getPeoplePowerModel().IsConnect) { sendDataToZhuju(getCountTongBuBt(), "255.255.255.254"); } }
private void sendDataInLED(byte[] buf, byte tp, string ipInfo) { if (PeoplePowerModel.getPeoplePowerModel().Jurisdiction == PeoplePowerModel.getPeoplePowerModel().CongjiValue) { tp = 2; } addEndAndsendData(buf, tp, "LEDSENDDATA"); }
public void setHisFileInfore() { if (PeoplePowerModel.getPeoplePowerModel().Jurisdiction == PeoplePowerModel.getPeoplePowerModel().CongjiValue) { return; } DataFileUtils dFileUtils = new DataFileUtils(); dFileUtils.serializeObject(hisFileDBeans, fileName3); }
public static PeoplePowerModel getPeoplePowerModel() { if (peopleModel == null) { lock (obje) { if (peopleModel == null) { peopleModel = new PeoplePowerModel(); } } } return(peopleModel); }
public void setHisFileData(string fileName) { if (PeoplePowerModel.getPeoplePowerModel().Jurisdiction == PeoplePowerModel.getPeoplePowerModel().CongjiValue) { return; } DataFileUtils dFileUtils = new DataFileUtils(); List <byte[]> chcheBy = new List <byte[]>(); try { foreach (CardUpDataBean cBean in oldUpCardDatas) { if (cBean == null) { continue; } chcheBy.Add(cBean.getCardUpByte(0x03)); } } catch { } dFileUtils.addDataInFile(chcheBy, fileName4 + fileName); }
/// <summary> /// 接收数据开始处 /// </summary> /// <param name="buf"></param> public void revePortsData(byte[] buf, string ipInfo) { if (buf.Length > 19 && TAG().Equals("FromMainModel") && PeoplePowerModel.getPeoplePowerModel().Jurisdiction != PeoplePowerModel.getPeoplePowerModel().CongjiValue) { if (checkPacket(buf, ipInfo)) { return; } // return; } else if (buf.Length != locationPack && (buf[0] != 0XFE || buf[buf.Length - 1] != 0xFD)) //为了将TCP数据放进来 { if (checkPacket(buf, ipInfo)) { return; } // return; } if (buf == null || buf.Length < 1) { return; } //if (index_buf == 0 && buf[0] != receVeByteHandle) return; if (buf[0] == receVeByteHandle && buf[buf.Length - 1] == receVeByteend) { if (buf[buf.Length - 2] == XWUtils.getCheckBit(buf, 0, buf.Length - 2)) { index_buf = 0; reveData(buf, ipInfo); return; } } if (index_buf == 0) { Array.Clear(bytesBuf, 0, bytesBuf.Length); //先清理,后面才好添加数据 } if (bytesBuf.Length <= buf.Length + 38) { index_buf = 0; Array.Clear(bytesBuf, 0, bytesBuf.Length); if (bytesBuf.Length < buf.Length) { return; } } else if (index_buf + buf.Length >= bytesBuf.Length) { Array.Copy(bytesBuf, index_buf - 38, bytesBuf, 0, 38); index_buf = 38; Array.Clear(bytesBuf, 38, bytesBuf.Length - 38); } Array.Copy(buf, 0, bytesBuf, index_buf, buf.Length); findPack(bytesBuf, ipInfo); index_buf += buf.Length; if (index_buf >= bytesBuf.Length) { index_buf = 0; } }