Commit ab52424f LN

增加点料参数

1 个父辈 989393cb
......@@ -50,6 +50,7 @@
<!--XRay射线最后一次使用时间-->
<add key ="XRay_Data" value ="2020-6-2"/>
<add key ="ThresholdValue" value ="30"/>
<add key ="CounParamConfig" value ="\XRAY\countParam.csv"/>
</appSettings>
<log4net>
......
......@@ -83,5 +83,7 @@ namespace OnlineStore.Common
public static string XRay_Data = "XRay_Data";
public static string ThresholdValue = "ThresholdValue";
public static string CounParamConfig = "CounParamConfig";
}
}
......@@ -139,6 +139,9 @@
<Content Include="Label\20200520172352.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\area.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\out\out.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
......@@ -172,6 +175,9 @@
<None Include="RobotConfig\Config_OutputEquip.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="XRAY\countParam.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
001279-4005.png 40
\ No newline at end of file
类型,阈值,面积
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,
......@@ -4,6 +4,7 @@ using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
......@@ -14,7 +15,7 @@ namespace OnlineStore.DeviceLibrary
{
public partial class X_RAY_Equip : EquipBase
{
public bool OpenXLine = true ;
public bool OpenXLine = true;
public ReelInfo In_ReelInfo = new ReelInfo();
public ReelInfo Work_ReelInfo = new ReelInfo();
......@@ -35,8 +36,11 @@ namespace OnlineStore.DeviceLibrary
private string path_XRAY = Application.StartupPath + @"\XRAY\";
private string path1_tif = Application.StartupPath + @"\XRAY\tif";
private string path2_png = Application.StartupPath + @"\XRAY\png";
private string path3_out = Application.StartupPath + @"\XRAY\out";
// 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)
{
......@@ -50,8 +54,9 @@ namespace OnlineStore.DeviceLibrary
ledProcessTimer.Elapsed += LedProcess;
IoCheckTimer.Elapsed += IoCheckTimerProcess;
MoveInfo = new RobotMoveInfo(Name);
SecMoveInfo = new RobotMoveInfo( Name.Trim() + "-SMove");
Task.Factory.StartNew(delegate {
SecMoveInfo = new RobotMoveInfo(Name.Trim() + "-SMove");
Task.Factory.StartNew(delegate
{
XRayLoad();
});
......@@ -61,12 +66,11 @@ namespace OnlineStore.DeviceLibrary
{
try
{
countImage = new CountImage("XRay");
countImage.SetDirectory(path1_tif, path2_png, path3_out);
countImage.SetDirectory(path1_tif, path2_out, path3_area);
LogUtil.info(Name + "CountImage path1【" + path1_tif + "】");
LogUtil.info(Name + "CountImage path2【" + path2_png + "】");
LogUtil.info(Name + "CountImage path3【" + path3_out + "】");
LogUtil.info(Name + "CountImage path2【" + path2_out + "】");
LogUtil.info(Name + "CountImage path3【" + path3_area + "】");
LogUtil.info(Name + "CountImage SetDirectory: 完成");
carerayImage = new CarerayImage("XRay");
......@@ -91,13 +95,47 @@ namespace OnlineStore.DeviceLibrary
{
System.IO.Directory.CreateDirectory(path1_tif);
}
if (!System.IO.Directory.Exists(path2_png))
//if (!System.IO.Directory.Exists(path2_png))
//{
// System.IO.Directory.CreateDirectory(path2_png);
//}
if (!System.IO.Directory.Exists(path2_out))
{
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))
{
System.IO.Directory.CreateDirectory(path2_png);
continue;
}
if (!System.IO.Directory.Exists(path3_out))
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
{
System.IO.Directory.CreateDirectory(path3_out);
LogUtil.error("未找到点料参数文件:" + configPath);
}
}
catch (Exception ex)
......@@ -143,7 +181,7 @@ namespace OnlineStore.DeviceLibrary
return false;
}
SetAllTimer(false );
SetAllTimer(false);
MoveInfo.EndMove();
SecMoveInfo.EndMove();
runStatus = RobotRunStatus.HomeMoving;
......@@ -175,7 +213,7 @@ namespace OnlineStore.DeviceLibrary
isNoAirCheck = false;
isInPro = false;
MoveInfo.NextMoveStep(StepEnum.XR01_CloseXLock);
WorkLog( "XRay复位 :关闭X光互锁信号");
WorkLog("XRay复位 :关闭X光互锁信号");
IOMove(IO_Type.X_Lock_On, IO_VALUE.LOW);
}
......@@ -261,12 +299,6 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.X_InLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.X_MLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.X_OLine_Run, IO_VALUE.LOW);
//IOMove(IO_Type.X_InDoor_Up, IO_VALUE.LOW);
//IOMove(IO_Type.X_InDoor_Down, IO_VALUE.LOW);
//IOMove(IO_Type.X_OutDoor_Up, IO_VALUE.LOW);
//IOMove(IO_Type.X_OutDoor_Down, IO_VALUE.LOW);
//IOMove(IO_Type.X_StopCylinder_Up, IO_VALUE.LOW);
//IOMove(IO_Type.X_StopCylinder_Down, IO_VALUE.LOW);
}
......@@ -359,5 +391,39 @@ namespace OnlineStore.DeviceLibrary
return msg;
}
}
public class CountParam
{
public CountParam(string pn, int th, string area)
{
this.PN = pn;
this.Threshold = th;
this.AreaValue = area;
}
public string PN = "";
public int Threshold = 0;
public string AreaValue = "";
internal static CountParam NewParam(string line)
{
try
{
string[] array = line.Split(',');
if (array.Length >= 3)
{
string pn = array[0].Trim();
int th = Convert.ToInt32(array[1].Trim());
string a = array[2].Trim();
return new CountParam(pn, th, a);
}
}
catch (Exception ex)
{
}
return null;
}
}
}
......@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
......@@ -154,11 +155,11 @@ namespace OnlineStore.DeviceLibrary
else
{
MoveInfo.NextMoveStep(StepEnum.XW08_DoorClose);
WorkLog("料盘处理:左侧门关闭,右侧门关闭,准备开始点料");
//WorkLog("料盘处理:左侧门关闭,右侧门关闭,挡停放行,准备开始点料");
// WorkLog("料盘处理:左侧门关闭,右侧门关闭,准备开始点料");
WorkLog("料盘处理:左侧门关闭,右侧门关闭,挡停放行,准备开始点料");
CylinderMove(MoveInfo, IO_Type.X_InDoor_Down, IO_Type.X_InDoor_Up);
CylinderMove(MoveInfo, IO_Type.X_OutDoor_Down, IO_Type.X_OutDoor_Up);
// CylinderMove(MoveInfo, IO_Type.X_StopCylinder_Down, IO_Type.X_StopCylinder_Up);
CylinderMove(MoveInfo, IO_Type.X_StopCylinder_Down, IO_Type.X_StopCylinder_Up);
}
}
......@@ -306,6 +307,7 @@ namespace OnlineStore.DeviceLibrary
}
private string lastFileName = "";
private int lastTh = 0;
private void XW13_GetXRayImage()
{
if (IOValue(IO_Type.X_Lock_On).Equals(IO_VALUE.LOW))
......@@ -335,16 +337,16 @@ namespace OnlineStore.DeviceLibrary
xRay.Stop();
}
int count = 99999;
countImage.GetCount(ThresholdValue, out count);
countImage.GetCount(lastTh, out count);
InXWork = false;
WorkLog("点料:获取点料结果["+ThresholdValue+"]=【" + count + "】,保存并上传结果");
WorkLog("点料:获取点料结果["+ lastTh + "]=【" + count + "】,保存并上传结果");
if (Work_ReelInfo.WareCount <= 0)
{
MoveInfo.MoveParam.WareCount = count;
Work_ReelInfo.WareCount = count;
}
string outF = path3_out + @"\" + lastFileName;
string outF = path2_out + @"\" + lastFileName;
try
{
if (System.IO.File.Exists(outF))
......@@ -404,6 +406,8 @@ namespace OnlineStore.DeviceLibrary
}
WorkLog("点料:获取X射线图形,保存到: " + fileP + ",备份到:" + backFile + ",记录时间" + lastData + ",停止X射线");
GetImageEvent?.Invoke(bmp);
UpdateArea(Work_ReelInfo.WareCode);
}
else
{
......@@ -434,7 +438,23 @@ namespace OnlineStore.DeviceLibrary
}
return lastFileName;
}
private void UpdateArea(string codeStr)
{
lastTh = ThresholdValue;
string[] codeArray = codeStr.Split(';');
if (codeArray.Length.Equals(2))
{
string pn = codeArray[0];
if (countParamMap.ContainsKey(pn))
{
string area = countParamMap[pn].AreaValue;
string fileValue = lastFileName + " " + area;
lastTh = countParamMap[pn].Threshold;
LogUtil.info("【" + codeStr + "】使用参数【" + lastTh + "】【" + area + "】,文件名【" + lastFileName + "】");
File.WriteAllText(path3_area, fileValue);
}
}
}
private void ClearFilePath()
{
try
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!