12345678910111213141516171819202122232425262728293031323334353637383940 |
- using ShakerService.Tools;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ShakerService
- {
- internal partial class Service
- {
- private void ReadFifo()
- {
- int perframelen = ViewModel.ShakerConfigViewModel.Instance.MaxResultChannelCount * ViewModel.ShakerConfigViewModel.Instance.SampleRate;
- uint readlen = 0;
- while(!maintokenSource.IsCancellationRequested)
- {
- if(ShakerFpga.ShakerFpga.Instance.波形数据.ElementsRemaining>=perframelen)
- {
- ShakerFpga.ShakerFpga.Instance.波形数据.ReadAcquire(ref ShakerDataCache.Instance.GetDataCacheref(0), (uint)perframelen, 100, ref readlen);
- SendData(ShakerDataCache.Instance.DataCache, (uint)ShakerDataCache.Instance.RowCount, (uint)ShakerDataCache.Instance.ColnumCount);
- break;
- }
- else
- {
- Task.Delay(10).Wait();
- }
- }
- }
- private void SendData(byte[] data, uint rowcount, uint colnumcount)
- {
- //异步发送数据
- Task.Run(() =>
- {
- Log.Default.Info("发送数据");
- Communication.Instance.Context.GetEvent(Shaker.Model.Topic.DATA)?.Publish(this, null, Shaker.Tools.Tools.CompressionBytes(data), rowcount, colnumcount);
- });
- }
- }
- }
|