public DataOut createDataOut(bool breakdown, DataIn _speed) { DataOut info = new DataOut(); if (breakdown) { info.T_o = this.lastTemp; info.T_zm = 0; info.timestamp = _speed.symTime; } else { info.T_o = this.lastTemp; info.T_zm = this.calcWaterTemp(); info.timestamp = _speed.symTime; } return(info); }
static async Task <int> Main(string[] args) { createServer(); string responseBody = receive(); Console.WriteLine("Odebrane dane : " + responseBody); DataOut info = new DataOut(); Function func = new Function(); DataIn _speed = new DataIn(); string strResultJson; int secondsWaiting = 0; int hours = 0; bool breakdown = false; _speed = JsonConvert.DeserializeObject <DataIn>(responseBody); Console.WriteLine("Press \"a\" to simulate breakdown"); while (true) { info = func.createDataOut(breakdown, _speed); if (hours++ > 8) { func.weatherTendencyChange(); hours = 0; } strResultJson = JsonConvert.SerializeObject(info); sendVal(strResultJson); while (secondsWaiting < 3600) { breakdown = checkBreakdown(breakdown); responseBody = receive(); _speed = JsonConvert.DeserializeObject <DataIn>(responseBody); Console.WriteLine(_speed.speed); secondsWaiting += 30 * _speed.speed; } secondsWaiting = 0; } }