public void Execute(SCPTuple tuple) { string json = tuple.GetString(0); var node = JObject.Parse(json); var temp = node.GetValue("temp"); JToken tempVal; if (node.TryGetValue("temp", out tempVal)) //assume must be a temperature reading { Context.Logger.Info("temp:" + temp.Value <double>()); JToken createDate = node.GetValue("createDate"); JToken deviceId = node.GetValue("deviceId"); _context.Emit(Constants.DEFAULT_STREAM_ID, new List <SCPTuple>() { tuple }, new List <object> { tempVal.Value <double>(), createDate.Value <string>(), deviceId.Value <string>() }); } _context.Ack(tuple); }
/// <summary> /// The Execute() function will be called, when a new tuple is available. /// </summary> /// <param name="tuple"></param> public void Execute(SCPTuple tuple) { ctx.Ack(tuple); //Log tuple content Context.Logger.Warn(tuple.GetString(0)); }
public void Execute(SCPTuple tuple) { var sensor = tuple.GetSensor(); _ctx.Emit(Constants.DEFAULT_STREAM_ID, new List <object>() { sensor.Name, sensor.Value }); _ctx.Ack(tuple); }
public void Execute(SCPTuple tuple) { try { double tempReading = tuple.GetDouble(0); String createDate = tuple.GetString(1); String deviceId = tuple.GetString(2); if (tempReading > _maxAlertTemp) { _context.Emit(new Values( "reading above bounds", tempReading, createDate, deviceId )); Context.Logger.Info("Emitting above bounds: " + tempReading); } else if (tempReading < _minAlertTemp) { _context.Emit(new Values( "reading below bounds", tempReading, createDate, deviceId )); Context.Logger.Info("Emitting below bounds: " + tempReading); } _context.Ack(tuple); } catch (Exception ex) { Context.Logger.Error(ex.ToString()); } }