public override bool WriteValue(IRtTag tag, IRtValue value) { if (IsConnected && keyValueMemory != null) { var writed = keyValueMemory.SetValue(tag.Topic, value.Binary, true); if (writed) { lock (rtTags) { foreach (var _tag in rtTags.Where(t => t.Topic == tag.Topic)) { _tag.RaiseOnSetValue(value); } } RaiseOnSetValue(tag); logger?.LogDebug("WriteValue TagName:{0} return:{1}", tag.TagName, true); return(true); } } logger?.LogWarning("WriteValue TagName:{0} return:{1}", tag.TagName, false); return(false); }
public override bool WriteValue(IRtTag tag, IRtValue value) { try { if (mqttClient.IsConnected) { RtTagMqttOptions options = tag.Options as RtTagMqttOptions; var writed = mqttClient.Client.Publish(tag.Topic, value.Binary, (byte)options.qosLevels, options.retain); if (writed > 0) { lock (rtTags) { foreach (var _tag in rtTags.Where(t => t.Topic == tag.Topic)) { _tag.RaiseOnSetValue(value); } } RaiseOnSetValue(tag); logger?.LogDebug("WriteValue TagName:{0} Value:{1} return:{2}", tag.TagName, tag.Value.Text, true); return(true); } } } catch { } logger?.LogWarning("WriteValue TagName:{0} return:{1}", tag.TagName, false); return(false); }
protected virtual void RaiseOnUpdatedValue(object sender, IRtValue value, DateTime?updated = null, bool status = true) { Value = value ?? valueNull; Updated = updated ?? DateTime.Now; Status = status; ValueUpdated?.Invoke(sender, this); }
public virtual bool Set(IRtValue value) { return(Connector.WriteValue(this, value)); }
public override bool WriteValue(string topic, IRtValue value, IRtTagOptions options = null) { return(WriteValue(new RtTagMqtt(this, topic, $"{prefix}{topic}", options as RtTagMqttOptions), value)); }
internal void RaiseOnUpdatedValue(IRtValue value, DateTime?updated = null, bool status = true) { base.RaiseOnUpdatedValue(Connector, value, updated, status); }
public RtTagBinaryDataParser(IRtTag tag, string dateTimePatter) : base(tag) { TagBinaryDataParserPattern = dateTimePatter; currentValueParsed = TryParseValue(tag); parsedTime = Updated; }
public override bool WriteValue(string topic, IRtValue value, IRtTagOptions options = null) { return(WriteValue(new RtTagMemoryMapped(this, topic, topic, options), value)); }
private RtMessage(string topic, IRtValue value, object raw) { Topic = topic; Value = value; Raw = raw; }
public abstract bool WriteValue(string topic, IRtValue value, IRtTagOptions options = null);
public abstract bool WriteValue(IRtTag tag, IRtValue value);
public RtTagJson(IRtTag tag, string jsonValuePattern) : base(tag) { TagJsonValuePattern = jsonValuePattern; currentValueParsed = TryParseValue(tag.Value.Text); parsedTime = Updated; }
internal void RaiseOnUpdatedValue(IRtValue value) { base.RaiseOnUpdatedValue(Connector, value); }
public override bool Set(IRtValue value) { throw new NotImplementedException(); }
public virtual bool Set(IRtValue value) { return(tag.Set(value)); }
public RtTagRegex(IRtTag tag, string regexPattern) : base(tag) { TagRegexValuePattern = regexPattern; currentValueParsed = TryParseValue(tag.Value.Text); parsedTime = Updated; }
public override bool Set(IRtValue value) { throw new InvalidOperationException($"Tag {TagName} is type JSON field, Write is not supported!"); }
public static IRtMessage Create(string topic, IRtValue value, object raw) { return(new RtMessage(topic, value, raw)); }