Utils/IoT/JsonSensor/Bosmon.cs
BlubbFish 29caf6f6f6 [BF] Fixing Senml
[NF] Senml now has a configure option to setup the guid
[NF] Zway-Bot now listen on /exit
[NF] Implment searchpath for Zway-Bot (/etc/zwaybot and %appdata%/zwaybot)
2018-05-07 16:52:24 +00:00

38 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BlubbFish.Utils.IoT.Connector;
using BlubbFish.Utils.IoT.Events;
using LitJson;
namespace BlubbFish.Utils.IoT.JsonSensor {
class Bosmon : AJsonSensor {
public Bosmon(Dictionary<String, String> settings, String name, ABackend backend) : base(settings, name, backend) {
}
public String Ric { get; private set; }
public String Message { get; private set; }
public String Func { get; private set; }
public DateTime Time { get; private set; }
protected override Boolean UpdateValue(BackendEvent e) {
try {
JsonData json = JsonMapper.ToObject(e.Message);
if(json.ContainsKey("TYPE_POCSAG")) {
if(this.settings["rics"].Split(';').ToList().Contains(json["Address"].ToString())) {
this.Ric = json["Address"].ToString();
this.Message = json["Msg"].ToString();
this.Func = json["Func"].ToString();
this.Time = new DateTime(Int64.Parse(json["Timestamp"].ToString()));
return true;
}
}
} catch(Exception) { }
//throw new NotImplementedException();
return false;
}
}
}