first commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<RootNamespace>BlubbFish.IoT.Pocsag.BosServerDatatypes</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Librarys\litjson\litjson\litjson.csproj" />
|
||||
<ProjectReference Include="..\..\Utils\ConnectorStorageJson\ConnectorStorageJson\ConnectorStorageJson.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Influx {
|
||||
public abstract class AInfluxMessage {
|
||||
public String ToInfluxString() {
|
||||
Type measurementType = this.GetType();
|
||||
PropertyInfoColumn[] cache = measurementType.GetProperties().Select(property => new PropertyInfoColumn { Column = (Column)property.GetCustomAttribute(typeof(Column)), Property = property }).Where(propertyInfo => propertyInfo.Column != null).ToArray();
|
||||
|
||||
Measurement measurementAttribute = (Measurement)measurementType.GetCustomAttribute(typeof(Measurement));
|
||||
PropertyInfoColumn measurementColumn = cache.SingleOrDefault(p => p.Column.IsMeasurement);
|
||||
|
||||
PointData point = new PointData(measurementAttribute.Name);
|
||||
foreach(PropertyInfoColumn propertyInfo in cache) {
|
||||
if(propertyInfo.Column.IsMeasurement) {
|
||||
continue;
|
||||
}
|
||||
Object value = propertyInfo.Property.GetValue(this);
|
||||
if(value == null) {
|
||||
continue;
|
||||
}
|
||||
String name = propertyInfo.Column.Name;
|
||||
if(propertyInfo.Column.IsTag && !String.IsNullOrEmpty(value.ToString())) {
|
||||
point.Tag(name, value.ToString());
|
||||
} else if(propertyInfo.Column.IsTimestamp) {
|
||||
if(value is DateTime date) {
|
||||
point.Timestamp(date);
|
||||
}
|
||||
} else {
|
||||
point.PutField(name, value);
|
||||
}
|
||||
}
|
||||
return point.ToLineProtocol();
|
||||
}
|
||||
}
|
||||
|
||||
internal class PropertyInfoColumn {
|
||||
internal PropertyInfo Property;
|
||||
internal Column Column;
|
||||
}
|
||||
|
||||
public class PointData {
|
||||
private static readonly DateTime EpochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
private readonly String _measurementName;
|
||||
private ImmutableSortedDictionary<String, String> _tags = ImmutableSortedDictionary<String, String>.Empty;
|
||||
private ImmutableSortedDictionary<String, Object> _fields = ImmutableSortedDictionary<String, Object>.Empty;
|
||||
private BigInteger _time;
|
||||
|
||||
public PointData(String measurementName) => this._measurementName = measurementName;
|
||||
|
||||
internal void PutField(String name, Object value) => this._fields = this._fields.Add(name, value);
|
||||
internal void Tag(String name, String value) => this._tags = this._tags.Add(name, value);
|
||||
|
||||
internal void Timestamp(DateTime timestamp) => this._time = timestamp.ToUniversalTime().Subtract(EpochStart).Ticks * 100;
|
||||
internal String ToLineProtocol() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
this.EscapeKey(sb, this._measurementName, false);
|
||||
this.AppendTags(sb);
|
||||
if(!this.AppendFields(sb)) {
|
||||
return "";
|
||||
}
|
||||
this.AppendTime(sb);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private void AppendTags(StringBuilder sb) {
|
||||
foreach(KeyValuePair<String, String> keyValue in this._tags) {
|
||||
_ = sb.Append(',');
|
||||
this.EscapeKey(sb, keyValue.Key);
|
||||
_ = sb.Append('=');
|
||||
this.EscapeKey(sb, keyValue.Value);
|
||||
}
|
||||
|
||||
_ = sb.Append(' ');
|
||||
}
|
||||
private Boolean AppendFields(StringBuilder sb) {
|
||||
Boolean appended = false;
|
||||
|
||||
foreach(KeyValuePair<String, Object> keyValue in this._fields) {
|
||||
String key = keyValue.Key;
|
||||
Object value = keyValue.Value;
|
||||
|
||||
if(this.IsNotDefined(value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.EscapeKey(sb, key);
|
||||
_ = sb.Append('=');
|
||||
|
||||
if(value is Double || value is Single) {
|
||||
_ = sb.Append(((IConvertible)value).ToString(CultureInfo.InvariantCulture));
|
||||
} else if(value is UInt32 || value is UInt64 || value is UInt16) {
|
||||
_ = sb.Append(((IConvertible)value).ToString(CultureInfo.InvariantCulture));
|
||||
_ = sb.Append('u');
|
||||
} else if(value is Byte || value is Int32 || value is Int64 || value is SByte || value is Int16) {
|
||||
_ = sb.Append(((IConvertible)value).ToString(CultureInfo.InvariantCulture));
|
||||
_ = sb.Append('i');
|
||||
} else if(value is Boolean b) {
|
||||
_ = sb.Append(b ? "true" : "false");
|
||||
} else if(value is String s) {
|
||||
_ = sb.Append('"');
|
||||
this.EscapeValue(sb, s);
|
||||
_ = sb.Append('"');
|
||||
} else if(value is IConvertible c) {
|
||||
_ = sb.Append(c.ToString(CultureInfo.InvariantCulture));
|
||||
} else {
|
||||
_ = sb.Append('"');
|
||||
this.EscapeValue(sb, value.ToString());
|
||||
_ = sb.Append('"');
|
||||
}
|
||||
|
||||
_ = sb.Append(',');
|
||||
appended = true;
|
||||
}
|
||||
|
||||
if(appended) {
|
||||
_ = sb.Remove(sb.Length - 1, 1);
|
||||
}
|
||||
|
||||
return appended;
|
||||
}
|
||||
private void AppendTime(StringBuilder sb) {
|
||||
_ = sb.Append(' ');
|
||||
_ = sb.Append(this._time.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
private void EscapeKey(StringBuilder sb, String key, Boolean escapeEqual = true) {
|
||||
foreach(Char c in key) {
|
||||
switch(c) {
|
||||
case '\n':
|
||||
_ = sb.Append("\\n");
|
||||
continue;
|
||||
case '\r':
|
||||
_ = sb.Append("\\r");
|
||||
continue;
|
||||
case '\t':
|
||||
_ = sb.Append("\\t");
|
||||
continue;
|
||||
case ' ':
|
||||
case ',':
|
||||
_ = sb.Append("\\");
|
||||
break;
|
||||
case '=':
|
||||
if(escapeEqual) {
|
||||
_ = sb.Append("\\");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
_ = sb.Append(c);
|
||||
}
|
||||
}
|
||||
private void EscapeValue(StringBuilder sb, String value) {
|
||||
foreach(Char c in value) {
|
||||
switch(c) {
|
||||
case '\\':
|
||||
case '\"':
|
||||
_ = sb.Append("\\");
|
||||
break;
|
||||
}
|
||||
|
||||
_ = sb.Append(c);
|
||||
}
|
||||
}
|
||||
private Boolean IsNotDefined(Object value) => value == null
|
||||
|| value is Double d && (Double.IsInfinity(d) || Double.IsNaN(d))
|
||||
|| value is Single f && (Single.IsInfinity(f) || Single.IsNaN(f));
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public sealed class Measurement : Attribute {
|
||||
public String Name {
|
||||
get;
|
||||
}
|
||||
|
||||
public Measurement(String name) => this.Name = name;
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public sealed class Column : Attribute {
|
||||
public String Name {
|
||||
get;
|
||||
}
|
||||
|
||||
public Boolean IsMeasurement {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Boolean IsTag {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Boolean IsTimestamp {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Column() {
|
||||
}
|
||||
|
||||
public Column(String name) => this.Name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
|
||||
using BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Influx {
|
||||
[Measurement("bosmon")]
|
||||
public class Bosmon : AInfluxMessage {
|
||||
|
||||
[Column("address", IsTag = true)]
|
||||
public UInt64 Address {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("function", IsTag = true)]
|
||||
public String Function {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("sendonline", IsTag = true)]
|
||||
public Boolean SendOnline {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("isprivate", IsTag = true)]
|
||||
public Boolean Isprivate {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("withgeo", IsTag = true)]
|
||||
public Boolean Withgeo {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("art")]
|
||||
public String Art {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("name")]
|
||||
public String Name {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("text")]
|
||||
public String Text {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column(IsTimestamp = true)]
|
||||
public DateTime Time {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("latitude")]
|
||||
public Double Lat {
|
||||
get;
|
||||
}
|
||||
|
||||
[Column("longitude")]
|
||||
public Double Lon {
|
||||
get;
|
||||
}
|
||||
|
||||
public Bosmon(PocsagParsed p, Boolean parseTime = false) {
|
||||
if(UInt64.TryParse(p.Raw.Address, out UInt64 adress)) {
|
||||
this.Address = adress;
|
||||
}
|
||||
this.Function = p.Raw.Function;
|
||||
this.SendOnline = p.Sendonline;
|
||||
this.Isprivate = p.Isprivate;
|
||||
this.Art = p.Funktion;
|
||||
this.Name = p.Name;
|
||||
this.Text = p.Raw.Message;
|
||||
this.Time = parseTime ? p.Date : DateTime.Now;
|
||||
if(p.Geo != null) {
|
||||
this.Lat = p.Geo.Latitude;
|
||||
this.Lon = p.Geo.Longitude;
|
||||
this.Withgeo = true;
|
||||
} else {
|
||||
this.Lat = 0;
|
||||
this.Lon = 0;
|
||||
this.Withgeo = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using BlubbFish.Utils.IoT.Connector.Storage;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Json {
|
||||
public class RicData : AJsonDatatype {
|
||||
public RicData() { }
|
||||
public RicData(String location, String shortdescription, String longdescription) {
|
||||
this.Location = location;
|
||||
this.ShortDescription = shortdescription;
|
||||
this.LongDescription = longdescription;
|
||||
}
|
||||
public String Location {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public String ShortDescription {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public String LongDescription {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt {
|
||||
public abstract class AMqttMessage {
|
||||
public String Datatype {
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
public DateTime Date {
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
protected AMqttMessage(String datatype) {
|
||||
this.Datatype = datatype;
|
||||
this.Date = DateTime.Now;
|
||||
}
|
||||
|
||||
protected AMqttMessage(String datatype, JsonData json) {
|
||||
this.Datatype = datatype;
|
||||
this.Date = DateTime.Parse(json.ToString(), new System.Globalization.CultureInfo("en-US", false));
|
||||
}
|
||||
|
||||
public virtual String ToJson() => JsonMapper.ToJson(this);
|
||||
|
||||
public static Boolean CheckJson(String message, Type t) {
|
||||
try {
|
||||
return CheckJson(JsonMapper.ToObject(message), t);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean CheckJson(JsonData json, Type t) {
|
||||
try {
|
||||
foreach(PropertyInfo p_info in t.GetProperties()) {
|
||||
if(p_info.Name == "Item") {
|
||||
continue;
|
||||
}
|
||||
if(p_info.CanRead) {
|
||||
if(p_info.PropertyType == typeof(String)) {
|
||||
if(!(json.ContainsKey(p_info.Name) && json[p_info.Name] != null && json[p_info.Name].IsString)) {
|
||||
return false;
|
||||
}
|
||||
} else if(p_info.PropertyType == typeof(DateTime)) {
|
||||
if(!(json.ContainsKey(p_info.Name) && json[p_info.Name] != null && json[p_info.Name].IsString)) {
|
||||
return false;
|
||||
}
|
||||
} else if(p_info.PropertyType == typeof(Boolean)) {
|
||||
if(!(json.ContainsKey(p_info.Name) && json[p_info.Name] != null && json[p_info.Name].IsBoolean)) {
|
||||
return false;
|
||||
}
|
||||
} else if(p_info.PropertyType == typeof(Double)) {
|
||||
if(!(json.ContainsKey(p_info.Name) && json[p_info.Name] != null && (json[p_info.Name].IsInt || json[p_info.Name].IsDouble || json[p_info.Name].IsLong))) {
|
||||
return false;
|
||||
}
|
||||
} else if(p_info.PropertyType.BaseType == typeof(AMqttMessage)) {
|
||||
if(json.ContainsKey(p_info.Name) && (json[p_info.Name] == null || json[p_info.Name].IsObject)) {
|
||||
if(json[p_info.Name] != null && !CheckJson(json[p_info.Name], p_info.PropertyType)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt {
|
||||
public class AddFilter : AMqttMessage {
|
||||
public String Ric {
|
||||
get;
|
||||
}
|
||||
public String Task {
|
||||
get;
|
||||
}
|
||||
public String Sender {
|
||||
get;
|
||||
}
|
||||
|
||||
public AddFilter(String ric, String task, String sender) : base("add-filter") {
|
||||
this.Ric = ric;
|
||||
this.Task = task;
|
||||
this.Sender = sender;
|
||||
}
|
||||
|
||||
public AddFilter(JsonData json) : base("add-filter", json["Date"]) {
|
||||
this.Ric = json["Ric"].ToString();
|
||||
this.Task = json["Task"].ToString();
|
||||
this.Sender = json["Sender"].ToString();
|
||||
}
|
||||
|
||||
public static AddFilter ConvertJson(String message) => new AddFilter(JsonMapper.ToObject(message));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt {
|
||||
public class GeoData : AMqttMessage {
|
||||
public Double Latitude {
|
||||
get;
|
||||
}
|
||||
public Double Longitude {
|
||||
get;
|
||||
}
|
||||
|
||||
public GeoData(Double latitude, Double longitude) : base("geo-data") {
|
||||
this.Latitude = latitude;
|
||||
this.Longitude = longitude;
|
||||
}
|
||||
|
||||
public GeoData(LitJson.JsonData json) : base("geo-data", json["Date"]) {
|
||||
this.Latitude = Double.Parse(json["Latitude"].ToString().Replace(',', '.'), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
||||
this.Longitude = Double.Parse(json["Longitude"].ToString().Replace(',', '.'), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt {
|
||||
public class InfluxStorage : AMqttMessage {
|
||||
public String Text {
|
||||
get;
|
||||
}
|
||||
|
||||
public InfluxStorage(String text) : base("bosmon") => this.Text = text;
|
||||
|
||||
public InfluxStorage(JsonData json) : base("bosmon", json["Date"]) => this.Text = "";
|
||||
|
||||
public override String ToString() => this.Text;
|
||||
|
||||
public static InfluxStorage ConvertJson(String _) => new InfluxStorage("");
|
||||
|
||||
public override String ToJson() => this.Text;
|
||||
|
||||
public static new Boolean CheckJson(String _1, Type _2) => false;
|
||||
|
||||
public static new Boolean CheckJson(JsonData _1, Type _2) => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt {
|
||||
public class Message : AMqttMessage {
|
||||
public String Text {
|
||||
get;
|
||||
}
|
||||
|
||||
public Message(String text) : base("message") => this.Text = text;
|
||||
|
||||
public Message(JsonData json) : base("message", json["Date"]) => this.Text = json["Text"].ToString();
|
||||
|
||||
public override String ToString() => this.Text;
|
||||
|
||||
public static Message ConvertJson(String message) => new Message(JsonMapper.ToObject(message));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt {
|
||||
public class PocsagHttp : AMqttMessage {
|
||||
public String Function {
|
||||
get;
|
||||
}
|
||||
public String Flags {
|
||||
get;
|
||||
}
|
||||
public String Message {
|
||||
get;
|
||||
}
|
||||
public String Type {
|
||||
get;
|
||||
}
|
||||
public String Address {
|
||||
get;
|
||||
}
|
||||
|
||||
|
||||
public PocsagHttp(String function, String flags, String message, String type, String address) : base("pocsag-http") {
|
||||
this.Function = function;
|
||||
this.Flags = flags;
|
||||
this.Message = message;
|
||||
this.Type = type;
|
||||
this.Address = address;
|
||||
}
|
||||
|
||||
public PocsagHttp(JsonData json) : base("pocsag-http", json["Date"]) {
|
||||
this.Function = json["Function"].ToString();
|
||||
this.Flags = json["Flags"].ToString();
|
||||
this.Message = json["Message"].ToString();
|
||||
this.Type = json["Type"].ToString();
|
||||
this.Address = json["Address"].ToString();
|
||||
}
|
||||
|
||||
public PocsagHttp(String function, String flags, String message, String type, String address, Double timestamp) : base("pocsag-http") {
|
||||
this.Function = function;
|
||||
this.Flags = flags;
|
||||
this.Message = message;
|
||||
this.Type = type;
|
||||
this.Address = address;
|
||||
this.Date = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(timestamp).ToLocalTime();
|
||||
}
|
||||
|
||||
public static PocsagHttp ConvertJson(String message) => new PocsagHttp(JsonMapper.ToObject(message));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt {
|
||||
public class PocsagParsed : AMqttMessage {
|
||||
public PocsagHttp Raw {
|
||||
get;
|
||||
}
|
||||
public String Funktion {
|
||||
get;
|
||||
}
|
||||
public String Name {
|
||||
get;
|
||||
}
|
||||
public RicDescription Ric {
|
||||
get;
|
||||
}
|
||||
public GeoData Geo {
|
||||
get;
|
||||
}
|
||||
public Boolean Sendonline {
|
||||
get;
|
||||
}
|
||||
public Boolean Isprivate {
|
||||
get;
|
||||
}
|
||||
|
||||
public PocsagParsed(PocsagHttp raw, String funktion, String name, RicDescription ric, GeoData geo, Boolean sendonline, Boolean isprivate) : base("pocsag-parsed") {
|
||||
this.Raw = raw;
|
||||
this.Funktion = funktion;
|
||||
this.Name = name;
|
||||
this.Ric = ric;
|
||||
this.Geo = geo;
|
||||
this.Sendonline = sendonline;
|
||||
this.Isprivate = isprivate;
|
||||
}
|
||||
|
||||
public PocsagParsed(JsonData json) : base("pocsag-parsed", json["Date"]) {
|
||||
this.Raw = new PocsagHttp(json["Raw"]);
|
||||
this.Funktion = json["Funktion"].ToString();
|
||||
this.Name = json["Name"].ToString();
|
||||
this.Ric = json["Ric"] is null ? null : new RicDescription(json["Ric"]);
|
||||
this.Geo = json["Geo"] is null ? null : new GeoData(json["Geo"]);
|
||||
this.Sendonline = (Boolean)json["Sendonline"];
|
||||
this.Isprivate = (Boolean)json["Isprivate"];
|
||||
}
|
||||
|
||||
public PocsagParsed(PocsagHttp raw, String funktion, String name, RicDescription ric, GeoData geo, Boolean sendonline, Boolean isprivate, DateTime date) : base("pocsag-parsed") {
|
||||
this.Raw = raw;
|
||||
this.Funktion = funktion;
|
||||
this.Name = name;
|
||||
this.Ric = ric;
|
||||
this.Geo = geo;
|
||||
this.Sendonline = sendonline;
|
||||
this.Isprivate = isprivate;
|
||||
this.Date = date;
|
||||
}
|
||||
|
||||
public override String ToString() => "[" + this.Funktion + "] " + this.Name + ": " + this.Raw.Message;
|
||||
|
||||
public String ToTextString() => System.Text.RegularExpressions.Regex.Replace(this.Raw.Message, @"#C(?<lon>.+?),(?<lat>.+?)#", "").Trim();
|
||||
|
||||
public String ToTitleString() => this.Ric is RicDescription && this.Ric.ShortDescription != "" ? this.Ric.ShortDescription : this.Name;
|
||||
|
||||
public static PocsagParsed ConvertJson(String message) => new PocsagParsed(JsonMapper.ToObject(message));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt {
|
||||
public class RicDescription : AMqttMessage {
|
||||
public String Address {
|
||||
get;
|
||||
}
|
||||
|
||||
public String Location {
|
||||
get;
|
||||
}
|
||||
|
||||
public String ShortDescription {
|
||||
get;
|
||||
}
|
||||
|
||||
public String LongDescription {
|
||||
get;
|
||||
}
|
||||
|
||||
public RicDescription(String address, String location, String shortdescription, String longdescription) : base("ric-description") {
|
||||
this.Address = address;
|
||||
this.Location = location;
|
||||
this.ShortDescription = shortdescription;
|
||||
this.LongDescription = longdescription;
|
||||
}
|
||||
|
||||
public RicDescription(JsonData json) : base("ric-description", json["Date"]) {
|
||||
this.Address = json["Address"].ToString();
|
||||
this.Location = json["Location"].ToString();
|
||||
this.ShortDescription = json["ShortDescription"].ToString();
|
||||
this.LongDescription = json["LongDescription"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user