public static TelemetryData Random(string deviceID, string seqNo, string msg, int min, int max) { TelemetryTypes type = (TelemetryTypes)random.Next(0, 2); var rnd = random.Next(0, 101); if (rnd <= max && rnd >= min) { type = TelemetryTypes.B; } var ret = new TelemetryData() { Temperature = rnd, SeqNo = seqNo, Timestamp = DateTime.UtcNow, Type = type, DeviceId = deviceID, UID = "UID-" + Guid.NewGuid().ToString(), DCorAC = (DCAC)random.Next(0, 1), ADSLor3G = random.Next(100) >= 50 ? "ADSL" : "3G", Message = msg }; return(ret); }
public static TelemetryData Random(string deviceID, string seqNo, string msg, int min, int max) { TelemetryTypes type = (TelemetryTypes)random.Next(0, 2); var rnd = random.Next(0, 101); if (rnd <= max && rnd >= min) { type = TelemetryTypes.B; } var ret = new TelemetryData() { Temperature = rnd, SeqNo = seqNo, Timestamp = DateTime.UtcNow, Type = type, DeviceId = deviceID, UID = "UID-" + Guid.NewGuid().ToString(), DCorAC = (DCAC)random.Next(0, 1), ADSLor3G = random.Next(100) >= 50 ? "ADSL" : "3G", Pressure = random.Next(1000), Message = msg, FanSpeed = random.Next(3000) }; return ret; }
static string GenerateMessage(int seq, string message) { var msg = TelemetryData.Random(deviceId, string.Format("{0}{1}", DateTime.UtcNow.ToString("yyyymmdd"), seq.ToString("0000000")), message, min, max); return(JsonConvert.SerializeObject(msg)); }