private ObjectSignals GetObjectSignals(string customer, int nrCars, int nrSignals, CancellationToken cancellationToken) { Random rand = new Random(); var signals = new ObjectSignals(); for (int c = 0; c < nrCars; c++) { var obj = new IoTObject(); obj.id = $"{customer}-{c}"; int previousTemp = 30; for (int s = 0; s < nrSignals; s++) { int change = rand.Next(11) - 5; IOTObjectMetric iotObject = new IOTObjectMetric() { IOTObjectId = s.ToString(), Value = previousTemp + change }; obj.Signals.Add(iotObject); previousTemp = iotObject.Value; } signals.Objects.Add(obj); } return(signals); }
// GET: api/IOTObject/5 public ObjectSignals Get(string customer, int nrCars, int nrSignals) { Random rand = new Random(); var signals = new ObjectSignals(); for (int c = 0; c < nrCars; c++) { var obj = new IoTObject(); obj.id = $"{customer}-{c.ToString()}"; int previousTemp = 30; for (int s = 0; s < nrSignals; s++) { int change = rand.Next(11) - 5; IOTObjectMetric iotObject = new IOTObjectMetric() { IOTObjectId = s.ToString(), Value = previousTemp + change }; obj.Signals.Add(iotObject); previousTemp = iotObject.Value; } signals.Objects.Add(obj); } Thread.Sleep(1000); return(signals); }