public override IRtTag AddTag(string tagName, string topic, IRtTagOptions options) { var tag = GetTag(tagName); if (tag != null) { return(tag); } RtTagMemoryMapped t = new RtTagMemoryMapped(this, tagName, topic, options); lock (rtTags) { rtTags.Add(t); } logger?.LogDebug("AddTag TagName:{0}", t.TagName); return(t); }
public override IRtTag AddTag(string tagName, string topic, IRtTagOptions options) { var tag = GetTag(tagName); if (tag != null) { return(tag); } RtTagMqtt t = new RtTagMqtt(this, tagName, $"{prefix}{topic}", (options as RtTagMqttOptions)); lock (rtTags) { rtTags.Add(t); } Subscribe(t); logger?.LogInformation("AddTag TagName:{0} prefix:{1}", t.TagName, prefix); return(t); }
public override bool WriteValue(string topic, IRtValue value, IRtTagOptions options = null) { return(WriteValue(new RtTagMqtt(this, topic, $"{prefix}{topic}", options as RtTagMqttOptions), value)); }
public RtTagMemoryMapped(RtConnectorMemoryMapped connector, string tagName, string topic, IRtTagOptions options) { ConnectorMM = connector; Connector = connector; TagName = tagName; Topic = topic; base.Options = options; base.Status = connector.ReadTagStatus(Topic); }
public abstract bool WriteValue(string topic, IRtValue value, IRtTagOptions options = null);
public abstract IRtTag AddTag(string tagName, string topic, IRtTagOptions options);
public static IRtTag AddTagDefinition(this IRtConnector conn, string tagDefinition, IRtTagOptions options = null) { var tsplit = tagDefinition.Split(new[] { "@" }, 2, StringSplitOptions.None); var topic = tsplit[0]; if (tsplit.Length > 1) { var tag = conn.GetOrAddTag(topic, options); var tagDefinitionPattern = tsplit[1]; if (tagDefinitionPattern.StartsWith("JSON:")) { var jsonValuePattern = tagDefinitionPattern.Remove(0, 5); return(new RtTagJson(tag, jsonValuePattern)); } else if (tagDefinitionPattern.StartsWith("RGX:")) { var regexPattern = tagDefinitionPattern.Remove(0, 4); return(new RtTagRegex(tag, regexPattern)); } else if (tagDefinitionPattern.StartsWith("DT:")) { var dateTimePattern = tagDefinitionPattern.Remove(0, 3); return(new RtTagDateTime(tag, dateTimePattern)); } else if (tagDefinitionPattern.StartsWith("UL:")) { var ultraLightValuePattern = tagDefinitionPattern.Remove(0, 3); return(new RtTagUltraLight(tag, ultraLightValuePattern)); } else if (tagDefinitionPattern.StartsWith("BDP:")) { var dataParserPattern = tagDefinitionPattern.Remove(0, 4); return(new RtTagBinaryDataParser(tag, dataParserPattern)); } } return(conn.GetOrAddTag(topic, options)); }
public static RtTagType <TValue> AddTagDefinition <TValue>(this IRtConnector conn, string tagDefinition, IRtTagOptions options = null) { return(new RtTagType <TValue>(conn.AddTagDefinition(tagDefinition, options))); }
public static RtTagType <TValue> GetOrAddTag <TValue>(this IRtConnector conn, string topic, IRtTagOptions options = null) { return(new RtTagType <TValue>(conn.GetOrAddTag(topic, topic, options))); }
public static IRtTag GetOrAddTag(this IRtConnector conn, string tagName, string topic, IRtTagOptions options = null) { var tag = conn.GetTag(tagName); if (tag == null) { tag = conn.AddTag(tagName, topic, options); } return(tag); }
public static IRtTag GetOrAddTag(this IRtConnector conn, string topic, IRtTagOptions options = null) { return(conn.GetOrAddTag(topic, topic, options)); }
public static bool SetJson <T>(this IRtConnector conn, string topic, T json, IRtTagOptions options = null) { return(conn.WriteValue(topic, RtValue.Create(JsonSerializer.Serialize(json)), options)); }
public static bool SetBinary(this IRtConnector conn, string topic, byte[] value, IRtTagOptions options = null) { return(conn.WriteValue(topic, RtValue.Create(value), options)); }
public static bool SetNumeric(this IRtConnector conn, string topic, double value, IRtTagOptions options = null) { return(conn.WriteValue(topic, RtValue.Create(value), options)); }
public static IRtTag AddExpression(IRtConnector creator, string expresionFull, IRtTagOptions options = null) { MatchCollection matches = rgx.Matches(expresionFull); if (matches.Count > 0) { string expresion = expresionFull; int i = 0; var argumentsTags = new IRtTag[matches.Count]; foreach (Match match in matches) { var tagDefinition = match.Value.Trim().TrimStart('{').TrimEnd('}'); argumentsTags[i] = creator.AddTagDefinition(tagDefinition, options); expresion = expresion.Replace(match.Value, $"arg{i}"); i++; } return(new RtTagExpression(expresionFull, expresion, argumentsTags)); } else if (expresionFull.StartsWith("=")) { return(new RtTagExpression(expresionFull, expresionFull, null)); } else { return(creator.AddTagDefinition(expresionFull, options)); } }
public override bool WriteValue(string topic, IRtValue value, IRtTagOptions options = null) { return(WriteValue(new RtTagMemoryMapped(this, topic, topic, options), value)); }