Пример #1
0
        static bool TagIsReady(string tagName)
        {
            bool returnValue = false;

            try
            {
                // Check to see if we already konw the tag is ready
                returnValue = _HistorianTags.subscribetags.Single(s => s.historianTag.TagName.Equals(tagName)).tagisready;

                //We have not registered that the tag is ready so go check again
                if (!returnValue)
                {
                    HistorianTagStatus tagStatus = new HistorianTagStatus();
                    tagStatus.TagName = tagName;

                    _historian.GetTagStatusByName(ref tagStatus);

                    returnValue = !(tagStatus.Pending | tagStatus.ErrorOccurred);

                    //If it comes back ready then stick that back into the object for cacheing
                    if (returnValue)
                    {
                        _HistorianTags.subscribetags.Single(s => s.historianTag.TagName.Equals(tagName)).tagisready = returnValue;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                returnValue = false;
            }

            return(returnValue);
        }