@@ -532,7 +532,6 @@ namespace BPASmartClient.Device | |||
variableMonitors.ElementAt(index).CurrentValue = item.GetValue(status)?.ToString(); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
@@ -0,0 +1,41 @@ | |||
<Application x:Class="BPASmartClient.DosingSystemSingle.App" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle"> | |||
<Application.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecCheckBox.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecTitleBarButton.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/GlobalStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecComboBox.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecIcoButtonStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecToggleButton.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/BeveledRadioButtonStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/DatePickeerDictionary.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/TextBoxStyle.xaml" /> | |||
<ResourceDictionary> | |||
<con:ColorConverter x:Key="ColorConverter" /> | |||
<con:TextConverter x:Key="TextConverter" /> | |||
<con:VisibleTypeConverter x:Key="VisibleTypeConverter" /> | |||
<con:StatusConverter x:Key="StatusConverter" /> | |||
<con:StringToIconConverter x:Key="StringToIconConverter" /> | |||
<con:BoolToVisibilityConvert x:Key="BoolToVisibilityConvert" /> | |||
<con:CountIsVisiableConvert x:Key="CountIsVisiableConvert" /> | |||
<con:BoolToFillColorConverter x:Key="BoolToFillColorConverter" /> | |||
<con:RecipeStatusConvert x:Key="RecipeStatusConvert" /> | |||
</ResourceDictionary> | |||
<ResourceDictionary> | |||
<ImageBrush x:Key="hbl" ImageSource="/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||
<ImageBrush x:Key="dbxt" ImageSource="/BPASmartClient.CustomResource;component/Image/顶部线条.png" /> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Application.Resources> | |||
</Application> |
@@ -0,0 +1,300 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Linq; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using BPASmartClient.CustomResource.Pages.Enums; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.CustomResource.Pages.View; | |||
using BPASmartClient.CustomResource.Pages.ViewModel; | |||
using BPASmartClient.DosingSystemSingle.View; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
/// <summary> | |||
/// Interaction logic for App.xaml | |||
/// </summary> | |||
public partial class App : Application | |||
{ | |||
public static Window MainWindow; | |||
public EventWaitHandle ProgramStarted { get; set; } | |||
protected override void OnStartup(StartupEventArgs e) | |||
{ | |||
bool createNew; | |||
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "DosingSystemSingleApp", out createNew); | |||
if (!createNew) | |||
{ | |||
MessageBox.Show("程序已启动"); | |||
App.Current.Shutdown(); | |||
Environment.Exit(0); | |||
} | |||
base.OnStartup(e); | |||
BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut(); | |||
MenuInit(); | |||
DataInit(); | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 | |||
}), "设备初始化"); | |||
MainView mv = new MainView(); | |||
mv.TitleName = "味魔方管理系统软件[简称:味魔方] 1.0.1"; | |||
LoginView lv = new LoginView(); | |||
var res = lv.ShowDialog(); | |||
if (res != null && res == true) | |||
{ | |||
BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.ShowUserLog("用户登录"); | |||
mv.Show(); | |||
} | |||
else | |||
mv.Close(); | |||
MainWindow = mv; | |||
} | |||
protected override void OnExit(ExitEventArgs e) | |||
{ | |||
base.OnExit(e); | |||
Json<LocaPar>.Save(); | |||
Json<DevicePar>.Save(); | |||
BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.LogSave(); | |||
ThreadManage.GetInstance().Dispose(); | |||
} | |||
private void MenuInit() | |||
{ | |||
#region 配方管理菜单 | |||
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>(); | |||
RecipeManage.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "配方管理", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
ToggleWindowPath = "View.RecipeSettingsView" | |||
}); | |||
RecipeManage.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "配方下发", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
ToggleWindowPath = "View.RecipeControlView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
MainMenuName = "配方管理", | |||
Alias = "Recipe Management", | |||
subMenumodels = RecipeManage, | |||
}); | |||
#endregion | |||
#region 参数设置 | |||
ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>(); | |||
ParSet.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "原料参数设置", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
ToggleWindowPath = "View.DeviceMaterialParView" | |||
}); | |||
ParSet.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "设备参数设置", | |||
SubMenuPermission = new Permission[] { Permission.管理员 }, | |||
AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
ToggleWindowPath = "View.CommParSetView" | |||
}); | |||
//ParSet.Add(new SubMenumodel() | |||
//{ | |||
// SubMenuName = "出料口管理设置", | |||
// SubMenuPermission = new Permission[] { Permission.管理员 }, | |||
// AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
// ToggleWindowPath = "View.OutletManagementView" | |||
//}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
MainMenuName = "参数设置", | |||
Alias = "Parameter Set", | |||
subMenumodels = ParSet, | |||
}); | |||
#endregion | |||
#region 手动控制 | |||
/*ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>(); | |||
ManualControl.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "气缸手动控制", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
ToggleWindowPath = "View.ManualControlView" | |||
}); | |||
ManualControl.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "输送带手动控制", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
ToggleWindowPath = "View.ConveyerBeltManualView" | |||
}); | |||
//ManualControl.Add(new SubMenumodel() | |||
//{ | |||
// SubMenuName = "料仓控制", | |||
// SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
// AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
// ToggleWindowPath = "View.StockControlView" | |||
//}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "手动控制", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
Alias = "Parameter Set", | |||
subMenumodels = ManualControl, | |||
});*/ | |||
#endregion | |||
#region 消息日志 | |||
ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>(); | |||
InfoLog.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "操作日志", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.UserLogView" | |||
}); | |||
InfoLog.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "运行日志", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.RunLogView" | |||
}); | |||
InfoLog.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "报警记录", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.AlarmView" | |||
}); | |||
InfoLog.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "调试日志", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.DebugLogView" | |||
}); | |||
//InfoLog.Add(new SubMenumodel() | |||
//{ | |||
// SubMenuName = "报表数据", | |||
// SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 }, | |||
// AssemblyName = "BPASmartClient.CustomResource", | |||
// ToggleWindowPath = "Pages.View.ReportView" | |||
//}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "消息日志", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
Alias = "Message Log", | |||
subMenumodels = InfoLog, | |||
}); | |||
#endregion | |||
#region 硬件设备监控 | |||
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>(); | |||
DeviceMonitor.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "原料设备列表", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
ToggleWindowPath = "View.DeviceListView" | |||
}); | |||
DeviceMonitor.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "设备状态", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystemSingle", | |||
ToggleWindowPath = "View.HardwareStatusView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "设备监控", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
Alias = "Device Monitor", | |||
subMenumodels = DeviceMonitor, | |||
}); | |||
#endregion | |||
#region 用户管理 | |||
ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>(); | |||
UserManager.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "用户登录", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.SubPagLoginView" | |||
}); | |||
UserManager.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "密码修改", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.PasswordChangeView" | |||
}); | |||
UserManager.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "用户管理", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.UserManagerView" | |||
}); | |||
//UserManager.Add(new SubMenumodel() | |||
//{ | |||
// SubMenuName = "NFC登录管理", | |||
// SubMenuPermission = new Permission[] { Permission.管理员 }, | |||
// AssemblyName = "BPASmartClient.CustomResource", | |||
// ToggleWindowPath = "Pages.View.NfcSetView" | |||
//}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "用户管理", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
Alias = "User Management", | |||
subMenumodels = UserManager, | |||
}); | |||
#endregion | |||
} | |||
private void DataInit() | |||
{ | |||
//Config.GetInstance.Init(); | |||
Json<LocaPar>.Read(); | |||
Json<DevicePar>.Read(); | |||
Json<LocaMaterial>.Read(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
using System.Windows; | |||
[assembly: ThemeInfo( | |||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | |||
//(used if a resource is not found in the page, | |||
// or application resource dictionaries) | |||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | |||
//(used if a resource is not found in the page, | |||
// app, or any theme specific resource dictionaries) | |||
)] |
@@ -0,0 +1,86 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>WinExe</OutputType> | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<None Remove="hbl.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="hbl.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Helper" Version="1.0.33" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.84" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.S7Net\BPASmartClient.S7Net.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Update="View\NewOutletView.xaml.cs"> | |||
<SubType>Code</SubType> | |||
</Compile> | |||
<Compile Update="View\OutletManagementView.xaml.cs"> | |||
<SubType>Code</SubType> | |||
</Compile> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Page Update="View\ChangeDeviceNameView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\CommParSetView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\ConveyerBeltManualView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\DeviceListView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\DeviceMaterialParView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\HardwareStatusView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\ManualControlView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\NewMaterialView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\NewOutletView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
<SubType>Designer</SubType> | |||
</Page> | |||
<Page Update="View\NewRecipeView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\OutletManagementView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
<SubType>Designer</SubType> | |||
</Page> | |||
<Page Update="View\RecipeControlView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\RecipeSettingsView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\StockControlView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,31 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows.Data; | |||
using System.Windows.Media; | |||
namespace BPASmartClient.DosingSystemSingle.Converter | |||
{ | |||
public class DataTableRedundantConverter : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (value != null && value is bool bit) | |||
{ | |||
if (bit) | |||
return new SolidColorBrush(Color.FromArgb(255, 245, 63, 98)); | |||
else | |||
return new SolidColorBrush(Color.FromArgb(255, 42, 178, 231)); | |||
} | |||
return default; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows.Data; | |||
namespace BPASmartClient.DosingSystemSingle.Converter | |||
{ | |||
public class RunStatusConvert : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (value is ushort tempValue) | |||
{ | |||
if (tempValue == 1) return "等待配料"; | |||
if (tempValue == 2) return "配料中"; | |||
if (tempValue == 3) return "配料完成"; | |||
} | |||
return "等待配料"; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
public class EnbleConvert : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (value is ushort tempValue) | |||
{ | |||
if (tempValue == 0) return true; | |||
if (tempValue == 1) return false; | |||
} | |||
return true; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
public class IntToSourceConvert : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (value is ushort tempValue) | |||
{ | |||
if (tempValue == 0) return "本地原料"; | |||
if (tempValue == 1) return "设备原料"; | |||
} | |||
return "未知"; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class AlarmInfo | |||
{ | |||
/// <summary> | |||
/// 1#急停 | |||
/// </summary> | |||
[Alarm("1#急停")] | |||
public bool EStop1 { get; set; } | |||
/// <summary> | |||
/// 伺服故障 | |||
/// </summary> | |||
[Alarm("伺服故障")] | |||
public bool Servo { get; set; } | |||
/// <summary> | |||
/// 变频器故障 | |||
/// </summary> | |||
[Alarm("变频器故障")] | |||
public bool Inverter { get; set; } | |||
/// <summary> | |||
/// 2#急停 | |||
/// </summary> | |||
[Alarm("2#急停")] | |||
public bool EStop2 { get; set; } | |||
/// <summary> | |||
/// 料仓上限 | |||
/// </summary> | |||
[Alarm("料仓上限")] | |||
public bool SiloUpperLimit { get; set; } | |||
/// <summary> | |||
/// 料仓下限 | |||
/// </summary> | |||
[Alarm("料仓下限")] | |||
public bool SiloLowerLimit { get; set; } | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class ConveyerBeltModel : NotifyBase | |||
{ | |||
public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } } | |||
private string _mName; | |||
public int Num { get { return _mNum; } set { _mNum = value; OnPropertyChanged(); } } | |||
private int _mNum; | |||
public int Speed | |||
{ | |||
get { return _mSpeed; } | |||
set | |||
{ | |||
_mSpeed = value; | |||
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBW{Num * 2 + 132}", (short)value); | |||
//SiemensDevice.GetInstance.MySiemens.WriteInt16(4, (short)value, (Num * 2 + 132)); | |||
MessageNotify.GetInstance.ShowRunLog($"DB4.DBW{Num * 2 + 132},{value}"); | |||
OnPropertyChanged(); | |||
} | |||
} | |||
private int _mSpeed; | |||
public bool ConveyerBeltWork | |||
{ | |||
get { return _mConveyerBeltWork; } | |||
set | |||
{ | |||
_mConveyerBeltWork = value; | |||
if (Num >= 1 && Num <= 32) | |||
{ | |||
var add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", Num, 6); | |||
SiemensDevice.GetInstance.MySiemens.Write(add, value); | |||
MessageNotify.GetInstance.ShowRunLog($"{add},{value}"); | |||
} | |||
OnPropertyChanged(); | |||
} | |||
} | |||
private bool _mConveyerBeltWork; | |||
public bool Control { get; set; } | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class CylinderStatusModel : NotifyBase | |||
{ | |||
/// <summary> | |||
/// 气缸原点信号 | |||
/// </summary> | |||
public bool HomeStatus { get { return _mHomeStatus; } set { _mHomeStatus = value; OnPropertyChanged(); } } | |||
private bool _mHomeStatus; | |||
/// <summary> | |||
/// 气缸到位信号 | |||
/// </summary> | |||
public bool InPlace { get { return _mInPlace; } set { _mInPlace = value; OnPropertyChanged(); } } | |||
private bool _mInPlace; | |||
} | |||
} |
@@ -0,0 +1,105 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class DeviceAddress | |||
{ | |||
/// <summary> | |||
/// 设备名称起始地址 | |||
/// </summary> | |||
public static string DeviceName { get; set; } = "LW0"; | |||
/// <summary> | |||
/// 料仓重量反馈起始地址 | |||
/// </summary> | |||
public static string WeightFeedback { get; set; } = "LW52"; | |||
/// <summary> | |||
/// 重量设置地址 | |||
/// </summary> | |||
public static string WeightSet { get; set; } = "LW21"; | |||
/// <summary> | |||
/// 启动信号地址 | |||
/// </summary> | |||
public static string Start { get; set; } = "LW20"; | |||
/// <summary> | |||
/// 下料重量反馈地址 | |||
/// </summary> | |||
public static string CutWeightFeedback { get; set; } = "LW54"; | |||
/// <summary> | |||
/// 设备编号 | |||
/// </summary> | |||
public static string DeviceNum { get; set; } = "LW57"; | |||
/// <summary> | |||
/// 设备故障编码 | |||
/// </summary> | |||
public static string DeviceAlarmCode { get; set; } = "LW51"; | |||
/// <summary> | |||
/// 原料设备类型 | |||
/// 1:膏体,2:液体,3:粉体 | |||
/// </summary> | |||
public static string MaterialDeviceType { get; set; } = "LW56"; | |||
/// <summary> | |||
/// 设备运行状态地址 | |||
/// </summary> | |||
public static string RunStatus { get; set; } = "LW60"; | |||
/// <summary> | |||
/// 出料完成,置位该信号,plc复位运行状态 | |||
/// </summary> | |||
public static string FinfishStatus { get; set; } = "LW40"; | |||
/// <summary> | |||
/// 慢加重量 | |||
/// </summary> | |||
public static string SlowlyAddWeight { get; set; } = "LW23"; | |||
/// <summary> | |||
/// 提前关阀重量 | |||
/// </summary> | |||
public static string PreCloseValveWeight { get; set; } = "LW25"; | |||
/// <summary> | |||
/// 快加速度 | |||
/// </summary> | |||
public static string RapidAcceleration { get; set; } = "LW27"; | |||
/// <summary> | |||
/// 慢加速度 | |||
/// </summary> | |||
public static string SlowAcceleration { get; set; } = "LW29"; | |||
/// <summary> | |||
/// 伺服手动速度 | |||
/// </summary> | |||
public static string ServoManualSpeed { get; set; } = "LW31"; | |||
/// <summary> | |||
/// 料仓上限重量 | |||
/// </summary> | |||
public static string SiloUpperLimitWeight { get; set; } = "LW33"; | |||
/// <summary> | |||
/// 料仓下限重量 | |||
/// </summary> | |||
public static string LowerLimitWeightOfSilo { get; set; } = "LW35"; | |||
/// <summary> | |||
/// 搅拌速度 | |||
/// </summary> | |||
public static string StirringSpeed { get; set; } = "LW37"; | |||
} | |||
} |
@@ -0,0 +1,78 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class DeviceCurrentStatus : NotifyBase | |||
{ | |||
/// <summary> | |||
/// 当前料仓重量反馈 | |||
/// </summary> | |||
public double Weight { get { return _mWeight; } set { _mWeight = value; OnPropertyChanged(); } } | |||
private double _mWeight; | |||
/// <summary> | |||
/// 重量设置 | |||
/// </summary> | |||
public float SetWeight { get { return _mSetWeight; } set { _mSetWeight = value; OnPropertyChanged(); } } | |||
private float _mSetWeight; | |||
///// <summary> | |||
///// 下料控制 | |||
///// </summary> | |||
//public bool IsLayOff { get { return _mIsLayOff; } set { _mIsLayOff = value; OnPropertyChanged(); } } | |||
//private bool _mIsLayOff; | |||
/// <summary> | |||
/// 下料控制 | |||
/// </summary> | |||
public bool BaitingControl { get { return _mBaitingControl; } set { _mBaitingControl = value; OnPropertyChanged(); } } | |||
private bool _mBaitingControl; | |||
/// <summary> | |||
/// 设备运行状态 | |||
/// </summary> | |||
public bool RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } } | |||
private bool _mRunStatus; | |||
/// <summary> | |||
/// 设备编号 | |||
/// </summary> | |||
public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } } | |||
private int _mDeviceNum; | |||
/// <summary> | |||
/// 设备名称 | |||
/// </summary> | |||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||
private string _mDeviceName; | |||
/// <summary> | |||
/// 仓盖是否被打开 | |||
/// </summary> | |||
public bool IsOpen { get { return _mIsOpen; } set { _mIsOpen = value; OnPropertyChanged(); } } | |||
private bool _mIsOpen; | |||
/// <summary> | |||
/// 料仓时候有报警 | |||
/// </summary> | |||
public bool IsFault { get { return _mIsFault; } set { _mIsFault = value; OnPropertyChanged(); } } | |||
private bool _mIsFault; | |||
/// <summary> | |||
/// 桶到位检测 | |||
/// </summary> | |||
public bool BucketFlagbit { get { return _mBucketFlagbit; } set { _mBucketFlagbit = value; OnPropertyChanged(); } } | |||
private bool _mBucketFlagbit; | |||
} | |||
} |
@@ -0,0 +1,403 @@ | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.DosingSystemSingle.ViewModel; | |||
using BPASmartClient.Modbus; | |||
using BPASmartClient.Model; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Net.NetworkInformation; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Text.RegularExpressions; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class DeviceInquire | |||
{ | |||
private volatile static DeviceInquire _Instance; | |||
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire()); | |||
private DeviceInquire() { } | |||
string IPSegment = "192.168.0."; | |||
ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>(); | |||
List<string> InvalidIP = new List<string>();//无效 IP 集合 | |||
List<string> IPLists = new List<string>();//启动 Ping 任务IP集合 | |||
ConcurrentQueue<string> IPQueues = new ConcurrentQueue<string>();//pincomplete 完成队列 | |||
public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>(); | |||
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>(); | |||
public ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>(); | |||
private void DeviceDataInit() | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
for (int i = 0; i < DeviceLists.Count; i++) | |||
{ | |||
string deviceName = DeviceLists.ElementAt(i).Value.DeviceName; | |||
int TopIndex = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName); | |||
int BottomIndex = Array.FindIndex(BottomDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName); | |||
if (TopIndex >= 0 && TopIndex < TopDeviceCurrentStatuses.Count) | |||
{ | |||
TopDeviceCurrentStatuses.ElementAt(TopIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback; | |||
TopDeviceCurrentStatuses.ElementAt(TopIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; | |||
} | |||
if (BottomIndex >= 0 && BottomIndex < BottomDeviceCurrentStatuses.Count) | |||
{ | |||
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback; | |||
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; | |||
} | |||
int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key/* && p.DeviceName != DeviceLists.ElementAt(i).Value.DeviceName && p.DeviceNum != DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum*/); | |||
if (deviceIndex >= 0 && deviceIndex < devices.Count) | |||
{ | |||
devices.ElementAt(deviceIndex).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName; | |||
devices.ElementAt(deviceIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; | |||
} | |||
} | |||
Thread.Sleep(200); | |||
}), "设备状态监听"); | |||
} | |||
private void TestData() | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
DeviceLists.TryAdd($"192.168.1.{i + 1}", new DeviceStatus() { DeviceName = $"测试设备{i + 1}" }); | |||
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() | |||
{ | |||
DeviceName = $"测试设备{i + 1}", | |||
DeviceNum = i + 1, | |||
Weight = new Random().Next(100, 10000) / 100.0 | |||
}); | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel() | |||
{ | |||
DeviceIp = $"192.168.1.{i + 1}", | |||
RawMaterialName = $"测试设备{i + 1}", | |||
}); | |||
devices.Add(new Devices() | |||
{ | |||
DeviceName = $"测试设备{i + 1}", | |||
DeviceNum = i + 1, | |||
IpAddress = $"192.168.1.{i + 1}", | |||
}); | |||
} | |||
for (int i = 8; i < 16; i++) | |||
{ | |||
DeviceLists.TryAdd($"192.168.1.{i + 1}", new DeviceStatus() { DeviceName = $"测试设备{i + 1}" }); | |||
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() | |||
{ | |||
DeviceName = $"测试设备{i + 1}", | |||
DeviceNum = i + 1, | |||
Weight = new Random().Next(100, 10000) / 100.0 | |||
}); | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel() | |||
{ | |||
DeviceIp = $"192.168.1.{i + 1}", | |||
RawMaterialName = $"测试设备{i + 1}", | |||
}); | |||
devices.Add(new Devices() | |||
{ | |||
DeviceName = $"测试设备{i + 1}", | |||
DeviceNum = i + 1, | |||
IpAddress = $"192.168.1.{i + 1}", | |||
}); | |||
} | |||
} | |||
public void Init() | |||
{ | |||
if (!string.IsNullOrEmpty(Json<DevicePar>.Data.BaseParModel.NetworkSegAddress)) IPSegment = Json<DevicePar>.Data.BaseParModel.NetworkSegAddress; | |||
else Json<DevicePar>.Data.BaseParModel.NetworkSegAddress = IPSegment; | |||
//TestData(); | |||
IpAddressLines(); | |||
//SiemensDevice.GetInstance.Connect(Json<DevicePar>.Data.BaseParModel.DeviceAddress); | |||
DeviceDataInit(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
if (IPQueues.Count >= IPLists.Count) | |||
IpAddressLines(); | |||
Thread.Sleep(5000); | |||
}), "配料机设备上线监听", true); | |||
} | |||
public void Rescan() | |||
{ | |||
InvalidIP.Clear(); | |||
} | |||
public DeviceStatus GetDevice(string ip) | |||
{ | |||
if (ip != null) | |||
{ | |||
if (DeviceLists.ContainsKey(ip)) return DeviceLists[ip]; | |||
else return new DeviceStatus(); | |||
//var res = DeviceLists.Values.FirstOrDefault(p => p.IpAddress == ip); | |||
//if (res != null) return res; | |||
} | |||
return new DeviceStatus(); | |||
} | |||
public List<DeviceStatus> GetDevice() | |||
{ | |||
List<DeviceStatus> deviceStatuses = new List<DeviceStatus>(); | |||
foreach (var device in DeviceLists) | |||
{ | |||
deviceStatuses.Add(device.Value); | |||
} | |||
return deviceStatuses; | |||
} | |||
private void IpAddressLines() | |||
{ | |||
IPLists.Clear(); | |||
IPQueues.Clear(); | |||
/*for (int i = 1; i <= 255; i++) | |||
{ | |||
if (!InvalidIP.Contains($"{IPSegment}{i}") && !DeviceLists.ContainsKey($"{IPSegment}{i}")) | |||
{ | |||
string pattern = @"^(([1-9]\d?)|(1\d{2})|(2[01]\d)|(22[0-3]))(\.((1?\d\d?)|(2[04]/d)|(25[0-5]))){3}$"; | |||
if (Regex.IsMatch($"{IPSegment}{i}", pattern)) | |||
{ | |||
IPLists.Add($"{IPSegment}{i}"); | |||
} | |||
} | |||
}*/ | |||
IPLists.Add($"{IPSegment}10"); | |||
IPLists.Add($"{IPSegment}20"); | |||
IPLists.Add($"{IPSegment}30"); | |||
IPLists.ForEach((item) => | |||
{ | |||
Ping myPing = new Ping(); | |||
myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted); | |||
myPing.SendAsync(item, 1000, null); | |||
}); | |||
} | |||
private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e) | |||
{ | |||
if (e.Reply.Status == IPStatus.Success) | |||
{ | |||
string ip = e.Reply.Address.ToString(); | |||
if (!DeviceLists.ContainsKey(ip)) | |||
{ | |||
DeviceStatus DS = new DeviceStatus(); | |||
DS.modbusTcp.IsReconnect = false; | |||
DS.modbusTcp.ConnectOk = new Action(() => | |||
{ | |||
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");//读取设备名称 | |||
if (DeviceName.Length > 0) | |||
{ | |||
DeviceLists.TryAdd(ip, DS); | |||
DeviceLists[ip].Init(DeviceName); | |||
DeviceLists[ip].modbusTcp.IsReconnect = false; | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); | |||
if (TopDeviceCurrentStatuses.Count <= 7) | |||
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | |||
else | |||
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | |||
for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++) | |||
{ | |||
for (int m = 0; m < Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) | |||
{ | |||
if (Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; | |||
} | |||
} | |||
} | |||
if (Global.DeviceRawMaterials.Count > 0) | |||
{ | |||
if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceName) == null) | |||
{ | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 }); | |||
} | |||
} | |||
else | |||
{ | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 }); | |||
} | |||
})); | |||
} | |||
else | |||
{ | |||
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); | |||
} | |||
}); | |||
DS.modbusTcp.ConnectFail = new Action(() => | |||
{ | |||
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); | |||
}); | |||
DS.modbusTcp.Disconnect = new Action(() => | |||
{ | |||
if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip); | |||
var res = devices.FirstOrDefault(P => P.IpAddress == ip); | |||
if (res != null && devices.Contains(res)) | |||
{ | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
devices.Remove(res); | |||
var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName); | |||
if (item != null) Global.DeviceRawMaterials.Remove(item); | |||
var topRes = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == res.DeviceName); | |||
var bottomRes = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == res.DeviceName); | |||
if (topRes != null) TopDeviceCurrentStatuses.Remove(topRes); | |||
if (bottomRes != null) BottomDeviceCurrentStatuses.Remove(bottomRes); | |||
})); | |||
} | |||
if (DeviceLists.ContainsKey(ip)) | |||
{ | |||
DeviceLists[ip].Dispose(); | |||
var res11 = DeviceLists[ip]; | |||
DeviceLists.TryRemove(ip, out res11); | |||
} | |||
}); | |||
Task.Run(new Action(() => | |||
{ | |||
DS.modbusTcp.ModbusTcpConnect(ip, 502);//PLC连接 | |||
IPQueues.Enqueue(e.Reply.Address.ToString()); | |||
})); | |||
} | |||
else IPQueues.Enqueue(e.Reply.Address.ToString()); | |||
} | |||
else IPQueues.Enqueue(e.Reply.Address.ToString()); | |||
} | |||
} | |||
public class DeviceStatus | |||
{ | |||
#region 对象属性声明 | |||
public string DeviceName = String.Empty; | |||
public string IpAddress => modbusTcp.IPAdress; | |||
/// <summary> | |||
/// 设备状态 | |||
/// </summary> | |||
public RawMaterialDeviceStatus deviceStatus { get; set; } = new RawMaterialDeviceStatus(); | |||
public ModbusTcp modbusTcp = new ModbusTcp(); | |||
public bool IsConnected => modbusTcp.Connected; | |||
#endregion | |||
public void Init(string DeviceName) | |||
{ | |||
modbusTcp.Show = new Action<string>((s) => { MessageNotify.GetInstance.ShowRunLog(s); }); | |||
modbusTcp.ShowEx = new Action<string>((s) => { MessageNotify.GetInstance.ShowRunLog(s); }); | |||
this.DeviceName = DeviceName; | |||
AlarmHelper<AlarmInfo>.Init(); | |||
if (modbusTcp.Connected) | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
this.DeviceName = modbusTcp.GetString(DeviceAddress.DeviceName, 20)?.Trim()?.Replace(" ", ""); | |||
deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态 | |||
deviceStatus.WeightFeedback = this.modbusTcp.ReadShort(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量 | |||
deviceStatus.NowWeightFeedback = this.modbusTcp.GetReal(DeviceAddress.CutWeightFeedback);//获取下料重量 | |||
deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号 | |||
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码 | |||
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop1 = deviceStatus.DeviceAlarmCode.GetBitValue(1); | |||
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).Servo = deviceStatus.DeviceAlarmCode.GetBitValue(2); | |||
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).Inverter = deviceStatus.DeviceAlarmCode.GetBitValue(3); | |||
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop2 = deviceStatus.DeviceAlarmCode.GetBitValue(7); | |||
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloUpperLimit = deviceStatus.DeviceAlarmCode.GetBitValue(8); | |||
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloLowerLimit = deviceStatus.DeviceAlarmCode.GetBitValue(9); | |||
if (DeviceName=="A20") { | |||
//MessageNotify.GetInstance.ShowRunLog($"{this.modbusTcp.GetReal(DeviceAddress.WeightSet)}"); | |||
} | |||
Thread.Sleep(10); | |||
}), $"{DeviceName} 开始监听", true); | |||
} | |||
} | |||
public void SetDeviceName(string name) | |||
{ | |||
this.modbusTcp.Write(DeviceAddress.DeviceName, new ushort[20]); | |||
this.modbusTcp.SetString(DeviceAddress.DeviceName, name); | |||
} | |||
public void StatusReset() | |||
{ | |||
this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1); | |||
//var res = modbusTcp.Read(DeviceAddress.RunStatus); | |||
} | |||
public void Dispose() | |||
{ | |||
ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听"); | |||
} | |||
public void Start(float Value) | |||
{ | |||
if (modbusTcp.Connected) | |||
{ | |||
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); | |||
if (res != null) | |||
{ | |||
prop1: | |||
modbusTcp.SetReal(DeviceAddress.SlowlyAddWeight, res.SlowlyAddWeight); | |||
var Value1 = (float)this.modbusTcp.GetReal(DeviceAddress.SlowlyAddWeight); | |||
if (Value1 != null && Value1.ToString() != res.SlowlyAddWeight.ToString()) goto prop1; | |||
prop2: | |||
modbusTcp.SetReal(DeviceAddress.PreCloseValveWeight, res.PreCloseValveWeight); | |||
var Value2 = (float)this.modbusTcp.GetReal(DeviceAddress.PreCloseValveWeight); | |||
if (Value2 != null && Value2.ToString() != res.PreCloseValveWeight.ToString()) goto prop2; | |||
prop3: | |||
modbusTcp.SetUint(DeviceAddress.RapidAcceleration, (uint)res.RapidAcceleration); | |||
var Value3 = this.modbusTcp.GetUint(DeviceAddress.RapidAcceleration); | |||
if (Value3 != null && Value3.ToString() != res.RapidAcceleration.ToString()) goto prop3; | |||
prop4: | |||
modbusTcp.SetUint(DeviceAddress.SlowAcceleration, (uint)res.SlowAcceleration); | |||
var Value4 = this.modbusTcp.GetUint(DeviceAddress.SlowAcceleration); | |||
if (Value4 != null && Value4.ToString() != res.SlowAcceleration.ToString()) goto prop4; | |||
prop5: | |||
modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); | |||
var Value5 = this.modbusTcp.GetUint(DeviceAddress.ServoManualSpeed); | |||
if (Value5 != null && Value5.ToString() != res.ServoManualSpeed.ToString()) goto prop5; | |||
prop6: | |||
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); | |||
var Value6 = this.modbusTcp.GetUint(DeviceAddress.SiloUpperLimitWeight); | |||
if (Value6 != null && Value6.ToString() != res.SiloUpperLimitWeight.ToString()) goto prop6; | |||
prop7: | |||
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); | |||
var Value7 = this.modbusTcp.GetUint(DeviceAddress.LowerLimitWeightOfSilo); | |||
if (Value7 != null && Value7.ToString() != res.LowerLimitWeightOfSilo.ToString()) goto prop7; | |||
prop8: | |||
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); | |||
var Value8 = this.modbusTcp.GetUint(DeviceAddress.StirringSpeed); | |||
if (Value8 != null && Value8.ToString() != res.StirringSpeed.ToString()) goto prop8; | |||
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成"); | |||
} | |||
prop9: | |||
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量 | |||
var Value9 = this.modbusTcp.GetReal(DeviceAddress.WeightSet); | |||
if (Value9 != null && Value9.ToString() != Value.ToString()) goto prop9; | |||
/* | |||
prop10: | |||
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 | |||
var Value10 = (short[])this.modbusTcp.Read(DeviceAddress.Start); | |||
if (Value10 != null && Value10[0] != 1) goto prop10;*/ | |||
//modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 | |||
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动"); | |||
Thread.Sleep(100); | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class GlobalDevice | |||
{ | |||
/// <summary> | |||
/// PLC 设备数据 | |||
/// </summary> | |||
public static PlcToComputer PlcData { get; set; } = new PlcToComputer(); | |||
/// <summary> | |||
/// 电机速度 | |||
/// </summary> | |||
public static ushort[] MotorSpeed { get; set; } = new ushort[32]; | |||
/// <summary> | |||
/// 输送带控制 | |||
/// </summary> | |||
public static uint MotorControl { get; set; } | |||
/// <summary> | |||
/// 输送带控制反馈 | |||
/// </summary> | |||
public static uint MotorControlFeedback { get; set; } | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
/// <summary> | |||
/// 出料口信息 | |||
/// </summary> | |||
public class OutletInfoModel : NotifyBase | |||
{ | |||
/// <summary> | |||
/// 出料口名称 | |||
/// </summary> | |||
public string OutletName { get { return _mOutletName; } set { _mOutletName = value; OnPropertyChanged(); } } | |||
private string _mOutletName; | |||
/// <summary> | |||
/// 出料口位置 | |||
/// </summary> | |||
public int OutletLoc { get { return _mOutletLoc; } set { _mOutletLoc = value; OnPropertyChanged(); } } | |||
private int _mOutletLoc; | |||
/// <summary> | |||
/// 出料口对应的料仓信息 | |||
/// </summary> | |||
public ObservableCollection<string> SiloInfos { get; set; } = new ObservableCollection<string>(); | |||
} | |||
} |
@@ -0,0 +1,65 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class RawMaterialDeviceStatus | |||
{ | |||
/// <summary> | |||
/// 原料类型 | |||
/// 1:膏体 | |||
/// 2:液体 | |||
/// 3:粉体 | |||
/// </summary> | |||
public ushort RawMaterialType { get; set; } | |||
/// <summary> | |||
/// 料仓重量反馈 | |||
/// </summary> | |||
public float WeightFeedback { get; set; } | |||
/// <summary> | |||
/// 当前出料重量反馈 | |||
/// </summary> | |||
public float NowWeightFeedback { get; set; } | |||
/// <summary> | |||
/// 上限反馈 | |||
/// </summary> | |||
public bool UpLimitFeedback { get; set; } | |||
/// <summary> | |||
/// 下限反馈 | |||
/// </summary> | |||
public bool DownLimitFeedback { get; set; } | |||
/// <summary> | |||
/// 下料重量反馈 | |||
/// </summary> | |||
public float CutWeightFeedback { get; set; } | |||
/// <summary> | |||
/// 设备运行状态 | |||
/// 0:未知 | |||
/// 1:等待配料 | |||
/// 2:配料中 | |||
/// 3:配料完成 | |||
/// </summary> | |||
public ushort RunStatus { get; set; } | |||
/// <summary> | |||
/// 设备故障编码 | |||
/// </summary> | |||
public ushort DeviceAlarmCode { get; set; } | |||
/// <summary> | |||
/// 设备料仓编号 | |||
/// </summary> | |||
public ushort DeviceNum { get; set; } | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Model; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
/// <summary> | |||
/// 配方模块 | |||
/// </summary> | |||
public class RecipeModel : NotifyBase | |||
{ | |||
[Newtonsoft.Json.JsonIgnore] | |||
public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } | |||
private bool _mIsEnable = true; | |||
/// <summary> | |||
/// 序号 | |||
/// </summary> | |||
public int SerialNum { get { return _mSerialNum; } set { _mSerialNum = value; OnPropertyChanged(); } } | |||
private int _mSerialNum; | |||
/// <summary> | |||
/// 配方名称 | |||
/// </summary> | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName; | |||
/// <summary> | |||
/// 配方编码 | |||
/// </summary> | |||
public string RecipCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } | |||
private string _mRecipCode; | |||
[Newtonsoft.Json.JsonIgnore] | |||
public AutoResetEvent Are { get; set; } = new AutoResetEvent(false); | |||
[Newtonsoft.Json.JsonIgnore] | |||
public string RecipStatus { get { return _mRecipStatus; } set { _mRecipStatus = value; OnPropertyChanged(); } } | |||
private string _mRecipStatus; | |||
/// <summary> | |||
/// 原料集合 | |||
/// </summary> | |||
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>(); | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class RecipeProcess : NotifyBase | |||
{ | |||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialName; | |||
public int RawMaterialStatus { get { return _mRawMaterialStatus; } set { _mRawMaterialStatus = value; OnPropertyChanged(); } } | |||
private int _mRawMaterialStatus; | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle.Model | |||
{ | |||
public class ComputerToPlc | |||
{ | |||
} | |||
} |
@@ -0,0 +1,113 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
/// <summary> | |||
/// PLC 到上位机数据 | |||
/// </summary> | |||
public class PlcToComputer | |||
{ | |||
public PlcToComputer() | |||
{ | |||
for (int i = 0; i < cylinderFlagBitStatus.Length; i++) | |||
{ | |||
cylinderFlagBitStatus[i] = new CylinderFlagBitStatus(); | |||
} | |||
} | |||
/// <summary> | |||
/// 心跳 | |||
/// </summary> | |||
public bool Heartbeat { get; set; } | |||
/// <summary> | |||
/// 接收配方完成 | |||
/// </summary> | |||
public bool ResComplete { get; set; } | |||
/// <summary> | |||
/// 系统启动或停止状态 | |||
/// </summary> | |||
public bool SystemStartOrStop { get; set; } | |||
/// <summary> | |||
/// 手自动状态 | |||
/// </summary> | |||
public bool HandOrAuto { get; set; } | |||
/// <summary> | |||
/// 桶位置反馈 | |||
/// </summary> | |||
public short[] LocationFeedback { get; set; } = new short[32]; | |||
/// <summary> | |||
/// 桶是否允许配料 | |||
/// </summary> | |||
public bool[] IsAllowIngredients { get; set; } = new bool[32]; | |||
/// <summary> | |||
/// 报警信息 | |||
/// </summary> | |||
public bool[] ArrayInfo { get; set; } = new bool[32]; | |||
/// <summary> | |||
/// 本地急停 | |||
/// </summary> | |||
public bool LocalEStop { get; set; } | |||
/// <summary> | |||
/// 远程急停 | |||
/// </summary> | |||
public bool RemoteEStop { get; set; } | |||
/// <summary> | |||
/// 上桶工位检测 | |||
/// </summary> | |||
public bool OnDetection { get; set; } | |||
/// <summary> | |||
/// 下桶工位检测 | |||
/// </summary> | |||
public bool UnderDetection { get; set; } | |||
/// <summary> | |||
/// 上桶工位气缸检测 | |||
/// </summary> | |||
public CylinderFlagBitStatus OnCylinderDetection { get; set; } = new CylinderFlagBitStatus(); | |||
/// <summary> | |||
/// 下桶工位气缸检测 | |||
/// </summary> | |||
public CylinderFlagBitStatus UnderCylinderDetection { get; set; } = new CylinderFlagBitStatus(); | |||
/// <summary> | |||
/// 工位光电检测 | |||
/// </summary> | |||
public bool[] StationDetection { get; set; } = new bool[32]; | |||
/// <summary> | |||
/// 气缸状态信号 | |||
/// </summary> | |||
public CylinderFlagBitStatus[] cylinderFlagBitStatus { get; set; } = new CylinderFlagBitStatus[32]; | |||
} | |||
/// <summary> | |||
/// 气缸到位检测类 | |||
/// </summary> | |||
public class CylinderFlagBitStatus | |||
{ | |||
/// <summary> | |||
/// 气缸原点信号 | |||
/// </summary> | |||
public bool HomeSignal { get; set; } | |||
/// <summary> | |||
/// 气缸到位信号 | |||
/// </summary> | |||
public bool InPlaceSignal { get; set; } | |||
} | |||
} |
@@ -0,0 +1,61 @@ | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class StockStatusModel : NotifyBase | |||
{ | |||
/// <summary> | |||
/// 料仓物料重量 | |||
/// </summary> | |||
public double MaterialWeight { get { return _materialWeight; } set { _materialWeight = value; OnPropertyChanged(); } } | |||
private double _materialWeight; | |||
/// <summary> | |||
/// 料仓物料名称 | |||
/// </summary> | |||
public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } } | |||
private string _materialName; | |||
/// <summary> | |||
/// 是否真在运行 | |||
/// </summary> | |||
public bool IsRunning { get { return _isRunning; } set { _isRunning = value; OnPropertyChanged(); } } | |||
private bool _isRunning; | |||
/// <summary> | |||
/// 是否正在下料 | |||
/// </summary> | |||
public bool IsLayOff { get { return _isLayOff; } set { _isLayOff = value; OnPropertyChanged(); } } | |||
private bool _isLayOff; | |||
/// <summary> | |||
/// 是否开盖 | |||
/// </summary> | |||
public bool IsOpen { get { return _mIsOpen; } set { _mIsOpen = value; OnPropertyChanged(); } } | |||
private bool _mIsOpen; | |||
/// <summary> | |||
/// 是否故障报警 | |||
/// </summary> | |||
public bool IsFault { get { return _isFault; } set { _isFault = value; OnPropertyChanged(); } } | |||
private bool _isFault; | |||
/// <summary> | |||
/// 下料状态 0:未出料 1:出料指令下发 2:出料完成 | |||
/// </summary> | |||
public int IssueStatus { get { return _isIssueStatus; } set { _isIssueStatus = value; OnPropertyChanged(); } } | |||
private int _isIssueStatus; | |||
/// <summary> | |||
/// 下料重量 | |||
/// </summary> | |||
public double IssueWeight { get { return _IssueWeight; } set { _IssueWeight = value; OnPropertyChanged(); } } | |||
private double _IssueWeight; | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class ViewModelBase : NotifyBase | |||
{ | |||
public int Index { get; set; } = -1; | |||
public BPARelayCommand AddCommand { get; set; }//添加 | |||
public BPARelayCommand CancelCommand { get; set; }//取消 | |||
public BPARelayCommand SaveCommand { get; set; }//保存 | |||
public BPARelayCommand<object> RemoveCommand { get; set; }//移除 | |||
public BPARelayCommand<object> DetailsCommand { get; set; }//编辑 | |||
/// <summary> | |||
/// 错误信息 | |||
/// </summary> | |||
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||
private string _mErrorInfo = string.Empty; | |||
} | |||
} |
@@ -0,0 +1,78 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Diagnostics; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
/// <summary> | |||
/// 基础参数 | |||
/// </summary> | |||
public class BasePar : NotifyBase | |||
{ | |||
/// <summary> | |||
/// 设备扫描网段 | |||
/// </summary> | |||
public string NetworkSegAddress { get { return _mNetworkSegAddress; } set { _mNetworkSegAddress = value; OnPropertyChanged(); } } | |||
private string _mNetworkSegAddress = "192.168.0."; | |||
/// <summary> | |||
/// 输送带设备 PLC IP 地址 | |||
/// </summary> | |||
public string DeviceAddress { get { return _mDeviceAddress; } set { _mDeviceAddress = value; OnPropertyChanged(); } } | |||
private string _mDeviceAddress = "192.168.0.15"; | |||
/// <summary> | |||
/// 输送带数量 | |||
/// </summary> | |||
public int ConveyerBeltCount | |||
{ | |||
get { return _mConveyerBeltCount; } | |||
set | |||
{ | |||
_mConveyerBeltCount = value; | |||
//var temp = ConveyerBeltModels; | |||
//App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Clear(); }); | |||
//for (int i = 0; i < value; i++) | |||
//{ | |||
// App.Current.Dispatcher.Invoke(() => | |||
// { | |||
// ConveyerBeltModels.Add(new ConveyerBeltModel() | |||
// { | |||
// Name = $"输送带{i + 1}速度", | |||
// Num = i + 1, | |||
// Speed = (i >= 0 && i < temp.Count) ? temp.ElementAt(i).Speed : 0 | |||
// }); | |||
// }); | |||
//} | |||
OnPropertyChanged(); | |||
} | |||
} | |||
private int _mConveyerBeltCount = 0; | |||
/// <summary> | |||
/// 升降气缸数量 | |||
/// </summary> | |||
public int LiftCylinderCount { get { return _mLiftCylinderCount; } set { _mLiftCylinderCount = value; OnPropertyChanged(); } } | |||
private int _mLiftCylinderCount = 0; | |||
/// <summary> | |||
/// 阻挡气缸数量 | |||
/// </summary> | |||
public int BlockCylinderCount { get { return _mBlockCylinderCount; } set { _mBlockCylinderCount = value; OnPropertyChanged(); } } | |||
private int _mBlockCylinderCount = 0; | |||
/// <summary> | |||
/// 托盘气缸数量 | |||
/// </summary> | |||
public int PalletCylinderCount { get { return _mPalletCylinderCount; } set { _mPalletCylinderCount = value; OnPropertyChanged(); } } | |||
private int _mPalletCylinderCount = 0; | |||
//public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class DevicePar : NotifyBase | |||
{ | |||
/// <summary> | |||
/// 配料设备参数 | |||
/// </summary> | |||
public ObservableCollection<DeviceParModel> deviceParModels { get; set; } = new ObservableCollection<DeviceParModel>(); | |||
public ObservableCollection<OutletInfoModel> OutletInfoModels { get; set; } = new ObservableCollection<OutletInfoModel>(); | |||
public BasePar BaseParModel { get { return _mBaseParModel; } set { _mBaseParModel = value; OnPropertyChanged(); } } | |||
private BasePar _mBaseParModel = new BasePar(); | |||
} | |||
} |
@@ -0,0 +1,75 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class DeviceParModel : NotifyBase | |||
{ | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string MaterialName { get { return _mMaterialName; } set { _mMaterialName = value; OnPropertyChanged(); } } | |||
private string _mMaterialName = string.Empty; | |||
/// <summary> | |||
/// 慢加重量 | |||
/// </summary> | |||
public float SlowlyAddWeight { get { return _mSlowlyAddWeight; } set { _mSlowlyAddWeight = value; OnPropertyChanged(); } } | |||
private float _mSlowlyAddWeight; | |||
/// <summary> | |||
/// 提前关阀重量 | |||
/// </summary> | |||
public float PreCloseValveWeight { get { return _mPreCloseValveWeight; } set { _mPreCloseValveWeight = value; OnPropertyChanged(); } } | |||
private float _mPreCloseValveWeight; | |||
/// <summary> | |||
/// 快加速度 | |||
/// </summary> | |||
public int RapidAcceleration { get { return _mRapidAcceleration; } set { _mRapidAcceleration = value; OnPropertyChanged(); } } | |||
private int _mRapidAcceleration; | |||
/// <summary> | |||
/// 慢加速度 | |||
/// </summary> | |||
public int SlowAcceleration { get { return _mSlowAcceleration; } set { _mSlowAcceleration = value; OnPropertyChanged(); } } | |||
private int _mSlowAcceleration; | |||
/// <summary> | |||
/// 伺服手动速度 | |||
/// </summary> | |||
public int ServoManualSpeed { get { return _mServoManualSpeed; } set { _mServoManualSpeed = value; OnPropertyChanged(); } } | |||
private int _mServoManualSpeed; | |||
/// <summary> | |||
/// 料仓上限重量 | |||
/// </summary> | |||
public int SiloUpperLimitWeight { get { return _mSiloUpperLimitWeight; } set { _mSiloUpperLimitWeight = value; OnPropertyChanged(); } } | |||
private int _mSiloUpperLimitWeight; | |||
/// <summary> | |||
/// 料仓下限重量 | |||
/// </summary> | |||
public int LowerLimitWeightOfSilo { get { return _mLowerLimitWeightOfSilo; } set { _mLowerLimitWeightOfSilo = value; OnPropertyChanged(); } } | |||
private int _mLowerLimitWeightOfSilo; | |||
/// <summary> | |||
/// 搅拌速度 | |||
/// </summary> | |||
public int StirringSpeed { get { return _mStirringSpeed; } set { _mStirringSpeed = value; OnPropertyChanged(); } } | |||
private int _mStirringSpeed; | |||
/// <summary> | |||
/// 是否重复 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } } | |||
private bool _mIsRedundant; | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.DosingSystemSingle.ViewModel; | |||
using BPASmartClient.Model; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class LocaPar | |||
{ | |||
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>(); | |||
} | |||
} |
@@ -0,0 +1,91 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.S7Net; | |||
using BPA.Helper; | |||
using S7.Net; | |||
namespace BPASmartClient.DosingSystemSingle | |||
{ | |||
public class SiemensDevice | |||
{ | |||
private volatile static SiemensDevice _Instance; | |||
public static SiemensDevice GetInstance => _Instance ?? (_Instance = new SiemensDevice()); | |||
private SiemensDevice() { } | |||
public SiemensHelper MySiemens { get; set; } = new SiemensHelper(); | |||
private bool IsConnect { get; set; } | |||
bool tempValue = false; | |||
public void Connect(string ip) | |||
{ | |||
try | |||
{ | |||
while (!MySiemens.IsConnected) | |||
{ | |||
MySiemens.Connect(S7.Net.CpuType.S71200, ip); | |||
Thread.Sleep(2000); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
IsConnect = MySiemens.IsConnected; | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
if (IsConnect) MySiemens.Write("DB4.DBX0.0", tempValue);//设备心跳 | |||
tempValue = !tempValue; | |||
Thread.Sleep(100); | |||
}), "设备心跳", true); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
if (IsConnect) | |||
{ | |||
GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);//获取PLC到上位机的数据 | |||
var res = MySiemens.Read(DataType.DataBlock, 4, 134, VarType.Word, 32); | |||
if (res != null && res is ushort[] ushorts && ushorts.Length == 32) | |||
{ | |||
GlobalDevice.MotorSpeed = ushorts; | |||
} | |||
GlobalDevice.MotorControl = MySiemens.Read<uint>("DB5.DBD6");//获取输送带控制信号 | |||
//GlobalDevice.MotorControlFeedback = MySiemens.Read<uint>("DB3.DBD0");//获取当前输送带运行状态 | |||
GlobalDevice.MotorControl = (uint)(GlobalDevice.MotorControl.ToBytes(BPA.Helper.DataFormat.ABCD)).ToInt(); | |||
Thread.Sleep(50); | |||
} | |||
}), "读取输送线设备数据", true); | |||
} | |||
/// <summary> | |||
/// 通过顺序编号获取西门子数据地址 | |||
/// </summary> | |||
/// <param name="Prefix">地址标头</param> | |||
/// <param name="num">编号</param> | |||
/// <param name="StartAdd">起始地址</param> | |||
/// <returns></returns> | |||
public string GetSiemensBitSingleAdd(string Prefix, int num, int StartAdd = 0) | |||
{ | |||
if (num > 0) | |||
{ | |||
string Add = string.Empty; | |||
var FirstAdd = num / 8; | |||
var EndAdd = (num % 8); | |||
if (EndAdd == 0) | |||
{ | |||
FirstAdd--; | |||
EndAdd = 7; | |||
} | |||
else EndAdd--; | |||
Add = $"{Prefix}{FirstAdd + StartAdd}.{EndAdd}"; | |||
return Add; | |||
} | |||
return default; | |||
} | |||
} | |||
} |
@@ -0,0 +1,122 @@ | |||
<Window | |||
x:Class="BPASmartClient.DosingSystemSingle.View.ChangeDeviceNameView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
Title="ChangeDeviceNameView" | |||
Width="400" | |||
Height="200" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.DataContext> | |||
<vm:ChangeDeviceNameViewModel /> | |||
</Window.DataContext> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
<ResourceDictionary> | |||
<!--#region ListBox样式--> | |||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="border" CornerRadius="8"> | |||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
<Border | |||
Name="br" | |||
Background="#FF0B2F5F" | |||
BorderThickness="1"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition Height="0.5*" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
Background="Transparent" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
Text="请输入新设备名称:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="200" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
FontSize="16" | |||
Text="{Binding DeviceName}" /> | |||
</StackPanel> | |||
<TextBlock | |||
Grid.Row="1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="16" | |||
Foreground="Red" | |||
Text="{Binding ErrorInfo}" /> | |||
<Grid Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Grid.Column="1" | |||
Width="148" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
Command="{Binding AddCommand}" | |||
Content="确认" /> | |||
<Button | |||
Name="btClose" | |||
Width="148" | |||
Height="30" | |||
Command="{Binding CancelCommand}" | |||
Content="取消" /> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</Window> |
@@ -0,0 +1,31 @@ | |||
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.Shapes; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// ChangeDeviceNameView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class ChangeDeviceNameView : Window | |||
{ | |||
public ChangeDeviceNameView() | |||
{ | |||
InitializeComponent(); | |||
//ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose"); | |||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose", true); | |||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | |||
} | |||
} | |||
} |
@@ -0,0 +1,228 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.CommParSetView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:CommparSetViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Grid.Column="3" | |||
Width="120" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Left" | |||
Command="{Binding SaveCommand}" | |||
Content="保存参数" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<WrapPanel Grid.Row="1" Grid.ColumnSpan="4"> | |||
<Grid Width="350" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="配料设备网段:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommBaseParModel.NetworkSegAddress, UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
<Grid Width="350" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="输送带PLC地址:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommBaseParModel.DeviceAddress, UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
<Grid Width="350" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="升降气缸数量:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommBaseParModel.LiftCylinderCount, UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
<Grid Width="350" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="阻挡气缸数量:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommBaseParModel.BlockCylinderCount, UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
<Grid | |||
Width="350" | |||
Margin="5" | |||
Background="Transparent"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="托盘气缸数量:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommBaseParModel.PalletCylinderCount, UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
<Grid | |||
Width="350" | |||
Margin="5" | |||
Background="Transparent"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="输送带数量:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommBaseParModel.ConveyerBeltCount, UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
</WrapPanel> | |||
<!--<Grid Grid.Row="2" Grid.ColumnSpan="4"> | |||
<ListView | |||
Grid.Column="1" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding CommBaseParModel.ConveyerBeltModels}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="350" | |||
Margin="5" | |||
Background="Transparent"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Name}" /> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text=":" /> | |||
</StackPanel> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding Speed, UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid>--> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,30 @@ | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// CommParSetView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class CommParSetView : UserControl | |||
{ | |||
public CommParSetView() | |||
{ | |||
InitializeComponent(); | |||
this.Unloaded += (o, e) => { Json<DevicePar>.Save(); }; | |||
} | |||
} | |||
} |
@@ -0,0 +1,132 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.ConveyerBeltManualView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<Style x:Key="radioButtonStyle" TargetType="RadioButton"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Opacity="0.8"> | |||
<ContentControl | |||
Margin="{TemplateBinding Margin}" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
FontSize="{TemplateBinding FontSize}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
<Image | |||
Name="image" | |||
Source="/BPASmartClient.CustomResource;component/Image/边框线.png" | |||
Stretch="Fill" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="False"> | |||
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/边框线.png" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/透明背景.png" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="gr" Property="Opacity" Value="1" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
<vm:ConveyerBeltManualViewModel /> | |||
</UserControl.DataContext> | |||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding ConveyerBeltModels}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Margin="8"> | |||
<Grid | |||
Name="cy" | |||
Grid.Row="0" | |||
Margin="5"> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=cy, Path=ActualWidth}" | |||
Height="{Binding ElementName=cy, Path=ActualHeight}" /> | |||
<StackPanel Background="Transparent"> | |||
<Grid Height="40"> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,10,0,0" | |||
VerticalAlignment="Top" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<StackPanel | |||
Margin="0,0,20,0" | |||
HorizontalAlignment="Right" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="输送带速度:" /> | |||
<TextBox | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding Speed, UpdateSourceTrigger=PropertyChanged}" /> | |||
<TextBlock | |||
Margin="20,0,5,0" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#00c2f4" | |||
Text="输送带控制" /> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding ConveyerBeltWork}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
</StackPanel> | |||
</Grid> | |||
<Grid Name="gr" Height="200"> | |||
<pry:ConveyBelt2 | |||
Grid.RowSpan="4" | |||
Margin="-12,0,10,0" | |||
BeltDashThickess="50" | |||
BeltHeight="{Binding ElementName=gr, Path=ActualHeight}" | |||
BeltWidth="{Binding ElementName=gr, Path=ActualWidth}" | |||
IsRun="{Binding ConveyerBeltWork}" /> | |||
</Grid> | |||
</StackPanel> | |||
</Grid> | |||
</Grid> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// ConveyerBeltManualView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class ConveyerBeltManualView : UserControl | |||
{ | |||
public ConveyerBeltManualView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,164 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.DeviceListView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:DeviceListViewModel /> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem"> | |||
<Style.Resources> | |||
<!-- SelectedItem with focus --> | |||
<SolidColorBrush | |||
x:Key="{x:Static SystemColors.HighlightBrushKey}" | |||
Opacity=".4" | |||
Color="White" /> | |||
<!-- SelectedItem without focus --> | |||
<SolidColorBrush | |||
x:Key="{x:Static SystemColors.ControlBrushKey}" | |||
Opacity=".4" | |||
Color="White" /> | |||
</Style.Resources> | |||
<!-- 设置触发器 --> | |||
<Style.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter Property="Background" Value="White" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
</Trigger> | |||
<Trigger Property="IsFocused" Value="true"> | |||
<Setter Property="Background" Value="White" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
</Trigger> | |||
</Style.Triggers> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid Margin="-5,0,5,0"> | |||
<Grid> | |||
<ListView | |||
Grid.Column="1" | |||
Margin="10" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding devices}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Border | |||
Name="ShadowElement" | |||
Width="180" | |||
Height="150" | |||
Margin="10" | |||
VerticalAlignment="Top" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ClipToBounds="True" | |||
CornerRadius="0"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/蓝色背景.png" Stretch="Fill" /> | |||
</Border.Background> | |||
<Grid Margin="20,0"> | |||
<!--<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions>--> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Grid.Row="0" | |||
Grid.ColumnSpan="2" | |||
Margin="0,10,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#00BEFA" | |||
Text="{Binding DeviceName}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Grid.Row="1" | |||
FontSize="14" | |||
Foreground="#aa00BEFA" | |||
Text="设备IP:" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
FontSize="14" | |||
Foreground="#aa00BEFA" | |||
Text="{Binding IpAddress}" /> | |||
</StackPanel> | |||
<Button | |||
Grid.Row="2" | |||
Width="130" | |||
Height="30" | |||
Margin="0,0,0,0" | |||
VerticalAlignment="Top" | |||
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding IpAddress}" | |||
Content="修改原料名称" | |||
FontSize="16" | |||
IsEnabled="{Binding IsEnable}" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<!--<Button | |||
Grid.Row="1" | |||
Grid.Column="0" | |||
Grid.ColumnSpan="2" | |||
Foreground="#00BEFA" | |||
Width="130" | |||
Height="30" | |||
Margin="0,0,0,10" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
Command="{Binding DataContext.ChangeNameCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding IpAddress}" | |||
Content="修改原料名称" | |||
IsEnabled="{Binding IsEnable}"> | |||
<Button.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/系统名称.png" /> | |||
</Button.Background> | |||
</Button>--> | |||
</Grid> | |||
</Border> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// DeviceListView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class DeviceListView : UserControl | |||
{ | |||
public DeviceListView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,370 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.DeviceMaterialParView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:con="clr-namespace:BPASmartClient.DosingSystemSingle.Converter" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="1080" | |||
d:DesignWidth="1920" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:DeviceMaterialParViewModel /> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<SolidColorBrush x:Key="tabColor" Color="#FF2AB2E7" /> | |||
<!--<SolidColorBrush x:Key="bordColor" Color="#33ffffff" />--> | |||
<SolidColorBrush x:Key="bordColor" Color="#332AB2E7" /> | |||
<con:DataTableRedundantConverter x:Key="tabConvert" /> | |||
<Style x:Key="RowRadioButtonStyle" TargetType="{x:Type RadioButton}"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type RadioButton}"> | |||
<Border | |||
x:Name="NvaBor" | |||
Background="Transparent" | |||
BorderBrush="#FF2AB2E7" | |||
BorderThickness="0"> | |||
<ContentControl | |||
Margin="10,4" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
FontSize="16" /> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="NvaBor" Property="Background" Value="#22ffffff" /> | |||
<Setter TargetName="NvaBor" Property="BorderThickness" Value="0" /> | |||
</Trigger> | |||
<MultiTrigger> | |||
<MultiTrigger.Conditions> | |||
<Condition Property="IsChecked" Value="false" /> | |||
<Condition Property="IsMouseOver" Value="True" /> | |||
</MultiTrigger.Conditions> | |||
<MultiTrigger.Setters> | |||
<Setter TargetName="NvaBor" Property="Background" Value="#22ffffff" /> | |||
</MultiTrigger.Setters> | |||
</MultiTrigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="InputTextboxStyle" TargetType="TextBox"> | |||
<Setter Property="Margin" Value="5,0,0,0" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="HorizontalAlignment" Value="Left" /> | |||
<Setter Property="Width" Value="150" /> | |||
<Setter Property="Height" Value="40" /> | |||
<Setter Property="CaretBrush" Value="{StaticResource TitleBorderColor}" /> | |||
<Setter Property="Foreground" Value="{StaticResource TitleBorderColor}" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="FontSize" Value="14" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
</Style> | |||
<Style x:Key="ControlButtonStyle" TargetType="Button"> | |||
<Setter Property="Margin" Value="0" /> | |||
<Setter Property="FontSize" Value="18" /> | |||
<Setter Property="Foreground" Value="#FFF53F62" /> | |||
<Setter Property="FontWeight" Value="SemiBold" /> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border | |||
Name="TitleBarBr" | |||
BorderBrush="#00c2f4" | |||
BorderThickness="0" | |||
CornerRadius="0" | |||
Opacity="0.8"> | |||
<ContentPresenter | |||
Margin="{TemplateBinding Margin}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
<Border.Background> | |||
<ImageBrush | |||
ImageSource="/BPASmartClient.CustomResource;component/Image/组合边框1.1.png" | |||
Opacity="0.8" | |||
Stretch="Fill" /> | |||
</Border.Background> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="TitleBarBr" Property="Opacity" Value="1" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="TitleTextblockStyle" TargetType="TextBlock"> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="Foreground" Value="{StaticResource tabColor}" /> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontWeight" Value="SemiBold" /> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<Button | |||
Width="150" | |||
Height="40" | |||
Margin="10,0,10,0" | |||
Command="{Binding AddCommand}" | |||
Content="添加原料参数" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Width="150" | |||
Height="40" | |||
Margin="10,0,10,0" | |||
Command="{Binding SaveCommand}" | |||
Content="保存参数" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
</StackPanel> | |||
<!--#region 表格标题栏设置--> | |||
<Grid | |||
Grid.Row="1" | |||
Margin="0,10,0,0" | |||
Background="#ff0C255F"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="原料名称" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="慢加重量(g)" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="提前关阀重量" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="快加速度" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="4" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="慢加速度" /> | |||
<Grid Grid.Column="5"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="伺服手动速度" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="6" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="料仓上限重量" /> | |||
<Grid Grid.Column="7"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="料仓下限重量" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="8" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="搅拌速度" /> | |||
<Grid Grid.Column="9"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="功能操作" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="10" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<!--#endregion--> | |||
<Grid Grid.Row="2"> | |||
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding deviceParModels}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBox | |||
Grid.Column="0" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding MaterialName}" /> | |||
<Grid Grid.Column="1"> | |||
<TextBox | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding SlowlyAddWeight}" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBox | |||
Grid.Column="2" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding PreCloseValveWeight}" /> | |||
<Grid Grid.Column="3"> | |||
<TextBox | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding RapidAcceleration}" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBox | |||
Grid.Column="4" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding SlowAcceleration}" /> | |||
<Grid Grid.Column="5"> | |||
<TextBox | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding ServoManualSpeed}" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBox | |||
Grid.Column="6" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding SiloUpperLimitWeight}" /> | |||
<Grid Grid.Column="7"> | |||
<TextBox | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding LowerLimitWeightOfSilo}" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBox | |||
Grid.Column="8" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding StirringSpeed}" /> | |||
<Grid Grid.Column="9"> | |||
<Button | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding MaterialName}" | |||
Content="删除" | |||
FontSize="16" | |||
Style="{StaticResource ControlButtonStyle}" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="10" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,1" /> | |||
</Grid> | |||
<DataTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||
</Trigger> | |||
</DataTemplate.Triggers> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// DeviceMaterialParView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class DeviceMaterialParView : UserControl | |||
{ | |||
public DeviceMaterialParView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,488 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.HardwareStatusView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="1080" | |||
d:DesignWidth="1920" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:HardwareStatusViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.8*" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="0.8*" /> | |||
</Grid.RowDefinitions> | |||
<!--#region 顶部料仓--> | |||
<Grid Name="TopGrid"> | |||
<ListView | |||
Height="{Binding ElementName=TopGrid, Path=ActualHeight}" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ItemsSource="{Binding TopDeviceCurrentStatuses}" | |||
ScrollViewer.VerticalScrollBarVisibility="Disabled" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<!--<WrapPanel Orientation="Horizontal" IsItemsHost="True"/>--> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" | |||
Rows="1" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Border Margin="5" Background="Transparent"> | |||
<Grid Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition Height="0.6*" /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Grid.Row="1"> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="0,2,0,0" | |||
HorizontalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding Weight}" /> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text=" kg" /> | |||
</StackPanel> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="0,2,0,0" | |||
HorizontalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding DeviceNum}" /> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text=" 号仓" /> | |||
</StackPanel> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="0,2,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding DeviceName}" /> | |||
</StackPanel> | |||
<Grid Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<StackPanel Background="Transparent"> | |||
<Ellipse | |||
Width="30" | |||
Height="30" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Fill="{Binding BucketFlagbit, Converter={StaticResource BoolToFillColorConverter}}" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<Ellipse.OpacityMask> | |||
<RadialGradientBrush> | |||
<GradientStop Offset="0" Color="Transparent" /> | |||
<GradientStop Offset="1" Color="#00c2f4" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
<!--<Ellipse.RenderTransform> | |||
<ScaleTransform x:Name="Scale" /> | |||
</Ellipse.RenderTransform>--> | |||
</Ellipse> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#00c2f4" | |||
Text="到位检测" /> | |||
</StackPanel> | |||
<StackPanel Name="skp" Grid.Column="1"> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
Command="{Binding DataContext.RecipeControlCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding}" | |||
FontSize="20" | |||
IsChecked="{Binding BaitingControl}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#00c2f4" | |||
Text="出料控制" /> | |||
</StackPanel> | |||
</Grid> | |||
<Image | |||
Margin="20,30,20,0" | |||
Source="/BPASmartClient.CustomResource;component/Image/荧光/矩形发光.png" | |||
Stretch="Fill" | |||
Visibility="{Binding IsOpen, Converter={StaticResource BoolToVisibilityConvert}}" /> | |||
<Image Source="/BPASmartClient.CustomResource;component/Image/荧光/29.png" Visibility="{Binding BaitingControl, Converter={StaticResource BoolToVisibilityConvert}}" /> | |||
<Image | |||
Grid.RowSpan="2" | |||
Source="/BPASmartClient.CustomResource;component/Image/光柱.png" | |||
Stretch="Fill" /> | |||
<Grid | |||
Name="WeightGr" | |||
Height="45" | |||
Margin="20,-30,20,0"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/荧光/蓝色提示框.png" /> | |||
</Grid.Background> | |||
<TextBox | |||
Name="outName" | |||
Width="{Binding ElementName=WeightGr, Path=ActualWidth}" | |||
Height="{Binding ElementName=WeightGr, Path=ActualHeight}" | |||
Margin="0,-2,0,0" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
CaretBrush="#009dff" | |||
FontSize="20" | |||
Foreground="#009dff" | |||
Text="{Binding SetWeight}" /> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 输送带--> | |||
<Grid | |||
x:Name="gr" | |||
Grid.Row="1" | |||
Background="Transparent"> | |||
<!--<pry:ConveyorBelt | |||
Grid.Row="1" | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
Margin="10,0,30,0" | |||
ConveyorBeltWidth="70" | |||
Direction="0" | |||
StrokeBrush="#00BEFA" | |||
StrokeDashArray="1.5 1.5" | |||
StrokeFillBrush="#00BEFA" | |||
StrokeThickness="2" />--> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Grid Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<!--<Ellipse | |||
Width="30" | |||
Height="30" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Bottom" | |||
Fill="{Binding OnDetection, Converter={StaticResource BoolToFillColorConverter}}" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<Ellipse.OpacityMask> | |||
<RadialGradientBrush> | |||
<GradientStop Offset="0" Color="Transparent" /> | |||
<GradientStop Offset="1" Color="#00c2f4" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
</Ellipse> | |||
<Ellipse | |||
Grid.Column="5" | |||
Width="30" | |||
Height="30" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Bottom" | |||
Fill="{Binding UnderDetection, Converter={StaticResource BoolToFillColorConverter}}" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<Ellipse.OpacityMask> | |||
<RadialGradientBrush> | |||
<GradientStop Offset="0" Color="Transparent" /> | |||
<GradientStop Offset="1" Color="#00c2f4" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
</Ellipse>--> | |||
</Grid> | |||
<Grid Grid.Row="3"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<!--<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#00c2f4" | |||
Text="上桶工位检测" /> | |||
<TextBlock | |||
Grid.Column="5" | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#00c2f4" | |||
Text="下桶工位检测" />--> | |||
</Grid> | |||
<pry:ConveyBelt2 | |||
Grid.RowSpan="4" | |||
Margin="-12,0,10,0" | |||
BeltDashThickess="50" | |||
BeltHeight="{Binding ElementName=gr, Path=ActualHeight}" | |||
BeltWidth="{Binding ElementName=gr, Path=ActualWidth}" | |||
IsRun="{Binding ConveyerBeltStatus}" /> | |||
<!--<StackPanel | |||
Grid.Row="1" | |||
Margin="20,0,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="0,0,5,0" | |||
FontSize="20" | |||
Foreground="#00c2f4" | |||
Text="输送带控制" /> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding ConveyerBeltWork}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
</StackPanel>--> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 底部料仓--> | |||
<Grid Grid.Row="2"> | |||
<ListView | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ItemsSource="{Binding BottomDeviceCurrentStatuses}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" | |||
Rows="1" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Border Margin="5" Background="Transparent"> | |||
<Grid Height="270" Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition Height="0.6*" /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Grid.Row="1"> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="0,2,0,0" | |||
HorizontalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding Weight}" /> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text=" kg" /> | |||
</StackPanel> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="0,2,0,0" | |||
HorizontalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding DeviceNum}" /> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text=" 号仓" /> | |||
</StackPanel> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="0,2,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding DeviceName}" /> | |||
</StackPanel> | |||
<StackPanel Grid.Row="2" Orientation="Horizontal"> | |||
<StackPanel Background="Transparent"> | |||
<Ellipse | |||
Width="30" | |||
Height="30" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Fill="{Binding BucketFlagbit, Converter={StaticResource BoolToFillColorConverter}}" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<Ellipse.OpacityMask> | |||
<RadialGradientBrush> | |||
<GradientStop Offset="0" Color="Transparent" /> | |||
<GradientStop Offset="1" Color="#00c2f4" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
<!--<Ellipse.RenderTransform> | |||
<ScaleTransform x:Name="Scale" /> | |||
</Ellipse.RenderTransform>--> | |||
</Ellipse> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#00c2f4" | |||
Text="到位检测" /> | |||
</StackPanel> | |||
<StackPanel> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding BaitingControl}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#00c2f4" | |||
Text="出料控制" /> | |||
</StackPanel> | |||
</StackPanel> | |||
<Image | |||
Margin="20,30,20,0" | |||
Source="/BPASmartClient.CustomResource;component/Image/荧光/矩形发光.png" | |||
Stretch="Fill" | |||
Visibility="{Binding IsOpen, Converter={StaticResource BoolToVisibilityConvert}}" /> | |||
<Image Source="/BPASmartClient.CustomResource;component/Image/荧光/29.png" Visibility="{Binding BaitingControl, Converter={StaticResource BoolToVisibilityConvert}}" /> | |||
<Image | |||
Grid.RowSpan="2" | |||
Source="/BPASmartClient.CustomResource;component/Image/光柱.png" | |||
Stretch="Fill" /> | |||
<Grid | |||
Name="WeightGr" | |||
Height="45" | |||
Margin="20,-30,20,0"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/荧光/蓝色提示框.png" /> | |||
</Grid.Background> | |||
<TextBox | |||
Name="outName" | |||
Width="{Binding ElementName=WeightGr, Path=ActualWidth}" | |||
Height="{Binding ElementName=WeightGr, Path=ActualHeight}" | |||
Margin="0,-2,0,0" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
CaretBrush="#009dff" | |||
FontSize="20" | |||
Foreground="#009dff" | |||
Text="{Binding SetWeight}" /> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
<!--#endregion--> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,30 @@ | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// HardwareStatusView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class HardwareStatusView : UserControl | |||
{ | |||
public HardwareStatusView() | |||
{ | |||
InitializeComponent(); | |||
this.Unloaded += (o, e) => { ThreadManage.GetInstance().StopTask("输送带料仓状态监控"); }; | |||
} | |||
} | |||
} |
@@ -0,0 +1,525 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.ManualControlView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<Style x:Key="radioButtonStyle" TargetType="RadioButton"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Opacity="0.8"> | |||
<ContentControl | |||
Margin="{TemplateBinding Margin}" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
FontSize="{TemplateBinding FontSize}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
<Image | |||
Name="image" | |||
Source="/BPASmartClient.CustomResource;component/Image/边框线.png" | |||
Stretch="Fill" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="False"> | |||
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/边框线.png" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/透明背景.png" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="gr" Property="Opacity" Value="1" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
<vm:ManualControlViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel | |||
Margin="0,0,10,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<ToggleButton | |||
Width="100" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Background="Transparent" | |||
Command="{Binding SystemStart}" | |||
Content="{Binding SystemControlText}" | |||
FontSize="20" | |||
Style="{StaticResource SwitchToggleButtonStyle1}" /> | |||
<ToggleButton | |||
Width="100" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Background="Transparent" | |||
Command="{Binding ModelSwitch}" | |||
Content="{Binding ModelSwitchText}" | |||
FontSize="20" | |||
Style="{StaticResource SwitchToggleButtonStyle1}" /> | |||
<!--<Button | |||
Width="150" | |||
Height="40" | |||
Margin="10,0,10,0" | |||
Command="{Binding SystemStart}" | |||
Content="{Binding SystemControlText}" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Width="150" | |||
Height="40" | |||
Margin="10,0,10,0" | |||
Command="{Binding ModelSwitch}" | |||
Content="{Binding ModelSwitchText}" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" />--> | |||
</StackPanel> | |||
<ScrollViewer | |||
Grid.Row="1" | |||
HorizontalScrollBarVisibility="Disabled" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<StackPanel Margin="8"> | |||
<!--#region 升降气缸--> | |||
<Grid | |||
Name="cy" | |||
Grid.Row="0" | |||
Margin="5" | |||
Visibility="{Binding cylinderModels, Converter={StaticResource CountIsVisiableConvert}}"> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=cy, Path=ActualWidth}" | |||
Height="{Binding ElementName=cy, Path=ActualHeight}" /> | |||
<StackPanel Background="Transparent"> | |||
<Grid Height="40"> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,10,0,0" | |||
VerticalAlignment="Top" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="升降气缸控制" /> | |||
</Grid> | |||
<ListView | |||
Name="list1" | |||
Grid.Row="1" | |||
Margin="0,0,0,20" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding cylinderModels}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Disabled" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</StackPanel> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 阻挡气缸--> | |||
<Grid | |||
Name="zd" | |||
Grid.Row="1" | |||
Margin="5" | |||
Visibility="{Binding BlockCylinders, Converter={StaticResource CountIsVisiableConvert}}"> | |||
<pry:ImageBorder Width="{Binding ElementName=zd, Path=ActualWidth}" Height="{Binding ElementName=zd, Path=ActualHeight}" /> | |||
<StackPanel> | |||
<Grid Height="40"> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="阻挡气缸控制" /> | |||
</Grid> | |||
<ListView | |||
Name="list2" | |||
Grid.Row="1" | |||
Margin="0,0,0,20" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding BlockCylinders}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</StackPanel> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 托盘气缸--> | |||
<Grid | |||
Name="tp" | |||
Grid.Row="2" | |||
Margin="5" | |||
Visibility="{Binding PalletCylinders, Converter={StaticResource CountIsVisiableConvert}}"> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=tp, Path=ActualWidth}" | |||
Height="{Binding ElementName=tp, Path=ActualHeight}" /> | |||
<StackPanel> | |||
<Grid Height="40"> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="托盘气缸控制" /> | |||
</Grid> | |||
<ListView | |||
Name="list3" | |||
Grid.Row="2" | |||
Margin="0,0,0,20" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding PalletCylinders}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</StackPanel> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 上下桶工位气缸--> | |||
<Grid | |||
Name="onGrid" | |||
Grid.Row="2" | |||
Margin="5" | |||
Visibility="{Binding OtherHandCylinders, Converter={StaticResource CountIsVisiableConvert}}"> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=onGrid, Path=ActualWidth}" | |||
Height="{Binding ElementName=onGrid, Path=ActualHeight}" /> | |||
<StackPanel> | |||
<Grid Height="40"> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="上下桶工位气缸控制" /> | |||
</Grid> | |||
<ListView | |||
Name="list4" | |||
Grid.Row="2" | |||
Margin="0,0,0,20" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding OtherHandCylinders}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</StackPanel> | |||
</Grid> | |||
<!--#endregion--> | |||
</StackPanel> | |||
</ScrollViewer> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,43 @@ | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// ManualControlView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class ManualControlView : UserControl | |||
{ | |||
public ManualControlView() | |||
{ | |||
InitializeComponent(); | |||
this.Unloaded += (o, e) => { ThreadManage.GetInstance().StopTask("手动气缸状态监控"); }; | |||
this.SizeChanged += ManualControlView_SizeChanged; | |||
this.cy.Height = this.list1.ActualHeight + 40; | |||
this.zd.Height = this.list2.ActualHeight + 40; | |||
this.tp.Height = this.list3.ActualHeight + 40; | |||
this.onGrid.Height = this.list4.ActualHeight + 40; | |||
} | |||
private void ManualControlView_SizeChanged(object sender, SizeChangedEventArgs e) | |||
{ | |||
this.cy.Height = this.list1.ActualHeight + 40; | |||
this.zd.Height = this.list2.ActualHeight + 40; | |||
this.tp.Height = this.list3.ActualHeight + 40; | |||
this.onGrid.Height = this.list4.ActualHeight + 40; | |||
} | |||
} | |||
} |
@@ -0,0 +1,267 @@ | |||
<Window | |||
x:Class="BPASmartClient.DosingSystemSingle.View.NewMaterialView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
Title="NewMateritalView" | |||
Width="600" | |||
Height="350" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.DataContext> | |||
<vm:NewMaterialViewModel /> | |||
</Window.DataContext> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
<ResourceDictionary> | |||
<SolidColorBrush x:Key="tabColor" Color="#FF2AB2E7" /> | |||
<!--<SolidColorBrush x:Key="bordColor" Color="#33ffffff" />--> | |||
<SolidColorBrush x:Key="bordColor" Color="#332AB2E7" /> | |||
<Style x:Key="ControlButtonStyle" TargetType="Button"> | |||
<Setter Property="Margin" Value="0" /> | |||
<Setter Property="FontSize" Value="18" /> | |||
<Setter Property="Foreground" Value="#FFF53F62" /> | |||
<Setter Property="FontWeight" Value="SemiBold" /> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border | |||
Name="TitleBarBr" | |||
BorderBrush="#00c2f4" | |||
BorderThickness="0" | |||
CornerRadius="0" | |||
Opacity="0.8"> | |||
<ContentPresenter | |||
Margin="{TemplateBinding Margin}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
<Border.Background> | |||
<ImageBrush | |||
ImageSource="/BPASmartClient.CustomResource;component/Image/组合边框1.1.png" | |||
Opacity="0.8" | |||
Stretch="Fill" /> | |||
</Border.Background> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="TitleBarBr" Property="Opacity" Value="1" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="TitleTextblockStyle" TargetType="TextBlock"> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="Foreground" Value="{StaticResource tabColor}" /> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontWeight" Value="SemiBold" /> | |||
</Style> | |||
<!--#region ListBox样式--> | |||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="border" CornerRadius="8"> | |||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
<Border Name="br" BorderThickness="1"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/容器边框.png" /> | |||
</Border.Background> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="55" /> | |||
<RowDefinition Height="20" /> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="25" | |||
Foreground="#FF2AB2E7" | |||
Text="本地原料创建" /> | |||
<Grid Grid.Row="2" Margin="10,0"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="150" /> | |||
</Grid.ColumnDefinitions> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Background="Transparent" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
Text="请输入原料名称:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Height="30" | |||
FontSize="16" | |||
Text="{Binding MaterialName}" /> | |||
</Grid> | |||
<StackPanel Grid.Column="1" Orientation="Horizontal"> | |||
<Button | |||
Width="80" | |||
Height="30" | |||
Margin="5,0" | |||
Command="{Binding SaveCommand}" | |||
Content="添加" | |||
Cursor="Hand" /> | |||
<Button | |||
Name="btClose" | |||
Width="70" | |||
Height="30" | |||
Click="btClose_Click" | |||
Content="取消" /> | |||
</StackPanel> | |||
</Grid> | |||
<TextBlock | |||
Grid.Row="1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="16" | |||
Foreground="Red" | |||
Text="{Binding ErrorInfo}" /> | |||
<Grid Grid.Row="4" Margin="10,0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="*" /> | |||
</Grid.RowDefinitions> | |||
<Grid Margin="0,10,0,0" Background="#ff0C255F"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="150" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="原料名称" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="功能操作" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="2" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<ScrollViewer | |||
Grid.Row="1" | |||
BorderBrush="#FF2AB2E7" | |||
BorderThickness="1" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding Materials}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="150" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Foreground="{StaticResource TitleBorderColor}" | |||
Text="{Binding RawMaterialName}" /> | |||
<Grid Grid.Column="1"> | |||
<Button | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RawMaterialId}" | |||
Content="删除" | |||
FontSize="16" | |||
Style="{StaticResource ControlButtonStyle}" /> | |||
<Border BorderBrush="{StaticResource bordColor}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="2" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,1" /> | |||
</Grid> | |||
<DataTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||
</Trigger> | |||
</DataTemplate.Triggers> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
<!--</Border>--> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</Window> |
@@ -0,0 +1,35 @@ | |||
using BPASmartClient.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.Shapes; | |||
namespace BPASmartClient.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// NewMateritalView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class NewMaterialView : Window | |||
{ | |||
public NewMaterialView() | |||
{ | |||
InitializeComponent(); | |||
this.btClose.Click += (o, e) => { this.Close(); }; | |||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | |||
} | |||
private void btClose_Click(object sender, RoutedEventArgs e) | |||
{ | |||
this.Close(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,238 @@ | |||
<Window | |||
x:Class="BPASmartClient.DosingSystemSingle.View.NewOutletView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
Title="NewOutletView" | |||
Width="600" | |||
Height="400" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.DataContext> | |||
<vm:NewOutletViewModel /> | |||
</Window.DataContext> | |||
<Grid> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/容器边框.png" /> | |||
</Grid.Background> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.18*" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="{StaticResource FontColor}" | |||
Text="新建出料口" /> | |||
<Grid Grid.Row="1"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.2*" /> | |||
<RowDefinition Height="0.2*" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="15,0,0,0" | |||
HorizontalAlignment="Left" | |||
FontSize="16" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="出料口名称:" /> | |||
<TextBox | |||
Name="outName" | |||
Width="180" | |||
Height="35" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding OutletName}" /> | |||
<TextBlock | |||
Margin="15,0,0,0" | |||
HorizontalAlignment="Left" | |||
FontSize="16" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="出料口位置:" /> | |||
<TextBox | |||
Name="outLoc" | |||
Width="180" | |||
Height="35" | |||
Margin="5,0,0,0" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding OutletLoc}" /> | |||
</StackPanel> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Right" | |||
Orientation="Horizontal"> | |||
<!--<TextBox | |||
Name="outName" | |||
Width="180" | |||
Height="35" | |||
Margin="5,0,0,0" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" />--> | |||
<TextBlock | |||
Margin="0,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FFF53F62" | |||
Text="{Binding ErrorInfo}" /> | |||
<Button | |||
Width="90" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding AddCommand}" | |||
Content="添加原料" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Width="90" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding CancelCommand}" | |||
Content="取消" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Grid.Column="1" | |||
Width="90" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding SaveCommand}" | |||
Content="保存" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
</StackPanel> | |||
<Grid Grid.Row="2" Margin="15,0,10,10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="35" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 表格标题栏设置--> | |||
<Grid Margin="0,10,0,0" Background="#ff0C255F"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.68*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="原料" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="功能操作" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="2" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<!--#endregion--> | |||
<ScrollViewer | |||
Grid.Row="1" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding SiloInfos}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<!--<RadioButton Content="{Binding RawMaterialName}" Name="rb" GroupName="all"> | |||
<RadioButton.Template> | |||
<ControlTemplate TargetType="RadioButton">--> | |||
<Grid Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.68*" /> | |||
</Grid.ColumnDefinitions> | |||
<ComboBox | |||
Name="cb" | |||
Grid.Column="0" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
VerticalAlignment="Center" | |||
HorizontalContentAlignment="Left" | |||
BorderBrush="#FF074B92" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.SileName, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="{Binding SelectIndex}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding RawMaterialName}" /> | |||
<Button | |||
Grid.Column="1" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RawMaterialName}" | |||
Content="删除" | |||
FontSize="16" | |||
Style="{StaticResource ControlButtonStyle}" /> | |||
<!--<Button | |||
Grid.Column="1" | |||
Width="80" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RawMaterialName}" | |||
Content="删除" />--> | |||
</Grid> | |||
<!--</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton>--> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
</Grid> | |||
</Grid> | |||
</Grid> | |||
</Window> |
@@ -0,0 +1,29 @@ | |||
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.Shapes; | |||
namespace BPASmartClient.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// NewOutletView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class NewOutletView : Window | |||
{ | |||
public NewOutletView() | |||
{ | |||
InitializeComponent(); | |||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "NewOutletViewClose", true); | |||
} | |||
} | |||
} |
@@ -0,0 +1,265 @@ | |||
<Window | |||
x:Class="BPASmartClient.DosingSystemSingle.View.NewRecipeView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
Title="NewRecipeView" | |||
Width="550" | |||
Height="600" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.DataContext> | |||
<vm:NewRecipeViewModel /> | |||
</Window.DataContext> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
<ResourceDictionary> | |||
<!--#region ListBox样式--> | |||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="border" CornerRadius="8"> | |||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
<Border | |||
Name="br" | |||
BorderBrush="#0CADF5" | |||
BorderThickness="2"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" /> | |||
<!--<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹窗2.png" />--> | |||
</Border.Background> | |||
<Grid> | |||
<!--<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹窗.png" /> | |||
</Grid.Background>--> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="5" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--<Button | |||
Name="btClose" | |||
Margin="0,0,5,0" | |||
Padding="10,5" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
Content="X" | |||
FontSize="18" | |||
Foreground="White" /> | |||
<Border BorderBrush="#88DDDDDD" BorderThickness="0,0,0,1" />--> | |||
<Grid Grid.Row="1"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
Background="Transparent" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
Text="请输入配方名称:" /> | |||
<TextBlock | |||
Margin="0,0,10,0" | |||
HorizontalAlignment="Right" | |||
Background="Transparent" | |||
FontSize="16" | |||
Foreground="Red" | |||
Text="{Binding ErrorInfo}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="10,0,0,0" | |||
Orientation="Horizontal"> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="200" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
FontSize="16" | |||
Text="{Binding RecipeName}" /> | |||
<Button | |||
Width="148" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
Command="{Binding AddCommand}" | |||
Content="添加原料" | |||
Cursor="Hand" /> | |||
<Button | |||
Width="80" | |||
Height="30" | |||
Command="{Binding SaveCommand}" | |||
Content="确认" /> | |||
<Button | |||
Name="btClose" | |||
Width="80" | |||
Height="30" | |||
Margin="7,0,0,0" | |||
Content="取消" /> | |||
</StackPanel> | |||
<!--#region 表格标题栏设置--> | |||
<Grid | |||
Grid.Row="2" | |||
Margin="5,0" | |||
Background="#ff0C255F"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="原料名称" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
<TextBlock | |||
Grid.Column="1" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="重量" /> | |||
<Grid Grid.Column="2"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="删除" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="10" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<!--#endregion--> | |||
<ScrollViewer | |||
Grid.Row="3" | |||
Margin="5,0" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding RawMaterials}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton GroupName="all"> | |||
<RadioButton.Template> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Height="35"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<!--<ColumnDefinition Width="0.7*" />--> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
</Grid.ColumnDefinitions> | |||
<ComboBox | |||
Name="cb" | |||
Grid.Column="0" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF074B92" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="{Binding SelectIndex}" | |||
SelectionChanged="cb_SelectionChanged" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding RawMaterialName}" /> | |||
<TextBox | |||
Name="tb" | |||
Grid.Column="1" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
Text="{Binding RawMaterialWeight}" /> | |||
<TextBlock | |||
Grid.Column="1" | |||
Margin="0,0,8,4" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
Text="g" /> | |||
<Button | |||
Grid.Column="2" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RawMaterialId}" | |||
Content="删除" | |||
FontSize="16" | |||
Style="{StaticResource ControlButtonStyle}" /> | |||
</Grid> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</Window> |
@@ -0,0 +1,37 @@ | |||
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.Shapes; | |||
namespace BPASmartClient.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// NewRecipeView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class NewRecipeView : Window | |||
{ | |||
public NewRecipeView() | |||
{ | |||
InitializeComponent(); | |||
this.btClose.Click += (o, e) => { this.Close(); }; | |||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | |||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView", true); | |||
this.Unloaded += (o, s) => { Json<LocaPar>.Save(); }; | |||
} | |||
private void cb_SelectionChanged(object sender, SelectionChangedEventArgs e) | |||
{ | |||
//ActionManage.GetInstance.SendAsync("原料选择修改", (sender as ComboBox).SelectedValue); | |||
} | |||
} | |||
} |
@@ -0,0 +1,162 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.OutletManagementView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:OutletManagementViewModel /> | |||
</UserControl.DataContext> | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<Button | |||
Width="150" | |||
Height="40" | |||
Margin="10,0,10,0" | |||
Command="{Binding AddCommand}" | |||
Content="添加出料口" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Width="150" | |||
Height="40" | |||
Margin="10,0,10,0" | |||
Command="{Binding SaveCommand}" | |||
Content="保存参数" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
</StackPanel> | |||
<Grid Grid.Row="1"> | |||
<ListView | |||
Margin="10" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding OutletInfoModels}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Border | |||
Name="ShadowElement" | |||
Width="180" | |||
Height="150" | |||
Margin="10" | |||
VerticalAlignment="Top" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ClipToBounds="True" | |||
CornerRadius="0"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/蓝色背景.png" Stretch="Fill" /> | |||
</Border.Background> | |||
<Grid Margin="20,0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Grid.Row="0" | |||
Grid.ColumnSpan="2" | |||
Margin="0,10,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#00BEFA" | |||
Text="{Binding OutletName}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Grid.Row="1" | |||
FontSize="14" | |||
Foreground="#aa00BEFA" | |||
Text="出料口位置:" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
FontSize="14" | |||
Foreground="#aa00BEFA" | |||
Text="{Binding OutletLoc}" /> | |||
</StackPanel> | |||
<Grid | |||
Name="gr" | |||
Grid.Row="2" | |||
Height="30" | |||
Margin="0,0,0,10"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<pry:IcoButton | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
Margin="4,4,3,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="#11F53F62" | |||
BorderThickness="0" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}" | |||
CommandParameter="{Binding OutletName}" | |||
Content="删除" | |||
EnterBackground="#22F53F62" | |||
FontStyle="Normal" | |||
Foreground="#FFF53F62" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Column="1" | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
Margin="3,4,4,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="#112AB2E7" | |||
BorderThickness="0" | |||
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}" | |||
CommandParameter="{Binding OutletName}" | |||
Content="编辑" | |||
EnterBackground="#222AB2E7" | |||
Foreground="#FF2AB2E7" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,35 @@ | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// OutletManagementView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class OutletManagementView : UserControl | |||
{ | |||
public OutletManagementView() | |||
{ | |||
InitializeComponent(); | |||
this.Unloaded += OutletManagementView_Unloaded; | |||
} | |||
private void OutletManagementView_Unloaded(object sender, RoutedEventArgs e) | |||
{ | |||
Json<DevicePar>.Save(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,62 @@ | |||
using BPASmartClient.DosingSystemSingle.ViewModel; | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// RecipeControlView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class RecipeControlView : UserControl | |||
{ | |||
public RecipeControlView() | |||
{ | |||
InitializeComponent(); | |||
RadioButtonWait_Click(null, null); | |||
} | |||
private void RadioButtonCompelete_Click(object sender, RoutedEventArgs e) | |||
{ | |||
//repiceList.ItemsSource = RecipeControlViewModel.UserTreeCompelete; | |||
//repiceList.Visibility = Visibility.Visible; | |||
//repiceListMaking.Visibility = Visibility.Hidden; | |||
this.Wait.ItemsSource = RecipeControlViewModel.UserTreeCompelete; | |||
CookingGrid.Visibility = Visibility.Collapsed; | |||
WaitOrCompleteGrid.Visibility = Visibility.Visible; | |||
this.Wait.Visibility = Visibility.Visible; | |||
} | |||
private void RadioButtonWait_Click(object sender, RoutedEventArgs e) | |||
{ | |||
//repiceList.ItemsSource = RecipeControlViewModel.UserTreeWait; | |||
//repiceList.Visibility = Visibility.Visible; | |||
//repiceListMaking.Visibility = Visibility.Hidden; | |||
this.Wait.ItemsSource = RecipeControlViewModel.UserTreeWait; | |||
CookingGrid.Visibility = Visibility.Collapsed; | |||
WaitOrCompleteGrid.Visibility = Visibility.Visible; | |||
this.Wait.Visibility = Visibility.Visible; | |||
} | |||
private void RadioButtonMaking_Click(object sender, RoutedEventArgs e) | |||
{ | |||
//repiceListMaking.Visibility = Visibility.Visible; | |||
//repiceList.Visibility = Visibility.Hidden; | |||
WaitOrCompleteGrid.Visibility = Visibility.Collapsed; | |||
this.Wait.Visibility = Visibility.Collapsed; | |||
CookingGrid.Visibility = Visibility.Visible; | |||
} | |||
} | |||
} |
@@ -0,0 +1,319 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.RecipeSettingsView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||
<SolidColorBrush x:Key="CursorColor" Color="Aqua" /> | |||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | |||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
</Style> | |||
<Style x:Key="buttonStyle" TargetType="Button"> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="Foreground" Value="Aqua" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
</Style> | |||
<!--<Style x:Key="ListViewStyle" TargetType="ListView" />--> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
<vm:RecipeSettingsViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 操作按钮--> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<!--<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="10" | |||
HorizontalAlignment="Left" | |||
Command="{Binding NewMaterital}" | |||
Content="新建原料" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" />--> | |||
<!--<Button | |||
Width="140" | |||
Height="30" | |||
Margin="10 0" | |||
Command="{Binding NewMaterital}" | |||
Content="新建原料" | |||
FontSize="16" | |||
Style="{StaticResource ImageButtonStyle}" />--> | |||
<Button | |||
Width="140" | |||
Height="30" | |||
Margin="10 0" | |||
Command="{Binding NewRecipe}" | |||
Content="新建配方" | |||
FontSize="16" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Width="140" | |||
Height="30" | |||
Margin="10 0" | |||
Command="{Binding SaveRecipe}" | |||
Content="保存配方" | |||
FontSize="16" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<!--<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="10" | |||
HorizontalAlignment="Left" | |||
Command="{Binding NewRecipe}" | |||
Content="新建配方" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" />--> | |||
<!--<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="10" | |||
HorizontalAlignment="Left" | |||
Command="{Binding SaveRecipe}" | |||
Content="保存配方" | |||
FontSize="17" | |||
Foreground="Aqua" | |||
IcoText="" | |||
IsEnabled="True" | |||
Style="{StaticResource IcoButtonStyle}" />--> | |||
</StackPanel> | |||
<!--#endregion--> | |||
<ListBox | |||
Grid.Row="2" | |||
Margin="5" | |||
VerticalAlignment="Top" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ItemsSource="{Binding Recipes}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListBox.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<!--<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" />--> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListBox.ItemsPanel> | |||
<ListBox.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Name="tt" | |||
Width="180" | |||
Height="220" | |||
Margin="5"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="20" /> | |||
<RowDefinition Height="128" /> | |||
<RowDefinition Height="2" /> | |||
<RowDefinition Height="40" /> | |||
</Grid.RowDefinitions> | |||
<Image | |||
Grid.RowSpan="5" | |||
Source="/BPASmartClient.CustomResource;component/Image/配方背景/竖背景框.png" | |||
Stretch="Fill" /> | |||
<TextBlock | |||
Grid.Row="0" | |||
Margin="2,5,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Top" | |||
FontSize="18" | |||
Foreground="#FF2AB2E7" | |||
Text="{Binding RecipeName}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="5,0,0,0" | |||
VerticalAlignment="Top" | |||
Foreground="#FF2AB2E7" | |||
Text="配方信息:" /> | |||
<ScrollViewer | |||
Grid.Row="2" | |||
VerticalAlignment="Top" | |||
Background="Transparent" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<ItemsControl ItemsSource="{Binding RawMaterials}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="#aa2AB2E7" | |||
Text="{Binding RawMaterialName}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
<ItemsControl Grid.Column="1" ItemsSource="{Binding RawMaterials}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<StackPanel Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#aa2AB2E7" | |||
Text=":" /> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#aa2AB2E7" | |||
Text="{Binding RawMaterialWeight}" /> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#aa2AB2E7" | |||
Text="g" /> | |||
</StackPanel> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</Grid> | |||
</ScrollViewer> | |||
<!--<Grid | |||
Grid.Row="3" | |||
Height="2" | |||
VerticalAlignment="Bottom"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/直线.png" Stretch="Fill" /> | |||
</Grid.Background> | |||
</Grid>--> | |||
<Image | |||
Grid.Row="3" | |||
Width="{Binding ElementName=tt, Path=ActualWidth}" | |||
Height="2" | |||
VerticalAlignment="Bottom" | |||
Source="/BPASmartClient.CustomResource;component/Image/直线.png" | |||
Stretch="Fill" /> | |||
<Grid | |||
Name="gr" | |||
Grid.Row="4" | |||
Height="30" | |||
Margin="0,0,0,10" | |||
VerticalAlignment="Bottom" | |||
Background="Transparent"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Image | |||
Grid.ColumnSpan="2" | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="2" | |||
VerticalAlignment="Top" | |||
Source="/BPASmartClient.CustomResource;component/Image/直线.png" /> | |||
<pry:IcoButton | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
Margin="4,4,3,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="#11F53F62" | |||
BorderThickness="0" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipeName}" | |||
Content="删除" | |||
EnterBackground="#22F53F62" | |||
FontStyle="Normal" | |||
Foreground="#FFF53F62" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Column="1" | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
Margin="3,4,4,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="#112AB2E7" | |||
BorderThickness="0" | |||
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipeName}" | |||
Content="编辑" | |||
EnterBackground="#222AB2E7" | |||
Foreground="#FF2AB2E7" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
<!--</StackPanel>--> | |||
</Grid> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,54 @@ | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Reflection; | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// RecipeSettingsView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class RecipeSettingsView : UserControl | |||
{ | |||
public RecipeSettingsView() | |||
{ | |||
InitializeComponent(); | |||
this.Unloaded += RecipeSettingsView_Unloaded; | |||
} | |||
private void RecipeSettingsView_Unloaded(object sender, RoutedEventArgs e) | |||
{ | |||
Json<LocaPar>.Save(); | |||
} | |||
//public static void SetAlignment() | |||
//{ | |||
// //获取系统是以Left-handed(true)还是Right-handed(false) | |||
// var ifLeft = SystemParameters.MenuDropAlignment; | |||
// if (ifLeft) | |||
// { | |||
// Console.WriteLine($"系统为左撇子,转换为右撇子。"); | |||
// // change to false | |||
// var t = typeof(SystemParameters); | |||
// var field = t.GetField("_menuDropAlignment", BindingFlags.NonPublic | BindingFlags.Static); | |||
// field.SetValue(null, false); | |||
// ifLeft = SystemParameters.MenuDropAlignment; | |||
// } | |||
//} | |||
} | |||
} |
@@ -0,0 +1,343 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystemSingle.View.StockControlView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:define="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystemSingle.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystemSingle.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<Style x:Key="radioButtonStyle" TargetType="RadioButton"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Opacity="0.8"> | |||
<ContentControl | |||
Margin="{TemplateBinding Margin}" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
FontSize="{TemplateBinding FontSize}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
<Image | |||
Name="image" | |||
Source="/BPASmartClient.CustomResource;component/Image/边框线.png" | |||
Stretch="Fill" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="False"> | |||
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/边框线.png" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/透明背景.png" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="gr" Property="Opacity" Value="1" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="textBoxStyle" TargetType="TextBox"> | |||
<Setter Property="Background" Value="Transparent" /> | |||
</Style> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
<vm:StockControViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Grid x:Name="TopGrid"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.2*" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<ListView | |||
Grid.Row="1" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ItemsSource="{Binding statusTop}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" | |||
ScrollViewer.VerticalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" | |||
Rows="1" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.8*" /> | |||
<RowDefinition Height="0.1*" /> | |||
<RowDefinition Height="0.2*" /> | |||
</Grid.RowDefinitions> | |||
<define:MaterialStock | |||
Grid.Row="0" | |||
Margin="35,0,35,0" | |||
IsFaultState="{Binding IsFault}" | |||
IsLayOffState="{Binding IsLayOff}" | |||
IsOpenState="{Binding IsOpen}" | |||
IsRunning="{Binding RunStatus}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="0,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock Foreground="#00c2f4" Text="配料重量:" /> | |||
<TextBox | |||
Grid.Row="0" | |||
Width="80" | |||
Padding="2" | |||
Background="Transparent" | |||
BorderBrush="#00c2f4" | |||
CaretBrush="#00c2f4" | |||
Foreground="#00c2f4" | |||
Text="{Binding Weight}" /> | |||
</StackPanel> | |||
<Grid Grid.Row="2" VerticalAlignment="Bottom"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<StackPanel> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding IsOpen}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
Foreground="AliceBlue" | |||
Text="仓盖控制" /> | |||
</StackPanel> | |||
<StackPanel Grid.Column="1"> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding IsLayOff}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
Foreground="AliceBlue" | |||
Text="出料控制" /> | |||
</StackPanel> | |||
<!--<Button | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding DataContext.GaicangControlCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
Content="开盖" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" />--> | |||
<!--<Button | |||
Grid.Column="1" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding DataContext.BlowingControlCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
Content="出料" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" />--> | |||
</Grid> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
<Grid | |||
x:Name="midGrid" | |||
Grid.Row="1" | |||
Margin="0,0,0,0" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<define:ConveyBelt2 | |||
Grid.RowSpan="2" | |||
Margin="-12,0,10,0" | |||
BeltDashThickess="50" | |||
BeltHeight="{Binding ElementName=midGrid, Path=ActualHeight}" | |||
BeltWidth="{Binding ElementName=midGrid, Path=ActualWidth}" | |||
IsRun="{Binding ConveyerBeltWork}" /> | |||
<StackPanel | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
VerticalAlignment="Center" | |||
FontSize="18" | |||
Foreground="White" | |||
Text="输送带控制" /> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding ConveyerBeltWork}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<!--<Button | |||
Grid.Column="1" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding DataContext.BlowingControlCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
Content="出料" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" />--> | |||
<!--<RadioButton | |||
Width="130" | |||
Height="50" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="输送带启动" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Width="130" | |||
Height="50" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="输送带停止" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" />--> | |||
</StackPanel> | |||
</Grid> | |||
<Grid Grid.Row="2"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition Height="0.2*" /> | |||
</Grid.RowDefinitions> | |||
<ListView | |||
Grid.Row="0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ItemsSource="{Binding statusDown}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" | |||
ScrollViewer.VerticalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" | |||
Rows="1" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.8*" /> | |||
<RowDefinition Height="0.2*" /> | |||
</Grid.RowDefinitions> | |||
<define:MaterialStock | |||
Margin="35,0,35,0" | |||
IsFaultState="{Binding IsFault}" | |||
IsLayOffState="{Binding IsLayOff}" | |||
IsOpenState="{Binding IsOpen}" | |||
IsRunning="{Binding IsRunning}" /> | |||
<Grid Grid.Row="1" VerticalAlignment="Bottom"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<StackPanel> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding IsOpen}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
Foreground="AliceBlue" | |||
Text="仓盖控制" /> | |||
</StackPanel> | |||
<StackPanel Grid.Column="1"> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding IsLayOff}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
Foreground="AliceBlue" | |||
Text="出料控制" /> | |||
</StackPanel> | |||
</Grid> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,30 @@ | |||
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.DosingSystemSingle.View | |||
{ | |||
/// <summary> | |||
/// StockControlView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class StockControlView : UserControl | |||
{ | |||
public StockControlView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,61 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class ChangeDeviceNameViewModel : ViewModelBase | |||
{ | |||
public ChangeDeviceNameViewModel() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is string str) IpAddress = str; | |||
}), "ChangeDeviceNameViewOpen"); | |||
CancelCommand = new BPARelayCommand(() => { ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); }); | |||
AddCommand = new BPARelayCommand(() => | |||
{ | |||
if (string.IsNullOrEmpty(DeviceName)) | |||
{ | |||
ErrorInfo = "设备名称不能为空"; | |||
return; | |||
} | |||
int index = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.IpAddress == IpAddress); | |||
if (index >= 0 && index < DeviceInquire.GetInstance.devices.Count) | |||
{ | |||
if (DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == DeviceName) != null) | |||
ErrorInfo = "设备名称已存在"; | |||
else | |||
{ | |||
var res = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(index).DeviceName); | |||
if (res != null) | |||
{ | |||
res.RawMaterialName = DeviceName; | |||
DeviceInquire.GetInstance.devices.ElementAt(index).DeviceName = DeviceName; | |||
DeviceInquire.GetInstance.GetDevice(IpAddress).SetDeviceName(DeviceName);//设置PLC名称 | |||
for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++) | |||
{ | |||
for (int m = 0; m < Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; | |||
} | |||
} | |||
ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); | |||
} | |||
} | |||
} | |||
}); | |||
} | |||
private static string IpAddress = string.Empty; | |||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||
private string _mDeviceName; | |||
} | |||
} |
@@ -0,0 +1,44 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class CommparSetViewModel : NotifyBase | |||
{ | |||
public CommparSetViewModel() | |||
{ | |||
SaveCommand = new BPARelayCommand(() => | |||
{ | |||
if (!string.IsNullOrEmpty(CommBaseParModel.NetworkSegAddress)) | |||
{ | |||
var res = CommBaseParModel.NetworkSegAddress.Split("."); | |||
if (res != null) | |||
{ | |||
if (res.Length >= 3) | |||
{ | |||
StringBuilder sb = new StringBuilder(); | |||
for (int i = 0; i < 3; i++) sb.Append($"{res[i]}."); | |||
Json<DevicePar>.Data.BaseParModel.NetworkSegAddress = sb.ToString(); | |||
Json<DevicePar>.Save(); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"参数保存成功!"); | |||
} | |||
} | |||
} | |||
}); | |||
} | |||
public BasePar CommBaseParModel { get { return Json<DevicePar>.Data.BaseParModel; } set { Json<DevicePar>.Data.BaseParModel = value; OnPropertyChanged(); } } | |||
//private BasePar _mCommBaseParModel; | |||
public BPARelayCommand SaveCommand { get; set; } | |||
} | |||
} |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class ConveyerBeltManualViewModel : NotifyBase | |||
{ | |||
public ConveyerBeltManualViewModel() | |||
{ | |||
for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.ConveyerBeltCount; i++) | |||
{ | |||
ConveyerBeltModels.Add(new ConveyerBeltModel() | |||
{ | |||
Name = $"输送带{i + 1}控制", | |||
Num = i + 1, | |||
Speed = GlobalDevice.MotorSpeed[i], | |||
ConveyerBeltWork = GlobalDevice.MotorControl.GetBitValue((byte)(i + 1)) | |||
}); | |||
} | |||
} | |||
public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | |||
} | |||
} |
@@ -0,0 +1,52 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.DosingSystemSingle.View; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class DeviceListViewModel : ViewModelBase | |||
{ | |||
public DeviceListViewModel() | |||
{ | |||
DetailsCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is string str) | |||
{ | |||
ChangeDeviceNameView cdn = new ChangeDeviceNameView(); | |||
ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str); | |||
cdn.ShowDialog(); | |||
} | |||
}); | |||
devices = DeviceInquire.GetInstance.devices; | |||
} | |||
//public BPARelayCommand<object> ChangeNameCommand { get; set; } | |||
//public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>(); | |||
public ObservableCollection<Devices> devices { get; set; } | |||
} | |||
public class Devices : NotifyBase | |||
{ | |||
public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } } | |||
private string _mIpAddress; | |||
/// <summary> | |||
/// 设备编号 | |||
/// </summary> | |||
public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } } | |||
private int _mDeviceNum; | |||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||
private string _mDeviceName; | |||
} | |||
} |
@@ -0,0 +1,66 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using System.Diagnostics; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class DeviceMaterialParViewModel : ViewModelBase | |||
{ | |||
public DeviceMaterialParViewModel() | |||
{ | |||
deviceParModels = Json<DevicePar>.Data.deviceParModels; | |||
RemoveCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
var res = deviceParModels.FirstOrDefault(p => p.MaterialName == o?.ToString()); | |||
if (res != null) deviceParModels.Remove(res); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{o.ToString()}:原料删除成功!"); | |||
}); | |||
AddCommand = new BPARelayCommand(() => { deviceParModels.Add(new DeviceParModel()); }); | |||
SaveCommand = new BPARelayCommand(() => | |||
{ | |||
if (deviceParModels == null || deviceParModels.Count <= 0) | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"没有可保存的参数!"); | |||
return; | |||
} | |||
for (int i = 0; i < deviceParModels.Count; i++) | |||
{ | |||
if (deviceParModels.Where(p => p.MaterialName == deviceParModels.ElementAt(i).MaterialName)?.ToList()?.Count >= 2) | |||
deviceParModels.ElementAt(i).IsRedundant = true; | |||
else | |||
deviceParModels.ElementAt(i).IsRedundant = false; | |||
} | |||
if (deviceParModels.FirstOrDefault(p => p.IsRedundant == true) != null) | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"原料名称冲突,请检查后重试!"); | |||
return; | |||
} | |||
deviceParModels.Where(P => P.MaterialName.Length <= 0)?.ToList()?.ForEach(item => | |||
{ | |||
Json<DevicePar>.Data.deviceParModels.Remove(item); | |||
}); | |||
Json<DevicePar>.Save(); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"原料参数保存成功!"); | |||
}); | |||
} | |||
public ObservableCollection<DeviceParModel> deviceParModels { get; set; } | |||
//public BPARelayCommand<object> RemoveCommand { get; set; } | |||
//public BPARelayCommand AddCommand { get; set; } | |||
//public BPARelayCommand SaveCommand { get; set; } | |||
} | |||
} |
@@ -0,0 +1,137 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using System.Threading; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class HardwareStatusViewModel : NotifyBase | |||
{ | |||
public HardwareStatusViewModel() | |||
{ | |||
TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; | |||
BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; | |||
//for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.ConveyerBeltCount; i++) | |||
//{ | |||
// ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i}", Num = i++ }); | |||
//} | |||
//ConveyerBeltControlCommand = new BPARelayCommand<object>(o => | |||
//{ | |||
// if (o != null && o is int tempCount) | |||
// { | |||
// string add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", tempCount, 6); | |||
// int index = ConveyerBeltModels.ToList().FindIndex(p => p.Num == tempCount); | |||
// if (index >= 0 && index < ConveyerBeltModels.Count) | |||
// { | |||
// SiemensDevice.GetInstance.MySiemens.Write(add, !ConveyerBeltModels.ElementAt(index).Control); | |||
// } | |||
// } | |||
//}); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
for (int i = 0; i < Json<DevicePar>.Data.OutletInfoModels.Count; i++) | |||
{ | |||
int count = Json<DevicePar>.Data.OutletInfoModels.ElementAt(i).SiloInfos.Count; | |||
if (count >= 1) | |||
{ | |||
for (int m = 0; m < count; m++) | |||
{ | |||
var deviceName = Json<DevicePar>.Data.OutletInfoModels.ElementAt(i).SiloInfos.ElementAt(m); | |||
int topIndex = TopDeviceCurrentStatuses.ToList().FindIndex(p => p.DeviceName == deviceName); | |||
int bottomIndex = BottomDeviceCurrentStatuses.ToList().FindIndex(p => p.DeviceName == deviceName); | |||
if (topIndex >= 0 && topIndex < TopDeviceCurrentStatuses.Count) | |||
TopDeviceCurrentStatuses.ElementAt(i).BucketFlagbit = GlobalDevice.PlcData.StationDetection[i]; | |||
if (bottomIndex >= 0 && bottomIndex < BottomDeviceCurrentStatuses.Count) | |||
BottomDeviceCurrentStatuses.ElementAt(i).BucketFlagbit = GlobalDevice.PlcData.StationDetection[i]; | |||
} | |||
} | |||
} | |||
StatusUpdate(TopDeviceCurrentStatuses); | |||
StatusUpdate(BottomDeviceCurrentStatuses); | |||
OnDetection = GlobalDevice.PlcData.OnDetection; | |||
UnderDetection = GlobalDevice.PlcData.UnderDetection; | |||
ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0; | |||
Thread.Sleep(100); | |||
}), "输送带料仓状态监控"); | |||
RecipeControlCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is DeviceCurrentStatus currentStatus) | |||
{ | |||
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == currentStatus.DeviceName); | |||
if (res != null) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(res.IpAddress).Start(currentStatus.SetWeight); | |||
} | |||
} | |||
}); | |||
} | |||
private void StatusUpdate(ObservableCollection<DeviceCurrentStatus> devices) | |||
{ | |||
if (devices == null) return; | |||
for (int i = 0; i < devices.Count; i++) | |||
{ | |||
if (devices.ElementAt(i).BaitingControl) | |||
{ | |||
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName); | |||
if (res != null) | |||
{ | |||
var runStatus = DeviceInquire.GetInstance.GetDevice(res.IpAddress).deviceStatus.RunStatus; | |||
if (runStatus == 3) | |||
{ | |||
if (TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName) != null) | |||
{ | |||
TopDeviceCurrentStatuses.ElementAt(i).BaitingControl = false; | |||
} | |||
else if (BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName) != null) | |||
{ | |||
BottomDeviceCurrentStatuses.ElementAt(i).BaitingControl = false; | |||
} | |||
DeviceInquire.GetInstance.GetDevice(res.IpAddress).StatusReset(); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } | |||
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } | |||
public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | |||
public BPARelayCommand<object> ConveyerBeltControlCommand { get; set; } | |||
public BPARelayCommand<object> RecipeControlCommand { get; set; } | |||
/// <summary> | |||
/// 输送带状态 | |||
/// </summary> | |||
public bool ConveyerBeltStatus { get { return _mConveyerBeltStatus; } set { _mConveyerBeltStatus = value; OnPropertyChanged(); } } | |||
private bool _mConveyerBeltStatus; | |||
/// <summary> | |||
/// 上桶工位检测 | |||
/// </summary> | |||
public bool OnDetection { get { return _mOnDetection; } set { _mOnDetection = value; OnPropertyChanged(); } } | |||
private bool _mOnDetection; | |||
/// <summary> | |||
/// 下桶工位检测 | |||
/// </summary> | |||
public bool UnderDetection { get { return _mUnderDetection; } set { _mUnderDetection = value; OnPropertyChanged(); } } | |||
private bool _mUnderDetection; | |||
} | |||
} |
@@ -0,0 +1,208 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using System.Threading; | |||
using BPASmartClient.S7Net; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class ManualControlViewModel : NotifyBase | |||
{ | |||
public ManualControlViewModel() | |||
{ | |||
Init(); | |||
for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.LiftCylinderCount; i++) | |||
{ | |||
cylinderModels.Add(new CylinderModel() | |||
{ | |||
Name = $"升降气缸 {i + 1}", | |||
LeftTog = false, | |||
RightTog = false, | |||
Num = i + 1, | |||
}); | |||
} | |||
for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.BlockCylinderCount; i++) | |||
{ | |||
BlockCylinders.Add(new CylinderModel() | |||
{ | |||
Name = $"阻挡气缸 {i + 1}", | |||
LeftTog = false, | |||
RightTog = false, | |||
Num = i + 1, | |||
}); | |||
} | |||
for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.PalletCylinderCount; i++) | |||
{ | |||
PalletCylinders.Add(new CylinderModel() | |||
{ | |||
Name = $"托盘气缸 {i + 1}", | |||
LeftTog = false, | |||
RightTog = false, | |||
Num = i + 1, | |||
}); | |||
} | |||
OtherHandCylinders.Add(new CylinderModel() { Name = "上桶工位气缸" }); | |||
OtherHandCylinders.Add(new CylinderModel() { Name = "下桶工位气缸" }); | |||
Open = new BPARelayCommand<object>((o) => | |||
{ | |||
if (o != null) | |||
{ | |||
if (o.ToString().Contains("升降气缸")) | |||
{ | |||
int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString()); | |||
if (index >= 0 && index < cylinderModels.Count) | |||
{ | |||
var addRes = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", cylinderModels.ElementAt(index).Num); | |||
SiemensDevice.GetInstance.MySiemens.Write(addRes, true); | |||
} | |||
} | |||
else if (o.ToString().Contains("上桶工位气缸")) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.0", true); | |||
} | |||
else if (o.ToString().Contains("下桶工位气缸")) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.1", true); | |||
} | |||
} | |||
}); | |||
Close = new BPARelayCommand<object>((o) => | |||
{ | |||
if (o != null) | |||
{ | |||
if (o.ToString().Contains("升降气缸")) | |||
{ | |||
int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString()); | |||
if (index >= 0 && index < cylinderModels.Count) | |||
{ | |||
var addRes = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", cylinderModels.ElementAt(index).Num); | |||
SiemensDevice.GetInstance.MySiemens.Write(addRes, false); | |||
} | |||
} | |||
else if (o.ToString().Contains("上桶工位气缸")) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.0", false); | |||
} | |||
else if (o.ToString().Contains("下桶工位气缸")) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.1", false); | |||
} | |||
} | |||
}); | |||
SystemStart = new BPARelayCommand(() => | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("M10.0", SystemControlText == "停止" ? false : true); | |||
/*var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0"); | |||
SystemControlText = res ? "停止" : "启动";*/ | |||
}); | |||
ModelSwitch = new BPARelayCommand(() => | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("M10.1", ModelSwitchText == "手动" ? true : false); | |||
/*var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1"); | |||
ModelSwitchText = res ? "自动" : "手动";*/ | |||
}); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
for (int i = 0; i < cylinderModels.Count; i++) | |||
{ | |||
//升降气缸状态 | |||
cylinderModels.ElementAt(i).RightTog = (bool)GlobalDevice.PlcData.cylinderFlagBitStatus[i]?.HomeSignal; | |||
cylinderModels.ElementAt(i).LeftTog = (bool)GlobalDevice.PlcData.cylinderFlagBitStatus[i]?.InPlaceSignal; | |||
} | |||
//上桶工位气缸状态 | |||
OtherHandCylinders.ElementAt(0).RightTog = GlobalDevice.PlcData.OnCylinderDetection.HomeSignal; | |||
OtherHandCylinders.ElementAt(0).LeftTog = GlobalDevice.PlcData.OnCylinderDetection.InPlaceSignal; | |||
//下桶工位气缸状态 | |||
OtherHandCylinders.ElementAt(1).RightTog = GlobalDevice.PlcData.UnderCylinderDetection.HomeSignal; | |||
OtherHandCylinders.ElementAt(1).LeftTog = GlobalDevice.PlcData.UnderCylinderDetection.InPlaceSignal; | |||
SystemControlText = GlobalDevice.PlcData.SystemStartOrStop ? "停止" : "启动"; | |||
ModelSwitchText = GlobalDevice.PlcData.HandOrAuto ? "自动" : "手动"; | |||
Thread.Sleep(100); | |||
}), "手动气缸状态监控"); | |||
} | |||
private void Init() | |||
{ | |||
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0"); | |||
SystemControlText = res ? "停止" : "启动"; | |||
var res1 = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1"); | |||
ModelSwitchText = res1 ? "自动" : "手动"; | |||
} | |||
/// <summary> | |||
/// 升降气缸 | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> cylinderModels { get; set; } = new ObservableCollection<CylinderModel>(); | |||
/// <summary> | |||
/// 阻挡气缸 | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> BlockCylinders { get; set; } = new ObservableCollection<CylinderModel>(); | |||
/// <summary> | |||
/// 托盘气缸 | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> PalletCylinders { get; set; } = new ObservableCollection<CylinderModel>(); | |||
/// <summary> | |||
/// 其它手动控制气缸 | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> OtherHandCylinders { get; set; } = new ObservableCollection<CylinderModel>(); | |||
public BPARelayCommand<object> Open { get; set; } | |||
public BPARelayCommand<object> Close { get; set; } | |||
public BPARelayCommand SystemStart { get; set; } | |||
public BPARelayCommand ModelSwitch { get; set; } | |||
public string SystemControlText { get { return _mSystemControlText; } set { _mSystemControlText = value; OnPropertyChanged(); } } | |||
private string _mSystemControlText; | |||
public string ModelSwitchText { get { return _mModelSwitchText; } set { _mModelSwitchText = value; OnPropertyChanged(); } } | |||
private string _mModelSwitchText; | |||
} | |||
public class CylinderModel : NotifyBase | |||
{ | |||
public bool LeftTog { get { return _mLeftTog; } set { _mLeftTog = value; OnPropertyChanged(); } } | |||
private bool _mLeftTog; | |||
public bool RightTog { get { return _mRightTog; } set { _mRightTog = value; OnPropertyChanged(); } } | |||
private bool _mRightTog; | |||
public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } } | |||
private string _mName; | |||
public bool Control { get { return _mControl; } set { _mControl = value; OnPropertyChanged(); } } | |||
private bool _mControl; | |||
/// <summary> | |||
/// 气缸默认编号 | |||
/// </summary> | |||
public int Num { get; set; } | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPA.Helper; | |||
using BPASmartClient.Model; | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel; | |||
public class NewMaterialViewModel : ViewModelBase | |||
{ | |||
public ObservableCollection<RawMaterialModel> Materials { get; set; } = Json<LocaMaterial>.Data.LocalMaterails; | |||
public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } } | |||
private string _materialName = string.Empty; | |||
//public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||
//private string _mErrorInfo; | |||
//public BPARelayCommand<object> RemoveCommand { get; set; } | |||
//public BPARelayCommand SaveCommand { get; set; } | |||
private void Remove(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is string id) | |||
{ | |||
var res = Materials.FirstOrDefault(p => p.RawMaterialId == id); | |||
Materials.Remove(res); | |||
Json<LocaMaterial>.Save(); | |||
MessageNotify.GetInstance.ShowUserLog($"删除原料--{res.RawMaterialName}"); | |||
} | |||
} | |||
public NewMaterialViewModel() | |||
{ | |||
RemoveCommand = new BPARelayCommand<object>(Remove); | |||
SaveCommand = new BPARelayCommand(() => | |||
{ | |||
if (MaterialName == String.Empty) { ErrorInfo = "原料名称不能为空"; return; } | |||
if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == MaterialName) != null) { ErrorInfo = "设备中已存在该原料名称"; return; } | |||
if (Json<LocaMaterial>.Data.LocalMaterails.FirstOrDefault(p => p.RawMaterialName == MaterialName) != null) { ErrorInfo = "本地原料名称重复"; return; } | |||
Json<LocaMaterial>.Data.LocalMaterails.Add(new RawMaterialModel { RawMaterialName = MaterialName, RawMaterialId = Guid.NewGuid().ToString(), RawMaterialSource = 0 }); | |||
Json<LocaMaterial>.Save(); | |||
MessageNotify.GetInstance.ShowUserLog($"添加原料--{MaterialName}"); | |||
}); | |||
} | |||
} |
@@ -0,0 +1,119 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class NewOutletViewModel : ViewModelBase | |||
{ | |||
public NewOutletViewModel() | |||
{ | |||
DeviceInquire.GetInstance.devices.ToList()?.ForEach(item => { SileName.Add($"{item.DeviceName}"); }); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is OutletInfoModel tempOutletInfo) | |||
{ | |||
OutletName = tempOutletInfo.OutletName; | |||
OutletLoc = tempOutletInfo.OutletLoc; | |||
tempOutletInfo.SiloInfos?.ToList()?.ForEach((item => | |||
{ | |||
int tempIndex = Array.FindIndex(SileName.ToArray(), p => p == item); | |||
SiloInfos.Add(new RawMaterialInfo() { RawMaterialName = item, SelectIndex = tempIndex }); | |||
})); | |||
Index = Array.FindIndex(Json<DevicePar>.Data.OutletInfoModels.ToArray(), p => p.OutletName == tempOutletInfo.OutletName); | |||
} | |||
}), "OpenNewOutlet", true); | |||
AddCommand = new BPARelayCommand(() => { SiloInfos.Add(new RawMaterialInfo()); }); | |||
CancelCommand = new BPARelayCommand(() => { ActionManage.GetInstance.Send("NewOutletViewClose"); }); | |||
SaveCommand = new BPARelayCommand(() => | |||
{ | |||
ObservableCollection<string> SileNames = new ObservableCollection<string>(); | |||
SiloInfos.ToList()?.ForEach(item => { SileNames.Add(item.RawMaterialName); }); | |||
if (Index >= 0 && Index < Json<DevicePar>.Data.OutletInfoModels.Count) | |||
{ | |||
var array = Json<DevicePar>.Data.OutletInfoModels.ToArray(); | |||
var res = Array.FindIndex(array, p => p.OutletName == OutletName); | |||
if (res >= 0 && res != Index) | |||
{ | |||
ErrorInfo = "出料口名称已经存在!"; | |||
return; | |||
} | |||
var temp = Array.FindIndex(array, p => p.OutletLoc == OutletLoc); | |||
if (temp >= 0 && temp != Index) | |||
{ | |||
ErrorInfo = "出料口位置已存在!"; | |||
return; | |||
} | |||
Json<DevicePar>.Data.OutletInfoModels.ElementAt(Index).OutletName = OutletName; | |||
Json<DevicePar>.Data.OutletInfoModels.ElementAt(Index).OutletLoc = OutletLoc; | |||
Json<DevicePar>.Data.OutletInfoModels.ElementAt(Index).SiloInfos.Clear(); | |||
Json<DevicePar>.Data.OutletInfoModels.ElementAt(Index).SiloInfos = SileNames; | |||
//Control.GetInstance.OperationLog($"{OutletName} 编辑完成"); | |||
} | |||
else | |||
{ | |||
var res = Json<DevicePar>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == OutletName); | |||
if (res != null) | |||
{ | |||
ErrorInfo = "出料口名称已经存在!"; | |||
return; | |||
} | |||
var temp = Json<DevicePar>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletLoc == OutletLoc); | |||
if (temp != null) | |||
{ | |||
ErrorInfo = "出料口位置已存在!"; | |||
return; | |||
} | |||
Json<DevicePar>.Data.OutletInfoModels.Add(new OutletInfoModel() | |||
{ | |||
OutletLoc = OutletLoc, | |||
OutletName = OutletName, | |||
SiloInfos = SileNames | |||
}); | |||
//Control.GetInstance.OperationLog($"{OutletName} 添加成功"); | |||
} | |||
ActionManage.GetInstance.Send("NewOutletViewClose"); | |||
}); | |||
RemoveCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (!string.IsNullOrEmpty(o?.ToString())) | |||
{ | |||
var res = SiloInfos.FirstOrDefault(p => p.RawMaterialName == o.ToString()); | |||
if (res != null) SiloInfos.Remove(res); | |||
} | |||
}); | |||
} | |||
public string OutletName { get { return _mOutletName; } set { _mOutletName = value; OnPropertyChanged(); } } | |||
private string _mOutletName; | |||
public int OutletLoc { get { return _mOutletLoc; } set { _mOutletLoc = value; OnPropertyChanged(); } } | |||
private int _mOutletLoc; | |||
public ObservableCollection<RawMaterialInfo> SiloInfos { get; set; } = new ObservableCollection<RawMaterialInfo>(); | |||
public ObservableCollection<string> SileName { get; set; } = new ObservableCollection<string>(); | |||
} | |||
public class RawMaterialInfo : NotifyBase | |||
{ | |||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialName; | |||
public int SelectIndex { get { return _mSelectIndex; } set { _mSelectIndex = value; OnPropertyChanged(); } } | |||
private int _mSelectIndex; | |||
} | |||
} |
@@ -0,0 +1,210 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.UserControls; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class NewRecipeViewModel : ViewModelBase | |||
{ | |||
public NewRecipeViewModel() | |||
{ | |||
ActionManage.GetInstance.RegisterAsync(new Action<object>((o) => | |||
{ | |||
if (!string.IsNullOrEmpty(o?.ToString())) | |||
{ | |||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialName == o.ToString()) != null) | |||
{ | |||
App.Current.Dispatcher.Invoke(() => { MessageNotify.GetInstance.ShowDialog("当前原料和其它原料重复,请重新选择!", DialogType.Warning); }); | |||
} | |||
} | |||
}), "原料选择修改"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is RecipeModel rm) | |||
{ | |||
RecipeName = rm.RecipeName; | |||
foreach (var item in rm.RawMaterials) | |||
{ | |||
item.SelectIndex = Array.FindIndex(RawMaterialNames.ToArray(), p => p == item.RawMaterialName); | |||
RawMaterials.Add(item); | |||
} | |||
RecipCode = rm.RecipCode; | |||
Index = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipeName == RecipeName); | |||
} | |||
}), "Details", true); | |||
AddCommand = new BPARelayCommand(() => | |||
{ | |||
if (RawMaterials.Count >= DeviceInquire.GetInstance.devices.Count) | |||
{ | |||
MessageNotify.GetInstance.ShowDialog("原材料不足!"); | |||
return; | |||
} | |||
p: | |||
string guid = Guid.NewGuid().ToString(); | |||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialId == guid) == null) | |||
{ | |||
int index = RawMaterials.Count;//<= 0 ? 0 : RawMaterials.Count - 1; | |||
RawMaterials.Add(new RawMaterialModel() | |||
{ | |||
RawMaterialId = guid, | |||
SelectIndex = index | |||
}); | |||
} | |||
else goto p; | |||
}); | |||
RemoveCommand = new BPARelayCommand<object>((obj) => | |||
{ | |||
if (obj is string rm) | |||
{ | |||
var res = RawMaterials.FirstOrDefault(p => p.RawMaterialId == rm); | |||
if (res != null) RawMaterials.Remove(res); | |||
} | |||
}); | |||
SaveCommand = new BPARelayCommand(() => | |||
{ | |||
if (string.IsNullOrEmpty(RecipeName)) { MessageNotify.GetInstance.ShowDialog("请输入配方名称!", DialogType.Warning); ErrorInfo = "请输入配方名称"; return; } | |||
var tempRes = RawMaterials.GroupBy(p => p.RawMaterialName); | |||
if (tempRes.Count() != RawMaterials.Count) | |||
{ | |||
MessageNotify.GetInstance.ShowDialog("单前原料和其它原料重复,请重新选择!", DialogType.Warning); | |||
return; | |||
} | |||
//编辑配方 | |||
if (Index >= 0 && Index < Json<LocaPar>.Data.Recipes.Count) | |||
{ | |||
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipeName == RecipeName); | |||
if (res >= 0 && res != Index) | |||
{ | |||
ErrorInfo = "配方名称已经存在!"; | |||
MessageNotify.GetInstance.ShowDialog("配方名称已经存在!", DialogType.Warning); | |||
return; | |||
} | |||
Json<LocaPar>.Data.Recipes.ElementAt(Index).RecipeName = RecipeName; | |||
Json<LocaPar>.Data.Recipes.ElementAt(Index).RawMaterials.Clear(); | |||
RawMaterials.ToList()?.ForEach(item => | |||
{ | |||
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == item.RawMaterialName); | |||
if (res != null) | |||
{ | |||
item.DeviceIp = res.IpAddress; | |||
item.RawMaterialSource = 1; | |||
} | |||
else | |||
{ | |||
item.RawMaterialSource = 0; | |||
} | |||
Json<LocaPar>.Data.Recipes.ElementAt(Index).RawMaterials.Add(item); | |||
}); | |||
Json<LocaPar>.Save(); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{RecipeName} 配方编辑完成"); | |||
} | |||
else //新建配方 | |||
{ | |||
if (Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName) != null) | |||
{ | |||
ErrorInfo = "配方名称已存在!"; | |||
MessageNotify.GetInstance.ShowDialog("配方名称已经存在!", DialogType.Warning); | |||
return; | |||
} | |||
ObservableCollection<RawMaterialModel> TempRawMaterials = new ObservableCollection<RawMaterialModel>(); | |||
RawMaterials.ToList()?.ForEach(item => | |||
{ | |||
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == item.RawMaterialName); | |||
if (res != null) | |||
{ | |||
item.DeviceIp = res.IpAddress; | |||
item.RawMaterialSource = 1; | |||
} | |||
else | |||
{ | |||
item.RawMaterialSource = 0; | |||
} | |||
TempRawMaterials.Add(item); | |||
}); | |||
Json<LocaPar>.Data.Recipes.Add(new RecipeModel() | |||
{ | |||
RecipeName = RecipeName, | |||
RawMaterials = TempRawMaterials, | |||
}); | |||
Json<LocaPar>.Save(); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"新建配方成功!"); | |||
} | |||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | |||
}); | |||
if (Global.userInfo.permission == CustomResource.Pages.Enums.Permission.管理员) | |||
{ | |||
foreach (var item in Global.DeviceRawMaterials) | |||
{ | |||
RawMaterialNames.Add(item.RawMaterialName); | |||
} | |||
foreach (var item in Json<LocaMaterial>.Data.LocalMaterails) | |||
{ | |||
RawMaterialNames.Add(item.RawMaterialName); | |||
} | |||
} | |||
else | |||
{ | |||
foreach (var item in Global.DeviceRawMaterials) | |||
{ | |||
if (Global.userInfo.devRawMaterials.FirstOrDefault(p => p.RawMaterialName == item.RawMaterialName) != null) RawMaterialNames.Add(item.RawMaterialName); | |||
} | |||
foreach (var item in Json<LocaMaterial>.Data.LocalMaterails) | |||
{ | |||
if (Global.userInfo.locaRawMaterials.FirstOrDefault(p => p.RawMaterialName == item.RawMaterialName) != null) RawMaterialNames.Add(item.RawMaterialName); | |||
} | |||
} | |||
} | |||
private void AddRecipes() | |||
{ | |||
string date = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); | |||
var dates = date.Split("-").ToList(); | |||
StringBuilder sb = new StringBuilder(); | |||
dates?.ForEach((item) => { sb.Append(item); }); | |||
Json<LocaPar>.Data.Recipes.Add(new RecipeModel() | |||
{ | |||
SerialNum = Json<LocaPar>.Data.Recipes.Count + 1, | |||
RawMaterials = RawMaterials, | |||
RecipCode = sb.ToString(), | |||
RecipeName = RecipeName, | |||
}); | |||
} | |||
private string RecipCode = string.Empty; | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName = string.Empty; | |||
//public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||
//private string _mErrorInfo; | |||
//public BPARelayCommand AddCommand { get; set; } | |||
//public BPARelayCommand<object> RemoveCommand { get; set; } | |||
//public BPARelayCommand SaveCommand { get; set; } | |||
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>(); | |||
public ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>(); | |||
} | |||
} |
@@ -0,0 +1,56 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPASmartClient.DosingSystemSingle.View; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class OutletManagementViewModel : ViewModelBase | |||
{ | |||
public OutletManagementViewModel() | |||
{ | |||
AddCommand = new BPARelayCommand(() => | |||
{ | |||
NewOutletView newOutletView = new NewOutletView(); | |||
newOutletView.ShowDialog(); | |||
}); | |||
SaveCommand = new BPARelayCommand(() => { Json<DevicePar>.Save(); }); | |||
OutletInfoModels = Json<DevicePar>.Data.OutletInfoModels; | |||
RemoveCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (!string.IsNullOrEmpty(o?.ToString())) | |||
{ | |||
var res = Json<DevicePar>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString()); | |||
if (res != null) | |||
{ | |||
Json<DevicePar>.Data.OutletInfoModels.Remove(res); | |||
//Control.GetInstance.OperationLog($"{res.OutletName} 删除成功"); | |||
} | |||
} | |||
}); | |||
DetailsCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (!string.IsNullOrEmpty(o?.ToString())) | |||
{ | |||
var res = Json<DevicePar>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString()); | |||
if (res != null) | |||
{ | |||
NewOutletView newOutletView = new NewOutletView(); | |||
ActionManage.GetInstance.Send("OpenNewOutlet", res); | |||
newOutletView.ShowDialog(); | |||
} | |||
} | |||
}); | |||
} | |||
public ObservableCollection<OutletInfoModel> OutletInfoModels { get; set; } | |||
} | |||
} |
@@ -0,0 +1,301 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using System.Threading; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.Model.柔性味魔方; | |||
using BPASmartClient.Model; | |||
using System.Diagnostics; | |||
using Microsoft.EntityFrameworkCore.Metadata.Internal; | |||
using System.Data.SqlClient; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class RecipeControlViewModel : NotifyBase | |||
{ | |||
static ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>(); | |||
static ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>(); | |||
static ObservableCollection<string> RawMaterialReset = new ObservableCollection<string>(); | |||
public RecipeControlViewModel() | |||
{ | |||
StartCommand = new BPARelayCommand<object>(RecipeIssued); | |||
ChangeRecipeStateCommand = new BPARelayCommand<object>(ChangeRecipeState); | |||
CancelRecipeCommand = new BPARelayCommand<object>(CancelRecipe); | |||
RecipeRun(); | |||
RecipeStatusInquire(); | |||
} | |||
private async void CancelRecipe(object o) | |||
{ | |||
if (o != null && o is RecipeModel recipe) | |||
{ | |||
var res = MessageNotify.GetInstance.ShowDialog($"是否取消配方 【{recipe.RecipeName}】制作", DialogType.Warning); | |||
if (res) | |||
{ | |||
int index = Recipes.ToList().FindIndex(p => p.RecipeName == recipe.RecipeName); | |||
if (index >= 0 && index < Recipes.Count) | |||
{ | |||
await Task.Factory.StartNew(new Action(() => | |||
{ | |||
Recipes.ElementAt(index).IsEnable = true; | |||
Json<LocaPar>.Data.Recipes.ElementAt(index).IsEnable = true; | |||
Recipes.ElementAt(index).Are.Set(); | |||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方 [{recipe.RecipeName}] 取消成功"); | |||
})); | |||
} | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 配方下发 | |||
/// </summary> | |||
private void RecipeIssued(object o) | |||
{ | |||
if (o != null && o is string deviceName) | |||
{ | |||
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == deviceName); | |||
if (index >= 0 && index < Recipes.Count) | |||
{ | |||
for (int i = 0; i < Recipes.ElementAt(index).RawMaterials.Count; i++) | |||
{ | |||
if (Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialSource == 1) | |||
{ | |||
string ip = Recipes.ElementAt(index).RawMaterials.ElementAt(i).DeviceIp; | |||
var device = DeviceInquire.GetInstance.GetDevice(ip); | |||
if (!device.IsConnected) | |||
{ | |||
MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error); | |||
return; | |||
} | |||
} | |||
} | |||
Recipes.ElementAt(index).IsEnable = false; | |||
Json<LocaPar>.Data.Recipes.ElementAt(index).IsEnable = false; | |||
} | |||
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}"); | |||
RecipeNames.Enqueue(deviceName); | |||
var t = RecipeNames.GetHashCode(); | |||
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName); | |||
UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); | |||
} | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); | |||
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); | |||
} | |||
/// <summary> | |||
/// 配方业务执行 | |||
/// </summary> | |||
private void RecipeRun() | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
if (RecipeNames.Count > 0) | |||
{ | |||
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0)); | |||
if (index >= 0 && index < Recipes.Count) | |||
{ | |||
Recipes.ElementAt(index).Are.Reset(); | |||
Recipes.ElementAt(index).IsEnable = false; | |||
StockStatus.Clear(); | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
recipeProcesses.Clear(); | |||
if (UserTreeWait.Count > 0) UserTreeWait.RemoveAt(0); | |||
})); | |||
CurrentRecipeName = Recipes.ElementAt(index).RecipeName; | |||
var recipe = Recipes.ElementAt(index); | |||
ObservableCollection<RawMaterialModel> RawMater = new ObservableCollection<RawMaterialModel>(); | |||
foreach (var item in recipe.RawMaterials) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量 | |||
RawMater.Add(new RawMaterialModel() | |||
{ | |||
RawMaterialName = item.RawMaterialName, | |||
DeviceIp = item.DeviceIp, | |||
DownLimtFeedback = item.DownLimtFeedback, | |||
Loc = item.Loc, | |||
RawMaterialId = item.RawMaterialId, | |||
RawMaterialSource = item.RawMaterialSource, | |||
RawMaterialType = item.RawMaterialType, | |||
RawMaterialWeight = item.RawMaterialWeight, | |||
RecipeStatus = item.RecipeStatus, | |||
SelectIndex = item.SelectIndex, | |||
Status = item.Status, | |||
UpLimtFeedback = item.UpLimtFeedback, | |||
UpLimtWeightFeedback = item.UpLimtWeightFeedback, | |||
WeightFeedback = item.WeightFeedback, | |||
}); | |||
} | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
recipeProcesses.Add(new RecipeModel() | |||
{ | |||
RawMaterials = RawMater, | |||
IsEnable = recipe.IsEnable, | |||
RecipeName = recipe.RecipeName, | |||
SerialNum = recipe.SerialNum, | |||
RecipCode = recipe.RecipCode, | |||
}); | |||
}); | |||
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 | |||
RecipeNames.TryDequeue(out string deviceName); | |||
var recipeComple = Recipes.ElementAt(index); | |||
ObservableCollection<RawMaterialModel> RawMaterComple = new ObservableCollection<RawMaterialModel>(); | |||
foreach (var item in recipeComple.RawMaterials) | |||
{ | |||
RawMaterComple.Add(new RawMaterialModel() | |||
{ | |||
RawMaterialName = item.RawMaterialName, | |||
DeviceIp = item.DeviceIp, | |||
DownLimtFeedback = item.DownLimtFeedback, | |||
Loc = item.Loc, | |||
RawMaterialId = item.RawMaterialId, | |||
RawMaterialSource = item.RawMaterialSource, | |||
RawMaterialType = item.RawMaterialType, | |||
RawMaterialWeight = item.RawMaterialWeight, | |||
RecipeStatus = item.RecipeStatus, | |||
SelectIndex = item.SelectIndex, | |||
Status = item.Status, | |||
UpLimtFeedback = item.UpLimtFeedback, | |||
UpLimtWeightFeedback = item.UpLimtWeightFeedback, | |||
WeightFeedback = item.WeightFeedback, | |||
}); | |||
} | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
UserTreeCompelete.Add(new RecipeModel() | |||
{ | |||
RawMaterials = RawMaterComple, | |||
IsEnable = recipeComple.IsEnable, | |||
RecipeName = recipeComple.RecipeName, | |||
SerialNum = UserTreeCompelete.Count + 1, | |||
RecipCode = recipeComple.RecipCode, | |||
RecipStatus = "制作完成" | |||
}); | |||
}); | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
recipeProcesses.Clear(); | |||
CurrentRecipeName = string.Empty; | |||
}));//完成后清空当前配方 | |||
} | |||
} | |||
Thread.Sleep(1000); | |||
}), "启动配方下发"); | |||
} | |||
/// <summary> | |||
/// 配方执行状态监听 | |||
/// </summary> | |||
private void RecipeStatusInquire() | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
for (int i = 0; i < Recipes.Count; i++) | |||
{ | |||
for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++) | |||
{ | |||
var RunStatus = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus; | |||
//设备状态显示 | |||
if (Recipes.ElementAt(i).RecipeName == CurrentRecipeName) | |||
{ | |||
string tempRawMaterialName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName; | |||
int recIndex = recipeProcesses.ToList().FindIndex(p => p.RecipeName == CurrentRecipeName); | |||
if (recIndex >= 0 && recIndex < recipeProcesses.Count) | |||
{ | |||
int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName); | |||
if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count) | |||
{ | |||
//测试使用 | |||
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; | |||
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus == 3) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(index).DeviceIp).StatusReset(); | |||
if (!RawMaterialReset.Contains(Recipes.ElementAt(i).RawMaterials.ElementAt(index).RawMaterialName)) | |||
{ | |||
RawMaterialReset.Add(Recipes.ElementAt(i).RawMaterials.ElementAt(index).RawMaterialName); | |||
} | |||
} | |||
if (RawMaterialReset.Count >= recipeProcesses.ElementAt(recIndex).RawMaterials.Count) | |||
{ | |||
RawMaterialReset.Clear(); | |||
int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); | |||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||
Recipes.ElementAt(recipIndex).IsEnable = true; | |||
Json<LocaPar>.Data.Recipes.ElementAt(recipIndex).IsEnable = true; | |||
Recipes.ElementAt(recipIndex).Are.Set(); | |||
Thread.Sleep(100); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
Thread.Sleep(100); | |||
}), "RecipeControlViewModelStatusInquire"); | |||
} | |||
public BPARelayCommand<object> StartCommand { get; set; } | |||
public BPARelayCommand<object> ChangeRecipeStateCommand { get; set; } | |||
public BPARelayCommand<object> CancelRecipeCommand { get; set; } | |||
public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes; | |||
public static string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnStaticPropertyChanged(); } } | |||
private static string _RecipeName; | |||
/// <summary> | |||
/// 当前正在制作的配方 | |||
/// </summary> | |||
public static ObservableCollection<RecipeModel> recipeProcesses { get; set; } = new ObservableCollection<RecipeModel>(); | |||
/// <summary> | |||
/// 等待制作的配方 | |||
/// </summary> | |||
public static ObservableCollection<RecipeModel> UserTreeWait { get; set; } = new ObservableCollection<RecipeModel>(); | |||
/// <summary> | |||
/// 已完成的配方 | |||
/// </summary> | |||
public static ObservableCollection<RecipeModel> UserTreeCompelete { get; set; } = new ObservableCollection<RecipeModel>(); | |||
private void ChangeRecipeState(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is string id) | |||
{ | |||
var Recipe = recipeProcesses.FirstOrDefault(p => p.RecipeName == CurrentRecipeName); | |||
if (Recipe != null) | |||
{ | |||
var res = Recipe.RawMaterials.FirstOrDefault(p => p.RawMaterialId == id); | |||
if (res != null) | |||
{ | |||
if (res.RecipeStatus == 3) | |||
{ | |||
res.RecipeStatus = 1; | |||
} | |||
else | |||
{ | |||
res.RecipeStatus = 3; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,99 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPA.Helper; | |||
using BPASmartClient.DosingSystemSingle.View; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.Model; | |||
using BPASmartClient.CustomResource.UserControls.Enum; | |||
using System.Windows.Media; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.Model; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class RecipeSettingsViewModel : NotifyBase | |||
{ | |||
public RecipeSettingsViewModel() | |||
{ | |||
Recipes = Json<LocaPar>.Data.Recipes; | |||
NewMaterital = new BPARelayCommand(() => | |||
{ | |||
NewMaterialView newMateritalView = new NewMaterialView(); | |||
newMateritalView.ShowDialog(); | |||
}); | |||
NewRecipe = new BPARelayCommand(() => | |||
{ | |||
NewRecipeView nrv = new NewRecipeView(); | |||
nrv.ShowDialog(); | |||
MessageNotify.GetInstance.ShowUserLog("新建配方"); | |||
}); | |||
SaveRecipe = new BPARelayCommand(() => | |||
{ | |||
Json<LocaPar>.Save(); | |||
MessageNotify.GetInstance.ShowUserLog("保存配方"); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!"); | |||
}); | |||
RemoveCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (!string.IsNullOrEmpty(o?.ToString())) | |||
{ | |||
if (MessageNotify.GetInstance.ShowDialog($"是否删除【{o.ToString()}】配方,删除后数据将永久丢失!无法找回", DialogType.Warning)) | |||
{ | |||
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString()); | |||
if (res.IsEnable) | |||
{ | |||
if (res != null) Json<LocaPar>.Data.Recipes.Remove(res); | |||
Json<LocaPar>.Save(); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方删除成功!"); | |||
MessageNotify.GetInstance.ShowUserLog($"删除配方 {res.RecipeName}"); | |||
} | |||
else | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"删除【{o.ToString()}】配方失败,配方正在使用!"); | |||
} | |||
} | |||
} | |||
}); | |||
DetailsCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (!string.IsNullOrEmpty(o?.ToString())) | |||
{ | |||
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString()); | |||
if (res != null) | |||
{ | |||
NewRecipeView nrv = new NewRecipeView(); | |||
ActionManage.GetInstance.Send("Details", res); | |||
nrv.ShowDialog(); | |||
} | |||
//MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}"); | |||
} | |||
}); | |||
} | |||
public BPARelayCommand NewMaterital { get; set; } | |||
public BPARelayCommand NewRecipe { get; set; } | |||
public BPARelayCommand SaveRecipe { get; set; } | |||
public BPARelayCommand<object> EditCommand { get; set; } | |||
public BPARelayCommand<object> DetailsCommand { get; set; } | |||
public BPARelayCommand<object> RemoveCommand { get; set; } | |||
public ObservableCollection<RecipeModel> Recipes { get; set; } | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
| |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystemSingle.ViewModel | |||
{ | |||
public class StockControViewModel : NotifyBase | |||
{ | |||
public StockControViewModel() | |||
{ | |||
//Task.Factory.StartNew(() => | |||
//{ | |||
// App.Current.Dispatcher.Invoke(() => | |||
// { | |||
// for (int i = 0; i < 6; i++) | |||
// { | |||
// statusTop.Add(new StockStatusModel { IsFault = false, IsLayOff = true, IsRunning = true, MaterialName = $"{i + 1}号料仓", MaterialWeight = 85 + i }); | |||
// } | |||
// for (int i = 6; i < 12; i++) | |||
// { | |||
// statusDown.Add(new StockStatusModel { IsFault = false, IsLayOff = true, IsRunning = true, MaterialName = $"{i + 1}号料仓", MaterialWeight = 85 + i }); | |||
// } | |||
// }); | |||
//}); | |||
statusTop = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; | |||
statusDown = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; | |||
} | |||
public bool ConveyerBeltWork { get { return _mConveyerBeltWork; } set { _mConveyerBeltWork = value; OnPropertyChanged(); } } | |||
private bool _mConveyerBeltWork; | |||
public ObservableCollection<DeviceCurrentStatus> statusTop { get; set; } | |||
public ObservableCollection<DeviceCurrentStatus> statusDown { get; set; } | |||
} | |||
} |
@@ -7,6 +7,14 @@ | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<None Remove="hbl.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="hbl.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Communication" Version="1.0.36" /> | |||
</ItemGroup> | |||
@@ -17,6 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
/// </summary> | |||
public static bool HeartBeatFromPlc { get; set; } | |||
public static DateTime DosingTime { get; set; } | |||
/// <summary> | |||
/// plc心跳下发 | |||
/// </summary> | |||
@@ -56,5 +57,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
public static ushort TrayCylinder { get; set; } | |||
public static DB_Read HKPlc_Read = new DB_Read(); | |||
public static bool IsUseLocalName { get; set; } = true; | |||
} | |||
} |
@@ -29,7 +29,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC | |||
{ | |||
var res1 = HK_PLC_S7.ReadClass<DB_Read>(98); | |||
var res2 = HK_PLC_S7.ReadClass<StockBinName>(97); | |||
if (res1 != null && res1 is DB_Read data1) | |||
{ | |||
PlcRead = data1; | |||
@@ -46,7 +45,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC | |||
} | |||
} | |||
Thread.Sleep(10); | |||
}),"信号收发处理"); | |||
}),"信号收发处理",true); | |||
} | |||
/// <summary> | |||
/// 下发配方数据 | |||
@@ -12,6 +12,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
private int _mIp; | |||
public int DeviceIp { get { return _mIp; } set { _mIp = value; }} | |||
public short RawMaterialCount { get { return _mRawMaterialCount; } set { _mRawMaterialCount = value; OnPropertyChanged(); } } | |||
private short _mRawMaterialCount; | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
@@ -29,7 +29,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||
//var res3 = this.Siemens_PLC_S7.ReadClass<DL_DataColl_DB>(2391); | |||
if (res != null && res is DL_Start_DB start) | |||
{ | |||
if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request) && GVL_BigStation.SiemensSendRecipeStatus == 0) | |||
if (GVL_BigStation.Order_Request && GVL_BigStation.SiemensSendRecipeStatus == 0) | |||
{ | |||
GVL_BigStation.SiemensSendRecipeStatus = 1; | |||
this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true); | |||
@@ -8,7 +8,7 @@ | |||
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel" | |||
Title="RecipeInfosView" | |||
Width="800" | |||
Height="550" | |||
Height="620" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
@@ -290,29 +290,32 @@ | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,4,0,0"> | |||
<Button Content="添加原料" Width="180" Margin="0,0,10,0" Height="30" Background="Transparent" BorderBrush="#FF2AB2E7" Foreground="#FF2AB2E7" Cursor="Hand" Command="{Binding AddRecipe}" ></Button> | |||
<Button Content="确认更新" Height="30" Width="180" Background="Transparent" BorderBrush="#FF2AB2E7" Foreground="#FF2AB2E7" Command="{Binding Comfirm}"></Button> | |||
<Button Content="清除原料" Height="30" Width="180" Margin="0,0,10,0" Command="{Binding ClearRawMaterial}" Cursor="Hand"/> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Grid.Row="1" Margin="0,4,0,0" HorizontalAlignment="Center"> | |||
<Button Content="另存为" Height="30" Width="180" Margin="0,0,10,0" Command="{Binding SaveAs}" Cursor="Hand"/> | |||
<Button Click="Button_Click" Content="取消" Height="30" FontSize="20" Background="Transparent" BorderBrush="#FF2AB2E7" Foreground="#FF2AB2E7" Width="180" Cursor="Hand"></Button> | |||
<Button Content="确认" Margin="0,0,10,0" Height="30" Width="180" Background="Transparent" BorderBrush="#FF2AB2E7" Foreground="#FF2AB2E7" Command="{Binding Comfirm}"></Button> | |||
<Button Click="Button_Click" Content="取消" Margin="0,0,10,0" Height="30" FontSize="20" Background="Transparent" BorderBrush="#FF2AB2E7" Foreground="#FF2AB2E7" Width="180" Cursor="Hand"></Button> | |||
</StackPanel> | |||
</Grid> | |||
</UniformGrid> | |||
<Grid Grid.Row="2" Background="#FF2AB2E7" Margin="0,0,0,10"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="210"/> | |||
<ColumnDefinition Width="225"/> | |||
<ColumnDefinition Width="225"/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition Width="120"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock 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="原料重量" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"></TextBlock> | |||
<TextBlock Grid.Column="2" Text="托盘桶号" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/> | |||
<GridSplitter Grid.Column="2"></GridSplitter> | |||
<TextBlock Grid.Column="3" Text="操作" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/> | |||
<TextBlock Grid.Column="3" Text="原料重量" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"></TextBlock> | |||
<GridSplitter Grid.Column="3"></GridSplitter> | |||
<TextBlock Grid.Column="4" Text="操作" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/> | |||
</Grid> | |||
<ScrollViewer Grid.Row="3" VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding RawMaterialsInfo}"> | |||
@@ -328,11 +331,11 @@ | |||
<ControlTemplate> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="210"/> | |||
<ColumnDefinition Width="210"></ColumnDefinition> | |||
<ColumnDefinition Width="225"></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"> | |||
<ComboBox.ItemContainerStyle> | |||
@@ -344,27 +347,45 @@ | |||
</Style> | |||
</ComboBox.ItemContainerStyle>--> | |||
<!--</ComboBox>--> | |||
<TextBox Text="{Binding RawMaterialName}" Background="Transparent" FontSize="14" | |||
BorderBrush="#e69519" Foreground="LightGray" Width="190" Margin="10,0,0,10" ></TextBox> | |||
<StackPanel Grid.Column="1" Orientation="Horizontal" > | |||
<ComboBox | |||
Margin="3" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF074B92" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="14" | |||
Foreground="LightGray" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="{Binding RawMaterialCount}" | |||
MouseLeave="ComboBox_MouseLeave" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding RawMaterialName}"/> | |||
<StackPanel | |||
VerticalAlignment="Center" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center" > | |||
<TextBlock Grid.Column="1" Text="{Binding RawMaterialLocation}" 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"> | |||
<TextBox Text="{Binding RawMaterialBarrelNum}" Background="Transparent" FontSize="14" | |||
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox> | |||
BorderBrush="#e69519" Foreground="LightGray" Width="120" ></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Grid.Column="2"> | |||
<StackPanel | |||
Margin="3" Orientation="Horizontal" Grid.Column="3" HorizontalAlignment="Center"> | |||
<TextBox Text="{Binding RawMaterialWeight}" Background="Transparent" FontSize="14" | |||
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox> | |||
<TextBlock VerticalAlignment="Center" Margin="4,0,0,10" Text="Kg" Foreground="#e69519" ></TextBlock> | |||
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="3" | |||
<Button Grid.Column="4" | |||
Content="删除" | |||
Width="94" | |||
FontSize="14" | |||
Margin="0,0,20,10" | |||
Background="Transparent" | |||
BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Right" | |||
BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Center" | |||
Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" | |||
CommandParameter="{Binding RawMaterialName}"></Button> | |||
CommandParameter="{Binding RawMaterialCount}"></Button> | |||
</Grid> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
@@ -33,14 +33,9 @@ namespace BPASmartClient.JXJFoodBigStation.View | |||
this.Close(); | |||
} | |||
private void ComboBox_KeyUp(object sender, KeyEventArgs e) | |||
private void ComboBox_MouseLeave(object sender, MouseEventArgs e) | |||
{ | |||
} | |||
private void ComboBox_LostFocus(object sender, RoutedEventArgs e) | |||
{ | |||
ActionManage.GetInstance.Send("RawMaterialNames"); | |||
} | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
using BPA.Helper; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.JXJFoodBigStation.Model; | |||
using BPASmartClient.JXJFoodBigStation.Model.HK_PLC; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
@@ -18,6 +18,10 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
{ | |||
public RecipeInfosViewModel() | |||
{ | |||
foreach (var item in ProcessControl.GetInstance.RawMaterialsInfo) | |||
{ | |||
RawMaterialNames.Add(item.RawMaterialName); | |||
} | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is RecipeData rm) | |||
@@ -25,16 +29,26 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
RecipeName = rm.RecipeName; | |||
RecipeCode = rm.RecipeCode; | |||
TrayCode = rm.TrayCode; | |||
//RawMaterialsInfo = rm.RawMaterial; | |||
//var rest = RawMaterialsInfo.GetHashCode(); | |||
foreach (var item in rm.RawMaterial) | |||
{ | |||
item.RawMaterialCount = (short)Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == item.RawMaterialName); | |||
RawMaterialsInfo.Add(item); | |||
} | |||
} | |||
}), "RecipeInfo"); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
foreach (var item in RawMaterialsInfo) | |||
{ | |||
if (RawMaterialNames.Contains(item.RawMaterialName)) | |||
{ | |||
int index = Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == item.RawMaterialName); | |||
item.RawMaterialLocation = ProcessControl.GetInstance.RawMaterialsInfo.ElementAt(index).RawMaterialLocation; | |||
} | |||
} | |||
}), "RawMaterialNames",true); | |||
AddRecipe = new RelayCommand(() => { | |||
RawMaterialsInfo.Add(new RawMaterial()); | |||
}); | |||
@@ -79,40 +93,16 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
} | |||
}); | |||
SaveAs = new RelayCommand(() => { | |||
var bom = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName); | |||
var rec = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == RecipeCode); | |||
if (bom == null && rec != null)//配方名称更改 | |||
{ | |||
prop: string recipeCode = new Random().Next(10000, 99999).ToString();//配方唯一ID,后期根据实际要求更改 | |||
var res = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode); | |||
if (res == null) | |||
{ | |||
Json<LocalRecipe>.Data.Recipes.Add(new RecipeData { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode });//配方添加 | |||
Json<LocalRecipe>.Save(); | |||
} | |||
else | |||
{ | |||
goto prop; | |||
} | |||
ActionManage.GetInstance.Send("CloseRecipeInfosView"); | |||
} | |||
else | |||
{ | |||
MessageBox.Show("另存配方失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); | |||
} | |||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | |||
ClearRawMaterial = new RelayCommand(() => { | |||
RawMaterialsInfo.Clear(); | |||
}); | |||
RemoveRecipe = new RelayCommand<string>((materilaName) => { | |||
var res = RawMaterialsInfo.FirstOrDefault(p => p.RawMaterialName == materilaName); | |||
RemoveRecipe = new RelayCommand<short>((index) => { | |||
var res = RawMaterialsInfo.FirstOrDefault(p => p.RawMaterialCount == index); | |||
if (res != null) | |||
RawMaterialsInfo.Remove(res); | |||
}); | |||
} | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName; | |||
@@ -122,16 +112,22 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } | |||
private int _mTrayCode; | |||
public int SelectIndex { get { return _mSelectIndex; } set { _mSelectIndex = value; OnPropertyChanged(); } } | |||
private int _mSelectIndex; | |||
public RelayCommand ReturnPage { get; set; } | |||
public RelayCommand AddRecipe { get; set; } | |||
public RelayCommand Comfirm { get; set; } | |||
public RelayCommand SaveAs { get; set; } | |||
public RelayCommand ClearRawMaterial { get; set; } | |||
public RelayCommand<string> RemoveRecipe { get; set; } | |||
public RelayCommand<short> RemoveRecipe { get; set; } | |||
public ObservableCollection<RawMaterial> RawMaterialsInfo { get; set; } = new ObservableCollection<RawMaterial>() ; | |||
public ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>(); | |||
} | |||
} |
@@ -44,18 +44,11 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName); | |||
if (res != null) | |||
{ | |||
//Json<LocalRecipe>.Data.Recipes.Add(res); | |||
//for (int i = 0; i < Json<LocalRecipe>.Data.Recipes.Count; i++) | |||
//{ | |||
// foreach (var item in Json<LocalRecipe>.Data.Recipes.ElementAt(i).RawMaterial) | |||
// { | |||
// item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName); | |||
// } | |||
//} | |||
if (!ProcessControl.GetInstance.LocalRecipes.Contains(res)) | |||
{ | |||
ProcessControl.GetInstance.LocalRecipes.Add(res); | |||
MessageNotify.GetInstance.ShowAlarmLog($"手动下发配方:{recipeName}完成"); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"配方下发完成"); | |||
} | |||
} | |||
} | |||
@@ -12,24 +12,8 @@ using System.Threading.Tasks; | |||
namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
{ | |||
internal class SiemensRecipeSendDownViewModel : ObservableObject | |||
public class SiemensRecipeSendDownViewModel : ObservableObject | |||
{ | |||
//Json<RemoteRecipe>.Data.Recipes | |||
public static ObservableCollection<RawMaterial> a = new ObservableCollection<RawMaterial>() | |||
{ | |||
new RawMaterial() { RawMaterialName= "1",RawMaterialWeight=101, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "2",RawMaterialWeight=102, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "3",RawMaterialWeight=103, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "4",RawMaterialWeight=104, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "5",RawMaterialWeight=105, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "6",RawMaterialWeight=106, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "7",RawMaterialWeight=107, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "8",RawMaterialWeight=108, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "9",RawMaterialWeight=109, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "10",RawMaterialWeight=110, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "11",RawMaterialWeight=111, RawMaterialBarrelNum=1 }, | |||
new RawMaterial() { RawMaterialName= "12",RawMaterialWeight=112, RawMaterialBarrelNum=1 } | |||
}; | |||
public ObservableCollection<RecipeData> Recipes { get; set; } = Json<RemoteRecipe>.Data.Recipes; | |||
public SiemensRecipeSendDownViewModel() | |||
{ | |||
@@ -4,6 +4,6 @@ | |||
<add key="RawMaterial_IP" value="107.107.2."/> | |||
<add key="HKPlc_IP" value="107.107.2.88"/> | |||
<add key="Siemens_IP" value="107.107.2.200"/> | |||
<add key="WindSend_IP" value="107.107.2.90"/> | |||
<add key="WindSend_IP" value="107.107.2.210"/> | |||
</appSettings> | |||
</configuration> |
@@ -5,8 +5,14 @@ | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
<ApplicationIcon>hbl.ico</ApplicationIcon> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Content Include="hbl.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.84" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
@@ -74,9 +74,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
{ | |||
if (TrayNum == 1) | |||
{ | |||
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15) | |||
if (BarrelNum >= 6 && BarrelNum <= 8 && StockBinLocation >= 1 && StockBinLocation <= 15) | |||
{ | |||
if (BarrelNum == 1) | |||
if (BarrelNum == 6) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
@@ -88,7 +88,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
} | |||
MessageNotify.GetInstance.ShowRunLog($"托盘1—1号桶在料仓{StockBinLocation}配料"); | |||
} | |||
else if (BarrelNum == 2) | |||
else if (BarrelNum == 7) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
@@ -100,7 +100,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
} | |||
MessageNotify.GetInstance.ShowRunLog($"托盘1—2号桶在料仓{StockBinLocation}配料"); | |||
} | |||
else if (BarrelNum == 3) | |||
else if (BarrelNum == 8) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
@@ -130,7 +130,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
{ | |||
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15) | |||
{ | |||
if (BarrelNum == 1) | |||
if (BarrelNum == 6) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
@@ -142,7 +142,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
} | |||
MessageNotify.GetInstance.ShowRunLog($"托盘2—1号桶在料仓{StockBinLocation}配料"); | |||
} | |||
else if (BarrelNum == 2) | |||
else if (BarrelNum == 7) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
@@ -154,7 +154,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
} | |||
MessageNotify.GetInstance.ShowRunLog($"托盘2—2号桶在料仓{StockBinLocation}配料"); | |||
} | |||
else if (BarrelNum == 3) | |||
else if (BarrelNum == 8) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
@@ -146,6 +146,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
for (int i = 0; i < recipe.WindSend.Count; i++) | |||
{ | |||
RecipeFinishInfo.Powder[i] = new UDT2(); | |||
RecipeFinishInfo.Powder[i].Powder_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName; | |||
RecipeFinishInfo.Powder[i].Powder_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight; | |||
} | |||
if (GVL_SmallStation.SiemensSendRecipeStatus == 6) | |||
{ | |||
@@ -170,8 +172,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
try | |||
{ | |||
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); | |||
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); | |||
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); | |||
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); | |||
WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); | |||
if (HKDevice.IsConnected) | |||
{ | |||
@@ -194,7 +196,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
/*if (!HKDevice.IsConnected) | |||
if (!HKDevice.IsConnected) | |||
{ | |||
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); | |||
MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接"); | |||
@@ -205,7 +207,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); | |||
MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接"); | |||
if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功"); | |||
}*/ | |||
} | |||
if (!WindSendDevice.IsConnected) | |||
{ | |||
WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); | |||
@@ -228,11 +230,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.2", true); | |||
}), "SystemPause", true); | |||
ActionManage.GetInstance.CancelRegister("SystemReset"); | |||
ActionManage.GetInstance.CancelRegister("ManualSystemReset"); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.2", false); | |||
}), "SystemReset", true); | |||
//DeviceInquire.GetInstance.GetDevice((int)8)?.Start((float)100.1); | |||
}), "ManualSystemReset", true); | |||
ActionManage.GetInstance.CancelRegister("SystemAutoMode"); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
@@ -293,16 +296,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i); | |||
} | |||
/* | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
HKDevice.HK_PLC_S7.Write<bool>("M10.0", true); | |||
}), "ManualEStop", true); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
HKDevice.HK_PLC_S7.Write<bool>("M10.0", false); | |||
}), "ManualEReset", true);*/ | |||
} | |||
private void ManualOpen() | |||
{ | |||
@@ -624,10 +617,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.7", false); | |||
} | |||
if (RTrig.GetInstance("DB3.DBX1.7").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.7")) )//允许下配方1或者允许下配方2 | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.7"))//允许下配方1或者允许下配方2 | |||
{ | |||
GVL_SmallStation.IsAllowSiemensSendRecipe = true; | |||
MessageNotify.GetInstance.ShowRunLog("Plc允许下发配方"); | |||
//MessageNotify.GetInstance.ShowRunLog("Plc允许下发配方"); | |||
} | |||
GVL_SmallStation.Station1Sensor = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.1"); | |||
@@ -640,7 +633,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true); | |||
GVL_SmallStation.AGV_PutTray1Finish = false; | |||
//MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc"); | |||
MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc"); | |||
} | |||
if (GVL_SmallStation.Station1HaveTray) | |||
{ | |||
@@ -681,33 +674,33 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
if (SiemensDevice.IsConnected) | |||
{ | |||
short TrayCylinder = 0; | |||
short TraySensor = 0; | |||
ushort TrayCylinder = 0; | |||
ushort TraySensor = 0; | |||
if (GVL_SmallStation.Station1Sensor) | |||
{ | |||
TraySensor = SetBitValue(TraySensor, 1, true); | |||
TraySensor = TraySensor.SetBitValue(1, true); | |||
} | |||
else | |||
{ | |||
TraySensor = SetBitValue(TraySensor, 0, false); | |||
TraySensor = TraySensor.SetBitValue(0, false); | |||
} | |||
if (!GVL_SmallStation.Station1Cylinder) | |||
{ | |||
TrayCylinder = SetBitValue(TrayCylinder, 1, true); | |||
TrayCylinder = TrayCylinder.SetBitValue(1, true); | |||
} | |||
else | |||
{ | |||
TrayCylinder = SetBitValue(TrayCylinder, 0, false); | |||
TrayCylinder = TrayCylinder.SetBitValue(0, false); | |||
} | |||
this.SiemensDevice.Siemens_PLC_S7.Write<bool>("DB2231.DBX28.4", GVL_SmallStation.WindSendAllowAGVPutGet); | |||
this.SiemensDevice.Siemens_PLC_S7.Write<short>("DB2231.DBW190", TraySensor);//添加工位传感器的信号 | |||
this.SiemensDevice.Siemens_PLC_S7.Write<short>("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号 | |||
this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW190", TraySensor);//添加工位传感器的信号 | |||
this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号 | |||
if (SiemensDevice.XL_Status.AgvFinishPut == 1) | |||
if (RTrig.GetInstance("AGV_PutTray1Finish1111").Start(SiemensDevice.XL_Status.AgvFinishPut == 1)) | |||
{ | |||
GVL_SmallStation.AGV_PutTray1Finish = true; | |||
} | |||
if (SiemensDevice.XL_Status.AgvFinishGet == 1) | |||
if (RTrig.GetInstance("AGV_GetTray1Finish111").Start(SiemensDevice.XL_Status.AgvFinishGet == 1)) | |||
{ | |||
GVL_SmallStation.AGV_GetTray1Finish = true; | |||
} | |||
@@ -744,12 +737,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
GVL_SmallStation.SiemensSendRecipeStatus = 5; | |||
SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10); | |||
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); | |||
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); | |||
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); | |||
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},配料信号复位"); | |||
} | |||
} | |||
if (GVL_SmallStation.SiemensSendRecipeStatus == 5) | |||
{ | |||
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); | |||
if (SiemensDevice.XL_Status.Dosing_Confirm == false) | |||
{ | |||
RecipeQueue.Enqueue(data.RecipeCode); | |||
@@ -864,27 +858,30 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
WindSendData.TargetRecipeCode = code; | |||
WindSendData.IsAllowDosing = true; | |||
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(0).RawMaterialName == DeviceName.味精.ToString()) | |||
foreach (var item in RemoteRecipes.ElementAt(index).WindSend) | |||
{ | |||
WindSendData.RawMaterial1_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(0).RawMaterialWeight; | |||
} | |||
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(1).RawMaterialName == DeviceName.白糖.ToString()) | |||
{ | |||
WindSendData.RawMaterial2_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(1).RawMaterialWeight; | |||
} | |||
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(2).RawMaterialName == DeviceName.食盐.ToString()) | |||
{ | |||
WindSendData.RawMaterial3_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(2).RawMaterialWeight; | |||
} | |||
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(3).RawMaterialName == DeviceName.芽菜香料粉.ToString()) | |||
{ | |||
WindSendData.RawMaterial4_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(3).RawMaterialWeight; | |||
} | |||
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(4).RawMaterialName == DeviceName.香料A.ToString()) | |||
{ | |||
WindSendData.RawMaterial5_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(4).RawMaterialWeight; | |||
if (item.RawMaterialName == "0037") | |||
{ | |||
WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight; | |||
} | |||
if (item.RawMaterialName == "0038") | |||
{ | |||
WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight; | |||
} | |||
if (item.RawMaterialName == "") | |||
{ | |||
WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight; | |||
} | |||
if (item.RawMaterialName == "") | |||
{ | |||
WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight; | |||
} | |||
if (item.RawMaterialName == "0036") | |||
{ | |||
WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight; | |||
} | |||
} | |||
WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 5); | |||
WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 95); | |||
} | |||
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) | |||
{ | |||
@@ -1257,32 +1254,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
private void testData() | |||
{ | |||
/*RawMaterialsNamePos.Add("0041", 1); | |||
RawMaterialsNamePos.Add("0042", 2); | |||
RawMaterialsNamePos.Add("0043", 3); | |||
RawMaterialsNamePos.Add("0044", 4); | |||
RawMaterialsNamePos.Add("0045", 5); | |||
RawMaterialsNamePos.Add("0046", 6); | |||
RawMaterialsNamePos.Add("0047", 7); | |||
RawMaterialsNamePos.Add("0048", 8); | |||
RawMaterialsNamePos.Add("0049", 9); | |||
RawMaterialsNamePos.Add("0050", 10); | |||
RawMaterialsNamePos.Add("0051", 11); | |||
RawMaterialsNamePos.Add("0052", 12); | |||
RawMaterialsNamePos.Add("0053", 13); | |||
RawMaterialsNamePos.Add("0054", 14); | |||
RawMaterialsNamePos.Add("0055", 15); | |||
RawMaterialsNamePos.Add("0056", 15); | |||
RawMaterialsNamePos.Add("0057", 15); | |||
RawMaterialsNamePos.Add("0058", 15); | |||
RawMaterialsNamePos.Add("0059", 15); | |||
RawMaterialsNamePos.Add("0060", 15);*/ | |||
RawMaterialsNamePos.Add("0051", 3); | |||
RawMaterialsNamePos.Add("0052", 4); | |||
RawMaterialsNamePos.Add("0054", 5); | |||
RawMaterialsNamePos.Add("0057", 6); | |||
RawMaterialsNamePos.Add("0050", 8); | |||
RawMaterialsNamePos.Add("0048", 13); | |||
RawMaterialsNamePos.Add("0036", 13);//I+G | |||
RawMaterialsNamePos.Add("0037", 13);//味精 | |||
RawMaterialsNamePos.Add("0038", 13);//白糖 | |||
} | |||
public short SetBitValue(short data, byte offset, bool val) | |||
@@ -365,7 +365,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
if (modbusTcp.Connected) | |||
{ | |||
//配料设备参数写入 | |||
/*//配料设备参数写入 | |||
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); | |||
if (res != null) | |||
{ | |||
@@ -389,7 +389,56 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
else | |||
{ | |||
MessageNotify.GetInstance.ShowRunLog($"发送失败" + DeviceAddress.Start); | |||
}*/ | |||
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); | |||
if (res != null) | |||
{ | |||
prop1: | |||
modbusTcp.SetReal(DeviceAddress.SlowlyAddWeight, res.SlowlyAddWeight); | |||
var Value1 = (float)this.modbusTcp.GetReal(DeviceAddress.SlowlyAddWeight); | |||
if (Value1 != null && Value1.ToString() != res.SlowlyAddWeight.ToString()) goto prop1; | |||
prop2: | |||
modbusTcp.SetReal(DeviceAddress.PreCloseValveWeight, res.PreCloseValveWeight); | |||
var Value2 = (float)this.modbusTcp.GetReal(DeviceAddress.PreCloseValveWeight); | |||
if (Value2 != null && Value2.ToString() != res.PreCloseValveWeight.ToString()) goto prop2; | |||
prop3: | |||
modbusTcp.SetUint(DeviceAddress.RapidAcceleration, (uint)res.RapidAcceleration); | |||
var Value3 = this.modbusTcp.GetUint(DeviceAddress.RapidAcceleration); | |||
if (Value3 != null && Value3.ToString() != res.RapidAcceleration.ToString()) goto prop3; | |||
prop4: | |||
modbusTcp.SetUint(DeviceAddress.SlowAcceleration, (uint)res.SlowAcceleration); | |||
var Value4 = this.modbusTcp.GetUint(DeviceAddress.SlowAcceleration); | |||
if (Value4 != null && Value4.ToString() != res.SlowAcceleration.ToString()) goto prop4; | |||
prop5: | |||
modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); | |||
var Value5 = this.modbusTcp.GetUint(DeviceAddress.ServoManualSpeed); | |||
if (Value5 != null && Value5.ToString() != res.ServoManualSpeed.ToString()) goto prop5; | |||
prop6: | |||
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); | |||
var Value6 = this.modbusTcp.GetUint(DeviceAddress.SiloUpperLimitWeight); | |||
if (Value6 != null && Value6.ToString() != res.SiloUpperLimitWeight.ToString()) goto prop6; | |||
prop7: | |||
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); | |||
var Value7 = this.modbusTcp.GetUint(DeviceAddress.LowerLimitWeightOfSilo); | |||
if (Value7 != null && Value7.ToString() != res.LowerLimitWeightOfSilo.ToString()) goto prop7; | |||
prop8: | |||
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); | |||
var Value8 = this.modbusTcp.GetUint(DeviceAddress.StirringSpeed); | |||
if (Value8 != null && Value8.ToString() != res.StirringSpeed.ToString()) goto prop8; | |||
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成"); | |||
} | |||
prop9: | |||
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量 | |||
var Value9 = this.modbusTcp.GetReal("LW65"); | |||
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},读取设置重量:{Value9}"); | |||
if (Value9 != null && Value9.ToString() != Value.ToString()) goto prop9; | |||
/*prop10: | |||
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 | |||
var Value10 = (short[])this.modbusTcp.Read(DeviceAddress.Start); | |||
if (Value10 != null && Value10[0] != 1) goto prop10;*/ | |||
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 | |||
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动"); | |||
} | |||
} | |||
} | |||
@@ -18,9 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
public XL_DataColl_DB DataColl = new XL_DataColl_DB(); | |||
public void Init() | |||
{ | |||
if (IsConnected) | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
if (IsConnected) | |||
{ | |||
var Start = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(2201); | |||
var Status = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2231); | |||
@@ -28,7 +28,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
//var DataColl = this.Siemens_PLC_S7.ReadClass<XL_DataColl_DB>(2291); | |||
if (Start != null && Start is XL_Start_DB st) | |||
{ | |||
if (GVL_SmallStation.IsAllowSiemensSendRecipe && GVL_SmallStation.SiemensSendRecipeStatus == 0) | |||
if (GVL_SmallStation.IsAllowSiemensSendRecipe && GVL_SmallStation.SiemensSendRecipeStatus == 0) | |||
{ | |||
GVL_SmallStation.SiemensSendRecipeStatus = 1; | |||
this.Siemens_PLC_S7.Write("DB2201.DBX450.0", true); | |||
@@ -42,7 +42,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
this.Siemens_PLC_S7.Write("DB2201.DBX450.0", false); | |||
} | |||
} | |||
if (Start.Order_Request_ACK == false && GVL_SmallStation.SiemensSendRecipeStatus == 2) | |||
if (Start.Order_Request_ACK == false && GVL_SmallStation.SiemensSendRecipeStatus == 2) | |||
{ | |||
GVL_SmallStation.IsAllowSiemensSendRecipe = false; | |||
GVL_SmallStation.SiemensSendRecipeStatus = 3; | |||
@@ -50,7 +50,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
} | |||
if (Finish != null && Finish is XL_Finish_DB FinishData) | |||
{ | |||
if (FinishData.Ask_For_Finish_PLC && GVL_SmallStation.SiemensSendRecipeStatus == 7) | |||
if (FinishData.Ask_For_Finish_PLC && GVL_SmallStation.SiemensSendRecipeStatus == 7) | |||
{ | |||
FinishData.Order_No = ""; | |||
FinishData.Product_Code = ""; | |||
@@ -71,17 +71,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
} | |||
if (Status != null && Status is XL_Status_DB state) | |||
{ | |||
for (int i = 0; i < XL_Status.Powder.Length; i++) | |||
for (int i = 0; i < XL_Status.Powder.Length; i++) | |||
{ | |||
XL_Status.Powder[i] = new PowderStatus(); | |||
} | |||
XL_Status = state; | |||
} | |||
var res = ProcessControl.GetInstance.HKDevice.DeviceStatus; | |||
if (res != null) | |||
if (res != null) | |||
{ | |||
DataColl.HeartBeatWithPLC = res.HeartBeat; | |||
DataColl.SystemStart = res.DeviceRun; | |||
@@ -92,9 +92,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
DataColl.Alarm = res.Alarm; | |||
this.Siemens_PLC_S7.WriteClass<XL_DataColl_DB>(DataColl, 2291); | |||
} | |||
Thread.Sleep(10); | |||
}),"监听服务数据",true); | |||
} | |||
} | |||
Thread.Sleep(10); | |||
}),"监听服务数据",true); | |||
} | |||
} | |||
} |
@@ -25,7 +25,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
if (IsConnected) | |||
{ | |||
var res1 = this.Siemens_PLC_S7.ReadClass<WindSend_Read>(94); | |||
/*if (res1 != null && res1 is WindSend_Read readData) | |||
if (res1 != null && res1 is WindSend_Read readData) | |||
{ | |||
GVL_SmallStation.WindSendAllowAGVPutGet = readData.HoodLiftInPlace; | |||
Siemens_PLC_S7.Write<bool>("DB95.DBX38.2", GVL_SmallStation.Station1HaveTray);//工站1有托盘 | |||
@@ -36,16 +36,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
if (RTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign)) | |||
{ | |||
GVL_SmallStation.WindSendDosingComple = true; | |||
Siemens_PLC_S7.Write("DB95.DBX38.1", true); | |||
} | |||
if (TTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign)) | |||
{ | |||
Siemens_PLC_S7.Write("DB95.DBX38.1", false); | |||
} | |||
}*/ | |||
} | |||
//测试 | |||
var res = this.Siemens_PLC_S7.ReadClass<WindSend_Write>(95); | |||
/*var res = this.Siemens_PLC_S7.ReadClass<WindSend_Write>(95); | |||
if (res != null && res is WindSend_Write write) | |||
{ | |||
if (res1.SystemRunStatus == 1 && test) | |||
@@ -77,7 +76,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
Siemens_PLC_S7.Write("DB95.DBX38.1", false); | |||
} | |||
} | |||
}*/ | |||
/*if (RTrig.GetInstance("CurrentCompleteSign").Start(res.CurrentCompleteSign)) | |||
{ | |||
ActionManage.GetInstance.Send("WindSendDosingFinish"); | |||
@@ -109,16 +108,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
Thread.Sleep(10);*/ | |||
} | |||
}),"监听服务数据"); | |||
}),"监听粉料数据",true); | |||
} | |||
} | |||
enum DeviceName | |||
{ | |||
味精, | |||
白糖, | |||
食盐, | |||
芽菜香料粉, | |||
香料A | |||
} | |||
} |
@@ -56,6 +56,15 @@ | |||
FontSize="20" | |||
Panel.ZIndex="0" | |||
Style="{StaticResource ImageButtonStyle}"></Button> | |||
<Button | |||
Width="200" | |||
Height="40" | |||
Margin="5,0,5,0" | |||
Command="{Binding Test5Command}" | |||
Content="粉料仓提升到位" | |||
FontSize="20" | |||
Panel.ZIndex="0" | |||
Style="{StaticResource ImageButtonStyle}"></Button> | |||
</StackPanel> | |||
@@ -89,7 +89,7 @@ | |||
<WrapPanel VerticalAlignment="Center" Grid.Column="1"> | |||
<TextBlock | |||
Width="100" | |||
Margin="10,0,10,0" | |||
Margin="2,0,10,0" | |||
Background="Transparent" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
@@ -122,28 +122,36 @@ | |||
</WrapPanel> | |||
<WrapPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Column="1"> | |||
<Button | |||
Width="100" | |||
Width="80" | |||
Height="40" | |||
Margin="5,0,5,0" | |||
Margin="2,0,2,0" | |||
Command="{Binding AddCommand}" | |||
Content="添加原料" | |||
FontSize="20" | |||
Content="添加小料" | |||
FontSize="16" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Width="100" | |||
Width="80" | |||
Height="40" | |||
Margin="2,0,2,0" | |||
Command="{Binding AddFLCommand}" | |||
Content="添加粉料" | |||
FontSize="16" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Width="80" | |||
Height="40" | |||
Margin="5,0,10,0" | |||
Margin="2,0,2,0" | |||
Command="{Binding SaveCommand}" | |||
Content="保存配方" | |||
FontSize="20" | |||
FontSize="16" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Name ="Close" | |||
Width="100" | |||
Width="80" | |||
Height="40" | |||
Margin="5,0,5,0" | |||
Margin="2,0,2,0" | |||
Content="取消" | |||
FontSize="20" | |||
FontSize="16" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
</WrapPanel> | |||
</Grid> | |||
@@ -173,7 +173,7 @@ | |||
Foreground="#FF2AB2E7" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="0" | |||
SelectedIndex="{Binding SelectIndex}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding RawMaterialName}" /> | |||
@@ -37,13 +37,17 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
{ | |||
GVL_SmallStation.CylinderReset = true; | |||
}); | |||
Test5Command = new RelayCommand(() => | |||
{ | |||
GVL_SmallStation.WindSendAllowAGVPutGet = true; | |||
}); | |||
CLearRecipeInfo = new RelayCommand(() => | |||
{ | |||
ActionManage.GetInstance.Send("CLearRecipeInfo"); | |||
}); | |||
SystemReset = new RelayCommand(() => | |||
{ | |||
ActionManage.GetInstance.Send("SystemReset"); | |||
ActionManage.GetInstance.Send("ManualSystemReset"); | |||
}); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
@@ -55,6 +59,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
public RelayCommand Test2Command { get; set; } | |||
public RelayCommand Test3Command { get; set; } | |||
public RelayCommand Test4Command { get; set; } | |||
public RelayCommand Test5Command { get; set; } | |||
public bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnPropertyChanged(); } } | |||
private bool _mHeartbeat; | |||
@@ -43,42 +43,39 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
AddCommand = new RelayCommand(() => | |||
{ | |||
int MaxRawMaterial = 15; | |||
if (GVL_SmallStation.GetInstance.IsUseWindSend && TrayNum == 1) | |||
if (RawMaterial.Count < MaxRawMaterial) | |||
{ | |||
MaxRawMaterial = 20; | |||
RawMaterial.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
RawMaterialName = "原料" + (RawMaterial.Count + 1), | |||
RawMaterialLocation = RawMaterial.Count + 1, | |||
RawMaterialBarrelNum = 1, | |||
RawMaterialWeight = 1 | |||
}); | |||
} | |||
else | |||
{ | |||
MaxRawMaterial = 15; | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"原料最多添加{MaxRawMaterial}种"); | |||
} | |||
if (RawMaterial.Count < MaxRawMaterial) | |||
}); | |||
AddFLCommand = new RelayCommand(() => | |||
{ | |||
int MaxRawMaterial = 5; | |||
if (WindSendRawMaterial.Count < MaxRawMaterial) | |||
{ | |||
if (RawMaterial.Count < 15) | |||
WindSendRawMaterial.Add(new WindSendRawMaterial() | |||
{ | |||
RawMaterial.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
RawMaterialName = "原料" + (RawMaterial.Count + 1), | |||
RawMaterialLocation = RawMaterial.Count + 1, | |||
RawMaterialBarrelNum = 1, | |||
RawMaterialWeight = 100 | |||
}); | |||
} | |||
else | |||
{ | |||
RawMaterial.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
RawMaterialName = "粉料" + (RawMaterial.Count -14), | |||
RawMaterialLocation = (RawMaterial.Count - 14), | |||
RawMaterialBarrelNum = 7, | |||
RawMaterialWeight = 100 | |||
}); | |||
} | |||
RawMaterialName = "粉料" + (RawMaterial.Count + 1 ), | |||
RawMaterialWeight = 1 | |||
}); | |||
} | |||
else | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"原料最多添加{MaxRawMaterial}种"); | |||
} | |||
}); | |||
SaveCommand = new RelayCommand(() => | |||
{ | |||
@@ -97,6 +94,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
TrayNum = 1; | |||
} | |||
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>(); | |||
ObservableCollection<WindSendRawMaterial> WindSendRawMaterials = new ObservableCollection<WindSendRawMaterial>(); | |||
if (RawMaterial == null || RawMaterial.Count <= 0) | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"没有可保存的参数!"); | |||
@@ -122,11 +120,22 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
RawMaterialBarrelNum = item.RawMaterialBarrelNum, | |||
RawMaterialWeight = item.RawMaterialWeight, | |||
}); | |||
} | |||
foreach (var item in WindSendRawMaterial) | |||
{ | |||
WindSendRawMaterials.Add(new WindSendRawMaterial() | |||
{ | |||
RawMaterialName = item.RawMaterialName, | |||
RawMaterialWeight=item.RawMaterialWeight, | |||
}); | |||
} | |||
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).RecipeName= RecipeName; | |||
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).TrayCode = TrayNum; | |||
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).RecipeCode = RecipeCode; | |||
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).RawMaterial = RawMaterial; | |||
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).RawMaterial = RawMaterials; | |||
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).WindSend = WindSendRawMaterials; | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"修改配方完成!"); | |||
} | |||
else | |||
@@ -140,12 +149,22 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
RawMaterialWeight = item.RawMaterialWeight, | |||
}); | |||
} | |||
foreach (var item in WindSendRawMaterial) | |||
{ | |||
WindSendRawMaterials.Add(new WindSendRawMaterial() | |||
{ | |||
RawMaterialName = item.RawMaterialName, | |||
RawMaterialWeight = item.RawMaterialWeight, | |||
}); | |||
} | |||
Json<LocalRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||
{ | |||
RecipeName = RecipeName, | |||
RecipeCode = RecipeCode, | |||
TrayCode = TrayNum, | |||
RawMaterial = RawMaterials, | |||
WindSend = WindSendRawMaterials, | |||
}); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"自定义配方添加完成!"); | |||
} | |||
@@ -166,9 +185,12 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
public ObservableCollection<RemoteRecipeRawMaterial> RawMaterial { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>(); | |||
public ObservableCollection<WindSendRawMaterial> WindSendRawMaterial { get; set; } = new ObservableCollection<WindSendRawMaterial>(); | |||
public RelayCommand<object> RemoveCommand { get; set; } | |||
public RelayCommand AddCommand { get; set; } | |||
public RelayCommand AddFLCommand { get; set; } | |||
public RelayCommand SaveCommand { get; set; } | |||
} | |||
@@ -25,6 +25,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
RecipeName = rm.RecipeName; | |||
foreach (var item in rm.RawMaterials) | |||
{ | |||
item.SelectIndex = Array.FindIndex(RawMaterialNames.ToArray(), p => p == item.RawMaterialName); | |||
RawMaterials.Add(item); | |||
} | |||
RecipeCode = rm.RecipCode; | |||
@@ -35,14 +35,15 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
Recipes.ElementAt(index).IsEnable = false; | |||
} | |||
MessageNotify.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}"); | |||
devices.Enqueue(deviceName); | |||
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName); | |||
UserTreeWait.Add(new RecipeModel { RecipeName = deviceName, RawMaterials = res.RawMaterials }); | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
UserTreeWait.Add(new RecipeModel { RecipeName = deviceName, RawMaterials = res.RawMaterials }); | |||
}); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); | |||
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); | |||
devices.Enqueue(deviceName); | |||
} | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); | |||
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); | |||
}); | |||
ChangeRecipeStateCommand = new RelayCommand<object>(ChangeRecipeState); | |||
@@ -483,10 +483,10 @@ namespace BPASmartClient.Modbus | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <param name="value"></param> | |||
public void SetReal(string StartAddress, float value) | |||
public void SetReal(string StartAddress, float value,int Retries = 1) | |||
{ | |||
var bytes = BitConverter.GetBytes(value); | |||
Write(StartAddress, bytes.BytesToUshorts()); | |||
Write(StartAddress, bytes.BytesToUshorts(), Retries); | |||
} | |||
/// <summary> | |||
@@ -19,7 +19,7 @@ | |||
</COMReference> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.CustomResource" Version="1.0.19" /> | |||
<PackageReference Include="BPA.CustomResource" Version="1.0.23" /> | |||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1418.22" /> | |||
</ItemGroup> | |||