public MPoint this[int index] { get { MPoint mPoint = new MPoint(); mPoint.X = X[index]; for (int i = 0; i < Y.Length; i++) { mPoint.Y[i] = Y[i].Value[index]; } return(mPoint); } set { X[index] = value.X; for (int i = 0; i < Y.Length; i++) { Y[i].Value[index] = value.Y[i]; } } }
public MPoints Decode(MemoryStream memoryStream) { List <MPoint> mPoints = new List <MPoint>(); while (true) { if (PSP.Decode(memoryStream, ref package) == true) { break; } MPoint mPoint = new MPoint(); DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); dateTime = dateTime.AddSeconds(package.Item[0].Value); dateTime = dateTime.AddMilliseconds(package.Item[1].Value); mPoint.X = dateTime; for (int i = 0; i < mPoint.Y.Length; i++) { mPoint.Y[i] = (int)package.Item[i + 2].Value; } ; mPoints.Add(mPoint); } //Debug.Print(mPoints.Count.ToString()); if (mPoints.Count == 0) { return(null); } MPoints points = new MPoints(mPoints.Count); for (int i = 0; i < mPoints.Count; i++) { points[i] = mPoints[i]; } return(points); }
private async Task <MPoints> BlockDecreaseAsync(int position, int blockSize) { return(await Task.Run(() => { using (FileStream fs = File.OpenRead(fileName)) { //StreamDecoding sd = new StreamDecoding(fs); MPoints mPointsOut = new MPoints(2); MPoints mPointsBlock; //Создание блока из потока //mPointsBlock = sd.DecodingBlock(blockSize, position); //StreamControl sc = new StreamControl(); //sc.SeleсtStream(fs); //var s = sc.ReadStream(blockSize, position); PackagePSP package = new PackagePSP(new PackagePSPStructure(StartBit.ZERO, 32, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12)); List <MPoint> mPoints = new List <MPoint>(); while (true) { // if (PSP.Decode(s, ref package) == true) break; MPoint mPoint = new MPoint(); DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); dateTime = dateTime.AddSeconds(package.Item[0].Value); dateTime = dateTime.AddMilliseconds(package.Item[1].Value); mPoint.X = dateTime; for (int i = 0; i < mPoint.Y.Length; i++) { mPoint.Y[i] = (int)package.Item[i + 2].Value; } ; mPoints.Add(mPoint); } //Debug.Print(mPoints.Count.ToString()); if (mPoints.Count == 0) { return null; } MPoints points = new MPoints(mPoints.Count); for (int i = 0; i < mPoints.Count; i++) { points[i] = mPoints[i]; } //Выборка первой и последней даты в блоке mPointsOut.X[0] = points.X.First(); mPointsOut.X[1] = points.X.Last(); //Выборка минимальных и максимальных Y значений for (int g = 0; g < mPointsOut.Y.Length; g++) { mPointsOut.Y[g].Value[0] = points.Y[g].Value.Min(); mPointsOut.Y[g].Value[1] = points.Y[g].Value.Max(); } return mPointsOut; } } )); }