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); }
private static async Task WriteDataToOcsAsync(PIPoint piPoint, List <AFValue> afValues, IQiDataService data) { var streamId = GetStreamId(piPoint); switch (PIQiTypes.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.)"); }