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

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

            await metadata.CreateOrUpdateStreamAsync(new SdsStream()
            {
                Id          = id,
                Name        = piPoint.Name,
                TypeId      = PISdsTypes.GetSdsTypeId(dataType),
                Description = piPoint.GetAttribute(PICommonPointAttributes.Descriptor).ToString()
            });

            //write stream metadata from PIPoint attributes
            await metadata.UpdateStreamMetadataAsync(id, otherAttributes);
        }
Esempio n. 2
0
        private static async Task WriteDataToOcsAsync(PIPoint piPoint, List <AFValue> afValues, ISdsDataService data)
        {
            var streamId = GetStreamId(piPoint);

            switch (PISdsTypes.GetDataType(piPoint.PointType))
            {
            case StreamDataType.Integer:
                await WriteDataForIntegerStreamAsync(data, afValues, streamId);

                break;

            case StreamDataType.Float:
                await WriteDataForFloatStreamAsync(data, afValues, streamId);

                break;

            case StreamDataType.String:
                await WriteDataForStringStreamAsync(data, afValues, streamId);

                break;

            case StreamDataType.Blob:
                await WriteDataForBlobStreamAsync(data, afValues, streamId);

                break;

            case StreamDataType.Time:
                await WriteDataForTimeStreamAsync(data, afValues, streamId);

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Console.WriteLine(
                $"Writing data for point: {piPoint.Name} to stream {streamId} ({afValues.Count} values written.)");
        }