コード例 #1
0
        private void SendDataThreadMethod(object param)
        {
            //send resoultion information first
            _dataAccess.UpdateWidgets("REALTIME_VIEWER_RESOLUTION", (int)
                                      ((_realTimeViewerPixelsPerColumn << 16) | _realTimeViewerBytesPerPixel));

            int scaleValueBits = (int)((AppConfiguration.BytesPerPixel - _realTimeViewerBytesPerPixel) * 8);

            CancellationToken token = (CancellationToken)param;

            while (!token.IsCancellationRequested)
            {
                try
                {
                    DataInfo dataInfo = _inComingDataColl.Take(token);

                    //if (_dataAccess.Detectors.PixelPerColumn != _realTimeViewerPixelsPerColumn)
                    if (AppConfiguration.BytesPerPixel != _realTimeViewerBytesPerPixel)
                    {
                        //downscale data to reduce bandwidth
                        byte[] downscaledData      = new byte[_realTimeViewerPixelsPerColumn * _realTimeViewerBytesPerPixel];
                        int    downscaledDataIndex = 0;

                        for (int index = 0; index < dataInfo.LineData.Length; index++)
                        {
                            if ((index % _pixelInterval) == 0)
                            {
                                uint[] value = new uint[1];
                                value[0] = dataInfo.LineData[index].Value >> scaleValueBits;
                                Buffer.BlockCopy(value, 0, downscaledData, downscaledDataIndex, (int)_realTimeViewerBytesPerPixel);
                                downscaledDataIndex += (int)_realTimeViewerBytesPerPixel;
                            }
                        }

                        _realTimeViewerHost.SendData(downscaledData);
                    }
                    else
                    {
                        _realTimeViewerHost.SendData(dataInfo.LineData, (uint)AppConfiguration.BytesPerPixel);
                    }
                }
                catch (Exception exp)
                {
                    if (!token.IsCancellationRequested)
                    {
                        _log.LogError(exp);
                    }
                }
            }
        }
コード例 #2
0
ファイル: RealTimeViewer.cs プロジェクト: marzlia/CXPortal
        private void SendAgent()
        {
            while (!_sendEnd.WaitOne(0))
            {
                try
                {
                    DataInfo dataInfo = _inComingDataColl.Take(_sendCancel.Token);
                    if ((IsDualEnergy && dataInfo.XRayInfo.Energy == XRayEnergyEnum.HighEnergy) || !IsDualEnergy)
                    {
                        byte[] scaledData = new byte[dataInfo.LineData.Length / AppConfiguration.RealTimeViewerPixelInterval];

                        Parallel.For(0, scaledData.Length, i =>
                        {
                            scaledData[i] = (byte)(dataInfo.LineData[i * AppConfiguration.RealTimeViewerPixelInterval].Value >> 8);
                        });

                        _realTimeViewerHost.SendData(scaledData);
                    }
                }
                catch (Exception exp)
                {
                    if (!_sendEnd.WaitOne(0))
                    {
                        _log.LogError(exp);
                    }
                }
            }
        }