Commit cbf0aa24 LN

历史记录查询修改

1 个父辈 9475593b
5S1 2 3
6C1D1 2 5
6D551 2 7
7H5S1 2 3
......@@ -31,8 +31,9 @@ namespace OnlineStore.AutoCountClient
}
else
{
DateTime time1 = DateTime.Now.AddDays(-4);
dtpStartTime.Value = new DateTime(time1.Year, time1.Month, time1.Day, 0, 0, 0);
DateTime time1 = DateTime.Now.AddHours(-6);
//dtpStartTime.Value = new DateTime(time1.Year, time1.Month, time1.Day, 0, 0, 0);
dtpStartTime.Value = time1;
DateTime time = DateTime.Now.AddDays(-1);
dtpEndTime.Value = new DateTime(time.Year, time.Month, time.Day, 23, 59, 59);
dtpEndTime.Value = DateTime.Now;
......@@ -66,41 +67,47 @@ namespace OnlineStore.AutoCountClient
PreStartTime = startTime;
PreEndTime = endTime;
string code = txtCode.Text.Trim();
lastList = new List<XRayHistory>();
string[][] array = null;
bool result = RobotManager.robot.sQLite.Select(code, startTime.ToString(), endTime.ToString(), out array);
LogUtil.error("查数据【" + code + "】【" + startTime.ToString() + "】【" + endTime.ToString() + "】结果:" + result + "," + RobotManager.robot.sQLite.ErrInfo);
if (array != null && array.Length > 0)
{
LogUtil.info("共查询到【" + array.Length + "】行数据");
this.dataGridView1.Rows.Clear();
int index = 1;
foreach (string[] a in array)
try
{
lastList = new List<XRayHistory>();
string[][] array = null;
string str = "yyyy-MM-dd HH:mm:ss";
string startStr = startTime.ToString(str);
string endStr = endTime.ToString(str);
bool result = RobotManager.robot.sQLite.Select(code, startStr,endStr, out array);
LogUtil.error("查数据【" + code + "】【" + startStr + "】【" + endStr + "】结果:" + result + "," + RobotManager.robot.sQLite.ErrInfo);
if (array != null && array.Length > 0)
{
DataGridViewRow view = new DataGridViewRow();
view.CreateCells(dataGridView1);
view.Cells[0].Value = index;
LogUtil.info("共查询到【" + array.Length + "】行数据");
lastList.Add(new XRayHistory(index, a[0], a[1], a[2], a[3], a[4]));
for (int i = 1; i < a.Length; i++)
this.dataGridView1.Rows.Clear();
int index = 1;
foreach (string[] a in array)
{
view.Cells[i].Value = a[i];
DataGridViewRow view = new DataGridViewRow();
view.CreateCells(dataGridView1);
view.Cells[0].Value = index;
if (a.Length >= 6)
{
XRayHistory his = new XRayHistory(index, a[0], a[1], a[2], a[3], a[4], a[5]);
lastList.Add(his);
view.Cells[Column_Code.Index] .Value= his.Code;
view.Cells[Column_Count.Index].Value = his.Count;
view.Cells[Column_Data.Index].Value = his.DataStr;
view.Cells[Column_Height.Index].Value = his.Height;
view.Cells[Column_Width.Index].Value = his.Width;
view.Cells[Column_ImageName.Index].Value = his.FileName;
}
dataGridView1.Rows.Add(view);
index++;
}
//view.Cells[0].Value = point.pointNum.ToString();
//view.Cells[1].Value = point.PartNum.ToString();
//view.Cells[2].Value = point.pointName;
//view.Cells[3].Value = point.PositionX.ToString();
//view.Cells[4].Value = point.PositionY.ToString();
//view.Cells[5].Value = point.NodePositionX.ToString();
//view.Cells[6].Value = point.NodePositionY.ToString();
//view.Cells[7].Value = point.PositionNum.ToString();
//view.Cells[8].Value = point.NeedSoldering;
//view.Cells[9].Value = point.WeldTemp;
dataGridView1.Rows.Add(view);
index++;
}
}catch(Exception ex)
{
LogUtil.error("查询数据出错:" + ex.ToString());
}
}
private void btnBack_Click(object sender, EventArgs e)
......@@ -129,7 +136,7 @@ namespace OnlineStore.AutoCountClient
}
List<string> list = new List<string>();
list.Add("编号,条码,高度,宽度,数量,图片文件名");
list.Add("编号,条码,高度,宽度,数量,图片文件名,时间");
foreach(XRayHistory obj in lastList)
{
list.Add(obj.ToCSVStr());
......@@ -150,13 +157,14 @@ namespace OnlineStore.AutoCountClient
public class XRayHistory
{
public XRayHistory(int num,string code, string h, string w, string c, string fname)
public XRayHistory(int num,string code, string h, string w, string c, string fname,string dataStr)
{
this.Code = code;
this.Height = h;
this.Width = w;
this.Count = c;
this.FileName = fname;
this.DataStr = dataStr;
}
public int Num = 0;
......@@ -169,10 +177,11 @@ namespace OnlineStore.AutoCountClient
public string Count = "";
public string FileName = "";
public string DataStr = "";
public string ToCSVStr()
{
return Num+","+ Code + "," + Height + "," + Width + "," + Count + "," + FileName + ",";
return Num+","+ Code + "," + Height + "," + Width + "," + Count + "," + FileName + ","+DataStr;
}
}
}
......@@ -123,33 +123,18 @@
<metadata name="Column_Code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Width.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Height.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="Column_Data.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_ImageName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Num.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Width.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Height.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_ImageName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
......
......@@ -424,15 +424,22 @@ namespace OnlineStore.AutoCountClient
btnWorkTest.Enabled = false;
try
{
string filePath = txtImage.Text.Trim();
if (!File.Exists(filePath))
{
MessageBox.Show("请先选择正确的图片");
return;
}
txtResult.Text = "点料中...";
int th = (int)numTh.Value;
int wsize = (int)numWSize.Value;
int outCount = 0;
// equipBean.countImage.GetCount(th, out outCount);
int n = equipBean.carerayImage.GetCount(2, 3, out outCount, out Asa.API.EyemImage tpDstImg);
int n = equipBean.carerayImage.GetLocalCount(filePath, th, wsize, out outCount, out Asa.API.EyemImage tpDstImg);
txtResult.Text = outCount.ToString();
LogUtil.info(equipBean.Name + "用户点击 点料测试 结果[" + n + "]:" + outCount);
LogUtil.info(equipBean.Name + "用户点击 点料测试【" + filePath + "】【" + th + "】【" + wsize + "】 结果[" + n + "]:" + outCount);
}
catch (Exception ex)
{
......@@ -450,6 +457,21 @@ namespace OnlineStore.AutoCountClient
MessageBox.Show("保存阈值[" + th + "]成功!");
LogUtil.info("用户点击:保存阈值[" + th + "]成功!");
}
private void btnSelImage_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
openDialog.Title = "请选择要点料的图片";
openDialog.Filter = "(*.png)|*.png";
openDialog.DefaultExt = "png";
openDialog.InitialDirectory = Application.StartupPath + @"\XRAY\tif";
System.Windows.Forms.DialogResult result = openDialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel)
{
return;
}
txtImage.Text = openDialog.FileName;
}
}
}
......
......@@ -120,6 +120,9 @@
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 11</value>
</metadata>
<metadata name="fileSystemWatcher1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>107, 11</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
......
类型,阈值,面积
6J.42001.181,45,16
TY.7H230.00M,45,
6H.12160.0RH,45,11
8C.R2003.H81,45,35
8C.2R006.A8H,45,
8C.1R004.D8H,45,
类型,阈值,窗口大小
6D5S1,2,3
6C1D1,2,5
6D551,2,7
7H5S1,2,3
......@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary
public XRay xRay = null;
// public CountImage countImage = null;
// public CountImage countImage = null;
public CarerayImage carerayImage = null;
public bool xRayCanStart = false;
......@@ -39,7 +39,7 @@ namespace OnlineStore.DeviceLibrary
// private string path2_png = Application.StartupPath + @"\XRAY\png";
private string path2_out = Application.StartupPath + @"\XRAY\out\";
private string path3_area = Application.StartupPath + @"\XRAY\area.txt";
private string configPath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.CounParamConfig);
private Dictionary<string, CountParam> countParamMap = new Dictionary<string, CountParam>();
public X_RAY_Equip(string cid, XRay_Config config)
......@@ -65,7 +65,7 @@ namespace OnlineStore.DeviceLibrary
private void XRayLoad()
{
try
{
{
//countImage = new CountImage("Count");
//countImage.SetDirectory(path1_tif, path2_out, path3_area);
//LogUtil.info(Name + "CountImage path1【" + path1_tif + "】");
......@@ -74,7 +74,7 @@ namespace OnlineStore.DeviceLibrary
//LogUtil.info(Name + "CountImage SetDirectory: 完成");
carerayImage = new CarerayImage("XRay");
bool cResult = carerayImage.Open();
bool cResult = carerayImage.Open();
LogUtil.info(Name + "carerayImage.Open()=" + cResult);
xRay = new XRay("XRay");
......@@ -103,40 +103,7 @@ namespace OnlineStore.DeviceLibrary
{
System.IO.Directory.CreateDirectory(path2_out);
}
countParamMap = new Dictionary<string, CountParam>();
if (File.Exists(configPath))
{
try
{
string[] lines = File.ReadAllLines(configPath);
int index = -1;
foreach (string line in lines)
{
index++;
if (index.Equals(0))
{
continue;
}
CountParam param = CountParam.NewParam(line);
if (param != null)
{
if (!countParamMap.ContainsKey(param.PN))
{
countParamMap.Add(param.PN, param);
}
}
}
}
catch (Exception ex)
{
LogUtil.error("解析点料配置文件【" + configPath + "】出错:" + ex.ToString());
}
LogUtil.info("加载点料参数共【"+countParamMap.Count+"】条有效数据" + configPath);
}
else
{
LogUtil.error("未找到点料参数文件:" + configPath);
}
LoadParamMap();
}
catch (Exception ex)
{
......@@ -329,7 +296,7 @@ namespace OnlineStore.DeviceLibrary
}
}
LockOnProcess();
}
}
#endregion
......@@ -397,6 +364,46 @@ namespace OnlineStore.DeviceLibrary
return msg;
}
private void LoadParamMap()
{
countParamMap = new Dictionary<string, CountParam>();
string configPath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.CounParamConfig);
if (File.Exists(configPath))
{
try
{
string[] lines = File.ReadAllLines(configPath);
int index = -1;
foreach (string line in lines)
{
index++;
if (index.Equals(0))
{
continue;
}
CountParam param = CountParam.NewParam(line);
if (param != null)
{
if (!countParamMap.ContainsKey(param.PN))
{
countParamMap.Add(param.PN, param);
}
}
}
}
catch (Exception ex)
{
LogUtil.error("解析点料配置文件【" + configPath + "】出错:" + ex.ToString());
}
LogUtil.info("加载点料参数共【" + countParamMap.Count + "】条有效数据" + configPath);
}
else
{
LogUtil.error("未找到点料参数文件:" + configPath);
}
}
}
public class CountParam
......@@ -407,8 +414,15 @@ namespace OnlineStore.DeviceLibrary
this.Threshold = th;
this.AreaValue = area;
}
public CountParam(string pn, int th, int size)
{
this.PN = pn;
this.Threshold = th;
this.WindowSize = size;
}
public string PN = "";
public int Threshold = 0;
public int WindowSize = 0;
public string AreaValue = "";
internal static CountParam NewParam(string line)
......@@ -420,9 +434,9 @@ namespace OnlineStore.DeviceLibrary
{
string pn = array[0].Trim();
int th = Convert.ToInt32(array[1].Trim());
string a = array[2].Trim();
int size = Convert.ToInt32(array[2].Trim());
return new CountParam(pn, th, a);
return new CountParam(pn, th, size);
}
}
catch (Exception ex)
......@@ -431,6 +445,8 @@ namespace OnlineStore.DeviceLibrary
return null;
}
}
}
......@@ -326,7 +326,7 @@ namespace OnlineStore.DeviceLibrary
private string lastFileName = "";
private int lastTh = 0;
private int lastWSize = 0;
private void XW15_GetResult()
{
if (IOValue(IO_Type.X_Lock_On).Equals(IO_VALUE.LOW))
......@@ -346,8 +346,9 @@ namespace OnlineStore.DeviceLibrary
//WorkLog("点料:获取点料结果[" + lastTh + "]=【" + count + "】,result=" + result + ",保存并上传结果");
WorkLog("点料:开始调用 countImage.GetCount ");
int n = carerayImage.GetCount(2, 3, out count, out Asa.API.EyemImage tpDstImg);
WorkLog("点料:获取点料结果 【" + count + "】,n =" + n + ",保存并上传结果");
string fileP = path1_tif + @"\" + lastFileName;
int n = carerayImage.GetLocalCount(fileP, lastTh, lastWSize, out count, out Asa.API.EyemImage tpDstImg);
WorkLog("点料:获取点料结果 【" + count + "】【"+lastTh+"】【"+lastWSize+"】,n =" + n + ",保存并上传结果");
if (Work_ReelInfo.WareCount <= 0)
{
......@@ -475,20 +476,28 @@ namespace OnlineStore.DeviceLibrary
private void UpdateArea(string codeStr)
{
lastTh = ThresholdValue;
lastWSize = 3;
string[] codeArray = codeStr.Split(';');
string fileValue = "";
string area = "";
if (codeArray.Length.Equals(2))
{
string pn = codeArray[0];
string type = pn.Substring(0, 2) + pn.Substring(pn.Length - 3, 3);
if (countParamMap.ContainsKey(pn))
{
area = countParamMap[pn].AreaValue;
fileValue = lastFileName + " " + area;
lastTh = countParamMap[pn].Threshold;
}else if (countParamMap.ContainsKey(type))
{
lastTh = countParamMap[type].Threshold;
lastWSize = countParamMap[type].WindowSize;
}
}
LogUtil.info("【" + codeStr + "】使用参数【" + lastTh + "】【" + area + "】,文件名【" + lastFileName + "】内容【" + fileValue + "】");
LogUtil.info("【" + codeStr + "】使用参数【" + lastTh + "】【" + lastWSize + "】 ");
//LogUtil.info("【" + codeStr + "】使用参数【" + lastTh + "】【" + area + "】,文件名【" + lastFileName + "】内容【" + fileValue + "】");
File.WriteAllText(path3_area, fileValue);
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!