|
@@ -92,6 +92,22 @@ namespace BPASmartClient.MorkF |
|
|
ServerInit(); |
|
|
ServerInit(); |
|
|
DeviceProcessLogShow("MORKF 设备初始化完成"); |
|
|
DeviceProcessLogShow("MORKF 设备初始化完成"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 主任务 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public override void MainTask() |
|
|
|
|
|
{ |
|
|
|
|
|
MainProcessExcute(); |
|
|
|
|
|
//MinorProcessExcute(); |
|
|
|
|
|
//SingleProcess(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void Stop() |
|
|
|
|
|
{ |
|
|
|
|
|
IsHealth = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#region 调试代码 |
|
|
#region 调试代码 |
|
|
public void CommandRegist() |
|
|
public void CommandRegist() |
|
|
{ |
|
|
{ |
|
@@ -367,9 +383,240 @@ namespace BPASmartClient.MorkF |
|
|
ThreadManage.GetInstance().StopTask(String.Format(striConst, fryIndex.ToString(), nowStirFryGood.GoodName), new Action(() => { Plc1Reset(num); })); |
|
|
ThreadManage.GetInstance().StopTask(String.Format(striConst, fryIndex.ToString(), nowStirFryGood.GoodName), new Action(() => { Plc1Reset(num); })); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 重置程序 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public override void ResetProgram() |
|
|
|
|
|
{ |
|
|
|
|
|
IsHealth = true; |
|
|
|
|
|
morkFs.Clear(); |
|
|
|
|
|
morkFs = new Dictionary<int, GVL_MorkF>(); |
|
|
|
|
|
ml_morkf = new ML_MorkF(); |
|
|
|
|
|
|
|
|
|
|
|
//根据编号new炒锅实例对象 |
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
morkFs.Add(i, new GVL_MorkF()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region 公用PLC方法 |
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 获取设备PLC的所有状态 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
/// <param name="key"></param> |
|
|
|
|
|
/// <param name="action"></param> |
|
|
|
|
|
/// <param name="num">炒锅编号</param> |
|
|
|
|
|
private void GetStatus(string key, Action<object> action, int num) |
|
|
|
|
|
{ |
|
|
|
|
|
if (dicPort2peripheralStatus.ContainsKey(num)) |
|
|
|
|
|
{ |
|
|
|
|
|
if (dicPort2peripheralStatus[num].ContainsKey(key)) |
|
|
|
|
|
{ |
|
|
|
|
|
action((object)dicPort2peripheralStatus[num][key]);//获取PLC指定地址的状态值 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// PLC数据读取 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public override void ReadData() |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < morkFs.Count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
GetStatus("LB50", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (!morkFs.ContainsKey(i)) |
|
|
|
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
morkFs[i].FryPot1_InitialComplete = bools[0]; |
|
|
|
|
|
morkFs[i].FryPot1_HOBTPut = bools[1]; |
|
|
|
|
|
morkFs[i].FryPot1_HOBTGet = bools[2]; |
|
|
|
|
|
morkFs[i].FryPot1_MaterialIntoPot = bools[3]; |
|
|
|
|
|
morkFs[i].OutFoodCompelete = bools[4]; |
|
|
|
|
|
morkFs[i].CanOutFood = bools[5]; |
|
|
|
|
|
morkFs[i].GetFoodCompelete = bools[6]; |
|
|
|
|
|
morkFs[i].CanOutPotWashingWater = bools[7]; |
|
|
|
|
|
morkFs[i].ArmOnOrigin = bools[8]; |
|
|
|
|
|
morkFs[i].ArmOnWorking = bools[9]; |
|
|
|
|
|
morkFs[i].PotOnOrigin = bools[10]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}), i); |
|
|
|
|
|
} |
|
|
|
|
|
for (int j = 0; j < morkFs.Count; j++) |
|
|
|
|
|
{ |
|
|
|
|
|
GetStatus("LB74", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (!morkFs.ContainsKey(j)) |
|
|
|
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 14; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
morkFs[j].PassWay1_Compelete[i] = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}), j); |
|
|
|
|
|
} |
|
|
|
|
|
for (int i = 0; i < morkFs.Count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!morkFs.ContainsKey(i)) |
|
|
|
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GetStatus("LB90", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
morkFs[i].AutoMode = bools[0]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}), i); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取激光距离 |
|
|
|
|
|
GetStatus("VW270", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is int[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.LaserDistance = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取坐标X |
|
|
|
|
|
GetStatus("VD828", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is int[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.ArmPositionX = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取坐标Y |
|
|
|
|
|
GetStatus("VD832", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is int[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.ArmPositionY = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取爪子到达位置 |
|
|
|
|
|
GetStatus("M11.0", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools && bools.Length > 3) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
//ml_morkf.PawArrivePortOne = bools[0]; |
|
|
|
|
|
//ml_morkf.PawArrivePortTwo = bools[1]; |
|
|
|
|
|
//ml_morkf.PawArrivePortThree = bools[2]; |
|
|
|
|
|
|
|
|
|
|
|
if (isInitialPaw == false) |
|
|
|
|
|
{ |
|
|
|
|
|
isInitialArrive = true; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
//小炒爪子到达1号位上升沿信号捕获 |
|
|
|
|
|
if (RTrig.GetInstance("SmartGitdistance1Complete").Start(bools[0])) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.PawArrivePortOne = true; |
|
|
|
|
|
} |
|
|
|
|
|
//小炒爪子到达3号位上升沿信号捕获 |
|
|
|
|
|
if (RTrig.GetInstance("SmartGitdistance2Complete").Start(bools[1])) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.PawArrivePortTwo = true; |
|
|
|
|
|
} |
|
|
|
|
|
//小炒爪子到达3号位上升沿信号捕获 |
|
|
|
|
|
if (RTrig.GetInstance("SmartGitdistance3Complete").Start(bools[2])) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.PawArrivePortThree = true; |
|
|
|
|
|
} |
|
|
|
|
|
isInitialArrive = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取定位到达状态 |
|
|
|
|
|
GetStatus("M10.0", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
//ml_morkf.ArriveComplete = bools[i]; |
|
|
|
|
|
//小炒定点到达上升沿信号捕获 |
|
|
|
|
|
if (RTrig.GetInstance("SmartArriveComplete").Start(bools[i])) |
|
|
|
|
|
{ |
|
|
|
|
|
if (isInitialArrive == false) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show("到达上升沿为true,isInitialArrive is false"); |
|
|
|
|
|
isInitialArrive = true; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show("到达上升沿为true"); |
|
|
|
|
|
ml_morkf.ArriveComplete = true; |
|
|
|
|
|
isInitialArrive = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取总初始化完成 |
|
|
|
|
|
GetStatus("M10.2", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.InitialComplete = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//抓手初始化完成 |
|
|
|
|
|
GetStatus("M10.3", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.PawInitialComplete = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
|
#region 菜品库操作方法 |
|
|
|
|
|
|
|
|
#region 菜品库PLC操作方法 |
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 菜品库数据写入 |
|
|
/// 菜品库数据写入 |
|
|
/// </summary> |
|
|
/// </summary> |
|
@@ -727,17 +974,43 @@ namespace BPASmartClient.MorkF |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//加油 |
|
|
|
|
|
public void AddOil() |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 炒锅初始化 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public void PLCInite() |
|
|
{ |
|
|
{ |
|
|
|
|
|
for (int i = 0; i < morkFs.Count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
FirePot_Write("LB0", true, i); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
//加热启动 |
|
|
|
|
|
public void StartFire(int num) |
|
|
|
|
|
{ |
|
|
|
|
|
FirePot_Write("LB1", true, num); |
|
|
|
|
|
Thread.Sleep(200); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (int j = 0; j < sleepCount && !morkFs[i].FryPot1_InitialComplete; j++) |
|
|
|
|
|
{ |
|
|
|
|
|
Thread.Sleep(sleepTime); |
|
|
|
|
|
if (j >= sleepCount - 1) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show($"炒锅{j}初始化超时"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//while (!morkFs[i].FryPot1_InitialComplete) |
|
|
|
|
|
//{ |
|
|
|
|
|
// Thread.Sleep(500); |
|
|
|
|
|
//} |
|
|
|
|
|
FirePot_Write("LB0", false, i); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//加油 |
|
|
|
|
|
public void AddOil() |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
//加热启动 |
|
|
|
|
|
public void StartFire(int num) |
|
|
|
|
|
{ |
|
|
|
|
|
FirePot_Write("LB1", true, num); |
|
|
|
|
|
Thread.Sleep(200); |
|
|
|
|
|
} |
|
|
//加热停止 |
|
|
//加热停止 |
|
|
public void StopFire(int num) |
|
|
public void StopFire(int num) |
|
|
{ |
|
|
{ |
|
@@ -906,219 +1179,11 @@ namespace BPASmartClient.MorkF |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 重置程序 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public override void ResetProgram() |
|
|
|
|
|
{ |
|
|
|
|
|
IsHealth = true; |
|
|
|
|
|
morkFs.Clear(); |
|
|
|
|
|
morkFs = new Dictionary<int, GVL_MorkF>(); |
|
|
|
|
|
ml_morkf = new ML_MorkF(); |
|
|
|
|
|
|
|
|
|
|
|
//根据编号new炒锅实例对象 |
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
morkFs.Add(i, new GVL_MorkF()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool isInitialArrive = false; |
|
|
bool isInitialArrive = false; |
|
|
|
|
|
|
|
|
bool isInitialPaw = false; |
|
|
bool isInitialPaw = false; |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// PLC数据读取 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public override void ReadData() |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < morkFs.Count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
GetStatus("LB50", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (!morkFs.ContainsKey(i)) |
|
|
|
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if(objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
morkFs[i].FryPot1_InitialComplete = bools[0]; |
|
|
|
|
|
morkFs[i].FryPot1_HOBTPut = bools[1]; |
|
|
|
|
|
morkFs[i].FryPot1_HOBTGet = bools[2]; |
|
|
|
|
|
morkFs[i].FryPot1_MaterialIntoPot = bools[3]; |
|
|
|
|
|
morkFs[i].OutFoodCompelete = bools[4]; |
|
|
|
|
|
morkFs[i].CanOutFood = bools[5]; |
|
|
|
|
|
morkFs[i].GetFoodCompelete = bools[6]; |
|
|
|
|
|
morkFs[i].CanOutPotWashingWater = bools[7]; |
|
|
|
|
|
morkFs[i].ArmOnOrigin = bools[8]; |
|
|
|
|
|
morkFs[i].ArmOnWorking = bools[9]; |
|
|
|
|
|
morkFs[i].PotOnOrigin = bools[10]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}), i); |
|
|
|
|
|
} |
|
|
|
|
|
for (int j = 0; j < morkFs.Count; j++) |
|
|
|
|
|
{ |
|
|
|
|
|
GetStatus("LB74", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (!morkFs.ContainsKey(j)) |
|
|
|
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 14; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
morkFs[j].PassWay1_Compelete[i] = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}), j); |
|
|
|
|
|
} |
|
|
|
|
|
for (int i = 0; i < morkFs.Count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!morkFs.ContainsKey(i)) |
|
|
|
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GetStatus("LB90", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
morkFs[i].AutoMode = bools[0]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}), i); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取激光距离 |
|
|
|
|
|
GetStatus("VW270", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is int[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.LaserDistance = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取坐标X |
|
|
|
|
|
GetStatus("VD828", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is int[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.ArmPositionX = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取坐标Y |
|
|
|
|
|
GetStatus("VD832", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is int[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.ArmPositionY = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取爪子到达位置 |
|
|
|
|
|
GetStatus("M11.0", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools&&bools.Length > 3) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
//ml_morkf.PawArrivePortOne = bools[0]; |
|
|
|
|
|
//ml_morkf.PawArrivePortTwo = bools[1]; |
|
|
|
|
|
//ml_morkf.PawArrivePortThree = bools[2]; |
|
|
|
|
|
|
|
|
|
|
|
if(isInitialPaw == false) |
|
|
|
|
|
{ |
|
|
|
|
|
isInitialArrive = true; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
//小炒爪子到达1号位上升沿信号捕获 |
|
|
|
|
|
if (RTrig.GetInstance("SmartGitdistance1Complete").Start(bools[0])) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.PawArrivePortOne = true; |
|
|
|
|
|
} |
|
|
|
|
|
//小炒爪子到达3号位上升沿信号捕获 |
|
|
|
|
|
if (RTrig.GetInstance("SmartGitdistance2Complete").Start(bools[1])) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.PawArrivePortTwo = true; |
|
|
|
|
|
} |
|
|
|
|
|
//小炒爪子到达3号位上升沿信号捕获 |
|
|
|
|
|
if (RTrig.GetInstance("SmartGitdistance3Complete").Start(bools[2])) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.PawArrivePortThree = true; |
|
|
|
|
|
} |
|
|
|
|
|
isInitialArrive = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取定位到达状态 |
|
|
|
|
|
GetStatus("M10.0", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
//ml_morkf.ArriveComplete = bools[i]; |
|
|
|
|
|
//小炒定点到达上升沿信号捕获 |
|
|
|
|
|
if (RTrig.GetInstance("SmartArriveComplete").Start(bools[i])) |
|
|
|
|
|
{ |
|
|
|
|
|
if(isInitialArrive == false) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show("到达上升沿为true,isInitialArrive is false"); |
|
|
|
|
|
isInitialArrive = true; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show("到达上升沿为true"); |
|
|
|
|
|
ml_morkf.ArriveComplete = true; |
|
|
|
|
|
isInitialArrive = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//获取总初始化完成 |
|
|
|
|
|
GetStatus("M10.2", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.InitialComplete = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
//抓手初始化完成 |
|
|
|
|
|
GetStatus("M10.3", new Action<object>((objects) => |
|
|
|
|
|
{ |
|
|
|
|
|
if (objects is bool[] bools) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 1; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ml_morkf.PawInitialComplete = bools[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}), 2); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#region 联网交互 |
|
|
private void ServerInit() |
|
|
private void ServerInit() |
|
|
{ |
|
|
{ |
|
|
//物料信息 |
|
|
//物料信息 |
|
@@ -1269,7 +1334,11 @@ namespace BPASmartClient.MorkF |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 订单排序 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
/// <param name="potActions"></param> |
|
|
|
|
|
/// <returns></returns> |
|
|
private List<PotActions> OrderSort(List<PotActions> potActions) |
|
|
private List<PotActions> OrderSort(List<PotActions> potActions) |
|
|
{ |
|
|
{ |
|
|
if (potActions.Count > 1) |
|
|
if (potActions.Count > 1) |
|
@@ -1287,6 +1356,7 @@ namespace BPASmartClient.MorkF |
|
|
} |
|
|
} |
|
|
return potActions; |
|
|
return potActions; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 订单状态发布 |
|
|
/// 订单状态发布 |
|
|
/// </summary> |
|
|
/// </summary> |
|
@@ -1297,8 +1367,6 @@ namespace BPASmartClient.MorkF |
|
|
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid }); |
|
|
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 数据解析 |
|
|
/// 数据解析 |
|
|
/// </summary> |
|
|
/// </summary> |
|
@@ -1348,23 +1416,18 @@ namespace BPASmartClient.MorkF |
|
|
// } |
|
|
// } |
|
|
// } |
|
|
// } |
|
|
//} |
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
//暂时使用本地菜单 |
|
|
StartLocalOrder(); |
|
|
StartLocalOrder(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 主任务 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public override void MainTask() |
|
|
|
|
|
{ |
|
|
|
|
|
MainProcessExcute(); |
|
|
|
|
|
//MinorProcessExcute(); |
|
|
|
|
|
//SingleProcess(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private object lock_MainProcessExcute = new object(); |
|
|
private object lock_MainProcessExcute = new object(); |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 炒锅主流程 |
|
|
/// 炒锅主流程 |
|
|
/// </summary> |
|
|
/// </summary> |
|
@@ -1546,79 +1609,6 @@ namespace BPASmartClient.MorkF |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//辅流程执行 |
|
|
|
|
|
//private void MinorProcessExcute() |
|
|
|
|
|
//{ |
|
|
|
|
|
// if (!morkF.MinorProcessExcuteLock) |
|
|
|
|
|
// { |
|
|
|
|
|
// morkF.MinorProcessExcuteLock = true; |
|
|
|
|
|
// Task.Run(() => |
|
|
|
|
|
// { |
|
|
|
|
|
// if (morkF.MinorProcessFlag && morkF.TakeMaterialQueue.Count > 0 && morkF.listStirBom.Count > 0 ) |
|
|
|
|
|
// { |
|
|
|
|
|
// morkF.MinorProessStatus = true; |
|
|
|
|
|
// morkF.MainProcessStatus = false; |
|
|
|
|
|
// StirFryBom bom = morkF.listStirBom.ElementAt(0); |
|
|
|
|
|
// morkF.listStirBom.RemoveAt(0); |
|
|
|
|
|
// foreach (var res in bom.StirFryActions) |
|
|
|
|
|
// { |
|
|
|
|
|
// DeviceProcessLogShow($"执行流程{res.Time}"); |
|
|
|
|
|
// //机器人线程 |
|
|
|
|
|
// Task taskRobot = Task.Run(new Action(() => |
|
|
|
|
|
// { |
|
|
|
|
|
// foreach (var temp in res.RobotActions) |
|
|
|
|
|
// { |
|
|
|
|
|
// switch (temp) |
|
|
|
|
|
// { |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// })); |
|
|
|
|
|
// //炒锅线程操作 |
|
|
|
|
|
// Task taskPot = Task.Run(new Action(() => |
|
|
|
|
|
// { |
|
|
|
|
|
// foreach (var temp in res.PotActions) |
|
|
|
|
|
// { |
|
|
|
|
|
// switch (temp) |
|
|
|
|
|
// { |
|
|
|
|
|
// case StirFryPotAction.NONE: |
|
|
|
|
|
// break; |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// })); |
|
|
|
|
|
// Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束 |
|
|
|
|
|
// Task.Delay(res.During * 1000).Wait();//当前流程延迟 |
|
|
|
|
|
// if (morkF.MainProcessWait) |
|
|
|
|
|
// { |
|
|
|
|
|
// if (morkF.MainHasTakeMaterial) |
|
|
|
|
|
// { |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
// else |
|
|
|
|
|
// { |
|
|
|
|
|
// //关闭灶加热 |
|
|
|
|
|
// //阻塞辅流程 |
|
|
|
|
|
// minorReset.WaitOne(); |
|
|
|
|
|
// //morkF.MinorProessStatus = true; |
|
|
|
|
|
// //morkF.MainProcessStatus = false; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
// morkF.MinorOutMealComplete = true; |
|
|
|
|
|
// } |
|
|
|
|
|
// else |
|
|
|
|
|
// { |
|
|
|
|
|
// morkF.MinorProcessExcuteLock = false;//解除辅流程自锁 |
|
|
|
|
|
// } |
|
|
|
|
|
// }); |
|
|
|
|
|
// } |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 信号处理 |
|
|
/// 信号处理 |
|
@@ -1640,67 +1630,6 @@ namespace BPASmartClient.MorkF |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 获取炒锅PLC的所有状态 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
/// <param name="key"></param> |
|
|
|
|
|
/// <param name="action"></param> |
|
|
|
|
|
/// <param name="num">炒锅编号</param> |
|
|
|
|
|
private void GetStatus(string key, Action<object> action,int num) |
|
|
|
|
|
{ |
|
|
|
|
|
if(dicPort2peripheralStatus.ContainsKey(num)) |
|
|
|
|
|
{ |
|
|
|
|
|
if (dicPort2peripheralStatus[num].ContainsKey(key)) |
|
|
|
|
|
{ |
|
|
|
|
|
action((object)dicPort2peripheralStatus[num][key]);//获取PLC指定地址的状态值 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
///// <summary> |
|
|
|
|
|
///// 写数据 |
|
|
|
|
|
///// </summary> |
|
|
|
|
|
///// <param name="address"></param> |
|
|
|
|
|
///// <param name="value"></param> |
|
|
|
|
|
//private void WriteData(string address, object value) |
|
|
|
|
|
//{ |
|
|
|
|
|
// EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value }); |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 炒锅初始化 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public void PLCInite() |
|
|
|
|
|
{ |
|
|
|
|
|
for(int i = 0;i<morkFs.Count;i++) |
|
|
|
|
|
{ |
|
|
|
|
|
FirePot_Write("LB0", true, i); |
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < sleepCount && !morkFs[i].FryPot1_InitialComplete; j++) |
|
|
|
|
|
{ |
|
|
|
|
|
Thread.Sleep(sleepTime); |
|
|
|
|
|
if(j>=sleepCount-1) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show($"炒锅{j}初始化超时"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//while (!morkFs[i].FryPot1_InitialComplete) |
|
|
|
|
|
//{ |
|
|
|
|
|
// Thread.Sleep(500); |
|
|
|
|
|
//} |
|
|
|
|
|
FirePot_Write("LB0", false, i); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
|
|
|
|
public override void Stop() |
|
|
|
|
|
{ |
|
|
|
|
|
IsHealth = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void SimOrder() |
|
|
public override void SimOrder() |
|
|
{ |
|
|
{ |
|
|
ActionManage.GetInstance.Register(morkSim, "模拟小炒锅1订单"); |
|
|
ActionManage.GetInstance.Register(morkSim, "模拟小炒锅1订单"); |
|
|