Browse Source

上传

一拖四味魔方配料系统
lyw 8 months ago
parent
commit
8b5a12442d
2 changed files with 29 additions and 36 deletions
  1. +16
    -8
      DosingSystem/ExcuteControl .cs
  2. +13
    -28
      DosingSystem/Model/DeviceInquire.cs

+ 16
- 8
DosingSystem/ExcuteControl .cs View File

@@ -484,7 +484,7 @@ namespace BPASmartClient.DosingSystem
recipeProcesses.ElementAt(s).RawMaterials.ElementAt(t).RecipeStatus = 2;
recipeProcesses.ElementAt(s).RawMaterials.ElementAt(t).Status = (Status)1;
MessageNotify.GetInstance.ShowRunLog($"设备{DeviceInquire.GetInstance.DeviceLists[ip].DeviceName}配料状态:正在配料");
DeviceInquire.GetInstance.DeviceLists[ip].recipeC = -1;
});
}

@@ -638,19 +638,18 @@ namespace BPASmartClient.DosingSystem
ActionManage.GetInstance.Send("配料完成", UserTreeCompelete);
ActionManage.GetInstance.Send("历史记录", Json<OldRecipe>.Data.Recipes);
}

}
});
}

int recipecount = recipeProcesses.Count - (recipeNameNum - UserTreeCompelete.Count);
int re =0;
int re =-1;
if (recipecount < recipeProcesses.Count && recipecount >= 0)
{
re = recipeProcesses.ElementAt(recipecount).RawMaterials.ToList().FindIndex(a => a.RawMaterialName == DeviceInquire.GetInstance.DeviceLists[ip].DeviceName && a.Loc == DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PassPail && a.RecipeStatus != 3);

}
if (maxPail <= passPail && (recipeNameNum-1) < RecipeNames.Count && !DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PailArrive&&re<0&& recipNameNum_1==recipeNameNum)
if (maxPail <= passPail && recipeNameNum < RecipeNames.Count && !DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PailArrive&&re<0&& recipNameNum_1==recipeNameNum)
{
SimensSend.GetInstance.SendSimens.Write<ushort>($"DB1.DBW{810 + 2 * (dnum - 1)}", 0);
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}桶数已清零");
@@ -694,7 +693,7 @@ namespace BPASmartClient.DosingSystem
}
}
}
if (DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PailArrive)
if (DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PailArrive&& recipeNameNum - 1< RecipeNames.Count)
{
if (recipeNameNum > 0)
{
@@ -706,7 +705,16 @@ namespace BPASmartClient.DosingSystem
int re = 0;
if (recipecount < recipeProcesses.Count && recipecount >= 0)
{
DeviceInquire.GetInstance.DeviceLists[ip].UpdateState(recipeProcesses, recipecount, out re);
re = recipeProcesses.ElementAt(recipecount).RawMaterials.ToList().FindIndex(a => a.RawMaterialName == DeviceInquire.GetInstance.DeviceLists[ip].DeviceName && a.Loc == DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PassPail && a.RecipeStatus == 1);
if (re>=0)
{
float weight= recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re).RawMaterialWeight;
DeviceInquire.GetInstance.DeviceLists[ip].UpdateState(weight);
recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re).RecipeStatus = 2;
recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re).Status = (Status)1;
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}配料状态:正在配料");
}
}

}
@@ -774,7 +782,7 @@ namespace BPASmartClient.DosingSystem
if ( rep== DeviceInquire.GetInstance.devices.Count&&!allowStart)
{
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"可以开始放入配料桶!"); });
Mr_state();
/*Mr_state();*/
allowStart = true;
}
}
@@ -786,7 +794,7 @@ namespace BPASmartClient.DosingSystem
TaskManage.GetInstance.StartLong(() =>
{
string ip = "192.168.2.10";
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(ip) && doDeviceCount.ContainsKey(ip)&& RecipeNames.Count>0)
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(ip) && doDeviceCount.ContainsKey(ip)&& RecipeNames.Count>0&& doDeviceCount[ip] >0)
{

int maxPail = 0;


+ 13
- 28
DosingSystem/Model/DeviceInquire.cs View File

@@ -23,6 +23,7 @@ using System.Net.NetworkInformation;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BPASmartClient.DosingSystem
{
@@ -454,7 +455,6 @@ namespace BPASmartClient.DosingSystem
{
return Task.Factory.StartNew(() =>
{

ushort reset = 0;
reset = reset.SetBitValue(1, true);
modbusTcp.Write<ushort>(DeviceAddress.Finish_Point.ToAdd(), reset);
@@ -462,13 +462,13 @@ namespace BPASmartClient.DosingSystem
modbusTcp.Write<ushort>(DeviceAddress.Finish_Point.ToAdd(), 0);

int dnum = deviceStatus.DeviceNum;
if (dnum > 0) {
if (dnum > 0)
{
SimensSend.GetInstance.SendSimens.Write<bool>($"DB1.DBX70{(int)((dnum - 1) / 8)}.{(dnum - 1) % 8}", true);
Thread.Sleep(100);
SimensSend.GetInstance.SendSimens.Write<bool>($"DB1.DBX70{(int)((dnum - 1) / 8)}.{(dnum - 1) % 8}", false);
}
MessageNotify.GetInstance.ShowRunLog($"设备{DeviceName}配料状态:配料完成复位");

});
}

@@ -484,27 +484,18 @@ namespace BPASmartClient.DosingSystem
}

public void UpdateState(ObservableCollection<RecipeModel> recipeProcesses, int recipecount,out int re)
public Task UpdateState(float weight)
{
if (!start_down)
{
re = recipeProcesses.ElementAt(recipecount).RawMaterials.ToList().FindIndex(a => a.RawMaterialName == DeviceName && a.Loc == deviceStatus.PassPail && a.RecipeStatus == 1);
if (re>=0)
{
modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), 1);
modbusTcp.Write<float>(DeviceAddress.WeightSet.ToAdd(), recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re).RawMaterialWeight);//下发重量
start_down = true;
recipeC = recipecount;
mrCount = re;
MessageNotify.GetInstance.ShowRunLog($"设备{DeviceName}配料状态:下发开始配料信号");
}
}
else
return Task.Factory.StartNew(() =>
{
re = -1;
}
MessageNotify.GetInstance.ShowRunLog($"设备{DeviceName}配料状态:下发开始配料信号");
modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), 1);
modbusTcp.Write<float>(DeviceAddress.WeightSet.ToAdd(), weight);//下发重量
Thread.Sleep(100);
modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), 0);
});


}
#endregion

@@ -525,12 +516,6 @@ namespace BPASmartClient.DosingSystem
//获取设备运行状态
var rs = this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (rs.IsSuccess) deviceStatus.RunStatus = rs.Content;
if (deviceStatus.RunStatus ==2&& recipeC>=0&& mrCount>=0&&start_down)
{
startAction?.Invoke(recipeC, mrCount);
start_down = false;
}

////获取设备料仓剩余重量
var wf = this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (wf.IsSuccess) deviceStatus.WeightFeedback = (uint)(wf.Content);


Loading…
Cancel
Save