Ver código fonte

11

一拖四味魔方配料系统
ZhaoGang 1 ano atrás
pai
commit
8bf65b7687
4 arquivos alterados com 55 adições e 38 exclusões
  1. +12
    -5
      BPASmartClient.CustomResource/Pages/View/MainView.xaml
  2. +29
    -32
      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 Ver arquivo

@@ -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
- 32
DosingSystem/ExcuteControl .cs Ver arquivo

@@ -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,13 +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++)
{
//判断IP是否在列表中
@@ -1397,23 +1394,16 @@ 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)
@@ -1426,21 +1416,36 @@ 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)
{
//doDeviceCount 集合 键为各个设备,值为该设备执行过的配方。
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);
}

}
}
@@ -1502,9 +1507,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)
{
var deviceModbus = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp;
MessageNotify.GetInstance.ShowRunLog( $"下发配料信息{Recipes.ElementAt(doCount).RecipeName}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}");
//传送带停止
deviceModbus.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//设置下料重量
@@ -1553,11 +1555,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);
}
}
@@ -1587,7 +1588,6 @@ namespace BPASmartClient.DosingSystem
}
else
{
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
@@ -1621,9 +1621,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 Ver arquivo

@@ -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 Ver arquivo

@@ -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)


Carregando…
Cancelar
Salvar