public void ProcessCommand(Command command) { switch (command.command.ToLower()) { case "start": RecievesValues = true; Intervall = Double.Parse(command.parameter["intervall"], CultureInfo.InvariantCulture); LastSend = DateTime.Now.AddDays(-1); break; case "stop": RecievesValues = false; break; } }
public void SendValue(DeviceValue value) { if (RecievesValues && LastSend.AddSeconds(Intervall) <= DateTime.Now) { Command command = new Command(); command.command = "update"; command.parameter = new Dictionary<string, string>() { {"value", value.value}, {"unit", value.unit}, {"polarity", value.flow}, {"timestamp", (value.timestamp.Ticks / TimeSpan.TicksPerMillisecond).ToString(CultureInfo.InvariantCulture)} }; Session.Send(JsonConvert.SerializeObject(command)); LastSend = DateTime.Now; } }