private IEnumerable <Message> GenerateData(DateTime time, int start, int count) { StringBuilder sb = new StringBuilder(); Random random = new Random(); for (int i = start; i < start + count; i++) { MeterItem item = MeterItem.GenerateRandomMeterItem(i, time, _meterNum, random); yield return(new Message(item.ToString())); } }
public static MeterItem GenerateRandomMeterItem(int i, DateTime time, int meterNum, Random random) { MeterItem meterItem = new MeterItem(); meterItem.MeterName = "meter_" + i; meterItem.Manufacturer = Enums.GetRandomEnum <Manufacturers>().ToString(); meterItem.ManufacturerModel = Enums.GetRandomEnum <Models>().ToString(); meterItem.Substation = meterNum / 10 == 0 ? "1950" : ((i / (meterNum / 10)) + 1950).ToString(); // 1950 to 1959 meterItem.Transformer = meterNum / 100 == 0 ? "815970" : ((i / (meterNum / 100)) + 815970).ToString(); // 815900 to 815999 meterItem.Timestamp = time; meterItem.Average_voltage = random.Next(100); meterItem.Delivered_kVARh = random.Next(100); meterItem.Delivered_kWh = random.Next(100); meterItem.Received_kWh = random.Next(100); return(meterItem); }