public Task SetTemprature(TempratureReading reading) { if (this.tempratures.Keys.Contains(reading.DeviceId)) { this.tempratures[reading.DeviceId] = reading.Value; } else { this.tempratures.Add(reading.DeviceId, reading.Value); } //if (this.tempratures.Values.Average() > 100) //{ // Console.WriteLine("Average temprature is high {0}", this.tempratures.Values.Average()); //} return(TaskDone.Done); }
public async Task SetTemprature(double temprature) { if (this.State.LastValue < 100 && temprature > 100) { Console.WriteLine("High temprature {0}", temprature); } //// change state when needed. if (this.State.LastValue != temprature) { this.State.LastValue = temprature; await this.WriteStateAsync(); } var systemGrain = this.GrainFactory.GetGrain <ISystemGrain>(0, keyExtension: this.State.System); var reading = new TempratureReading { DeviceId = this.GetPrimaryKeyLong(), Time = DateTime.Now, Value = temprature }; await systemGrain.SetTemprature(reading); }