Commit ab52424f LN

增加点料参数

1 个父辈 989393cb
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
<!--XRay射线最后一次使用时间--> <!--XRay射线最后一次使用时间-->
<add key ="XRay_Data" value ="2020-6-2"/> <add key ="XRay_Data" value ="2020-6-2"/>
<add key ="ThresholdValue" value ="30"/> <add key ="ThresholdValue" value ="30"/>
<add key ="CounParamConfig" value ="\XRAY\countParam.csv"/>
</appSettings> </appSettings>
<log4net> <log4net>
......
...@@ -83,5 +83,7 @@ namespace OnlineStore.Common ...@@ -83,5 +83,7 @@ namespace OnlineStore.Common
public static string XRay_Data = "XRay_Data"; public static string XRay_Data = "XRay_Data";
public static string ThresholdValue = "ThresholdValue"; public static string ThresholdValue = "ThresholdValue";
public static string CounParamConfig = "CounParamConfig";
} }
} }
...@@ -139,6 +139,9 @@ ...@@ -139,6 +139,9 @@
<Content Include="Label\20200520172352.xml"> <Content Include="Label\20200520172352.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="XRAY\area.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\out\out.txt"> <Content Include="XRAY\out\out.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
...@@ -172,6 +175,9 @@ ...@@ -172,6 +175,9 @@
<None Include="RobotConfig\Config_OutputEquip.csv"> <None Include="RobotConfig\Config_OutputEquip.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="XRAY\countParam.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
001279-4005.png 40
\ No newline at end of file \ 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; ...@@ -4,6 +4,7 @@ using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
...@@ -11,10 +12,10 @@ using System.Threading.Tasks; ...@@ -11,10 +12,10 @@ using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary namespace OnlineStore.DeviceLibrary
{ {
public partial class X_RAY_Equip : EquipBase public partial class X_RAY_Equip : EquipBase
{ {
public bool OpenXLine = true ; public bool OpenXLine = true;
public ReelInfo In_ReelInfo = new ReelInfo(); public ReelInfo In_ReelInfo = new ReelInfo();
public ReelInfo Work_ReelInfo = new ReelInfo(); public ReelInfo Work_ReelInfo = new ReelInfo();
...@@ -23,11 +24,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -23,11 +24,11 @@ namespace OnlineStore.DeviceLibrary
public XRay_Config Config; public XRay_Config Config;
public XRay xRay = null; public XRay xRay = null;
public CountImage countImage = null; public CountImage countImage = null;
public CarerayImage carerayImage = null; public CarerayImage carerayImage = null;
public bool xRayCanStart = false; public bool xRayCanStart = false;
public string LastXRayState = "未知"; public string LastXRayState = "未知";
public bool InXWork = false; public bool InXWork = false;
...@@ -35,8 +36,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -35,8 +36,11 @@ namespace OnlineStore.DeviceLibrary
private string path_XRAY = Application.StartupPath + @"\XRAY\"; private string path_XRAY = Application.StartupPath + @"\XRAY\";
private string path1_tif = Application.StartupPath + @"\XRAY\tif"; private string path1_tif = Application.StartupPath + @"\XRAY\tif";
private string path2_png = Application.StartupPath + @"\XRAY\png"; // private string path2_png = Application.StartupPath + @"\XRAY\png";
private string path3_out = Application.StartupPath + @"\XRAY\out"; 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) public X_RAY_Equip(string cid, XRay_Config config)
{ {
...@@ -45,28 +49,28 @@ namespace OnlineStore.DeviceLibrary ...@@ -45,28 +49,28 @@ namespace OnlineStore.DeviceLibrary
baseConfig = config; baseConfig = config;
IsDebug = config.IsDebug.Equals(1); IsDebug = config.IsDebug.Equals(1);
Name = (" " + "点料模块 "); Name = (" " + "点料模块 ");
Init(); Init();
ledProcessTimer.Elapsed += LedProcess; ledProcessTimer.Elapsed += LedProcess;
IoCheckTimer.Elapsed += IoCheckTimerProcess; IoCheckTimer.Elapsed += IoCheckTimerProcess;
MoveInfo = new RobotMoveInfo(Name); MoveInfo = new RobotMoveInfo(Name);
SecMoveInfo = new RobotMoveInfo( Name.Trim() + "-SMove"); SecMoveInfo = new RobotMoveInfo(Name.Trim() + "-SMove");
Task.Factory.StartNew(delegate { Task.Factory.StartNew(delegate
XRayLoad(); {
XRayLoad();
}); });
} }
private void XRayLoad() private void XRayLoad()
{ {
try try
{ {
countImage = new CountImage("XRay"); 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 path1【" + path1_tif + "】");
LogUtil.info(Name + "CountImage path2【" + path2_png + "】"); LogUtil.info(Name + "CountImage path2【" + path2_out + "】");
LogUtil.info(Name + "CountImage path3【" + path3_out + "】"); LogUtil.info(Name + "CountImage path3【" + path3_area + "】");
LogUtil.info(Name + "CountImage SetDirectory: 完成"); LogUtil.info(Name + "CountImage SetDirectory: 完成");
carerayImage = new CarerayImage("XRay"); carerayImage = new CarerayImage("XRay");
...@@ -91,13 +95,47 @@ namespace OnlineStore.DeviceLibrary ...@@ -91,13 +95,47 @@ namespace OnlineStore.DeviceLibrary
{ {
System.IO.Directory.CreateDirectory(path1_tif); 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_png); System.IO.Directory.CreateDirectory(path2_out);
} }
if (!System.IO.Directory.Exists(path3_out)) countParamMap = new Dictionary<string, CountParam>();
if (File.Exists(configPath))
{ {
System.IO.Directory.CreateDirectory(path3_out); 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);
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -143,7 +181,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -143,7 +181,7 @@ namespace OnlineStore.DeviceLibrary
return false; return false;
} }
SetAllTimer(false ); SetAllTimer(false);
MoveInfo.EndMove(); MoveInfo.EndMove();
SecMoveInfo.EndMove(); SecMoveInfo.EndMove();
runStatus = RobotRunStatus.HomeMoving; runStatus = RobotRunStatus.HomeMoving;
...@@ -158,7 +196,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -158,7 +196,7 @@ namespace OnlineStore.DeviceLibrary
public override bool Reset() public override bool Reset()
{ {
StopMove(); StopMove();
runStatus = RobotRunStatus.Reset; runStatus = RobotRunStatus.Reset;
MoveInfo.NewMove(RobotMoveType.Reset); MoveInfo.NewMove(RobotMoveType.Reset);
LogInfo("开始重置: "); LogInfo("开始重置: ");
...@@ -172,10 +210,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -172,10 +210,10 @@ namespace OnlineStore.DeviceLibrary
SetWarnMsg(""); SetWarnMsg("");
alarmType = AlarmType.None; alarmType = AlarmType.None;
isInSuddenDown = false; isInSuddenDown = false;
isNoAirCheck = false; isNoAirCheck = false;
isInPro = false; isInPro = false;
MoveInfo.NextMoveStep(StepEnum.XR01_CloseXLock); MoveInfo.NextMoveStep(StepEnum.XR01_CloseXLock);
WorkLog( "XRay复位 :关闭X光互锁信号"); WorkLog("XRay复位 :关闭X光互锁信号");
IOMove(IO_Type.X_Lock_On, IO_VALUE.LOW); IOMove(IO_Type.X_Lock_On, IO_VALUE.LOW);
} }
...@@ -201,7 +239,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -201,7 +239,7 @@ namespace OnlineStore.DeviceLibrary
CylinderMove(MoveInfo, IO_Type.X_StopCylinder_Up, IO_Type.X_StopCylinder_Down); CylinderMove(MoveInfo, IO_Type.X_StopCylinder_Up, IO_Type.X_StopCylinder_Down);
} }
else else
{ {
WorkLog("XRay复位 :左侧们打开,右侧门打开,挡停不动作"); WorkLog("XRay复位 :左侧们打开,右侧门打开,挡停不动作");
} }
...@@ -219,7 +257,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -219,7 +257,7 @@ namespace OnlineStore.DeviceLibrary
} }
IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH); IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH);
} }
IOMove(IO_Type.X_OLine_Run, IO_VALUE.HIGH); IOMove(IO_Type.X_OLine_Run, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
} }
else if (MoveInfo.IsStep(StepEnum.XR03_LineRun)) else if (MoveInfo.IsStep(StepEnum.XR03_LineRun))
...@@ -246,7 +284,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -246,7 +284,7 @@ namespace OnlineStore.DeviceLibrary
runStatus = RobotRunStatus.Runing; runStatus = RobotRunStatus.Runing;
} }
} }
internal override void StopMove() internal override void StopMove()
{ {
SecMoveInfo.EndMove(); SecMoveInfo.EndMove();
...@@ -261,19 +299,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -261,19 +299,13 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.X_InLine_Run, IO_VALUE.LOW); IOMove(IO_Type.X_InLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.X_MLine_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_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);
} }
public override void StopRun() public override void StopRun()
{ {
SetAllTimer(false); SetAllTimer(false);
StopMove(); StopMove();
runStatus = RobotRunStatus.Wait; runStatus = RobotRunStatus.Wait;
} }
...@@ -286,7 +318,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -286,7 +318,7 @@ namespace OnlineStore.DeviceLibrary
} }
BusyMoveProcess(); BusyMoveProcess();
IOTimeOutProcess(); IOTimeOutProcess();
if (NoAlarm() && MoveInfo.MoveType.Equals(RobotMoveType.None)) if (NoAlarm() && MoveInfo.MoveType.Equals(RobotMoveType.None))
{ {
if (IOValue(IO_Type.X_ReelCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.X_InLine_Check).Equals(IO_VALUE.HIGH)) if (IOValue(IO_Type.X_ReelCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.X_InLine_Check).Equals(IO_VALUE.HIGH))
...@@ -358,6 +390,40 @@ namespace OnlineStore.DeviceLibrary ...@@ -358,6 +390,40 @@ namespace OnlineStore.DeviceLibrary
return msg; 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; ...@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
...@@ -154,11 +155,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -154,11 +155,11 @@ namespace OnlineStore.DeviceLibrary
else else
{ {
MoveInfo.NextMoveStep(StepEnum.XW08_DoorClose); 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_InDoor_Down, IO_Type.X_InDoor_Up);
CylinderMove(MoveInfo, IO_Type.X_OutDoor_Down, IO_Type.X_OutDoor_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 ...@@ -306,6 +307,7 @@ namespace OnlineStore.DeviceLibrary
} }
private string lastFileName = ""; private string lastFileName = "";
private int lastTh = 0;
private void XW13_GetXRayImage() private void XW13_GetXRayImage()
{ {
if (IOValue(IO_Type.X_Lock_On).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.X_Lock_On).Equals(IO_VALUE.LOW))
...@@ -335,16 +337,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -335,16 +337,16 @@ namespace OnlineStore.DeviceLibrary
xRay.Stop(); xRay.Stop();
} }
int count = 99999; int count = 99999;
countImage.GetCount(ThresholdValue, out count); countImage.GetCount(lastTh, out count);
InXWork = false; InXWork = false;
WorkLog("点料:获取点料结果["+ThresholdValue+"]=【" + count + "】,保存并上传结果"); WorkLog("点料:获取点料结果["+ lastTh + "]=【" + count + "】,保存并上传结果");
if (Work_ReelInfo.WareCount <= 0) if (Work_ReelInfo.WareCount <= 0)
{ {
MoveInfo.MoveParam.WareCount = count; MoveInfo.MoveParam.WareCount = count;
Work_ReelInfo.WareCount = count; Work_ReelInfo.WareCount = count;
} }
string outF = path3_out + @"\" + lastFileName; string outF = path2_out + @"\" + lastFileName;
try try
{ {
if (System.IO.File.Exists(outF)) if (System.IO.File.Exists(outF))
...@@ -404,6 +406,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -404,6 +406,8 @@ namespace OnlineStore.DeviceLibrary
} }
WorkLog("点料:获取X射线图形,保存到: " + fileP + ",备份到:" + backFile + ",记录时间" + lastData + ",停止X射线"); WorkLog("点料:获取X射线图形,保存到: " + fileP + ",备份到:" + backFile + ",记录时间" + lastData + ",停止X射线");
GetImageEvent?.Invoke(bmp); GetImageEvent?.Invoke(bmp);
UpdateArea(Work_ReelInfo.WareCode);
} }
else else
{ {
...@@ -434,7 +438,23 @@ namespace OnlineStore.DeviceLibrary ...@@ -434,7 +438,23 @@ namespace OnlineStore.DeviceLibrary
} }
return lastFileName; 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() private void ClearFilePath()
{ {
try try
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!