Реализована запись полученных кадров в файл

This commit is contained in:
Пытков Роман
2025-09-19 23:10:54 +03:00
parent c27e78cffe
commit af62ec6375
6 changed files with 183 additions and 6 deletions

27
Client/FrameAssembler.cs Normal file
View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using Domain;
namespace Client;
public class FrameAssembler
{
private readonly Action<List<Data>> _frameCallback;
private readonly List<Data> _buffer = new List<Data>();
private const int FrameSize = 9;
public FrameAssembler(Action<List<Data>> frameCallback)
{
_frameCallback = frameCallback ?? throw new ArgumentNullException(nameof(frameCallback));
}
public void AddData(Data data)
{
_buffer.Add(data);
if (_buffer.Count >= FrameSize)
{
_frameCallback(new List<Data>(_buffer));
_buffer.Clear();
}
}
}