public void write(DeviceValue value) { lock (this.events) { this.events.Add(value.ToJSON()); } if (!timer.Enabled) { timer.Start(); } if (this.influx != null) { influx.writeLine(value.ToInfluxLine()); } }
private void WriteDeviceItemInputParserResult(HidSharp.Reports.Input.DeviceItemInputParser parser) { while (parser.HasChanged) { int changedIndex = parser.GetNextChangedIndex(); var dataValue = parser.GetValue(changedIndex); uint key = dataValue.Usages.FirstOrDefault(); if (!values.ContainsKey(key)) { string disp = ((Usage)key).ToString(); if (disp.StartsWith("427")) { Console.WriteLine("SKIP: " + disp); continue; } DeviceValue tmp = new DeviceValue(); tmp.item = dataValue.DataItem; tmp.name = this.name + disp; values[key] = tmp; } DeviceValue v = values[key]; v.time = GrafanaQuery.ToUnixTime(DateTime.Now); if (v.item.ElementBits == 1) { v.value = (dataValue.GetLogicalValue() > 0) ? true : false; } else { v.value = dataValue.GetLogicalValue(); } if (sockets != null) { sockets.write(v); } //Console.WriteLine(v.ToJSON()); } }