Commit 488d9865 authored by 潘栩锋's avatar 潘栩锋 🚴

优化 优化查加热棒坏的逻辑

parent dce5e262
...@@ -130,13 +130,16 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -130,13 +130,16 @@ namespace FLY.FeedbackRenZiJia.Server
/// </summary> /// </summary>
public bool CheckEnable { get; set; } = false; public bool CheckEnable { get; set; } = false;
/// <summary>
/// 1块加热控制板 接多少路加热
/// </summary>
public int HeatsOfGroup { get; set; } = 12;
#endregion #endregion
#endregion #endregion
private IPLCLink plc; private IPLCLink plc;
FLY.Thick.Blowing.IService.IBlowingService blowingService; FLY.Thick.Blowing.IService.IBlowingService blowingService;
...@@ -255,7 +258,7 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -255,7 +258,7 @@ namespace FLY.FeedbackRenZiJia.Server
Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.Enable), this, nameof(CheckEnable), Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.Enable), this, nameof(CheckEnable), Misc.BindingOperations.BindingMode.TwoWay);
Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.CheckNo), this, nameof(CheckNo)); Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.CheckNo), this, nameof(CheckNo));
Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.Bads), this, nameof(Bads)); Misc.BindingOperations.SetBinding(mHeatCheck, nameof(mHeatCheck.Bads), this, nameof(Bads));
Misc.BindingOperations.SetBinding(this, nameof(HeatsOfGroup), mHeatCheck, nameof(mHeatCheck.HeatsOfGroup));
if (plc is PLCLink) if (plc is PLCLink)
{ {
((PLCLink)plc).Start(); ((PLCLink)plc).Start();
...@@ -994,6 +997,11 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -994,6 +997,11 @@ namespace FLY.FeedbackRenZiJia.Server
/// 检测线速度 使能 /// 检测线速度 使能
/// </summary> /// </summary>
public bool HasCheckFilmVelocity; public bool HasCheckFilmVelocity;
/// <summary>
/// 1块加热控制板 接多少路加热
/// </summary>
public int HeatsOfGroup = 12;
#endregion #endregion
} }
......
...@@ -635,7 +635,7 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -635,7 +635,7 @@ namespace FLY.FeedbackRenZiJia.Server
/// </summary> /// </summary>
public void Cal() public void Cal()
{ {
var thickpercents = Common.MyMath.ZoomOut(ThickPercents, BoltCnt / ChannelCnt); var thickpercents = ThickPercents;// Common.MyMath.ZoomOut(ThickPercents, BoltCnt / ChannelCnt);
int[] offsets = new int[ChannelCnt]; int[] offsets = new int[ChannelCnt];
for (int i = 0; i < ChannelCnt; i++) for (int i = 0; i < ChannelCnt; i++)
{ {
......
...@@ -40,7 +40,7 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -40,7 +40,7 @@ namespace FLY.FeedbackRenZiJia.Server
CHECK_MODE checkMode = CHECK_MODE.IDLE; CHECK_MODE checkMode = CHECK_MODE.IDLE;
int counter = 0; int counter = 0;
#region IHeatCheck #region IHeatCheck
public int HeatsOfGroup { get; set; } = 12;
/// <summary> /// <summary>
/// 有这个功能 /// 有这个功能
/// </summary> /// </summary>
...@@ -67,12 +67,102 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -67,12 +67,102 @@ namespace FLY.FeedbackRenZiJia.Server
#region 根据电流判断的加热棒状态 #region 根据电流判断的加热棒状态
/// <summary> /// <summary>
/// 加热棒是好的,但电流小,必须两条同时加热才可以。 /// 加热棒是好的,但电流小,必须两条同时加热才可以;
/// 加热棒分组
/// </summary> /// </summary>
private int HalfIdx; private int groupIdx;
private List<int> maybeIdx = new List<int>();
private List<GroupBad> groupBads = new List<GroupBad>();
class GroupBad
{
/// <summary>
/// 分组号
/// </summary>
public int group;
/// <summary>
/// 在 好的 maybe序号
/// </summary>
public int goodIdx = -1;
/// <summary>
/// 全部待测的加热棒序号
/// </summary>
List<int> maybe = new List<int>();
/// <summary>
/// 已经测试过的 maybe序号
/// </summary>
List<int> hasCheck = new List<int>();
/// <summary>
/// 获取下一个 需要检查的 序号
/// </summary>
/// <returns></returns>
public bool GetNextIdx()
{
for (int i = 0; i < maybe.Count(); i++) {
if (!hasCheck.Contains(i)) {
//这个没检查过,可以
checkIdx1 = i;
return true;
}
}
return false;
}
/// <summary>
/// 同时加热的加热棒0
/// </summary>
int checkIdx0;
/// <summary>
/// 同时加热的加热棒1
/// </summary>
int checkIdx1;
public int NextCheckIdx {
get { return checkIdx1 + 1; }
}
public int HeatIdx0
{
get { return maybe[checkIdx0]; }
}
public int HeatIdx1
{
get { return maybe[checkIdx1]; }
}
public bool GetCheckIdx(int startIdx)
{
if (startIdx >= maybe.Count() - 1)
return false;//不够数
//同一个组可以一起加热测试
checkIdx0 = startIdx;
checkIdx1 = startIdx + 1;
return true;
}
public void PushToHasCheck()
{
if(!hasCheck.Contains(checkIdx0))
hasCheck.Add(checkIdx0);
if (!hasCheck.Contains(checkIdx1))
hasCheck.Add(checkIdx1);
}
public void MarkGoodIdx()
{
goodIdx = checkIdx0;
}
public bool HasGood {
get {
return goodIdx != -1;
}
}
public void Add(int heatIdx) {
maybe.Add(heatIdx);
}
}
/// <summary> /// <summary>
/// 坏的加热棒 /// 坏的加热棒
/// </summary> /// </summary>
...@@ -259,6 +349,23 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -259,6 +349,23 @@ namespace FLY.FeedbackRenZiJia.Server
} }
} }
bool GetCheckIdx_2_loop(int grougIdx_start, int startIdx)
{
for (int i = grougIdx_start; i < groupBads.Count(); i++)
{
if(groupBads[i].GetCheckIdx(startIdx))
{
groupIdx = i;
return true;
}
startIdx = 0;
}
return false;
}
/// <summary> /// <summary>
/// 加热棒检测周期 /// 加热棒检测周期
/// </summary> /// </summary>
...@@ -337,7 +444,7 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -337,7 +444,7 @@ namespace FLY.FeedbackRenZiJia.Server
{ {
Bads[CheckNo - 1] = true; Bads[CheckNo - 1] = true;
NotifyPropertyChanged("Bads"); NotifyPropertyChanged(nameof(Bads));
OpenCircuit = true; OpenCircuit = true;
} }
...@@ -373,20 +480,37 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -373,20 +480,37 @@ namespace FLY.FeedbackRenZiJia.Server
{ {
if (counter == 0)//刚进入!!! if (counter == 0)//刚进入!!!
{ {
HalfIdx = -1;//可能坏的加热棒中,还没有一条是好的 groupIdx = -1;
for (int i = 0; i < Bads.Count(); i++)//登记全部坏的加热棒 groupBads.Clear();
for (int i = 0; i < Bads.Count(); i++)//分组登记全部坏的加热棒
{ {
int group = i / HeatsOfGroup;
if (Bads[i]) if (Bads[i])
{ {
maybeIdx.Add(i); if (groupBads.Count() == 0)
groupBads.Add(new GroupBad() { group = group });
else {
if (groupBads.Last().group != group) {
groupBads.Add(new GroupBad() { group = group });
}
}
groupBads.Last().Add(i);
} }
} }
CheckNo = maybeIdx.First() + 1;//当前检测的位置,现在没用!!!
//肯定有2条加热棒是坏了,不用检测maybeIdx.Count()
if(!GetCheckIdx_2_loop(0, 0))
{
//没有两条同一组,测试结束
Enable = false;//停止检测
return;
}
var groupBad = groupBads[groupIdx];
CheckNo = groupBad.HeatIdx1+1;//当前检测的位置,现在没用!!!
mHeatCell.ModifyPreHeats(getSingleHeat_100(mHeatCell.ChannelCnt, mHeatCell.ModifyPreHeats(getSingleHeat_100(mHeatCell.ChannelCnt,
maybeIdx[0], groupBad.HeatIdx0,
maybeIdx[1])); groupBad.HeatIdx1));
mHeatCell.HeatApply(); mHeatCell.HeatApply();
counter = 1; counter = 1;
...@@ -397,79 +521,68 @@ namespace FLY.FeedbackRenZiJia.Server ...@@ -397,79 +521,68 @@ namespace FLY.FeedbackRenZiJia.Server
} }
else//3秒后 else//3秒后
{ {
var groupBad = groupBads[groupIdx];
if (!HasElectricity)//没电流,肯定是坏了 if (!HasElectricity)//没电流,肯定是坏了
{ {
if (HalfIdx < 0)//还没有一个 "肯定是好的,只是电流不够的加热棒" if (!groupBad.HasGood)//还没找到好的加热棒
{ {
maybeIdx.RemoveRange(0, 2);//之前测试的两条肯定是坏的,不用再查了(这个有bug的) //继续
if (!GetCheckIdx_2_loop(groupIdx, groupBad.NextCheckIdx))
if (maybeIdx.Count() <= 1)
{ {
//只剩下一个,没法检测结束 //没有两条同一组,测试结束
Enable = false;//停止检测 Enable = false;//停止检测
return; return;
} }
} }
else else {
{ //checkIdx1是坏的
//已经有 好的!!!, 刚才测的那条肯定是坏的 groupBad.PushToHasCheck();
maybeIdx.RemoveAt(0); //获取下一个需要测试的
if(!groupBad.GetNextIdx())
if (maybeIdx.Count() == 0)
{ {
//全部检测完了 //这个分组已经查完,下一个分组
Enable = false;//停止检测 groupIdx++;
return; if (!GetCheckIdx_2_loop(groupIdx, 0))
{
//没有两条同一组,测试结束
Enable = false;//停止检测
return;
}
} }
} }
CheckNo = maybeIdx[0] + 1;
int idx1 = (HalfIdx >= 0) ? HalfIdx : maybeIdx[1];
mHeatCell.ModifyPreHeats(getSingleHeat_100(mHeatCell.ChannelCnt,
maybeIdx[0],
idx1));
mHeatCell.HeatApply();
counter = 1;
} }
else else
{ {
//刚才测量的是好的!!!!! //刚才测量的是好的!!!!!只是电流不够的加热棒
if (HalfIdx < 0)//还没有一个 "肯定是好的,只是电流不够的加热棒" groupBad.MarkGoodIdx(); //找到好的加热棒了,这个组的加热棒全部测试一次
{ groupBad.PushToHasCheck();
Bads[maybeIdx[0]] = false;//清除坏的记录 Bads[groupBad.HeatIdx0] = false;//清除坏的记录
Bads[maybeIdx[1]] = false; Bads[groupBad.HeatIdx1] = false;
HalfIdx = maybeIdx[0];//登记其中一条好的加热棒 NotifyPropertyChanged(nameof(Bads));
maybeIdx.RemoveRange(0, 2);
}
else
{
Bads[maybeIdx[0]] = false;//清除坏的记录
maybeIdx.RemoveAt(0);
}
NotifyPropertyChanged("Bads");
OpenCircuit = Bads.Any(b => b); OpenCircuit = Bads.Any(b => b);
if (maybeIdx.Count() <= 0) //获取下一个需要测试的
if(!groupBad.GetNextIdx())
{ {
//一个都不剩,完成 //这个分组已经查完,下一个分组
Enable = false;//停止检测 groupIdx++;
return; if (!GetCheckIdx_2_loop(groupIdx, 0))
{
//没有两条同一组,测试结束
Enable = false;//停止检测
return;
}
} }
CheckNo = maybeIdx[0] + 1;
mHeatCell.ModifyPreHeats(getSingleHeat_100(mHeatCell.ChannelCnt,
maybeIdx[0],
HalfIdx));
mHeatCell.HeatApply();
counter = 1;
} }
groupBad = groupBads[groupIdx];
CheckNo = groupBad.HeatIdx1 + 1;
mHeatCell.ModifyPreHeats(getSingleHeat_100(mHeatCell.ChannelCnt,
groupBad.HeatIdx0,
groupBad.HeatIdx1));
mHeatCell.HeatApply();
counter = 1;
} }
}break; }break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment