Browse Source

代码更新

master
pengliangyang 1 year ago
parent
commit
ab0b79bf63
4 changed files with 60 additions and 49 deletions
  1. +11
    -1
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  2. +19
    -27
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  3. +22
    -14
      BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
  4. +8
    -7
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs

+ 11
- 1
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -133,6 +133,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
}
}
}
//验证配方数据是否下发
Thread.Sleep(200);
if (!ReadPlcRecipeData(recipe))
{
App.Current.Dispatcher.Invoke(() =>
{
MessageNotify.GetInstance.ShowDialog($"配方{recipe.RecipeCode},plc配方数据和西门子配方数据不一致!", DialogType.Error);
});
}
MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},配方数据验证成功");
}
}
/// <summary>
@@ -197,7 +207,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
string Address = "";
float ReadWeight = (float)0.0;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
switch (barrel)
{
case 1:
@@ -219,6 +228,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
default:
break;
}
MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},地址:{Address},重量:{ReadWeight}");
if (Math.Floor(recipe.RawMaterial.ElementAt(index).RawMaterialWeight) != Math.Floor(ReadWeight))
{
return false;


+ 19
- 27
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -225,20 +225,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
GVL_BigStation.BarrelWasherSign = true;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");

HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
Thread.Sleep(200);
if (!HKDevice.ReadPlcRecipeData(LocalRecipes.ElementAt(index)))
{
App.Current.Dispatcher.Invoke(() =>
{
MessageNotify.GetInstance.ShowDialog($"plc配方数据和西门子配方数据不一致!", DialogType.Error);
});
};
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true);
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成");
}
}
else
@@ -246,7 +238,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true);
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成");
}
}
if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1)
@@ -254,12 +246,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (LocalRecipes.ElementAt(index).IsWashingBarrel)
{
HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位");
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},洗桶信号复位");
}
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false);
StockBinParReset();
GVL_BigStation.Recipe1DosingStatus = 2;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
}
if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish)
{
@@ -288,7 +280,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
default:
break;
}
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},配料完成");
foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
@@ -1001,7 +993,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
else
{
if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1)
if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1)
{
SiemensRecipeQueue1.Enqueue(data.RecipeCode);
MessageNotify.GetInstance.ShowRunLog($"本地配方,配方:{data.RecipeCode},加入队列1");
@@ -1346,7 +1338,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
GVL_BigStation.Recipe1DosingFinish = true;
GVL_BigStation.Recipe1DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方1,配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},配料完成");
ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index));
if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe)
{
@@ -1368,7 +1360,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe1Time).TotalSeconds;
FinishData.ProcessTime = Convert.ToInt16(a);
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
MessageNotify.GetInstance.ShowRunLog($"配方1,{code}配方配料完成,将信号反馈给西门子");
MessageNotify.GetInstance.ShowRunLog($"配方1,,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给西门子");
}
HKDevice.HK_PLC_S7.Write("DB99.DBX1.4", true);
GVL_BigStation.Recipe1DosingStatus = 3;
@@ -1382,7 +1374,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
});
GVL_BigStation.Recipe1DosingStatus = 0;
MessageNotify.GetInstance.ShowRunLog($"配方1,{code}配方配料完成,复位plc配料完成信号");
MessageNotify.GetInstance.ShowRunLog($"配方1,,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号");
}
}
}
@@ -1459,7 +1451,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
GVL_BigStation.BarrelWasherSign = false;
}
GVL_BigStation.Recipe2DosingFinish = true;
MessageNotify.GetInstance.ShowRunLog($"配方2,配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},配料完成");
ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index));
if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe)
{
@@ -1481,7 +1473,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe2Time).TotalSeconds;
FinishData.ProcessTime = Convert.ToInt16(a);
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
MessageNotify.GetInstance.ShowRunLog($"配方2,{code}配方配料完成,将信号反馈给西门子");
MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给西门子");
}
HKDevice.HK_PLC_S7.Write("DB99.DBX1.5", true);
GVL_BigStation.Recipe2DosingStatus = 3;
@@ -1496,7 +1488,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
});
GVL_BigStation.Recipe2DosingStatus = 0;
MessageNotify.GetInstance.ShowRunLog($"配方2,{code}配方配料完成,复位plc配料完成信号");
MessageNotify.GetInstance.ShowRunLog($"配方2,,配方编号:{code},托盘编号:{trayCode},,复位plc配料完成信号");
}
}
}
@@ -1573,7 +1565,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
GVL_BigStation.Recipe3DosingFinish = true;
GVL_BigStation.Recipe3DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方3,配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},配料完成");
ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index));
if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe)
{
@@ -1595,7 +1587,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe3Time).TotalSeconds;
FinishData.ProcessTime = Convert.ToInt16(a);
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
MessageNotify.GetInstance.ShowRunLog($"配方3,{code}配方配料完成,将信号反馈给西门子");
MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给西门子");
}
HKDevice.HK_PLC_S7.Write("DB99.DBX1.6", true);
GVL_BigStation.Recipe3DosingStatus = 3;
@@ -1609,7 +1601,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
});
GVL_BigStation.Recipe3DosingStatus = 0;
MessageNotify.GetInstance.ShowRunLog($"配方3,{code}配方配料完成,复位plc配料完成信号");
MessageNotify.GetInstance.ShowRunLog($"配方3,,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号");
}
}
}
@@ -1686,7 +1678,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
GVL_BigStation.Recipe4DosingFinish = true;
GVL_BigStation.Recipe4DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方4,配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},配料完成");
ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index));
if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe)
{
@@ -1708,7 +1700,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe4Time).TotalSeconds;
FinishData.ProcessTime = Convert.ToInt16(a);
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
MessageNotify.GetInstance.ShowRunLog($"配方4,{code}配方配料完成,将信号反馈给西门子");
MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给西门子");
}
HKDevice.HK_PLC_S7.Write("DB99.DBX1.7", true);
GVL_BigStation.Recipe4DosingStatus = 3;
@@ -1722,7 +1714,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
});
GVL_BigStation.Recipe4DosingStatus = 0;
MessageNotify.GetInstance.ShowRunLog($"配方4,{code}配方配料完成,复位plc配料完成信号");
MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号");
}
}
}


+ 22
- 14
BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml View File

@@ -7,7 +7,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel"
Title="RecipeInfosView"
Width="800"
Width="1000"
Height="620"
AllowsTransparency="True"
Background="{x:Null}"
@@ -305,17 +305,20 @@
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition Width="120"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="原料名称" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
<TextBlock Grid.Column="0" Text="原料位置" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
<GridSplitter></GridSplitter>
<TextBlock Grid.Column="1" Text="原料位置" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
<TextBlock Grid.Column="1" Text="原料名称" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
<GridSplitter Grid.Column="1"></GridSplitter>
<TextBlock Grid.Column="2" Text="原料中文名" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
<GridSplitter Grid.Column="1"></GridSplitter>
<TextBlock Grid.Column="2" Text="托盘桶号" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
<TextBlock Grid.Column="3" Text="托盘桶号" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
<GridSplitter Grid.Column="2"></GridSplitter>
<TextBlock Grid.Column="3" Text="原料重量" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"></TextBlock>
<TextBlock Grid.Column="4" Text="原料重量" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"></TextBlock>
<GridSplitter Grid.Column="3"></GridSplitter>
<TextBlock Grid.Column="4" Text="操作" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
<TextBlock Grid.Column="5" Text="操作" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
</Grid>
<ScrollViewer Grid.Row="3" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding RawMaterialsInfo}">
@@ -335,6 +338,7 @@
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding RawMaterialLocation}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus">
@@ -356,36 +360,40 @@
FontSize="14"
Foreground="LightGray"
IsEditable="False"
ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
SelectedIndex="{Binding RawMaterialCount}"
ItemsSource="{Binding DataContext.RawMaterialLocation, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
SelectedValue="{Binding RawMaterialLocation}"
MouseLeave="ComboBox_MouseLeave"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding RawMaterialName}"/>
Text="{Binding RawMaterialLocation}"/>
<StackPanel
VerticalAlignment="Center" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center" >
<TextBlock Grid.Column="1" Text="{Binding RawMaterialLocation}" Background="Transparent" FontSize="14" Foreground="LightGray" ></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding RawMaterialName}" Background="Transparent" FontSize="14" Foreground="LightGray" ></TextBlock>
</StackPanel>
<StackPanel
VerticalAlignment="Center" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Center" >
<TextBlock Grid.Column="1" Text="{Binding RawMaterialChineseName}" Background="Transparent" FontSize="14" Foreground="LightGray" ></TextBlock>
</StackPanel>
<!--<TextBox Text="{Binding RawMaterialName}" Background="Transparent" FontSize="14"
BorderBrush="#e69519" Foreground="LightGray" Width="190" Margin="10,0,0,10" ></TextBox>-->
<StackPanel
Margin="3" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Center">
Margin="3" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBox Text="{Binding RawMaterialBarrelNum}" Background="Transparent" FontSize="14"
BorderBrush="#e69519" Foreground="LightGray" Width="120" ></TextBox>
</StackPanel>
<StackPanel
Margin="3" Orientation="Horizontal" Grid.Column="3" HorizontalAlignment="Center">
Margin="3" Orientation="Horizontal" Grid.Column="4" HorizontalAlignment="Center">
<TextBox Text="{Binding RawMaterialWeight}" Background="Transparent" FontSize="14"
BorderBrush="#e69519" Foreground="LightGray" Width="120" ></TextBox>
<TextBlock FontSize="14" VerticalAlignment="Center" Margin="4,0,0,0" Text="Kg" Foreground="#e69519" ></TextBlock>
</StackPanel>
<Button Grid.Column="4"
<Button Grid.Column="5"
Content="删除"
Width="94"
FontSize="14"
Background="Transparent"
BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Center"
Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}"
CommandParameter="{Binding RawMaterialCount}"></Button>
CommandParameter="{Binding RawMaterialLocation}"></Button>
</Grid>
</ControlTemplate>
</RadioButton.Template>


+ 8
- 7
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs View File

@@ -22,7 +22,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
foreach (var item in ProcessControl.GetInstance.RawMaterialsInfo)
{
RawMaterialNames.Add(item.RawMaterialName);
RawMaterialLocation.Add(item.RawMaterialLocation);
}
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
@@ -34,7 +34,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
IsWashingBarrel = rm.IsWashingBarrel;
foreach (var item in rm.RawMaterial)
{
item.RawMaterialCount = Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == item.RawMaterialName);
//item.RawMaterialCount = Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == item.RawMaterialName);
RawMaterialsInfo.Add(item);
}
}
@@ -43,10 +43,11 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
foreach (var item in RawMaterialsInfo)
{
if (RawMaterialNames.Contains(item.RawMaterialName))
if (RawMaterialLocation.Contains(item.RawMaterialLocation))
{
int index = Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == item.RawMaterialName);
item.RawMaterialLocation = ProcessControl.GetInstance.RawMaterialsInfo.ElementAt(index).RawMaterialLocation;
int index = Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialLocation == item.RawMaterialLocation);
item.RawMaterialName = ProcessControl.GetInstance.RawMaterialsInfo.ElementAt(index).RawMaterialName;
item.RawMaterialChineseName = ProcessControl.GetInstance.RawMaterialsInfo.ElementAt(index).RawMaterialChineseName;
}
}
}), "RawMaterialNames",true);
@@ -111,7 +112,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
});

RemoveRecipe = new RelayCommand<int>((index) => {
var res = RawMaterialsInfo.FirstOrDefault(p => p.RawMaterialCount == index);
var res = RawMaterialsInfo.FirstOrDefault(p => p.RawMaterialLocation == index);
if (res != null)
RawMaterialsInfo.Remove(res);
});
@@ -141,6 +142,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel

public ObservableCollection<RawMaterial> RawMaterialsInfo { get; set; } = new ObservableCollection<RawMaterial>() ;

public ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>();
public ObservableCollection<int> RawMaterialLocation { get; set; } = new ObservableCollection<int>();
}
}

Loading…
Cancel
Save