private void RegistReader(ScanLine line, List <TargetModel> targets, int pageSize) { int iPageCount = 0; if (targets.Count == 0) { iPageCount = 0; } else if (targets.Count <= pageSize) { iPageCount = 1; } else if (targets.Count % pageSize == 0) { iPageCount = targets.Count / pageSize; } else { iPageCount = targets.Count / pageSize; iPageCount += 1; } int currentPage = 1; while (currentPage <= iPageCount) { var reader = new Reader(); reader.ReadHandler += Reader_ReadHandler; var data = (targets.Skip((currentPage - 1) * pageSize).Take(pageSize)).ToList(); foreach (var target in data) { DataItem item = new DataItem(); item.DataType = DataTypeHelper.GetDataType(target.DataType); item.VarType = DataTypeHelper.GetVarType(target.VarType); item.DB = target.DB; item.StartByteAdr = target.StartByteAdr; item.BitAdr = System.BitConverter.GetBytes(target.BitAdr)[0]; item.Count = target.Count; reader.Items.Add(target.Address, item); } line.RegistReader(reader); currentPage += 1; } }
private void RegistStringReader(ScanLine line, List <TargetModel> targets) { var reader = new StringReader(); reader.ReadHandler += Reader_ReadHandler; foreach (var target in targets) { DataItem item = new DataItem(); item.DataType = DataTypeHelper.GetDataType(target.DataType); item.VarType = DataTypeHelper.GetVarType(target.VarType); item.DB = target.DB; item.StartByteAdr = target.StartByteAdr; item.BitAdr = System.BitConverter.GetBytes(target.BitAdr)[0]; item.Count = target.Count; reader.Items.Add(target.Address, item); } line.RegistReader(reader); }