private void readResponse(bool isNewVersion) { this.controlType = (byte)(((int)this.frame[0] - (int)this.commandOrResponse) / 2); this.identifier = this.frame[1]; this.length = BitConverter.ToUInt16(new byte[2] { this.frame[3], this.frame[2] }, 0); this.maxLength = (ushort)4; int num1 = 4; while (num1 < this.frame.Length) { byte num2 = this.frame[num1 + 2]; byte[] responseOption = new byte[(int)num2]; for (int index = 0; index < (int)num2; ++index) { responseOption[index] = this.frame[num1 + index]; } OptionClass optionClass = new OptionClass(responseOption, isNewVersion); this.optionList.Add(optionClass); this.maxLength = (ushort)((uint)this.maxLength + (uint)optionClass.MaxLength); num1 += (int)num2; } if (this.frame.Length == (int)this.length) { return; } Program.ShowMessage("response字节数组编码有误,请申请重发!", true); }
public static void AddOptionValue(int id, string value, IPAddress ipAddr, byte controlType) { OptionListClass optionListClass = (OptionListClass)null; OptionClass optionClass1 = (OptionClass)null; for (int index = 0; index < DataListManger.SendOList.Count; ++index) { if (DataListManger.SendOList[index].IpAddr == ipAddr && (int)DataListManger.SendOList[index].ControlType == (int)controlType) { optionListClass = DataListManger.SendOList[index]; using (List <OptionClass> .Enumerator enumerator = DataListManger.SendOList[index].OptionList.GetEnumerator()) { while (enumerator.MoveNext()) { OptionClass current = enumerator.Current; if ((int)current.OptionType == id) { optionClass1 = current; break; } } break; } } } if (optionListClass == null) { optionListClass = new OptionListClass(ipAddr, controlType); DataListManger.SendOList.Add(optionListClass); } if (optionClass1 == null) { DataView dataView = ProtocolData.SelectFromDT("code=" + (object)id, true); if (dataView.Count != 1) { return; } OptionClass optionClass2 = new OptionClass(dataView[0], Encoding.Default.GetBytes(value)); optionListClass.OptionList.Add(optionClass2); } else { if (!(value != "")) { return; } string s = Encoding.Default.GetString(optionClass1.OptionData) + value; optionClass1.OptionData = Encoding.Default.GetBytes(s); optionClass1.createOption(); } }
public static void AddOption(OptionClass optionClass, IPAddress ipAddr, byte controlType) { for (int index = 0; index < DataListManger.SendOList.Count; ++index) { if (DataListManger.SendOList[index].IpAddr == ipAddr && (int)DataListManger.SendOList[index].ControlType == (int)controlType) { DataListManger.SendOList[index].OptionList.Add(optionClass); return; } } DataListManger.SendOList.Add(new OptionListClass(ipAddr, controlType) { OptionList = { optionClass } }); }