Esempio n. 1
0
        private bool OnTagValueChanged()
        {
            try
            {
                foreach (var monitorTagPair in MonitorTagChangeDic)
                {
                    if (!TagValueIsNotNullAndHasChanged(monitorTagPair, out var monitorTag, out var currentTagValue))
                    {
                        continue;
                    }

                    // 设置输出参数
                    OutMachineName.SetValue(monitorTag.TagOwner);
                    OutTagName.SetValue(monitorTag.Tag.TagName);

                    return(currentTagValue > 0);
                }

                return(false);
            }
            catch (Exception)
            {
                Log.Error("");
                return(false);
            }
        }
Esempio n. 2
0
        private bool OneTagValueChangedToOn()
        {
            try
            {
                for (var i = 0; i < LastTags.Count; i++)
                {
                    var monitorTag = MonitorTags[i];

                    if (!monitorTag.ShouldMonitor)
                    {
                        continue;
                    }

                    var lastTag = LastTags[i];

                    if (Tag.ValueEqual(monitorTag.Tag, lastTag))
                    {
                        continue;
                    }

                    if ((bool)monitorTag.Tag.TagValue)
                    {
                        Log.Info(
                            $"{lastTag.Owner.ResourceName}的触发信号发生变化,变化前值为:{lastTag.TagValue},变化后值为:{monitorTag.Tag.TagValue}.");

                        //查找到变化
                        lastTag.TagValue = monitorTag.Tag.TagValue;

                        // 设置输出参数
                        OutMachineName.SetValue(monitorTag.TagOwner);
                        OutTagName.SetValue(monitorTag.Tag.TagName);

                        return(true);
                    }

                    Log.Info(
                        $"{lastTag.Owner.ResourceName}的触发信号发生变化,变化前值为:{lastTag.TagValue},变化后值为:{monitorTag.Tag.TagValue}.");

                    lastTag.TagValue = monitorTag.Tag.TagValue;
                }

                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"{e}");
                return(false);
            }
        }
        private bool OneTagValueChangedToOff()
        {
            try
            {
                for (var i = 0; i < LastTags.Count; i++)
                {
                    var monitorTag = MonitorTags[i];

                    if (!monitorTag.ShouldMonitor)
                    {
                        continue;
                    }

                    var lastTag = LastTags[i];

                    if (Tag.ValueEqual(monitorTag.Tag, lastTag))
                    {
                        continue;
                    }
                    if (!(bool)monitorTag.Tag.TagValue)
                    {
                        //查找到变化
                        lastTag.TagValue = monitorTag.Tag.TagValue;

                        // 设置输出参数
                        OutMachineName.SetValue(monitorTag.TagOwner);
                        OutTagName.SetValue(monitorTag.Tag.TagName);

                        return(true);
                    }

                    lastTag.TagValue = monitorTag.Tag.TagValue;
                }

                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"检测下降沿触发条件失败,异常为:[{e.Message}]");
                return(false);
            }
        }