コード例 #1
0
 private List <TopBottomSurface> ResolveRawDataList(List <KObject> mRawDataList)
 {
     #region for loop
     Stopwatch sw = Stopwatch.StartNew();
     for (int i = 0; i < mRawDataList.Count; i++)
     {
         ResolveRawData(mRawDataList[i]);
     }
     Debug.WriteLine($"for loop consuming {sw.ElapsedMilliseconds}");
     #endregion
     #region parallel loop
     //Stopwatch sw = Stopwatch.StartNew();
     //Task.Run(() =>
     //{
     //    Parallel.For(0, BufferSize, (index) =>
     //    {
     //        mResult.Add(ResolveRawData(mRawDataList[index]));
     //    });
     //}).Wait();
     //Debug.WriteLine($"Parallel for consuming {sw.ElapsedMilliseconds}");
     #endregion
     StopAcq();
     DeviceStatusEvent?.Invoke(this, $"Finished / Stop Acq/ Return Result");
     return(mResult);
 }
コード例 #2
0
 public bool StartAcq()
 {
     if (mSensor.State != GoState.Ready)
     {
         mSensor.Stop();
     }
     mSensor.Start();
     DeviceStatusEvent?.Invoke(this, $"Start Acq");
     return(true);
 }
コード例 #3
0
 public bool InitialAcq()
 {
     mSystem = new GoSystem();
     mSensor = mSystem.FindSensorByIpAddress(KIpAddress.Parse(IPAddr));
     DeviceStatusEvent?.Invoke(this, $"Find device @ IP address {IPAddr}");
     mSystem.Connect();
     DeviceStatusEvent?.Invoke(this, $"Connect to {IPAddr}");
     mSystem.EnableData(true);
     mSystem.SetDataHandler(OnData);
     return(true);
 }
コード例 #4
0
 public bool StopAcq()
 {
     mSensor.Stop();
     DeviceStatusEvent?.Invoke(this, $"Stop Acq");
     return(true);
 }
コード例 #5
0
        private void ResolveRawData(KObject kData)
        {
            GoDataSet dataSet = (GoDataSet)kData;

            ushort[]         zValue           = new ushort[0];
            TopBottomSurface topBottomSurface = new TopBottomSurface(SurfaceType.TopBottom);

            for (UInt32 i = 0; i < dataSet.Count; i++)
            {
                GoDataMsg dataObj = (GoDataMsg)dataSet.Get(i);

                switch (dataObj.MessageType)
                {
                    #region SurfaceMsg
                case GoDataMessageType.Surface:
                    GocatorContext      mContext   = new GocatorContext();
                    GoUniformSurfaceMsg surfaceMsg = (GoUniformSurfaceMsg)dataObj;
                    long width      = surfaceMsg.Width;
                    long height     = surfaceMsg.Length;
                    long bufferSize = width * height;
                    mContext.XResolution = (double)surfaceMsg.XResolution / 1000000;
                    mContext.ZResolution = (double)surfaceMsg.ZResolution / 1000000;
                    mContext.XOffset     = (double)surfaceMsg.XOffset / 1000;
                    mContext.ZOffset     = (double)surfaceMsg.ZOffset / 1000 - mContext.ZResolution * 32768;
                    mContext.YResolution = (double)surfaceMsg.YResolution / 1000000;
                    mContext.Width       = (int)width;
                    mContext.Height      = (int)height;
                    IntPtr  bufferPointer = surfaceMsg.Data;
                    short[] ranges        = new short[bufferSize];
                    zValue = new ushort[bufferSize];
                    Marshal.Copy(bufferPointer, ranges, 0, ranges.Length);
                    Parallel.For(0, bufferSize, (index) =>
                    {
                        zValue[index] = (ushort)(ranges[index] + 32768);
                    });
                    if (surfaceMsg.Source.Value == 0)
                    {
                        topBottomSurface.TopSurfaceData = zValue;
                        mContextTop = mContext;
                    }
                    else if (surfaceMsg.Source.Value == 1)
                    {
                        topBottomSurface.BottomSurfaceData = zValue;
                        mContextBottom = mContext;
                    }

                    break;
                    #endregion


                case GoDataMessageType.SurfaceIntensity:
                    GoSurfaceIntensityMsg goSurfaceIntensityMsg = (GoSurfaceIntensityMsg)dataObj;
                    long   widthIntensity      = goSurfaceIntensityMsg.Width;
                    long   heightIntensity     = goSurfaceIntensityMsg.Length;
                    long   bufferSizeIntensity = widthIntensity * heightIntensity;
                    IntPtr bufferPointeri      = goSurfaceIntensityMsg.Data;
                    byte[] rangesIntensity     = new byte[bufferSizeIntensity];
                    Marshal.Copy(bufferPointeri, rangesIntensity, 0, rangesIntensity.Length);
                    if (goSurfaceIntensityMsg.Source.Value == 0)
                    {
                        topBottomSurface.TopSurfaceIntensityData = rangesIntensity;
                    }
                    else if (goSurfaceIntensityMsg.Source.Value == 1)
                    {
                        topBottomSurface.BottomSurfaceIntensityData = rangesIntensity;
                    }
                    break;
                }
            }
            mResult.Add(topBottomSurface);
            DeviceStatusEvent?.Invoke(this, $"Finished {100 * (mResult.Count) / BufferSize * 1.0} %");
        }