Пример #1
0
        private async Task UpdateDeltaComponentPortStats(DeltaComponent component)
        {
            const int bufLength = 1024;
            var       buf       = new byte[bufLength];

            var result = await Task.Run(() =>
                                        _native.TmcDntGetPortStats(_cid,
                                                                   component.TraceChain,
                                                                   ref buf,
                                                                   bufLength))
                         .ConfigureAwait(false);

            var portStatsString = EncodingUtil.Win1251BytesToUtf8(buf);

            if (result == 0 || portStatsString.IsNullOrEmpty())
            {
                return;
            }

            var(ticks, statusCount, analogCount, accumCount, messagesCount) = ParsePortStatsString(portStatsString);

            if (component.InitialPerformanceStats == null)
            {
                component.SetInitialPerformanceStats(ticks, statusCount, analogCount, accumCount, messagesCount);
                return;
            }

            component.UpdatePerformanceStatsAndString(ticks, statusCount, analogCount, accumCount, messagesCount);
        }