|
@@ -9,6 +9,9 @@ using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Windows.Forms.DataVisualization.Charting;
|
|
|
using Extender;
|
|
|
+using DBManager;
|
|
|
+using MeasureData;
|
|
|
+using System.Data.SQLite;
|
|
|
|
|
|
namespace OxfordTest
|
|
|
{
|
|
@@ -272,14 +275,71 @@ namespace OxfordTest
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ int li = 0;
|
|
|
//点采集
|
|
|
private void button25_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
+
|
|
|
long[] XrayData = new long[2000];
|
|
|
Dictionary<string, double> listElement = new Dictionary<string, double>();
|
|
|
- iExtender.XrayPointCollectiong(200,1, 1, out XrayData, out listElement);
|
|
|
+ iExtender.XrayPointCollectiong(200,44, 55, out XrayData, out listElement);
|
|
|
|
|
|
ShowData(XrayData, listElement);
|
|
|
+ li++;
|
|
|
+ Console.WriteLine(li.ToString());
|
|
|
+ //byte[] bArray = new byte[8000];
|
|
|
+
|
|
|
+ //for (int i = 0; i < 2000; i++)
|
|
|
+ //{
|
|
|
+ // byte[] temps = BitConverter.GetBytes(XrayData[i]);
|
|
|
+ // bArray[i * 4] = temps[0];
|
|
|
+ // bArray[i * 4 + 1] = temps[1];
|
|
|
+ // bArray[i * 4 + 2] = temps[2];
|
|
|
+ // bArray[i * 4 + 3] = temps[3];
|
|
|
+ //}
|
|
|
+
|
|
|
+ //SQLiteConnection m_db = new SQLiteConnection("data source =" + @"E:\HOZ\Test\MeasureDB.db");
|
|
|
+ //m_db.Open();
|
|
|
+
|
|
|
+ ////开启一个事务
|
|
|
+ //using (SQLiteTransaction tr = m_db.BeginTransaction())
|
|
|
+ //{
|
|
|
+ // //向能谱数据表插入数据
|
|
|
+ // string sql = "INSERT INTO XrayData(ID, APID, Type, X, Y, AreasID, ElementNum, XrayData) values ("
|
|
|
+ // + 2.ToString() + ","
|
|
|
+ // + 3.ToString() + ","
|
|
|
+ // + 0.ToString() + ","
|
|
|
+ // + 111.ToString() + ","
|
|
|
+ // + 222.ToString() + ","
|
|
|
+ // + (-1).ToString() + ","
|
|
|
+ // + listElement.Count.ToString() + ",:XrayData)";
|
|
|
+
|
|
|
+ // SQLiteCommand command = new SQLiteCommand(sql, m_db);
|
|
|
+ // command.Parameters.Add("XrayData", System.Data.DbType.Binary).Value = bArray; // BLOB
|
|
|
+ // command.ExecuteNonQuery();
|
|
|
+
|
|
|
+ // //向能谱元素表插入数据
|
|
|
+ // int i = 0;
|
|
|
+ // foreach (KeyValuePair<string, double> element in listElement)
|
|
|
+ // {
|
|
|
+
|
|
|
+ // sql = "INSERT INTO Element(XayID, ElementNum, ElementID, Name, Percent) values ("
|
|
|
+ // + 2.ToString() + ","
|
|
|
+ // + listElement.Count.ToString() + ","
|
|
|
+ // + i.ToString() + ",'"
|
|
|
+ // + element.Key + "',"
|
|
|
+ // + element.Value.ToString() + ")";
|
|
|
+
|
|
|
+ // command = new SQLiteCommand(sql, m_db);
|
|
|
+ // command.ExecuteNonQuery();
|
|
|
+ // i++;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // tr.Commit();
|
|
|
+ //}
|
|
|
+
|
|
|
+ //m_db.Close();
|
|
|
+ //m_db.Dispose();
|
|
|
}
|
|
|
|
|
|
void ShowData(long[] XrayData, Dictionary<string, double> listElement)
|
|
@@ -293,13 +353,27 @@ namespace OxfordTest
|
|
|
}
|
|
|
|
|
|
this.dataGridView1.Rows.Clear();
|
|
|
- int index = this.dataGridView1.Rows.Add();
|
|
|
+ int index = 0;
|
|
|
|
|
|
var ie = listElement.GetEnumerator();
|
|
|
while (ie.MoveNext())
|
|
|
{
|
|
|
+ this.dataGridView1.Rows.Add();
|
|
|
this.dataGridView1.Rows[index].Cells[0].Value = ie.Current.Key;
|
|
|
this.dataGridView1.Rows[index].Cells[1].Value = ie.Current.Value;
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ void ShowReadData(long[] XrayData)
|
|
|
+ {
|
|
|
+ Series series = chart1.Series[1];
|
|
|
+ series.Points.Clear();
|
|
|
+
|
|
|
+ for (int i = 0; i < 2000; i++)
|
|
|
+ {
|
|
|
+ series.Points.AddXY(i, XrayData[i]);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -329,5 +403,142 @@ namespace OxfordTest
|
|
|
iExtender.XrayAreaCollectiong(200, listSeg, out XrayData, out listElement);
|
|
|
ShowData(XrayData, listElement);
|
|
|
}
|
|
|
+
|
|
|
+ private void btnCreateDB_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ MeasureFile msf = new MeasureFile();
|
|
|
+ msf.FileName = @"E:\HOZ\Test\asd.msf";
|
|
|
+ MeasureDB db = new MeasureDB(msf);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void btnReadP_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ SQLiteConnection m_db = new SQLiteConnection("data source =" + @"E:\HOZ\Test\MeasureDB.db");
|
|
|
+ m_db.Open();
|
|
|
+
|
|
|
+ String sql = "Select XrayData from XrayData where ID =" + NUDNum.Value.ToString();
|
|
|
+ //SQLiteDataAdapter adapter = new SQLiteDataAdapter(sql, m_db);
|
|
|
+ //DataSet ds = new DataSet();
|
|
|
+ //adapter.Fill(ds);
|
|
|
+ //DataTable dt = ds.Tables[0];
|
|
|
+
|
|
|
+ SQLiteCommand cmd = new SQLiteCommand(sql, m_db);
|
|
|
+ SQLiteDataReader sdr = cmd.ExecuteReader();
|
|
|
+ sdr.Read();
|
|
|
+ byte[] blob = null;
|
|
|
+ blob = new byte[sdr.GetBytes(0, 0, null, 0, int.MaxValue)];
|
|
|
+ sdr.GetBytes(0, 0, blob, 0, blob.Length);
|
|
|
+
|
|
|
+ sdr.Close();
|
|
|
+ m_db.Close();
|
|
|
+ m_db.Dispose();
|
|
|
+
|
|
|
+ long[] rd = new long[blob.Length / 4];
|
|
|
+ for(int i=0;i<rd.Length;i++)
|
|
|
+ {
|
|
|
+ long temp = BitConverter.ToInt32(blob, i * 4);
|
|
|
+ rd[i] = temp + 10;
|
|
|
+ }
|
|
|
+
|
|
|
+ ShowReadData(rd);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void btnTest_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ List<Point> listPoints = new List<Point>();
|
|
|
+ List<List<Segment>> listFeature = new List<List<Segment>>();
|
|
|
+ List<Segment> ls = new List<Segment>();
|
|
|
+
|
|
|
+ listPoints.Add(new Point(Convert.ToInt32(txtpx1.Text), Convert.ToInt32(txtpy1.Text)));
|
|
|
+ listPoints.Add(new Point(Convert.ToInt32(txtpx2.Text), Convert.ToInt32(txtpy2.Text)));
|
|
|
+ listPoints.Add(new Point(Convert.ToInt32(txtpx3.Text), Convert.ToInt32(txtpy3.Text)));
|
|
|
+ listPoints.Add(new Point(Convert.ToInt32(txtpx4.Text), Convert.ToInt32(txtpy4.Text)));
|
|
|
+ listPoints.Add(new Point(Convert.ToInt32(txtpx5.Text), Convert.ToInt32(txtpy5.Text)));
|
|
|
+
|
|
|
+ Segment sgt = new Segment();
|
|
|
+ sgt.X = Convert.ToInt32(txtarea1x1.Text);
|
|
|
+ sgt.Y = Convert.ToInt32(txtarea1y1.Text);
|
|
|
+ sgt.Length = Convert.ToInt32(txtarea1l1.Text);
|
|
|
+ ls.Add(sgt);
|
|
|
+ sgt = new Segment();
|
|
|
+ sgt.X = Convert.ToInt32(txtarea1x2.Text);
|
|
|
+ sgt.Y = Convert.ToInt32(txtarea1y2.Text);
|
|
|
+ sgt.Length = Convert.ToInt32(txtarea1l2.Text);
|
|
|
+ ls.Add(sgt);
|
|
|
+ sgt = new Segment();
|
|
|
+ sgt.X = Convert.ToInt32(txtarea1x3.Text);
|
|
|
+ sgt.Y = Convert.ToInt32(txtarea1y3.Text);
|
|
|
+ sgt.Length = Convert.ToInt32(txtarea1l3.Text);
|
|
|
+ ls.Add(sgt);
|
|
|
+
|
|
|
+ listFeature.Add(ls);
|
|
|
+
|
|
|
+ ls = new List<Segment>();
|
|
|
+ sgt = new Segment();
|
|
|
+ sgt.X = Convert.ToInt32(txtarea2x1.Text);
|
|
|
+ sgt.Y = Convert.ToInt32(txtarea2y1.Text);
|
|
|
+ sgt.Length = Convert.ToInt32(txtarea2l1.Text);
|
|
|
+ ls.Add(sgt);
|
|
|
+ sgt = new Segment();
|
|
|
+ sgt.X = Convert.ToInt32(txtarea2x2.Text);
|
|
|
+ sgt.Y = Convert.ToInt32(txtarea2y2.Text);
|
|
|
+ sgt.Length = Convert.ToInt32(txtarea2l2.Text);
|
|
|
+ ls.Add(sgt);
|
|
|
+ sgt = new Segment();
|
|
|
+ sgt.X = Convert.ToInt32(txtarea2x3.Text);
|
|
|
+ sgt.Y = Convert.ToInt32(txtarea2y3.Text);
|
|
|
+ sgt.Length = Convert.ToInt32(txtarea2l3.Text);
|
|
|
+ ls.Add(sgt);
|
|
|
+
|
|
|
+ listFeature.Add(ls);
|
|
|
+
|
|
|
+ //向数据库插入分析点数据
|
|
|
+ MeasureFile msf = new MeasureFile();
|
|
|
+ msf.FileName = @"E:\HOZ\Test\asd.msf";
|
|
|
+ msf.MParam.EDSP.DwellTime = 200;
|
|
|
+ msf.MParam.EDSP.AreaTime = 200;
|
|
|
+ MeasureDB m_MeasDB = new MeasureDB(msf);
|
|
|
+
|
|
|
+ int analysispoints_id = 1;
|
|
|
+
|
|
|
+ m_MeasDB.InsetAPoint(analysispoints_id, "aa", @"D:\\", listPoints.Count, listFeature.Count);
|
|
|
+
|
|
|
+ long[] XrayData = null;
|
|
|
+ Dictionary<string, double> listElement = null;
|
|
|
+ int xraydata_id = 1;
|
|
|
+
|
|
|
+ //点扫描数据存储
|
|
|
+ for(int i=0;i<listPoints.Count;i++)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Points:" + i.ToString());
|
|
|
+ XrayData = new long[2000];
|
|
|
+ listElement = new Dictionary<string, double>();
|
|
|
+ Console.WriteLine("Points:" + i.ToString());
|
|
|
+ iExtender.XrayPointCollectiong(msf.MParam.EDSP.DwellTime, listPoints[i].X, listPoints[i].Y, out XrayData, out listElement);
|
|
|
+ Console.WriteLine("Points:" + i.ToString());
|
|
|
+ m_MeasDB.InsertAPointXay(analysispoints_id, xraydata_id, listPoints[i].X, listPoints[i].Y, XrayData, listElement);
|
|
|
+ xraydata_id++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //面扫描数据存储
|
|
|
+ int AreasNo = 0;
|
|
|
+ foreach (List<Segment> listSeg in listFeature)
|
|
|
+ {
|
|
|
+ XrayData = new long[2000];
|
|
|
+ listElement = new Dictionary<string, double>();
|
|
|
+
|
|
|
+ iExtender.XrayAreaCollectiong(msf.MParam.EDSP.AreaTime, listSeg, out XrayData, out listElement);
|
|
|
+
|
|
|
+ //写入数据库
|
|
|
+
|
|
|
+ AreasNo++;
|
|
|
+ m_MeasDB.InsertAAreaXay(analysispoints_id, xraydata_id, AreasNo, listSeg, XrayData, listElement);
|
|
|
+ xraydata_id++;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_MeasDB.CloseDB();
|
|
|
+
|
|
|
+ MessageBox.Show("测试完成!");
|
|
|
+ }
|
|
|
}
|
|
|
}
|