可用版本1
This commit is contained in:
@ -9,7 +9,8 @@ using System.Windows.Forms;
|
||||
|
||||
namespace mainProgram
|
||||
{
|
||||
public delegate void UpdateProgressBarInfoDelegate(int ipos, string vinfo);//申明代理:用于进度条的更新UpdateProgressBarInfoDelegate 1
|
||||
public delegate void UpdateProgressBarInfoDelegate(int ipos, string vinfo);//申明委托类型:用于进度条的更新
|
||||
public delegate void RadCompleteDelegate();//申明委托类型:福亮度完成后调用的委托
|
||||
|
||||
public class DateFolder : IComparable//接口
|
||||
{
|
||||
@ -195,6 +196,51 @@ namespace mainProgram
|
||||
}
|
||||
}
|
||||
|
||||
public string MetadataPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return mMetadataPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
mMetadataPath = value;
|
||||
}
|
||||
}
|
||||
public string RawPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return mRawPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
mRawPath = value;
|
||||
}
|
||||
}
|
||||
public string RadPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return mRadPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
mRadPath = value;
|
||||
}
|
||||
}
|
||||
public string SifPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return mSifPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
mSifPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateProject(string calFilePath, string dataPath)
|
||||
{
|
||||
if (mProjectPath.Length == 0)
|
||||
@ -226,16 +272,30 @@ namespace mainProgram
|
||||
|
||||
}
|
||||
|
||||
public void OpenProject()
|
||||
public bool OpenProject()
|
||||
{
|
||||
if (!Directory.Exists(mProjectPath))
|
||||
return false;
|
||||
|
||||
|
||||
mMetadataPath = Path.Combine(mProjectPath, ".project");
|
||||
mRawPath = Path.Combine(mProjectPath, "1raw");
|
||||
mRadPath = Path.Combine(mProjectPath, "2rad");
|
||||
mSifPath = Path.Combine(mProjectPath, "3sif");
|
||||
|
||||
BinaryReader br = new BinaryReader(new FileStream(Path.Combine(mMetadataPath, "CsvFileCount.dat"), FileMode.Open));
|
||||
mCsvFileCount = br.ReadInt32();
|
||||
br.Close();
|
||||
if (Directory.Exists(mMetadataPath) & Directory.Exists(mRawPath) & Directory.Exists(mRadPath) & Directory.Exists(mSifPath))
|
||||
{
|
||||
BinaryReader br = new BinaryReader(new FileStream(Path.Combine(mMetadataPath, "CsvFileCount.dat"), FileMode.Open));
|
||||
mCsvFileCount = br.ReadInt32();
|
||||
br.Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//if (false == Directory.Exists(mMetadataPath))
|
||||
//{
|
||||
@ -267,9 +327,9 @@ namespace mainProgram
|
||||
|
||||
}
|
||||
|
||||
public void DeleteData()
|
||||
public void DeleteFile(string name)
|
||||
{
|
||||
|
||||
File.Delete(name);
|
||||
}
|
||||
|
||||
//生成工程元数据
|
||||
@ -538,7 +598,7 @@ namespace mainProgram
|
||||
bw.Close();
|
||||
}
|
||||
|
||||
private void DelectDir(string srcPath)
|
||||
public void DelectDir(string srcPath)
|
||||
{
|
||||
DirectoryInfo dir = new DirectoryInfo(srcPath);
|
||||
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
|
||||
@ -557,6 +617,12 @@ namespace mainProgram
|
||||
|
||||
}
|
||||
|
||||
public void DelectDirIncludeItself(string srcPath)
|
||||
{
|
||||
DirectoryInfo dir = new DirectoryInfo(srcPath);
|
||||
dir.Delete(true);
|
||||
}
|
||||
|
||||
|
||||
//工程结构
|
||||
public void CreateProjectStructure()
|
||||
@ -590,13 +656,13 @@ namespace mainProgram
|
||||
}
|
||||
}
|
||||
|
||||
public int getTxtFileCount()
|
||||
public int getNonLinearFileCount()
|
||||
{
|
||||
string[] metaFilesPath = Directory.GetFileSystemEntries(mMetadataPath);
|
||||
int txtFileCount = 0;
|
||||
for (int i = 0; i < metaFilesPath.Length; i++)//
|
||||
{
|
||||
if (metaFilesPath[i].Contains("txt"))
|
||||
if (metaFilesPath[i].Contains("nonLinear"))
|
||||
{
|
||||
txtFileCount++;
|
||||
}
|
||||
@ -619,7 +685,11 @@ namespace mainProgram
|
||||
return datFileCount;
|
||||
}
|
||||
|
||||
public UpdateProgressBarInfoDelegate UpdateProgressBarInfo;//
|
||||
//如果一个委托不需要再其定义的类之外被触发,那么就可以将其转化为事件,这样可以保证它不会在外部被随意触发。
|
||||
//public UpdateProgressBarInfoDelegate UpdateProgressBarInfo;//申明委托变量
|
||||
public event UpdateProgressBarInfoDelegate UpdateProgressBarInfoEvent;//申明事件
|
||||
//public RadCompleteDelegate RadComplete;//申明委托变量
|
||||
public event RadCompleteDelegate RadCompleteEvent;//申明委托变量
|
||||
|
||||
//处理工程中的数据
|
||||
public void Rad()
|
||||
@ -627,16 +697,16 @@ namespace mainProgram
|
||||
int counter = 0;
|
||||
//读取标定文件:辐射定标文件 + 非线性校正文件
|
||||
int datFileCount = getCalFileCount();
|
||||
int txtFileCount = getTxtFileCount();
|
||||
int txtFileCount = getNonLinearFileCount();
|
||||
|
||||
CalData[] calDatas = new CalData[datFileCount];
|
||||
NonLinearData[] nonLinearDatas = new NonLinearData[txtFileCount];
|
||||
|
||||
int d1 = 0, d2 = 0;
|
||||
string[] metaFilesPath = Directory.GetFileSystemEntries(mMetadataPath);
|
||||
for (int i = 0; i < datFileCount + txtFileCount; i++)
|
||||
for (int i = 0; i < metaFilesPath.Length; i++)
|
||||
{
|
||||
if (metaFilesPath[i].Contains("txt"))
|
||||
if (metaFilesPath[i].Contains("nonLinear"))
|
||||
{
|
||||
nonLinearDatas[d1] = ReadNonLinearFile(metaFilesPath[i]);
|
||||
d1++;
|
||||
@ -653,11 +723,10 @@ namespace mainProgram
|
||||
DelectDir(mRadPath);
|
||||
string[] sourceFilesPath = Directory.GetFileSystemEntries(mRawPath);
|
||||
|
||||
for (int i = 0; i < sourceFilesPath.Length; i++)//mRawPath下的日期文件夹
|
||||
for (int i = 0; i < sourceFilesPath.Length; i++)//mRawPath下的每个日期文件夹
|
||||
{
|
||||
string sourceFilePath = sourceFilesPath[i];
|
||||
string[] forlders = sourceFilePath.Split('\\');
|
||||
|
||||
//构建rad中的输出文件夹
|
||||
string[] forlders = sourceFilesPath[i].Split('\\');
|
||||
string lastDirectory = forlders[forlders.Length - 1];
|
||||
string dest = Path.Combine(mRadPath, lastDirectory);
|
||||
|
||||
@ -666,8 +735,9 @@ namespace mainProgram
|
||||
Directory.CreateDirectory(dest);
|
||||
}
|
||||
|
||||
|
||||
string[] rawFiles = Directory.GetFileSystemEntries(Path.Combine(mRawPath, lastDirectory));
|
||||
foreach (string rawFileName in rawFiles)//日期文件夹下的文件
|
||||
foreach (string rawFileName in rawFiles)//日期文件夹下的每个DN值csv文件
|
||||
{
|
||||
string[] nameTmp = rawFileName.Split('\\');
|
||||
string name = nameTmp[nameTmp.Length - 1];
|
||||
@ -700,11 +770,30 @@ namespace mainProgram
|
||||
float tmp1 = (float)counter / (float)mCsvFileCount;
|
||||
float tmp2 = tmp1 * 100;
|
||||
|
||||
UpdateProgressBarInfo((int)tmp2, name + "\r\n");
|
||||
|
||||
//if (UpdateProgressBarInfo != null)//确认委托有方法
|
||||
//{
|
||||
// UpdateProgressBarInfo((int)tmp2, name + "\r\n");
|
||||
//}
|
||||
|
||||
if (UpdateProgressBarInfoEvent != null)
|
||||
{
|
||||
UpdateProgressBarInfoEvent((int)tmp2, name + "\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//福亮度转换完成后,需要做得动作
|
||||
////福亮度转换完成后,需要做得动作
|
||||
//if (RadComplete != null)//确认委托有方法
|
||||
//{
|
||||
// RadComplete();
|
||||
//}
|
||||
|
||||
if (RadCompleteEvent != null)//确认事件有方法可以执行
|
||||
{
|
||||
RadCompleteEvent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -743,19 +832,17 @@ namespace mainProgram
|
||||
CalData calFile;
|
||||
|
||||
string[] forlders = calFilePath.Split('\\');
|
||||
|
||||
string filename = forlders[forlders.Length - 1].Split('.')[0];
|
||||
string[] xx = filename.Split('_');
|
||||
|
||||
calFile.SN = xx[0];
|
||||
//string tmp = xx[1][xx[1].Length - 1];
|
||||
string[] tmp = filename.Split('_');
|
||||
calFile.SN = tmp[0];
|
||||
|
||||
int s = int.Parse(xx[1]);
|
||||
calFile.position = s;
|
||||
calFile.SN = filename;
|
||||
calFile.position = int.Parse(tmp[tmp.Length - 1]);
|
||||
|
||||
FileStream fs2 = new FileStream(calFilePath, FileMode.Open, FileAccess.Read);
|
||||
BinaryReader br = new BinaryReader(fs2);
|
||||
calFile.exposureTime = br.ReadUInt16();
|
||||
calFile.exposureTime = br.ReadUInt32();
|
||||
calFile.temperature = br.ReadSingle();
|
||||
calFile.pixelCount = br.ReadInt32();
|
||||
calFile.waveLengthInNM = new float[calFile.pixelCount];
|
||||
|
Reference in New Issue
Block a user