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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public virtual bool Set(IRtValue value)
 {
     return(Connector.WriteValue(this, value));
 }
예제 #5
0
 public override bool WriteValue(string topic, IRtValue value, IRtTagOptions options = null)
 {
     return(WriteValue(new RtTagMqtt(this, topic, $"{prefix}{topic}", options as RtTagMqttOptions), value));
 }
예제 #6
0
 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));
 }
예제 #9
0
 private RtMessage(string topic, IRtValue value, object raw)
 {
     Topic = topic;
     Value = value;
     Raw   = raw;
 }
예제 #10
0
 public abstract bool WriteValue(string topic, IRtValue value, IRtTagOptions options = null);
예제 #11
0
 public abstract bool WriteValue(IRtTag tag, IRtValue value);
예제 #12
0
 public RtTagJson(IRtTag tag, string jsonValuePattern) : base(tag)
 {
     TagJsonValuePattern = jsonValuePattern;
     currentValueParsed  = TryParseValue(tag.Value.Text);
     parsedTime          = Updated;
 }
예제 #13
0
 internal void RaiseOnUpdatedValue(IRtValue value)
 {
     base.RaiseOnUpdatedValue(Connector, value);
 }
예제 #14
0
 public override bool Set(IRtValue value)
 {
     throw new NotImplementedException();
 }
예제 #15
0
 public virtual bool Set(IRtValue value)
 {
     return(tag.Set(value));
 }
예제 #16
0
 public RtTagRegex(IRtTag tag, string regexPattern) : base(tag)
 {
     TagRegexValuePattern = regexPattern;
     currentValueParsed   = TryParseValue(tag.Value.Text);
     parsedTime           = Updated;
 }
예제 #17
0
 public override bool Set(IRtValue value)
 {
     throw new InvalidOperationException($"Tag {TagName} is type JSON field, Write is not supported!");
 }
예제 #18
0
 public static IRtMessage Create(string topic, IRtValue value, object raw)
 {
     return(new RtMessage(topic, value, raw));
 }