private List <FunNum16RequestDataBase> CovertAllCustomerRequestDataToRequestDataBase(List <FunNum16CustomerRequestData <T> > funNum16CustomerRequestDatas) { List <FunNum16RequestDataBase> funNum16RequestDataBases = new List <FunNum16RequestDataBase>(); foreach (FunNum16CustomerRequestData <T> item in funNum16CustomerRequestDatas) { FunNum16RequestDataBase requestDataBase = CovertSingleCustomerRequestDataToSingleRequestDataBase(item); funNum16RequestDataBases.Add(requestDataBase); } return(funNum16RequestDataBases); }
private FunNum16RequestDataBase CovertSingleCustomerRequestDataToSingleRequestDataBase(FunNum16CustomerRequestData <T> customerRequestData) { int byteCountOfT = GetByteCountOfT(); FunNum16RequestDataBase requestDataBase = new FunNum16RequestDataBase(); requestDataBase.DeviceAddress = customerRequestData.DeviceAddress; requestDataBase.FunctionNum = Convert.ToByte(Convert.ToInt32(customerRequestData.FunctionNum)); requestDataBase.StartingRegisterAddressHigh = (byte)(customerRequestData.StartingRegisterAddress / 256); requestDataBase.StartingRegisterAddressLow = (byte)(customerRequestData.StartingRegisterAddress % 256); List <byte> presetDataTemp = new List <byte>(); foreach (T singlePresetData in customerRequestData.PresetData) { //LH LH... byte[] bytePresetData = GenericBitConverter.GetBytes <T>(singlePresetData); if (this.DataAnalyzeMode == DataAnalyzeMode.DataHighToLow) { //HL HL for (int i = 0; i <= bytePresetData.Length / 2 && i < bytePresetData.Length; i += 2) { presetDataTemp.Add(bytePresetData[i + 1]); //先加入高位 presetDataTemp.Add(bytePresetData[i]); //后加入低位 } } else { //LH LH presetDataTemp.AddRange(bytePresetData.ToList()); } } requestDataBase.PresetData = presetDataTemp; return(requestDataBase); }