浏览代码

上传

一拖四味魔方配料系统
yaowen liu 11 个月前
父节点
当前提交
42744bb295
共有 4 个文件被更改,包括 55 次插入30 次删除
  1. +12
    -5
      BPASmartClient.CustomResource/Pages/View/MainView.xaml
  2. +29
    -24
      DosingSystem/ExcuteControl .cs
  3. +3
    -0
      DosingSystem/View/RecipeControlView.xaml
  4. +11
    -1
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 12
- 5
BPASmartClient.CustomResource/Pages/View/MainView.xaml 查看文件

@@ -432,6 +432,13 @@
</Window.Resources>

<Grid Background="#103153">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="764*"/>
<ColumnDefinition Width="104*"/>
<ColumnDefinition Width="28*"/>
<ColumnDefinition Width="41*"/>
<ColumnDefinition Width="263*"/>
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="50" />
@@ -442,10 +449,10 @@
<Border
x:Name="MoveBorder"
Height="50"
VerticalAlignment="Top"
VerticalAlignment="Center"
Background="#0C2349"
BorderBrush="#55ffffff"
BorderThickness="0,0,0,1">
BorderThickness="0,0,0,1" Grid.ColumnSpan="5">

<StackPanel Orientation="Horizontal">
<Image Margin="15,5,0,5" Source="../../Image/HBL.png" />
@@ -465,8 +472,8 @@
<UniformGrid
Width="150"
Height="50"
HorizontalAlignment="Right"
Columns="3">
HorizontalAlignment="Left"
Columns="3" Grid.Column="4" Margin="113,0,0,0">
<Button
Name="ButMin"
Content="&#xe664;"
@@ -490,7 +497,7 @@

<!--#region 显示区设置-->

<Grid Grid.Row="1">
<Grid Grid.Row="1" Grid.ColumnSpan="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />


+ 29
- 24
DosingSystem/ExcuteControl .cs 查看文件

@@ -890,11 +890,11 @@ namespace BPASmartClient.DosingSystem
}
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}");
RecipeNames.Enqueue(RecipeName);

var res = Recipes.FirstOrDefault(p => p.RecipeName == RecipeName);
App.Current.Dispatcher.Invoke(() => { UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = RecipeName, RawMaterials = res.RawMaterials }); });
}
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); });
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); });
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配方:{RecipeNames.Count}", Time = DateTime.Now.ToString() });

}
/// <summary>
@@ -1379,11 +1379,10 @@ namespace BPASmartClient.DosingSystem
recipeProcesses.Clear();
TaskManage.GetInstance.StartLong(() =>
{
SimensSend.GetInstance.SendSimens.Write("M0.0", true);
SimensSend.GetInstance.SendSimens.Write("M0.1", true);
if (RecipeNames.Count > 0)
{

SimensSend.GetInstance.SendSimens.Write("M0.0", true);
SimensSend.GetInstance.SendSimens.Write("M0.1", true);
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
@@ -1392,21 +1391,15 @@ namespace BPASmartClient.DosingSystem
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail <= DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 0)
{
if (!doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
doDeviceCount.TryAdd(DeviceInquire.GetInstance.devices[i].IpAddress,0);
}
else
if (doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
int index = 0;
int recipeNameNum = doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress];
if (doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount&& doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]< RecipeNames.Count)
if (recipeNameNum == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount && recipeNameNum < RecipeNames.Count)
{
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum));
if (index >= 0 && index < Recipes.Count)
{
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配方{RecipeNames.ElementAt(recipeNameNum)}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}",Time = DateTime.Now.ToString()});
int maxPail = 0;
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
{
@@ -1417,20 +1410,37 @@ namespace BPASmartClient.DosingSystem
}
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);
doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]);
App.Current.Dispatcher.Invoke(new Action(() =>
doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, recipeNameNum + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]);

App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方{RecipeNames.ElementAt(recipeNameNum)}{recipeNameNum}下发到设备{DeviceInquire.GetInstance.devices[i].DeviceName}"); });

if (doDeviceCount.ContainsKey("192.168.2.10") && UserTreeWait.Count > 0 && doDeviceCount["192.168.2.10"] > recipeProcesses.Count)
{
if (doDeviceCount.ContainsKey("192.168.2.10")&&UserTreeWait.Count > 0 && doDeviceCount["192.168.2.10"] > recipeProcesses.Count)
App.Current.Dispatcher.Invoke(() =>
{
recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
}
}));
});
}
if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.180" && recipeNameNum > 1 && recipeProcesses.Count > 0)
{
App.Current.Dispatcher.Invoke(() =>
{
RecipeModel recipe = recipeProcesses?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum));
recipe.RecipStatus = "制作完成";
UserTreeCompelete.Insert(0, recipe);
recipeProcesses.RemoveAt(recipeProcesses.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
});
}
}

}
}
else
{

doDeviceCount.TryAdd(DeviceInquire.GetInstance.devices[i].IpAddress, 0);
}

}
}
@@ -1488,7 +1498,6 @@ namespace BPASmartClient.DosingSystem
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
if (deviceSet != null && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].IsConnected == true)
{
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配料信息{Recipes.ElementAt(doCount).RecipeName}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}",Time = DateTime.Now.ToString() });
//传送带停止
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//设置下料重量
@@ -1536,11 +1545,10 @@ namespace BPASmartClient.DosingSystem
if (DeviceInquire.GetInstance.DeviceLists[ DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1)
{
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 0);
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"中转料仓正在配料,传送带停止", Time = DateTime.Now.ToString() });
}
else
{
SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)600);
SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)900);
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 1);
}
}
@@ -1604,9 +1612,6 @@ namespace BPASmartClient.DosingSystem
if (SimensSend.GetInstance.sendCtrlModel.SendInfo&& DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"设备{DeviceInquire.GetInstance.devices[i].DeviceName}检测到有桶,并且料仓输送阻塞" +
$"" +
$"", Time = DateTime.Now.ToString() });
}
else
{


+ 3
- 0
DosingSystem/View/RecipeControlView.xaml 查看文件

@@ -807,6 +807,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="50" />
</Grid.RowDefinitions>

<!--#region 表格标题栏设置-->
@@ -897,6 +898,8 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

<Button Grid.Row="2" Style="{DynamicResource ControlButtonStyle}" Content="停止配料" Command="{Binding }"/>
</Grid>
<!--#endregion-->



+ 11
- 1
DosingSystem/ViewModel/RecipeControlViewModel.cs 查看文件

@@ -46,9 +46,19 @@ namespace BPASmartClient.DosingSystem.ViewModel
}

}));
}

Close = new BPARelayCommand(() =>
{
SimensSend.GetInstance.SendSimens.Write("M0.0", false);
SimensSend.GetInstance.SendSimens.Write("M0.1", false);
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
});
}

public BPARelayCommand Close { get; set; }
//private async void CancelRecipe(object o)//RecipeName
//{
// if (o != null && o is RecipeModel recipe)


正在加载...
取消
保存