コード例 #1
0
ファイル: YcDataParser.cs プロジェクト: xiechongzhu/AK
 private void GetMinMax(ref int pos, int time, out MinMaxValue minMaxValue)
 {
     if (Config.GetInstance().minMaxValues == null || Config.GetInstance().minMaxValues.Count == 0)
     {
         minMaxValue = new MinMaxValue
         {
             MinX  = 0,
             MaxX  = 0,
             MinY  = 0,
             MaxY  = 0,
             MinZ  = 0,
             MaxZ  = 0,
             MinVx = 0,
             MaxVx = 0,
             MinVy = 0,
             MaxVy = 0,
             MinVz = 0,
             MaxVz = 0
         };
         return;
     }
     for (; pos < Config.GetInstance().minMaxValues.Count; ++pos)
     {
         if (time < Config.GetInstance().minMaxValues[pos].Time)
         {
             break;
         }
     }
     pos -= 1;
     if (pos >= Config.GetInstance().minMaxValues.Count)
     {
         pos = Config.GetInstance().minMaxValues.Count - 1;
     }
     if (pos < 0)
     {
         pos = 0;
     }
     minMaxValue = Config.GetInstance().minMaxValues[pos];
 }
コード例 #2
0
        private void LoadConfigExcelFile(String fileName)
        {
            minMaxValues.Clear();
            try
            {
                using (Stream fileStream = File.Open(fileName, FileMode.Open))
                {
                    XSSFWorkbook workbook = new XSSFWorkbook(fileStream);
                    ISheet       sheet    = workbook.GetSheetAt(0);
                    editLongitudeInit.Text   = sheet.GetRow(0).GetCell(1).ToString();
                    editLatitudeInit.Text    = sheet.GetRow(1).GetCell(1).ToString();
                    editHeightInit.Text      = sheet.GetRow(2).GetCell(1).ToString();
                    editAzimuthInit.Text     = sheet.GetRow(3).GetCell(1).ToString();
                    editPlacementHeight.Text = sheet.GetRow(4).GetCell(1).ToString();
                    editFligtShot.Text       = sheet.GetRow(5).GetCell(1).ToString();
                    editForwardLine.Text     = sheet.GetRow(6).GetCell(1).ToString();
                    editBackLine.Text        = sheet.GetRow(7).GetCell(1).ToString();
                    editSideLine.Text        = sheet.GetRow(8).GetCell(1).ToString();
                    editStation.Text         = sheet.GetRow(9).GetCell(1).ToString();
                    editSpeedError.Text      = sheet.GetRow(10).GetCell(1).ToString();
                    editPointError.Text      = sheet.GetRow(11).GetCell(1).ToString();

                    int startTime = 0;
                    sheet = workbook.GetSheetAt(1);
                    for (int i = 1; i <= sheet.LastRowNum; ++i)
                    {
                        int         time        = (int)sheet.GetRow(i).GetCell(0).NumericCellValue;
                        MinMaxValue minMaxValue = new MinMaxValue
                        {
                            Time  = (int)(sheet.GetRow(i).GetCell(0).NumericCellValue *1000),
                            MinX  = sheet.GetRow(i).GetCell(1).NumericCellValue,
                            MaxX  = sheet.GetRow(i).GetCell(2).NumericCellValue,
                            MinY  = sheet.GetRow(i).GetCell(3).NumericCellValue,
                            MaxY  = sheet.GetRow(i).GetCell(4).NumericCellValue,
                            MinZ  = sheet.GetRow(i).GetCell(5).NumericCellValue,
                            MaxZ  = sheet.GetRow(i).GetCell(6).NumericCellValue,
                            MinVx = sheet.GetRow(i).GetCell(7).NumericCellValue,
                            MaxVx = sheet.GetRow(i).GetCell(8).NumericCellValue,
                            MinVy = sheet.GetRow(i).GetCell(9).NumericCellValue,
                            MaxVy = sheet.GetRow(i).GetCell(10).NumericCellValue,
                            MinVz = sheet.GetRow(i).GetCell(11).NumericCellValue,
                            MaxVz = sheet.GetRow(i).GetCell(12).NumericCellValue
                        };
                        if (minMaxValue.Time < startTime)
                        {
                            throw new Exception(String.Format("第{0}行数据时间不正确", i));
                        }
                        if (minMaxValue.MinX >= minMaxValue.MaxX)
                        {
                            throw new Exception(String.Format("第{0}行数据位置X下限大于或等于上限", i));
                        }
                        if (minMaxValue.MinY >= minMaxValue.MaxY)
                        {
                            throw new Exception(String.Format("第{0}行数据位置Y下限大于或等于上限", i));
                        }
                        if (minMaxValue.MinZ >= minMaxValue.MaxZ)
                        {
                            throw new Exception(String.Format("第{0}行数据位置Z下限大于或等于上限", i));
                        }
                        if (minMaxValue.MinVx >= minMaxValue.MaxVx)
                        {
                            throw new Exception(String.Format("第{0}行数据速度Vx下限大于或等于上限", i));
                        }
                        if (minMaxValue.MinVy >= minMaxValue.MaxVy)
                        {
                            throw new Exception(String.Format("第{0}行数据速度Vy下限大于或等于上限", i));
                        }
                        if (minMaxValue.MinVz >= minMaxValue.MaxVz)
                        {
                            throw new Exception(String.Format("第{0}行数据速度Vz下限大于或等于上限", i));
                        }
                        startTime = minMaxValue.Time;
                        minMaxValues.Add(minMaxValue);
                    }
                    XtraMessageBox.Show(String.Format("读取分量上下限数据成功,共{0}条记录", minMaxValues.Count), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                minMaxValues.Clear();
                XtraMessageBox.Show("导入参数文件失败:" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }