Переглянути джерело

本地存储

一拖四味魔方配料系统
lyw 8 місяці тому
джерело
коміт
bd32efda18
11 змінених файлів з 344 додано та 7 видалено
  1. +7
    -1
      DosingSystem/App.xaml.cs
  2. +37
    -1
      DosingSystem/Converter/RunStatusConvert.cs
  3. +10
    -1
      DosingSystem/ExcuteControl .cs
  4. +1
    -1
      DosingSystem/Model/DeviceAddress.cs
  5. +4
    -2
      DosingSystem/Model/DeviceInquire.cs
  6. +8
    -0
      DosingSystem/Model/RawMaterialDeviceStatus.cs
  7. +6
    -0
      DosingSystem/Model/par/LocalRecipe.cs
  8. +192
    -0
      DosingSystem/View/MaterialDosageView.xaml
  9. +44
    -0
      DosingSystem/View/MaterialDosageView.xaml.cs
  10. +34
    -0
      DosingSystem/ViewModel/MaterialDosageViewModel.cs
  11. +1
    -1
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 7
- 1
DosingSystem/App.xaml.cs Переглянути файл

@@ -162,7 +162,13 @@ namespace BPASmartClient.DosingSystem
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.RecipeControlView"
});

RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "配方记录查询",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.MaterialDosageView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "",


+ 37
- 1
DosingSystem/Converter/RunStatusConvert.cs Переглянути файл

@@ -1,5 +1,8 @@
using System;
using BPASmartClient.Model;
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;

@@ -132,4 +135,37 @@ namespace BPASmartClient.DosingSystem.Converter
}
}

public class DownWeightConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
ObservableCollection <RawMaterialModel> temp = value as ObservableCollection<RawMaterialModel>;
if (temp!=null)
{
float weight = 0;
if ((int)parameter > 18)
{
temp.ToList().ForEach(a =>
{
weight += a.TotalWeight;
});
}
temp.ToList().ForEach(a =>
{
if (a.RawMaterialName == parameter.ToString())
{
weight += a.TotalWeight;
}
});
return weight;
}
return 0;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 10
- 1
DosingSystem/ExcuteControl .cs Переглянути файл

@@ -559,6 +559,8 @@ namespace BPASmartClient.DosingSystem
}

}

bool allowStart=false;
private void MatchRun()
{
@@ -667,7 +669,7 @@ namespace BPASmartClient.DosingSystem
if (recipe != null && recipe.RecipStatus != "制作完成")
{
int res = recipe.RawMaterials.ToList().FindIndex(a => a.RecipeStatus <3);
int res = recipe.RawMaterials.ToList().FindIndex(a => a.RecipeStatus !=3);
if (res < 0 )
{
recipe.RecipStatus = "制作完成";
@@ -751,6 +753,13 @@ namespace BPASmartClient.DosingSystem

}

int rep = doDeviceCount.Count(a => a.Value == 1);
if ( rep== DeviceInquire.GetInstance.devices.Count&&!allowStart)
{
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"可以开始放入配料桶!"); });
allowStart = true;
}
}

Thread.Sleep(10);


+ 1
- 1
DosingSystem/Model/DeviceAddress.cs Переглянути файл

@@ -28,7 +28,7 @@ namespace BPASmartClient.DosingSystem
/// <summary>
/// 下料重量反馈地址
/// </summary>
public static string CutWeightFeedback { get; set; } = "LW54";
public static string CutWeightFeedback { get; set; } = "LW58";

/// <summary>
/// 设备编号


+ 4
- 2
DosingSystem/Model/DeviceInquire.cs Переглянути файл

@@ -448,8 +448,8 @@ namespace BPASmartClient.DosingSystem
if (wf.IsSuccess) deviceStatus.WeightFeedback = (uint)(wf.Content);

////获取下料重量
var nwf = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (nwf.IsSuccess) deviceStatus.NowWeightFeedback = nwf.Content;
var nwf = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd(), 2, BPA.Helper.DataFormat.CDAB);
if (nwf.IsSuccess) deviceStatus.CutWeightFeedback = nwf.Content;

////获取设备编号
var dnum = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
@@ -461,6 +461,8 @@ namespace BPASmartClient.DosingSystem
deviceStatus.PailArrive = SimensSend.GetInstance.SendSimens.Read<bool>($"DB1.DBX80{(int)((dnum.Content-1)/8)}.{(dnum.Content-1)%8}").Content;
deviceStatus.PassPail = SimensSend.GetInstance.SendSimens.Read<ushort>($"DB1.DBW{810 + 2 * (dnum.Content - 1)}").Content;
deviceStatus.RecipePail = SimensSend.GetInstance.SendSimens.Read<int>($"DB1.DBW{710 + 4 * (dnum.Content - 1)}").Content;
deviceStatus.InPailAll = SimensSend.GetInstance.SendSimens.Read<int>($"DB1.DBW1000").Content;
deviceStatus.OutPailAll = SimensSend.GetInstance.SendSimens.Read<int>($"DB1.DBW1002").Content;
}
}



+ 8
- 0
DosingSystem/Model/RawMaterialDeviceStatus.cs Переглянути файл

@@ -118,5 +118,13 @@ namespace BPASmartClient.DosingSystem
/// 设置桶号
/// </summary>
public int RecipePail { get;set; }
/// <summary>
/// 进桶总数
/// </summary>
public int InPailAll { get; set; }
/// <summary>
/// 出桶总数
/// </summary>
public int OutPailAll { get; set; }
}
}

+ 6
- 0
DosingSystem/Model/par/LocalRecipe.cs Переглянути файл

@@ -13,5 +13,11 @@ namespace BPASmartClient.DosingSystem
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();


}
public class OldRecipe
{
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();


}
}

+ 192
- 0
DosingSystem/View/MaterialDosageView.xaml Переглянути файл

@@ -0,0 +1,192 @@
<UserControl x:Class="BPASmartClient.DosingSystem.View.MaterialDosageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View"
xmlns:vm ="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
xmlns:con ="clr-namespace:BPASmartClient.DosingSystem.Converter"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:MaterialDosageViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<con:DownWeightConvert x:Key="downWeightConvert"/>
<Style x:Key="myText" TargetType="TextBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" Background="Transparent" BorderBrush="White" BorderThickness="0.4">
<TextBlock Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Text}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="RadioState" TargetType="RadioButton">
<Setter Property="Margin" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#ddd" />
<Setter Property="VerticalContentAlignment" Value="Bottom" />
<Setter Property="Margin" Value="2,5" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="Consolas" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border
Name="radiobutton"
Background="{TemplateBinding Background}"
CornerRadius="5"
Opacity="0.85">
<Grid>
<!--<Border
x:Name="back_border"
BorderBrush="Black"
BorderThickness="0"
CornerRadius="1">
<Border.Effect>
<BlurEffect KernelType="Gaussian" Radius="2" />
</Border.Effect>
</Border>
<Border
x:Name="fore_border"
Margin="2"
BorderBrush="White"
BorderThickness="0"
CornerRadius="{Binding ElementName=button, Path=CornerRadius}"
Opacity="0.7">
<Border.Effect>
<BlurEffect KernelType="Gaussian" Radius="2" />
</Border.Effect>
</Border>-->


<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
TextBlock.FontFamily="{TemplateBinding FontFamily}"
TextBlock.FontSize="{TemplateBinding FontSize}"
TextBlock.Foreground="{TemplateBinding Foreground}" />

<Image
Name="im"
Source="/BPASmartClient.CustomResource;component/Image/按钮/组 8.png"
Stretch="Fill" />
</Grid>
</Border>

<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<!--<Setter TargetName="back_border" Property="BorderThickness" Value="1,0,1,1" />
<Setter TargetName="back_border" Property="CornerRadius" Value="5" />
<Setter TargetName="fore_border" Property="BorderThickness" Value="0,2,0,0" />
<Setter Property="Background" Value=" #4169E1" />-->
<Setter TargetName="im" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/按钮/组 7.png" />

</Trigger>

<Trigger Property="IsChecked" Value="False">
<Setter TargetName="im" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/按钮/组 8.png" />
</Trigger>

<Trigger Property="IsMouseOver" Value="True">
<!--<Setter TargetName="back_border" Property="BorderBrush" Value="white" />
<Setter TargetName="back_border" Property="BorderThickness" Value="1,1,1,1" />-->
<Setter TargetName="radiobutton" Property="Opacity" Value="1" />
<!--<Setter TargetName="im" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/按钮背景蓝色.png" />-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

</Setter.Value>

</Setter>

</Style>
</UserControl.Resources>
<Grid Margin="20,10" >
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Margin="0,0,0,10" Width="500" HorizontalAlignment="Right" VerticalAlignment="Center">
<pry:ImageBorder Width="{Binding ElementName=ggr, Path=ActualWidth}" Height="{Binding ElementName=ggr, Path=ActualHeight}" />
<UniformGrid Columns="3" HorizontalAlignment="Center" VerticalAlignment="Center">
<RadioButton Click="RadioButton_Click" Content="正在执行记录" GroupName="state" IsChecked="True" Style="{DynamicResource RadioState}" />
<RadioButton Click="RadioButton_Click_1" Content="已完成记录" GroupName="state" Style="{DynamicResource RadioState}" />
<RadioButton Click="RadioButton_Click_2" Content="历史记录" GroupName="state" Style="{DynamicResource RadioState}" />
</UniformGrid>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox Text="配方名称" Foreground="White" Style="{StaticResource myText}" />
<UniformGrid Grid.Column="1" Columns="19">
<TextBox Style="{StaticResource myText}" Text="1" Foreground="White" />
<TextBox Style="{StaticResource myText}" Text="2" Foreground="White"/>
<TextBox Style="{StaticResource myText}" Text="3" Foreground="White"/>
<TextBox Style="{StaticResource myText}" Text="4" Foreground="White" />
<TextBox Text="5" Foreground="White" Style="{StaticResource myText}" />
<TextBox Text="6" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="7" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="8" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="9" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="10" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="11" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="12" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="13" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="14" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="15" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="16" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="17" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="18" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="总量" Foreground="White" Style="{StaticResource myText}"/>
</UniformGrid>
</Grid>
<Grid Grid.Row="2" x:Name="OnGrid">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl x:Name="View" ItemsSource="{Binding recipeProcesses}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox Text="{Binding RecipeName}" Foreground="White" Style="{StaticResource myText}" />
<UniformGrid Grid.Column="1" Columns="19">
<TextBox Style="{StaticResource myText}" Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=1}" Foreground="White"/>
<TextBox Style="{StaticResource myText}" Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=2}" Foreground="White"/>
<TextBox Style="{StaticResource myText}" Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=3}" Foreground="White"/>
<TextBox Style="{StaticResource myText}" Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=4}" Foreground="White" />
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=5}" Foreground="White" Style="{StaticResource myText}" />
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=6}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=7}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=8}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=9}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=10}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=11}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=12}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=13}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=14}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=15}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=16}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=17}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=18}" Foreground="White" Style="{StaticResource myText}"/>
<TextBox Text="{Binding RawMaterials,Converter={StaticResource downWeightConvert},ConverterParameter=19}" Foreground="White" Style="{StaticResource myText}"/>
</UniformGrid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</UserControl>

+ 44
- 0
DosingSystem/View/MaterialDosageView.xaml.cs Переглянути файл

@@ -0,0 +1,44 @@
using BPA.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// MaterialDosageView.xaml 的交互逻辑
/// </summary>
public partial class MaterialDosageView : UserControl
{
public MaterialDosageView()
{
InitializeComponent();
}

private void RadioButton_Click(object sender, RoutedEventArgs e)
{
this.View.ItemsSource = ExcuteControl.GetInstance.recipeProcesses;
}

private void RadioButton_Click_1(object sender, RoutedEventArgs e)
{
this.View.ItemsSource = ExcuteControl.GetInstance.UserTreeCompelete;
}

private void RadioButton_Click_2(object sender, RoutedEventArgs e)
{
this.View.ItemsSource = Json<OldRecipe>.Data.Recipes;
}
}
}

+ 34
- 0
DosingSystem/ViewModel/MaterialDosageViewModel.cs Переглянути файл

@@ -0,0 +1,34 @@
using BPA.Helper;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.DosingSystem.ViewModel
{
public class MaterialDosageViewModel:NotifyBase
{
public MaterialDosageViewModel()
{
}
/// <summary>
/// 当前正在制作的配方
/// </summary>
public ObservableCollection<RecipeModel> recipeProcesses { get; set; } = ExcuteControl.GetInstance.recipeProcesses;

/// <summary>
/// 等待制作的配方
/// </summary>
public ObservableCollection<RecipeModel> OldRecipe { get; set; } = ExcuteControl.GetInstance.UserTreeWait;

/// <summary>
/// 已完成的配方
/// </summary>
public ObservableCollection<RecipeModel> UserTreeCompelete { get; set; } = ExcuteControl.GetInstance.UserTreeCompelete;
}

}

+ 1
- 1
DosingSystem/ViewModel/RecipeControlViewModel.cs Переглянути файл

@@ -1039,7 +1039,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
/// <summary>
/// 等待制作的配方
/// </summary>
public static ObservableCollection<RecipeModel> UserTreeWait { get; set; } = ExcuteControl.GetInstance.UserTreeWait;
public static ObservableCollection<RecipeModel> UserTreeWait { get; set; } = Json<OldRecipe>.Data.Recipes;

/// <summary>
/// 已完成的配方


Завантаження…
Відмінити
Зберегти