优化轴乱跑的问题

master
lhiven 10 months ago
parent 16ee029dcc
commit 690c9183f1

@ -3428,11 +3428,5 @@ namespace Rs.Framework
return SysConfigParam.GetValue<bool>(nameof(EnableIndexTimeStatistics));
}
}
/// <summary>
/// 设备是否是自动状态
/// </summary>
public static bool DeviceIsAuto { get; set; } = true;
}
}

@ -34,7 +34,7 @@ namespace Rs.MotionPlat.Flow
private void task() {
while (b_IsRun)
{
if(b_IsStop || !GlobalVar.DeviceIsAuto)
if(b_IsStop)
{
Thread.Sleep(stopWaitTime);
continue;

@ -39,7 +39,7 @@ namespace Rs.MotionPlat.Flow
,
,
,
,
,
,
//料仓放料
,
@ -132,7 +132,7 @@ namespace Rs.MotionPlat.Flow
{
while (run)
{
if (stop || !GlobalVar.DeviceIsAuto)
if (stop)
{
Thread.Sleep(10);
continue;
@ -508,7 +508,7 @@ namespace Rs.MotionPlat.Flow
needPlaceNozzle = GetPlaceNozzle(curFixture);
if (needPlaceNozzle != null)
{
flowStep = EDischargeFlowStep.;
flowStep = EDischargeFlowStep.;
break;
}
else
@ -516,7 +516,7 @@ namespace Rs.MotionPlat.Flow
//治具里面有产品但是吸嘴已经没有可以产品可以交换
if (GlobalVar.Clear && NozzleManager.GetIdelNozzle() != null)
{
flowStep = EDischargeFlowStep.;
flowStep = EDischargeFlowStep.;
break;
//在这里先去把要放的产品给放下去,再回来取
}
@ -537,25 +537,37 @@ namespace Rs.MotionPlat.Flow
}
break;
case EDischargeFlowStep.:
case EDischargeFlowStep.:
FixtureTakeFlow.Instance.Take(curFixture.Index);
if(needPlaceNozzle != null)
if(needPlaceNozzle != null && needPlaceNozzle.Status== ENozzleStatus.ToTest)
{
flowStep = EDischargeFlowStep.;
}
else
{
int num = TestFixtureManager.Instance.GetHaveProductFixtureList().Count();
if(GlobalVar.Clear && NozzleManager.GetToTestNozzle()==null && ((num==0) ||(NozzleManager.GetIdelNozzle() == null)))
{
int tounloadNum = NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count();
//if(GlobalVar.Clear && (
// (tounloadNum==3)
// || (num==0)
// ||(NozzleManager.GetToTestNozzle() == null)))
if(tounloadNum == 3
|| num == 0
//|| NozzleManager.GetToTestNozzle() == null
)
{
logInfo =GetClassName()+ $"clear:{GlobalVar.Clear},tounloadnum:{tounloadNum},num:{num}";
MessageQueue.Instance.Insert(logInfo);
//if(curFixture.Index==6)
//{
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock);
//}
CreateCheckFixtureQueue(curFixture.Index);
flowStep = EDischargeFlowStep.;
}
else
{
CreateCheckFixtureQueue(curFixture.Index);
flowStep = EDischargeFlowStep.;
}
}
@ -569,18 +581,41 @@ namespace Rs.MotionPlat.Flow
//lastFixtureIndex = checkFixtureList[0] - 1;
//lastFixtureIndex = curFixture.Index == checkFixtureList.Max() ? checkFixtureList.Min()-1 : curFixture.Index;
//lastFixtureIndex = curFixture.Index == 6 ? 0 : curFixture.Index;
if (NozzleManager.GetToTestNozzle() != null || (GlobalVar.Clear && TestFixtureManager.Instance.GetHasProuctFixtureCount()>0))
int num = TestFixtureManager.Instance.GetHaveProductFixtureList().Count();
int tounloadNum = NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count();
if (
tounloadNum==3
|| num==0
|| NozzleManager.GetToTestNozzle() == null
)
//GlobalVar.Clear && (
//NozzleManager.GetToTestNozzle() == null
//|| (tounloadNum == 3)
//|| (num == 0)
//|| (NozzleManager.GetIdelNozzle() == null)))
{
flowStep = EDischargeFlowStep.;
flowStep = EDischargeFlowStep.;
}
else
{
//if (curFixture.Index == 6)
flowStep = EDischargeFlowStep.;
}
// if (NozzleManager.GetToTestNozzle() != null
// ||(GlobalVar.Clear && TestFixtureManager.Instance.GetHasProuctFixtureCount()>0 && NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count<3))
//{
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock);
// flowStep = EDischargeFlowStep.到治具取料等待位;
//}
//else
//{
// //if (curFixture.Index == 6)
// //{
// // DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock);
// //}
// flowStep = EDischargeFlowStep.判断是否需要放料到料仓;
//}
flowStep = EDischargeFlowStep.;
}
}
break;

@ -165,7 +165,7 @@ namespace Rs.MotionPlat.Flow
{
while (run)
{
if (stop || !GlobalVar.DeviceIsAuto)
if (stop)
{
Thread.Sleep(10);
continue;

@ -65,7 +65,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
//Task.Run(() => {
while (!finished)
{
if(stop)
if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop)
{
Thread.Sleep(10);
continue;

@ -136,7 +136,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
{
while (run)
{
if (stop || !GlobalVar.DeviceIsAuto)
if (stop)
{
Thread.Sleep(10);
continue;

@ -99,6 +99,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName());
if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2))
{
Thread.Sleep(100);
AxisPosPrint.PrintXY1Y2CurrentPos($"已运动到治具{curFixture.Index}拍照位,", GetClassName());
flowStep = EFixturePlaceFlowStep.;
}
@ -167,6 +168,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName());
if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2))
{
Thread.Sleep(100);
AxisPosPrint.PrintXY1Y2CurrentPos($"已运动到治具{curFixture.Index}放料位上方,", GetClassName());
flowStep = EFixturePlaceFlowStep.1;
}
@ -205,7 +207,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
case EFixturePlaceFlowStep.2:
if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}"))
{
Thread.Sleep(100);
Thread.Sleep(300);
logInfo = GetClassName() + $"已运动到治具{curFixture.Index}放料位下方2";
MessageQueue.Instance.Insert(logInfo);
if (GlobalVar.RunSpace)

@ -185,6 +185,8 @@ namespace Rs.MotionPlat.Flow.SubFlow
break;
case EStockPlaceFlowStep.:
if (!curNozzle.HasProduct() || GlobalVar.RunSpace)
{
if(curNozzle.Product!=null)
{
PlaceFinishedEvent?.Invoke(curNozzle.Product);
logInfo = $"{GetClassName()}检测到吸嘴{curNozzle.NozzleIndex}无粘料,吸嘴{curNozzle.NozzleIndex}把产品SN:{curNozzle.Product.SN}放入OK料盘{curPlaceSlot.Index}穴位";
@ -192,6 +194,12 @@ namespace Rs.MotionPlat.Flow.SubFlow
tray.ChangeStatus(curPlaceSlot.Index, ESlotStatus.Have);
curNozzle.Product.ToString();
curNozzle.Clear();
}
else
{
curNozzle.Clear();
tray.ChangeStatus(curPlaceSlot.Index, ESlotStatus.Have);
}
finished = true;
flowStep = EStockPlaceFlowStep.;
}

@ -58,7 +58,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
/// 料仓取料
/// </summary>
/// <param name="className"></param>
public void Take(ETrayType trayType, int slotIndex,int nozzleIndex)
public void Take(ETrayType trayType, int slotIndex,int nozzleIndex, ProductLocationResult locaResult=null)
{
if (finished)
finished = false;
@ -105,6 +105,12 @@ namespace Rs.MotionPlat.Flow.SubFlow
targetPosition.Y2 += result.OffsetY;
}
}
if(locaResult!=null)
{
MessageQueue.Instance.Insert($"拍照偏移量 x:{locaResult.OffsetX},y:{locaResult.OffsetY}");
targetPosition.X += locaResult.OffsetX;
targetPosition.Y2 += locaResult.OffsetY;
}
double curLoadX = Ops.GetCurPosition(AxisControl.LoadX);
if (curLoadX - GlobalVar.FixtureSafePosX > 50)
{
@ -181,15 +187,22 @@ namespace Rs.MotionPlat.Flow.SubFlow
curNozzle.Product = new TestProduct() { SN = VirtualBarCode.Code, TestNum = 0, From = $"R{waitTakeProductSlot.Row + 1}C{waitTakeProductSlot.Column + 1}" };
}
else
{
if(OneGrabSixteenManager.Instance.GetResultBySlotIndex(slotIndex)!=null)
{
curNozzle.Product = new TestProduct() { SN = OneGrabSixteenManager.Instance.GetResultBySlotIndex(slotIndex).SN, TestNum = 0, From = $"R{waitTakeProductSlot.Row + 1}C{waitTakeProductSlot.Column + 1}" };
}
}
curNozzle.Status = ENozzleStatus.ToTest;
//curNozzle.Status = ENozzleStatus.ToUnload;
GlobalTray.NozzleTray.ChangeStatus(curNozzle.NozzleIndex, ESlotStatus.Have);
GlobalTray.InputTray.ChangeStatus(waitTakeProductSlot.Index, ESlotStatus.NotHave);
if(curNozzle.Product!=null)
{
logInfo = $"{GetClassName()} from r{waitTakeProductSlot.Row + 1}c{waitTakeProductSlot.Column + 1} 穴位索引:{waitTakeProductSlot.Index} 产品:{curNozzle.Product.SN}被吸嘴{curNozzle.NozzleIndex}取料完成,";
MessageQueue.Instance.Insert(logInfo);
}
//flowStep = EStockTakeFlowStep.判断是否需要从料仓取料;
finished = true;
flowStep = EStockTakeFlowStep.;

@ -202,7 +202,7 @@ namespace Rs.MotionPlat
GlobalTray.NozzleTray = trayNozzle ;
//StockManager.Instance.Start();
LoadStockStatus();
switchButton1.Checked = GlobalVar.DeviceIsAuto;
switchButton1.Checked = GlobalVar.Clear; ;
@ -272,7 +272,7 @@ namespace Rs.MotionPlat
int.TryParse(lblPassNum.Text,out int passNum);
int.TryParse(lblNgNum.Text, out int ngNum);
totalNum++;
if (pro.Result == "PASS")
if (pro!= null && pro.Result == "PASS")
{
passNum++;
}

@ -1,6 +1,7 @@
using Rs.Controls;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Entitys;
using Rs.MotionPlat.Flow.NormalFlow;
using Rs.MotionPlat.Flow.SafePosFlow;
using Rs.MotionPlat.Flow.SubFlow;
using System;
@ -27,6 +28,10 @@ namespace Rs.MotionPlat.SysConfig
private void btnSelect_Click(object sender, EventArgs e)
{
if(!string.IsNullOrEmpty(txtSn.Text))
{
ThreePointLocationFlow.Instance.Location(ETrayType.ReTest);
}
SelectProduct();
}
@ -47,15 +52,15 @@ namespace Rs.MotionPlat.SysConfig
string[] files = Directory.GetFiles(selectDir);
if (files != null && files.Length > 0)
{
List<int> fint = new List<int>();
foreach (string file in files)
{
string fname = Path.GetFileName(file);
string[] items = fname.Split('-');
int index =int.Parse(Path.GetFileNameWithoutExtension(items[1]));
fint.Add(index);
}
fileName = $"{DateTime.Now.ToString("yyyyMMdd")}-{fint.Max()+1}.csv";
//List<int> fint = new List<int>();
//foreach (string file in files)
//{
// string fname = Path.GetFileName(file);
// string[] items = fname.Split('-');
// int index =int.Parse(Path.GetFileNameWithoutExtension(items[1]));
// fint.Add(index);
//}
fileName = $"{DateTime.Now.ToString("yyyyMMdd")}-{files.Length+1}.csv";
}
else
{
@ -79,12 +84,12 @@ namespace Rs.MotionPlat.SysConfig
if(txtSn.Text.IndexOf(fixtureret.SN)>=0)
{
ProductLocationResult ret = OneGrabSixteenManager.Instance.GetResultByIndex(0);
ret.SlotIndex = i+1;
ret.SN= fixtureret.SN;
ret.OffsetX = fixtureret.OffsetX;
ret.OffsetY = fixtureret.OffsetY;
StockTakeFlow.Instance.Take( ETrayType.Grr, i + 1, 1);
//ProductLocationResult ret = OneGrabSixteenManager.Instance.GetResultByIndex(0);
//ret.SlotIndex = i+1;
//ret.SN= fixtureret.SN;
//ret.OffsetX = fixtureret.OffsetX;
//ret.OffsetY = fixtureret.OffsetY;
StockTakeFlow.Instance.Take( ETrayType.Grr, i + 1, 1, fixtureret);
TraySlot slot = GlobalTray.RetestTray.GetSlot(Rs.Controls.ESlotStatus.NotHave);
StockPlaceFlow.Instance.Place(ETrayType.ReTest, slot.Index, 1);
}

@ -402,7 +402,7 @@ namespace Rs.MotionPlat.SysConfig
private void btnInputToEmpty_Click(object sender, EventArgs e)
{
Task.Run(() => {
TakeTrayFlow.Instance.Take(ETrayType.Empty, ETrayType.Empty);
TakeTrayFlow.Instance.Take(ETrayType.Input, ETrayType.Empty);
});
}

@ -67,6 +67,7 @@
this.textBox4 = new System.Windows.Forms.TextBox();
this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@ -518,11 +519,22 @@
this.button8.Text = "button7";
this.button8.UseVisualStyleBackColor = true;
//
// button9
//
this.button9.Location = new System.Drawing.Point(434, 362);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(180, 106);
this.button9.TabIndex = 38;
this.button9.Text = "产品搬运";
this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// TestFrm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1336, 854);
this.Controls.Add(this.button9);
this.Controls.Add(this.button8);
this.Controls.Add(this.button7);
this.Controls.Add(this.button6);
@ -589,5 +601,6 @@
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
}
}

@ -313,5 +313,25 @@ namespace Rs.MotionPlat
{
}
private void button9_Click(object sender, EventArgs e)
{
Task.Run(() => {
while (true)
{
TraySlot slot = GlobalTray.GrrTray.GetSlot(ESlotStatus.Have);
if(slot==null)
{
break;
}
else
{
StockTakeFlow.Instance.Take(ETrayType.Grab, slot.Index, 1);
slot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave);
StockPlaceFlow.Instance.Place(ETrayType.ReTest, slot.Index, 1);
}
}
});
}
}
}

Loading…
Cancel
Save