예제 #1
0
 private void Window_Initialized(object sender, EventArgs e)
 {
     initialApi();
     _syncContext  = SynchronizationContext.Current;
     _dataContext  = new DataContext();
     _profileShape = new ProfileShape();
     sb            = new StringBuilder();
     if (File.Exists(filePath))
     {
         File.Delete(filePath);
     }
 }
예제 #2
0
        void ProfileProcessingFunc(KObject data, int dataQuene)
        {
            GoDataSet _dataSource = new GoDataSet();

            _dataSource = (GoDataSet)data;
            DataContext   _dataContext  = new DataContext();
            ProfileShape  _profileShape = new ProfileShape();
            StringBuilder sb            = new StringBuilder();
            StringBuilder rawSb         = new StringBuilder();

            for (UInt32 i = 0; i < _dataSource.Count; i++)
            {
                GoDataMsg dataObj = (GoDataMsg)_dataSource.Get(i);
                switch (dataObj.MessageType)
                {
                case GoDataMessageType.ResampledProfile:
                {
                    GoResampledProfileMsg profileMsg = (GoResampledProfileMsg)dataObj;
                    _dataContext.xResolution = (double)profileMsg.XResolution / 1000000;
                    _dataContext.zResolution = (double)profileMsg.ZResolution / 1000000;
                    _dataContext.xOffset     = (double)profileMsg.XOffset / 1000;
                    _dataContext.zOffset     = (double)profileMsg.ZOffset / 1000;
                    _profileShape.width      = profileMsg.Width;
                    _profileShape.size       = profileMsg.Size;
                    //generate csv file for point data save
                    short[]        points        = new short[_profileShape.width];
                    ProfilePoint[] profileBuffer = new ProfilePoint[_profileShape.width];
                    IntPtr         pointsPtr     = profileMsg.Data;
                    Marshal.Copy(pointsPtr, points, 0, points.Length);

                    for (UInt32 arrayIndex = 0; arrayIndex < _profileShape.width; ++arrayIndex)
                    {
                        if (points[arrayIndex] != -32768)
                        {
                            profileBuffer[arrayIndex].x = _dataContext.xOffset + _dataContext.xResolution * arrayIndex;
                            profileBuffer[arrayIndex].z = _dataContext.zOffset + _dataContext.zResolution * points[arrayIndex];
                        }
                        else
                        {
                            profileBuffer[arrayIndex].x = _dataContext.xOffset + _dataContext.xResolution * arrayIndex;
                            profileBuffer[arrayIndex].z = -32768;
                        }

                        zValueList.Add(profileBuffer[arrayIndex].z);
                    }


                    sb.Clear();


                    if (!File.Exists(filePath))
                    {
                        sb.Append("Index,");

                        for (int k = 0; k < profileBuffer.Length; k++)
                        {
                            sb.Append(profileBuffer[k].x.ToString() + ",");
                        }
                        sb.Append(Environment.NewLine);
                        File.AppendAllText(filePath, sb.ToString());
                        //updateMsg("Create file sucessfully");
                        sb.Clear();
                    }

                    sb.Append(dataQuene.ToString() + ",");
                    //Get Value   save to file
                    for (int k = 0; k < profileBuffer.Length; k++)
                    {
                        sb.Append(profileBuffer[k].z.ToString() + ",");
                    }
                    sb.Append(Environment.NewLine);
                    // write to file
                    File.AppendAllText(filePath, sb.ToString());
                    sb.Clear();
                }
                break;

                default: break;
                }
            }
        }