Exemplo n.º 1
0
        private static async Task CreateStreamBasedOnPIPointAsync(PIPoint piPoint,
                                                                  IEnumerable <string> pointAttributes, IQiMetadataService metadata)
        {
            var otherAttributes = pointAttributes.Where(s => s != PICommonPointAttributes.Descriptor)
                                  .ToDictionary(s => s, s => piPoint.GetAttribute(s).ToString());

            var id       = GetStreamId(piPoint);
            var dataType = PIQiTypes.GetDataType(piPoint.PointType);

            await metadata.CreateOrUpdateStreamAsync(new QiStream()
            {
                Id          = id,
                Name        = piPoint.Name,
                TypeId      = PIQiTypes.GetQiTypeId(dataType),
                Description = piPoint.GetAttribute(PICommonPointAttributes.Descriptor).ToString()
            });

            //write stream metadata from PIPoint attributes
            await metadata.UpdateStreamMetadataAsync(id, otherAttributes);
        }
Exemplo n.º 2
0
        public PIPointStepAttribute(string piPointName, string piServerName)
        {
            FindPIPoint findPIPoint = new FindPIPoint(piPointName, piServerName);
            PIPoint     piPoint     = findPIPoint.piPoint;

            piPoint.LoadAttributes(PICommonPointAttributes.Step);

            object step = piPoint.GetAttribute(PICommonPointAttributes.Step);

            if (Convert.ToInt32(step) == 1)
            {
                isStep = true;
            }
            else
            {
                isStep = false;
            }
        }
Exemplo n.º 3
0
        private AFValue Calculate(AFTime time, AFAttributeList inputAttributes, AFValues inputValues)
        {
            if (time == null) {
                throw new ArgumentException("No timestamp");
            }

            if (inputAttributes == null || inputAttributes.Count == 0) {
                throw new ArgumentException("No input attributes");
            }

            try {
                PIPoint tag = inputAttributes[0].PIPoint;
                if (tag == null) {
                    throw new ArgumentException("No PI point");
                }

                tag.LoadAttributes(PropertyName);
                object result = tag.GetAttribute(PropertyName);

                return new AFValue(base.Attribute, result, time, Attribute.DefaultUOM);
            } catch {
                throw new ArgumentException("Failed extracting tag property");
            }
        }