Commit 289bedb8 刘韬

新增点料算法setFinetuning支持

1 个父辈 f2d7e2f6
......@@ -35,14 +35,18 @@ namespace OnlineStore.Common
File.WriteAllText(algopnFile, s);
File.Copy(algopnFile, algopnFile + "."+DateTime.Now.ToShortDateString(), true);
}
public static void Set(string pn, string value)
public static void Set(string pn, string value, double? finetuning = null)
{
if (string.IsNullOrEmpty(pn))
return;
if (string.IsNullOrEmpty(value))
return;
//Common.LOG.Info($"set pnalgo pn:{pn}, algo:{value}");
//Common.LOG.Info($"set pnalgo pn:{pn}, algo:{value}, finetuning:{finetuning}");
if (finetuning != null)
value = value + "," + finetuning.ToString();
if (algopnList.ContainsKey(pn))
algopnList[pn] = value;
else
......@@ -50,10 +54,25 @@ namespace OnlineStore.Common
SaveFile();
}
public static string MatchPN(string pn)
public static string MatchPN(string pn, out bool hasMatch, out double? finetuning)
{
hasMatch = false;
finetuning = null;
if (algopnList.ContainsKey(pn))
return algopnList[pn];
{
hasMatch = true;
var value = algopnList[pn];
if (value.IndexOf(",") > 0)
{
var vs = value.Split(',');
if (double.TryParse(vs[1], out double result))
{
value = vs[0];
finetuning = result;
}
}
return value;
}
else
return "auto";
}
......
......@@ -147,32 +147,44 @@ namespace DeviceLibrary
try
{
int xplate_getimage_retry_times = ConfigHelper.Config.Get("xplate_getimage_retry_times",5);
int xplate_open_retry_times = ConfigHelper.Config.Get("xplate_open_retry_times", 3);
for (int ii = 1; ii <= xplate_getimage_retry_times; ii++) {
bool rtn = RobotManage.xrayImage.GetImage(1);
if (!rtn)
{
if (ii == xplate_getimage_retry_times)
return false;
for (int jj = 1; jj <= xplate_open_retry_times; jj++)
{
bool closeR = RobotManage.xrayImage.Close();
if (!closeR)
MoveInfo.log("carerayImage.Close = " + closeR);
MoveInfo.log($"xray plate Close ii={ii}, times={jj}, result={closeR}");
Thread.Sleep(500);
Thread.Sleep(500 * jj + (jj - 1) * 1000);
rtn = RobotManage.xrayImage.Open();
Thread.Sleep(500);
if (!rtn)
{
MoveInfo.log("xray plate open failed.");
MoveInfo.log($"xray plate open failed ii={ii}, times={jj}");
if (jj == xplate_open_retry_times)
return false;
continue;
}
rtn = RobotManage.xrayImage.GetImage(1);
if (!rtn)
{
MoveInfo.log("get image from plate failed 2");
return false;
else
break;
}
Thread.Sleep(1000 * ii+(ii-1)*2000);
}
else
break;
}
MoveInfo.log("get image from plate scusses");
RobotManage.xrayImage.WindowWidth = 30000;
RobotManage.xrayImage.WindowLevel = 15000;
//RobotManage.xrayImage.WindowWidth = 30000;
//RobotManage.xrayImage.WindowLevel = 15000;
bmp = RobotManage.xrayImage.Get48bImage();
Directory.CreateDirectory(xraydir);
......@@ -212,8 +224,16 @@ namespace DeviceLibrary
int result = 0;
int ShrinkOffset = ConfigHelper.Config.Get<int>("ShrinkOffset",100);
var pps = MoveInfo.ReelParam.PN.Split('-');
var type = Pn_Algo_Match.MatchPN(pps[0]);
MoveInfo.log($"匹配到算法.{pps[0]}={type}");
var type = Pn_Algo_Match.MatchPN(pps[0],out _,out double? finetuning);
MoveInfo.log($"匹配到算法.{pps[0]}={type}, finetuning={finetuning}");
if (finetuning != null)
{
XrayImage.setFineTuning = finetuning.Value;
}
else
{
XrayImage.setFineTuning = ConfigHelper.Config.Get("setFineTuningDefault", 0.7);
}
if (type.StartsWith("IP_Template_PARTS"))
{
if (!File.Exists(type.Substring(17 + 1)))
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!