@@ -12,7 +12,7 @@ namespace BPASmartClient.JXJFoodBigStation.Properties { | |||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | ||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] | |||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] | |||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { | ||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); | ||||
@@ -563,10 +563,12 @@ | |||||
</Grid> | </Grid> | ||||
<!--#region 底部料仓--> | <!--#region 底部料仓--> | ||||
<Grid Grid.Row="2"> | |||||
<Grid Grid.Row="2" x:Name="bottomGrid"> | |||||
<ListView | <ListView | ||||
x:Name="buttonListView" | x:Name="buttonListView" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
Height="{Binding ElementName=bottomGrid, Path=ActualHeight}" | |||||
Background="Transparent" | Background="Transparent" | ||||
BorderThickness="0" | BorderThickness="0" | ||||
ItemsSource="{Binding BottomDeviceCurrentStatuses}" | ItemsSource="{Binding BottomDeviceCurrentStatuses}" | ||||
@@ -577,6 +579,7 @@ | |||||
<UniformGrid | <UniformGrid | ||||
HorizontalAlignment="Left" | HorizontalAlignment="Left" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
FlowDirection="LeftToRight" | |||||
Columns="7" | Columns="7" | ||||
Rows="1" /> | Rows="1" /> | ||||
</ItemsPanelTemplate> | </ItemsPanelTemplate> | ||||
@@ -717,6 +720,7 @@ | |||||
</DataTemplate> | </DataTemplate> | ||||
</ListView.ItemTemplate> | </ListView.ItemTemplate> | ||||
</ListView> | </ListView> | ||||
</Grid> | </Grid> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
@@ -25,7 +25,7 @@ namespace BPASmartClient.Model | |||||
public string DeviceIp { get; set; } | public string DeviceIp { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 料筒位置 | |||||
/// 桶号 | |||||
/// </summary> | /// </summary> | ||||
public int Loc { get { return _mLoc; } set { _mLoc = value; OnPropertyChanged(); } } | public int Loc { get { return _mLoc; } set { _mLoc = value; OnPropertyChanged(); } } | ||||
private int _mLoc; | private int _mLoc; | ||||
@@ -59,8 +59,8 @@ namespace BPASmartClient.DosingSystem | |||||
} | } | ||||
base.OnStartup(e); | base.OnStartup(e); | ||||
SystemHelper.GetInstance.CreateDesktopShortcut(); | SystemHelper.GetInstance.CreateDesktopShortcut(); | ||||
MenuInit(); | |||||
DataInit(); | DataInit(); | ||||
MenuInit(); | |||||
//SiemensTest.GetInstance.Init(); | //SiemensTest.GetInstance.Init(); | ||||
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 | DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 | ||||
MainView mv = new MainView(); | MainView mv = new MainView(); | ||||
@@ -194,13 +194,13 @@ namespace BPASmartClient.DosingSystem | |||||
ToggleWindowPath = "View.ConveyerBeltManualView" | ToggleWindowPath = "View.ConveyerBeltManualView" | ||||
}); | }); | ||||
ManualControl.Add(new SubMenumodel() | |||||
{ | |||||
SubMenuName = "配料输送带控制", | |||||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||||
AssemblyName = "BPASmartClient.DosingSystem", | |||||
ToggleWindowPath = "View.TempManageControlView" | |||||
}); | |||||
//ManualControl.Add(new SubMenumodel() | |||||
//{ | |||||
// SubMenuName = "配料输送带控制", | |||||
// SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||||
// AssemblyName = "BPASmartClient.DosingSystem", | |||||
// ToggleWindowPath = "View.TempManageControlView" | |||||
//}); | |||||
//ManualControl.Add(new SubMenumodel() | //ManualControl.Add(new SubMenumodel() | ||||
//{ | //{ | ||||
@@ -280,15 +280,27 @@ namespace BPASmartClient.DosingSystem | |||||
AssemblyName = "BPASmartClient.DosingSystem", | AssemblyName = "BPASmartClient.DosingSystem", | ||||
ToggleWindowPath = "View.DeviceListView" | ToggleWindowPath = "View.DeviceListView" | ||||
}); | }); | ||||
DeviceMonitor.Add(new SubMenumodel() | |||||
//2023/6/29修改 | |||||
if ((ConveryType)Enum.Parse(typeof(ConveryType), Json<DevicePar>.Data.BaseParModel.ConveryType) == ConveryType.U型) | |||||
{ | { | ||||
SubMenuName = "设备状态", | |||||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||||
AssemblyName = "BPASmartClient.DosingSystem", | |||||
ToggleWindowPath = "View.HardwareStatusView" | |||||
}); | |||||
DeviceMonitor.Add(new SubMenumodel() | |||||
{ | |||||
SubMenuName = "设备状态", | |||||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||||
AssemblyName = "BPASmartClient.DosingSystem", | |||||
ToggleWindowPath = "View.UHardwareStatusView" | |||||
}); | |||||
} | |||||
else | |||||
{ | |||||
DeviceMonitor.Add(new SubMenumodel() | |||||
{ | |||||
SubMenuName = "设备状态", | |||||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||||
AssemblyName = "BPASmartClient.DosingSystem", | |||||
ToggleWindowPath = "View.HardwareStatusView" | |||||
}); | |||||
} | |||||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | MenuManage.GetInstance.menuModels.Add(new MenuModel() | ||||
{ | { | ||||
MainMenuIcon = "", | MainMenuIcon = "", | ||||
@@ -0,0 +1,115 @@ | |||||
using BPA.Helper; | |||||
using BPASmartClient.CustomResource.Pages.Model; | |||||
using BPASmartClient.DosingSystem.ViewModel; | |||||
using BPASmartClient.Model; | |||||
using S7.Net.Types; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | |||||
using System.Diagnostics; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.DosingSystem | |||||
{ | |||||
/// <summary> | |||||
/// 业务逻辑执行类 | |||||
/// </summary> | |||||
public class ExcuteControl | |||||
{ | |||||
private static ExcuteControl Instance; | |||||
public static ExcuteControl GetInstance => Instance ??= new ExcuteControl(); | |||||
/// <summary> | |||||
/// 配料完成计数 | |||||
/// </summary> | |||||
int Comcount = 0; | |||||
public ExcuteControl() { } | |||||
/// <summary> | |||||
/// 配料逻辑 | |||||
/// </summary> | |||||
/// <param name="recipeModel">当前执行的配方</param> | |||||
public void BusinessExcute(RecipeModel recipeModel) | |||||
{ | |||||
ThreadManage.GetInstance.StartLong(new Action(() => { | |||||
#region 直线双仓型 | |||||
//拿到当前配方 | |||||
for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++)//遍历允许配料的料桶 | |||||
{ | |||||
if (GlobalDevice.PlcData.IsAllowIngredients[j]) | |||||
{ | |||||
int barrelNum = j + 1;//桶号 | |||||
int stockLoc = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的料仓位置 0~6 双仓情况下返回的位置是否一样,料仓ip设置顺序怎样的 | |||||
if (stockLoc >= 1 && stockLoc <= Json<DevicePar>.Data.BaseParModel.StockCount) | |||||
{ | |||||
int index = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == stockLoc); | |||||
if (index >= 0) | |||||
{ | |||||
//查出到配料位置的原料 | |||||
int result = Array.FindIndex(recipeModel.RawMaterials.ToArray(), p => (p.Loc == barrelNum && p.DeviceIp == DeviceInquire.GetInstance.devices.ElementAt(index).IpAddress));//待定 | |||||
if (result != -1 && DeviceInquire.GetInstance.GetDevice(recipeModel.RawMaterials[result].DeviceIp).deviceStatus.RunStatus == 1 && RecipeControlViewModel.recipeProcesses.ElementAt(0).RawMaterials[result].Status == Status.等待配料) | |||||
{ | |||||
var weight = recipeModel.RawMaterials[result].RawMaterialWeight; | |||||
DeviceInquire.GetInstance.GetDevice(recipeModel.RawMaterials.ElementAt(index).DeviceIp).Start(weight);//所有参数下发并启动配料 | |||||
MessageNotify.GetInstance.ShowRunLog($"{recipeModel.RawMaterials[result].DeviceIp}:正在配料"); | |||||
RecipeControlViewModel.recipeProcesses.ElementAt(0).RawMaterials[result].Status = Status.正在配料; | |||||
} | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
continue; | |||||
} | |||||
} | |||||
} | |||||
//配料完成后逻辑 | |||||
for (int k = 0; k < recipeModel.RawMaterials.Count; k++) | |||||
{ | |||||
if (DeviceInquire.GetInstance.GetDevice(recipeModel.RawMaterials.ElementAt(k).DeviceIp).deviceStatus.RunStatus == 3 && RecipeControlViewModel.recipeProcesses.ElementAt(0).RawMaterials[k].Status != Status.配料完成)//配料完成 | |||||
{ | |||||
int DeviceNum = DeviceInquire.GetInstance.GetDevice(recipeModel.RawMaterials.ElementAt(k).DeviceIp).deviceStatus.DeviceNum; | |||||
Comcount++; | |||||
DeviceInquire.GetInstance.GetDevice(recipeModel.RawMaterials.ElementAt(k).DeviceIp).StatusReset();//料仓复位 | |||||
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true); | |||||
Task.Run(() => | |||||
{ | |||||
int cout = DeviceNum - 1; | |||||
while (!SiemensDevice.GetInstance.MySiemens.Read<bool>($"DB3.DBX148.{cout}").Content) //DB3.DBX148.0-31 148.0-148.5代表6个料仓位置 | |||||
{ | |||||
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{cout}", true); | |||||
Thread.Sleep(200); | |||||
} | |||||
while (SiemensDevice.GetInstance.MySiemens.Read<bool>($"DB3.DBX148.{cout}").Content) | |||||
{ | |||||
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{cout}", false); | |||||
} | |||||
MessageNotify.GetInstance.ShowRunLog($"{cout}号气缸复位信号写入成功!"); | |||||
}); | |||||
RecipeControlViewModel.recipeProcesses.ElementAt(0).RawMaterials[k].Status = Status.配料完成; | |||||
if (Comcount >= recipeModel.RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && | |||||
{ | |||||
Comcount = 0; | |||||
App.Current.Dispatcher.Invoke(new Action(() => { RecipeControlViewModel.recipeProcesses.Clear(); })); | |||||
MessageNotify.GetInstance.ShowUserLog($"配方:{recipeModel.RecipeName},配料完成"); | |||||
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX202.0", true);//配料完成 | |||||
MessageNotify.GetInstance.ShowRunLog($"配方:{recipeModel.RecipeName},配料完成"); | |||||
recipeModel.Are.Set();//待定 | |||||
Thread.Sleep(100); | |||||
} | |||||
} | |||||
} | |||||
#endregion | |||||
Thread.Sleep(10); | |||||
}),"配料业务逻辑"); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | |||||
public enum ConveryType | |||||
{ | |||||
U型, | |||||
直线型, | |||||
} | |||||
} |
@@ -20,6 +20,7 @@ namespace BPASmartClient.DosingSystem | |||||
{ | { | ||||
public class DeviceInquire | public class DeviceInquire | ||||
{ | { | ||||
int stockCount;//料仓数 | |||||
private volatile static DeviceInquire _Instance; | private volatile static DeviceInquire _Instance; | ||||
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire()); | public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire()); | ||||
private DeviceInquire() { } | private DeviceInquire() { } | ||||
@@ -203,7 +204,8 @@ namespace BPASmartClient.DosingSystem | |||||
} | } | ||||
} | } | ||||
}*/ | }*/ | ||||
for (int i = 0; i < 6; i++) | |||||
stockCount = Json<DevicePar>.Data.BaseParModel.StockCount; | |||||
for (int i = 0; i < stockCount; i++) | |||||
{ | { | ||||
IPLists.Add($"{IPSegment}{(i + 1) * 10}"); | IPLists.Add($"{IPSegment}{(i + 1) * 10}"); | ||||
} | } | ||||
@@ -239,8 +241,8 @@ namespace BPASmartClient.DosingSystem | |||||
App.Current.Dispatcher.Invoke(new Action(() => | App.Current.Dispatcher.Invoke(new Action(() => | ||||
{ | { | ||||
devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); | devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); | ||||
if (TopDeviceCurrentStatuses.Count <= 7) | |||||
//2023/7/3调整 | |||||
if (stockCount<=8||(stockCount>8&&TopDeviceCurrentStatuses.Count <= stockCount / 2 + 1 &&int.TryParse( ip.Split('.')[3],out int res)&&res<= (stockCount / 2 + 1)*10)) | |||||
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | ||||
else | else | ||||
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | ||||
@@ -97,35 +97,35 @@ namespace BPASmartClient.DosingSystem.Model | |||||
try | try | ||||
{ | { | ||||
//D1001 | //D1001 | ||||
string head = (Convert.ToInt32(address.Substring(1, 1))).ToString(); | |||||
int num = Convert.ToInt32(address.Substring(2, 3)); | |||||
string head = (System.Convert.ToInt32(address.Substring(1, 1))).ToString(); | |||||
int num = System.Convert.ToInt32(address.Substring(2, 3)); | |||||
int len = num.ToString().Length; | int len = num.ToString().Length; | ||||
string tail = string.Empty; | string tail = string.Empty; | ||||
switch (len) | switch (len) | ||||
{ | { | ||||
case 1: | case 1: | ||||
if ((Convert.ToInt32(address.Substring(4, 1))).ToString().Length > 1) | |||||
if ((System.Convert.ToInt32(address.Substring(4, 1))).ToString().Length > 1) | |||||
{ | { | ||||
tail = "0" + (Convert.ToInt32(address.Substring(4, 1))).ToString(); | |||||
tail = "0" + (System.Convert.ToInt32(address.Substring(4, 1))).ToString(); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
tail = "00" + (Convert.ToInt32(address.Substring(4, 1))).ToString(); | |||||
tail = "00" + (System.Convert.ToInt32(address.Substring(4, 1))).ToString(); | |||||
} | } | ||||
break; | break; | ||||
case 2: | case 2: | ||||
if ((Convert.ToInt32(address.Substring(3, 2))).ToString().Length > 2) | |||||
if ((System.Convert.ToInt32(address.Substring(3, 2))).ToString().Length > 2) | |||||
{ | { | ||||
tail = (Convert.ToInt32(address.Substring(3, 2))).ToString(); | |||||
tail = (System.Convert.ToInt32(address.Substring(3, 2))).ToString(); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
tail = "0" + (Convert.ToInt32(address.Substring(3, 2))).ToString(); | |||||
tail = "0" + (System.Convert.ToInt32(address.Substring(3, 2))).ToString(); | |||||
} | } | ||||
break; | break; | ||||
case 3: | case 3: | ||||
tail = (Convert.ToInt32(address.Substring(2, 3))).ToString(); | |||||
tail = (System.Convert.ToInt32(address.Substring(2, 3))).ToString(); | |||||
break; | break; | ||||
} | } | ||||
@@ -26,6 +26,37 @@ namespace BPASmartClient.DosingSystem | |||||
public string DeviceAddress { get { return _mDeviceAddress; } set { _mDeviceAddress = value; OnPropertyChanged(); } } | public string DeviceAddress { get { return _mDeviceAddress; } set { _mDeviceAddress = value; OnPropertyChanged(); } } | ||||
private string _mDeviceAddress = "192.168.0.15"; | private string _mDeviceAddress = "192.168.0.15"; | ||||
/// <summary> | |||||
/// 料仓数量 | |||||
/// </summary> | |||||
public int StockCount { get { return _stockCount; } set { _stockCount = value; OnPropertyChanged(); } } | |||||
private int _stockCount = 0; | |||||
/// <summary> | |||||
/// 当前使用的输送线类型 | |||||
/// </summary> | |||||
public string ConveryType { get { return _converyType; } set { _converyType = value; OnPropertyChanged(); } } | |||||
private string _converyType; | |||||
/// <summary> | |||||
/// 输送线类型集合 | |||||
/// </summary> | |||||
private List<string> _converyTypeList=new List<string> (); | |||||
public List<string> ConveryTypeList { | |||||
get { return _converyTypeList; } | |||||
set { | |||||
foreach (var item in value) | |||||
{ | |||||
if (_converyTypeList.Contains(item)) | |||||
{ | |||||
continue; | |||||
} | |||||
_converyTypeList.Add(item); | |||||
} | |||||
OnPropertyChanged(); } } | |||||
/// <summary> | /// <summary> | ||||
/// 输送带数量 | /// 输送带数量 | ||||
/// </summary> | /// </summary> | ||||
@@ -54,6 +85,8 @@ namespace BPASmartClient.DosingSystem | |||||
} | } | ||||
private int _mConveyerBeltCount = 0; | private int _mConveyerBeltCount = 0; | ||||
/// <summary> | /// <summary> | ||||
/// 升降气缸数量 | /// 升降气缸数量 | ||||
/// </summary> | /// </summary> | ||||
@@ -38,7 +38,7 @@ namespace BPASmartClient.DosingSystem | |||||
TaskManage.GetInstance.StartLong(new Action(() => | TaskManage.GetInstance.StartLong(new Action(() => | ||||
{ | { | ||||
GlobalDevice.PlcData = MySiemens.Read<PlcToComputer>(3).Content;//获取PLC到上位机的数据 | GlobalDevice.PlcData = MySiemens.Read<PlcToComputer>(3).Content;//获取PLC到上位机的数据 | ||||
//var tt = MySiemens.Read<PlcToComputer>(3);//获取PLC到上位机的数据 | |||||
//var tt = MySiemens.Read<PlcToComputer>(3);//获取PLC到上位机的数据 | |||||
var res = MySiemens.Read<ushort[]>("DB4.DBW134", 32).Content; | var res = MySiemens.Read<ushort[]>("DB4.DBW134", 32).Content; | ||||
if (res != null && res is ushort[] ushorts && ushorts.Length == 32) | if (res != null && res is ushort[] ushorts && ushorts.Length == 32) | ||||
{ | { | ||||
@@ -6,6 +6,7 @@ | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | ||||
xmlns:Themes1="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic" | |||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -13,7 +14,159 @@ | |||||
<UserControl.DataContext> | <UserControl.DataContext> | ||||
<vm:CommparSetViewModel /> | <vm:CommparSetViewModel /> | ||||
</UserControl.DataContext> | </UserControl.DataContext> | ||||
<UserControl.Resources> | |||||
<ResourceDictionary> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||||
<ResourceDictionary> | |||||
<SolidColorBrush x:Key="foreground" Color="#009DFF" /> | |||||
<SolidColorBrush x:Key="borderBrush" Color="#009DFF" /> | |||||
<Style x:Key="ComboBoxStyle1" TargetType="{x:Type ComboBox}"> | |||||
<Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}" /> | |||||
<Setter Property="Foreground" Value="{DynamicResource foreground}" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="BorderBrush" Value="{DynamicResource borderBrush}" /> | |||||
<Setter Property="BorderThickness" Value="1" /> | |||||
<Setter Property="Margin" Value="0,0,0,0" /> | |||||
<Setter Property="Padding" Value="0" /> | |||||
<Setter Property="Height" Value="24" /> | |||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" /> | |||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> | |||||
<Setter Property="ScrollViewer.CanContentScroll" Value="true" /> | |||||
<Setter Property="ScrollViewer.PanningMode" Value="Both" /> | |||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" /> | |||||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||||
<Setter Property="IsTextSearchCaseSensitive" Value="true" /> | |||||
<Setter Property="IsEditable" Value="true" /> | |||||
<Setter Property="StaysOpenOnEdit" Value="true" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type ComboBox}"> | |||||
<Border | |||||
Background="{TemplateBinding Background}" | |||||
BorderBrush="{TemplateBinding BorderBrush}" | |||||
BorderThickness="{TemplateBinding BorderThickness}" | |||||
SnapsToDevicePixels="true"> | |||||
<Grid> | |||||
<Themes1:ClassicBorderDecorator | |||||
x:Name="Border" | |||||
BorderBrush="{x:Static Themes1:ClassicBorderDecorator.ClassicBorderBrush}" | |||||
BorderStyle="None" | |||||
BorderThickness="2"> | |||||
<Popup | |||||
x:Name="PART_Popup" | |||||
AllowsTransparency="true" | |||||
Focusable="False" | |||||
IsOpen="{TemplateBinding IsDropDownOpen}" | |||||
Placement="Bottom" | |||||
PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"> | |||||
<Themes1:SystemDropShadowChrome | |||||
x:Name="Shdw" | |||||
MinWidth="{Binding ActualWidth, ElementName=Border}" | |||||
MaxHeight="{TemplateBinding MaxDropDownHeight}" | |||||
Color="Transparent"> | |||||
<Border | |||||
x:Name="DropDownBorder" | |||||
BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" | |||||
BorderThickness="1"> | |||||
<Border.Background> | |||||
<SolidColorBrush Color="#264c73" /> | |||||
</Border.Background> | |||||
<ScrollViewer x:Name="DropDownScrollViewer"> | |||||
<Grid RenderOptions.ClearTypeHint="Enabled"> | |||||
<Canvas | |||||
Width="0" | |||||
Height="0" | |||||
HorizontalAlignment="Left" | |||||
VerticalAlignment="Top"> | |||||
<Rectangle | |||||
x:Name="OpaqueRect" | |||||
Width="{Binding ActualWidth, ElementName=DropDownBorder}" | |||||
Height="{Binding ActualHeight, ElementName=DropDownBorder}" | |||||
Fill="{Binding Background, ElementName=DropDownBorder}" /> | |||||
</Canvas> | |||||
<ItemsPresenter | |||||
x:Name="ItemsPresenter" | |||||
KeyboardNavigation.DirectionalNavigation="Contained" | |||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||||
</Grid> | |||||
</ScrollViewer> | |||||
</Border> | |||||
</Themes1:SystemDropShadowChrome> | |||||
</Popup> | |||||
</Themes1:ClassicBorderDecorator> | |||||
<DockPanel Margin="2"> | |||||
<FrameworkElement Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" DockPanel.Dock="Right" /> | |||||
<Border x:Name="SelectedItemBorder" Margin="{TemplateBinding Padding}"> | |||||
<ContentPresenter | |||||
Margin="1,1,1,1" | |||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||||
Content="{TemplateBinding SelectionBoxItem}" | |||||
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" | |||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" | |||||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" | |||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||||
</Border> | |||||
</DockPanel> | |||||
<ToggleButton | |||||
Width="Auto" | |||||
MinWidth="0" | |||||
MinHeight="0" | |||||
Margin="2" | |||||
ClickMode="Press" | |||||
Focusable="false" | |||||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" | |||||
Style="{StaticResource ComboBoxTransparentButtonStyle}" /> | |||||
</Grid> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="IsDropDownOpen" Value="false" /> | |||||
</MultiTrigger.Conditions> | |||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" /> | |||||
</MultiTrigger> | |||||
<Trigger Property="HasItems" Value="false"> | |||||
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" /> | |||||
</Trigger> | |||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" /> | |||||
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" /> | |||||
</Trigger> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="IsGrouping" Value="true" /> | |||||
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" /> | |||||
</MultiTrigger.Conditions> | |||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false" /> | |||||
</MultiTrigger> | |||||
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="true"> | |||||
<Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5" /> | |||||
<Setter TargetName="Shdw" Property="Color" Value="#71000000" /> | |||||
</Trigger> | |||||
<Trigger SourceName="DropDownScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false"> | |||||
<Setter TargetName="OpaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" /> | |||||
<Setter TargetName="OpaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Style.Triggers> | |||||
<Trigger Property="IsEditable" Value="true"> | |||||
<Setter Property="IsTabStop" Value="false" /> | |||||
<Setter Property="Padding" Value="1" /> | |||||
<Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}" /> | |||||
</Trigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid> | <Grid> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
@@ -82,7 +235,64 @@ | |||||
Style="{StaticResource TextBoxStyle}" | Style="{StaticResource TextBoxStyle}" | ||||
Text="{Binding CommBaseParModel.DeviceAddress, UpdateSourceTrigger=PropertyChanged}" /> | Text="{Binding CommBaseParModel.DeviceAddress, UpdateSourceTrigger=PropertyChanged}" /> | ||||
</Grid> | </Grid> | ||||
<Grid Width="350" Margin="5"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Margin="0,0,2,0" | |||||
HorizontalAlignment="Right" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="输送线类型:" /> | |||||
<ComboBox | |||||
Grid.Column="1" | |||||
Width="170" | |||||
Height="35" | |||||
HorizontalAlignment="Right" | |||||
FontSize="20" | |||||
Text="{Binding CommBaseParModel.ConveryType,UpdateSourceTrigger=PropertyChanged}" | |||||
ItemsSource="{Binding CommBaseParModel.ConveryTypeList,UpdateSourceTrigger=PropertyChanged}"> | |||||
<ComboBox.ItemContainerStyle> | |||||
<Style TargetType="{x:Type ComboBoxItem}"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="#009DFF" /> | |||||
</Style> | |||||
</ComboBox.ItemContainerStyle> | |||||
</ComboBox> | |||||
<!--<TextBox | |||||
Grid.Column="1" | |||||
Width="170" | |||||
Height="35" | |||||
HorizontalAlignment="Right" | |||||
FontSize="20" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding CommBaseParModel.StockCount, 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.StockCount, UpdateSourceTrigger=PropertyChanged}" /> | |||||
</Grid> | |||||
<Grid Width="350" Margin="5"> | <Grid Width="350" Margin="5"> | ||||
<Grid.ColumnDefinitions> | <Grid.ColumnDefinitions> | ||||
<ColumnDefinition /> | <ColumnDefinition /> | ||||
@@ -99,13 +99,14 @@ | |||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
FontSize="20" | FontSize="20" | ||||
Foreground="#00c2f4" | Foreground="#00c2f4" | ||||
Text="输送带控制" /> | |||||
Text="输送带状态" /> | |||||
<ToggleButton | <ToggleButton | ||||
Width="80" | Width="80" | ||||
Height="30" | Height="30" | ||||
Margin="5,0,5,0" | Margin="5,0,5,0" | ||||
Background="Transparent" | Background="Transparent" | ||||
IsEnabled="False" | |||||
FontSize="20" | FontSize="20" | ||||
IsChecked="{Binding ConveyerBeltWork}" | IsChecked="{Binding ConveyerBeltWork}" | ||||
Style="{StaticResource SwitchToggleButtonStyle}" /> | Style="{StaticResource SwitchToggleButtonStyle}" /> | ||||
@@ -35,17 +35,19 @@ | |||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | ||||
<ListView.ItemsPanel> | <ListView.ItemsPanel> | ||||
<ItemsPanelTemplate> | <ItemsPanelTemplate> | ||||
<!--<WrapPanel Orientation="Horizontal" IsItemsHost="True"/>--> | |||||
<UniformGrid | <UniformGrid | ||||
HorizontalAlignment="Left" | HorizontalAlignment="Left" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
Columns="8" | |||||
Columns="{Binding StockNum}" | |||||
Rows="1" /> | Rows="1" /> | ||||
</ItemsPanelTemplate> | </ItemsPanelTemplate> | ||||
</ListView.ItemsPanel> | </ListView.ItemsPanel> | ||||
<ListView.ItemTemplate> | <ListView.ItemTemplate> | ||||
<DataTemplate> | <DataTemplate> | ||||
<Border Margin="5" Background="Transparent"> | <Border Margin="5" Background="Transparent"> | ||||
<Grid Background="Transparent"> | <Grid Background="Transparent"> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
@@ -105,6 +107,8 @@ | |||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<StackPanel Background="Transparent"> | <StackPanel Background="Transparent"> | ||||
<Ellipse | <Ellipse | ||||
Width="30" | Width="30" | ||||
Height="30" | Height="30" | ||||
@@ -129,9 +133,13 @@ | |||||
FontSize="16" | FontSize="16" | ||||
Foreground="#00c2f4" | Foreground="#00c2f4" | ||||
Text="到位检测" /> | Text="到位检测" /> | ||||
</StackPanel> | </StackPanel> | ||||
<StackPanel Name="skp" Grid.Column="1"> | <StackPanel Name="skp" Grid.Column="1"> | ||||
<ToggleButton | <ToggleButton | ||||
Width="80" | Width="80" | ||||
Height="30" | Height="30" | ||||
@@ -150,6 +158,7 @@ | |||||
FontSize="16" | FontSize="16" | ||||
Foreground="#00c2f4" | Foreground="#00c2f4" | ||||
Text="出料控制" /> | Text="出料控制" /> | ||||
</StackPanel> | </StackPanel> | ||||
</Grid> | </Grid> | ||||
@@ -191,6 +200,7 @@ | |||||
</Grid> | </Grid> | ||||
</Grid> | </Grid> | ||||
</Border> | </Border> | ||||
</DataTemplate> | </DataTemplate> | ||||
</ListView.ItemTemplate> | </ListView.ItemTemplate> | ||||
</ListView> | </ListView> | ||||
@@ -332,7 +342,7 @@ | |||||
<UniformGrid | <UniformGrid | ||||
HorizontalAlignment="Left" | HorizontalAlignment="Left" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
Columns="8" | |||||
Columns="{Binding StockNum}" | |||||
Rows="1" /> | Rows="1" /> | ||||
</ItemsPanelTemplate> | </ItemsPanelTemplate> | ||||
</ListView.ItemsPanel> | </ListView.ItemsPanel> | ||||
@@ -391,57 +401,63 @@ | |||||
</StackPanel> | </StackPanel> | ||||
<StackPanel Grid.Row="2" Orientation="Horizontal"> | |||||
<StackPanel Background="Transparent"> | |||||
<Ellipse | |||||
<!--<StackPanel Grid.Row="2" Orientation="Horizontal">--> | |||||
<Grid Grid.Row="2"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition/> | |||||
<ColumnDefinition/> | |||||
</Grid.ColumnDefinitions> | |||||
<StackPanel Background="Transparent"> | |||||
<Ellipse | |||||
Width="30" | Width="30" | ||||
Height="30" | Height="30" | ||||
HorizontalAlignment="Center" | HorizontalAlignment="Center" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
Fill="{Binding BucketFlagbit, Converter={StaticResource BoolToFillColorConverter}}" | Fill="{Binding BucketFlagbit, Converter={StaticResource BoolToFillColorConverter}}" | ||||
RenderTransformOrigin="0.5,0.5"> | RenderTransformOrigin="0.5,0.5"> | ||||
<Ellipse.OpacityMask> | |||||
<RadialGradientBrush> | |||||
<GradientStop Offset="0" Color="Transparent" /> | |||||
<GradientStop Offset="1" Color="#00c2f4" /> | |||||
</RadialGradientBrush> | |||||
</Ellipse.OpacityMask> | |||||
<!--<Ellipse.RenderTransform> | |||||
<Ellipse.OpacityMask> | |||||
<RadialGradientBrush> | |||||
<GradientStop Offset="0" Color="Transparent" /> | |||||
<GradientStop Offset="1" Color="#00c2f4" /> | |||||
</RadialGradientBrush> | |||||
</Ellipse.OpacityMask> | |||||
<!--<Ellipse.RenderTransform> | |||||
<ScaleTransform x:Name="Scale" /> | <ScaleTransform x:Name="Scale" /> | ||||
</Ellipse.RenderTransform>--> | </Ellipse.RenderTransform>--> | ||||
</Ellipse> | |||||
</Ellipse> | |||||
<TextBlock | |||||
<TextBlock | |||||
Margin="0,5,0,0" | Margin="0,5,0,0" | ||||
HorizontalAlignment="Center" | HorizontalAlignment="Center" | ||||
FontSize="16" | FontSize="16" | ||||
Foreground="#00c2f4" | Foreground="#00c2f4" | ||||
Text="到位检测" /> | Text="到位检测" /> | ||||
</StackPanel> | |||||
</StackPanel> | |||||
<StackPanel> | |||||
<ToggleButton | |||||
<StackPanel Grid.Column="1"> | |||||
<ToggleButton | |||||
Width="80" | Width="80" | ||||
Height="30" | Height="30" | ||||
Margin="5,0,5,0" | Margin="5,0,5,0" | ||||
HorizontalAlignment="Center" | |||||
HorizontalAlignment="Right" | |||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
Background="Transparent" | Background="Transparent" | ||||
FontSize="20" | FontSize="20" | ||||
IsChecked="{Binding BaitingControl}" | IsChecked="{Binding BaitingControl}" | ||||
Style="{StaticResource SwitchToggleButtonStyle}" /> | Style="{StaticResource SwitchToggleButtonStyle}" /> | ||||
<TextBlock | |||||
<TextBlock | |||||
Margin="0,5,0,0" | Margin="0,5,0,0" | ||||
HorizontalAlignment="Center" | |||||
HorizontalAlignment="Right" | |||||
FontSize="16" | FontSize="16" | ||||
Foreground="#00c2f4" | Foreground="#00c2f4" | ||||
Text="出料控制" /> | Text="出料控制" /> | ||||
</StackPanel> | |||||
</StackPanel> | |||||
<Image | |||||
</StackPanel> | |||||
<!--</StackPanel>--> | |||||
</Grid> | |||||
<Image | |||||
Margin="20,30,20,0" | Margin="20,30,20,0" | ||||
Source="/BPASmartClient.CustomResource;component/Image/荧光/矩形发光.png" | Source="/BPASmartClient.CustomResource;component/Image/荧光/矩形发光.png" | ||||
Stretch="Fill" | Stretch="Fill" | ||||
@@ -7,6 +7,7 @@ | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | ||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -47,12 +48,14 @@ | |||||
</Setter.Value> | </Setter.Value> | ||||
</Setter> | </Setter> | ||||
</Style> | </Style> | ||||
</UserControl.Resources> | </UserControl.Resources> | ||||
<UserControl.DataContext> | <UserControl.DataContext> | ||||
<vm:ManualControlViewModel /> | <vm:ManualControlViewModel /> | ||||
</UserControl.DataContext> | </UserControl.DataContext> | ||||
<Grid> | <Grid> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition Height="40" /> | <RowDefinition Height="40" /> | ||||
@@ -0,0 +1,396 @@ | |||||
<UserControl x:Class="BPASmartClient.DosingSystem.View.UHardwareStatusView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
<UserControl.DataContext> | |||||
<vm:UHardwareStatusViewModel/> | |||||
</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> | |||||
<UniformGrid | |||||
HorizontalAlignment="Left" | |||||
VerticalAlignment="Top" | |||||
Columns="{Binding StockNum}" | |||||
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" | |||||
Margin="0,10,0,0"> | |||||
<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="{Binding ConveyerBeltStatus}" | |||||
StrokeBrush="#00BEFA" | |||||
StrokeDashArray="1.5 1.5" | |||||
StrokeFillBrush="#00BEFA" | |||||
StrokeThickness="2" /> | |||||
</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="{Binding StockNum}" | |||||
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">--> | |||||
<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 Grid.Column="1"> | |||||
<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>--> | |||||
</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--> | |||||
</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.DosingSystem.View | |||||
{ | |||||
/// <summary> | |||||
/// UHardwareStatusView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class UHardwareStatusView : UserControl | |||||
{ | |||||
public UHardwareStatusView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -37,6 +37,8 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
public BasePar CommBaseParModel { get { return Json<DevicePar>.Data.BaseParModel; } set { Json<DevicePar>.Data.BaseParModel = value; OnPropertyChanged(); } } | public BasePar CommBaseParModel { get { return Json<DevicePar>.Data.BaseParModel; } set { Json<DevicePar>.Data.BaseParModel = value; OnPropertyChanged(); } } | ||||
//private BasePar _mCommBaseParModel; | //private BasePar _mCommBaseParModel; | ||||
public BPARelayCommand SaveCommand { get; set; } | public BPARelayCommand SaveCommand { get; set; } | ||||
} | } | ||||
@@ -20,7 +20,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
Num = i + 1, | Num = i + 1, | ||||
Speed = GlobalDevice.MotorSpeed[i], | Speed = GlobalDevice.MotorSpeed[i], | ||||
ConveyerBeltWork = GlobalDevice.MotorControl.GetBitValue((byte)(i + 1)) | ConveyerBeltWork = GlobalDevice.MotorControl.GetBitValue((byte)(i + 1)) | ||||
}); | |||||
}) ; | |||||
} | } | ||||
} | } | ||||
public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | ||||
@@ -8,7 +8,7 @@ using System.Collections.Concurrent; | |||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using System.Windows; | using System.Windows; | ||||
using BPASmartClient.DosingSystem.View; | using BPASmartClient.DosingSystem.View; | ||||
using System.Windows.Data; | |||||
namespace BPASmartClient.DosingSystem.ViewModel | namespace BPASmartClient.DosingSystem.ViewModel | ||||
{ | { | ||||
@@ -16,6 +16,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public DeviceListViewModel() | public DeviceListViewModel() | ||||
{ | { | ||||
DetailsCommand = new BPARelayCommand<object>((o) => | DetailsCommand = new BPARelayCommand<object>((o) => | ||||
{ | { | ||||
if (o != null && o is string str) | if (o != null && o is string str) | ||||
@@ -25,13 +26,24 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
cdn.ShowDialog(); | cdn.ShowDialog(); | ||||
} | } | ||||
}); | }); | ||||
devices = DeviceInquire.GetInstance.devices; | |||||
//devices = DeviceInquire.GetInstance.devices; | |||||
//2023/6/29新加 改为升序排列显示 | |||||
devices = ConvertToObservableCollention(DeviceInquire.GetInstance.devices.OrderByDescending(p => p.IpAddress.Split(".")[3]).Reverse()); | |||||
} | } | ||||
//public BPARelayCommand<object> ChangeNameCommand { get; set; } | |||||
//public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>(); | |||||
public ObservableCollection<Devices> devices { get; set; } | public ObservableCollection<Devices> devices { get; set; } | ||||
public ObservableCollection<T> ConvertToObservableCollention<T>(IEnumerable<T> array) | |||||
{ | |||||
ObservableCollection<T> collec =new ObservableCollection<T>(); | |||||
foreach (var item in array) | |||||
{ | |||||
collec.Add(item); | |||||
} | |||||
return collec; | |||||
} | |||||
} | } | ||||
public class Devices : NotifyBase | public class Devices : NotifyBase | ||||
@@ -8,6 +8,7 @@ using System.Collections.Concurrent; | |||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using System.Windows; | using System.Windows; | ||||
using System.Threading; | using System.Threading; | ||||
using BPASmartClient.DosingSystem.Model; | |||||
namespace BPASmartClient.DosingSystem.ViewModel | namespace BPASmartClient.DosingSystem.ViewModel | ||||
{ | { | ||||
@@ -15,9 +16,14 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public HardwareStatusViewModel() | public HardwareStatusViewModel() | ||||
{ | { | ||||
TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; | |||||
BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; | |||||
//TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; | |||||
//BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; | |||||
//2023/7/3调整 | |||||
TopDeviceCurrentStatuses = ConvertToObservableCollention(DeviceInquire.GetInstance.TopDeviceCurrentStatuses.OrderByDescending(p => p.DeviceNum).Reverse()); | |||||
BottomDeviceCurrentStatuses = ConvertToObservableCollention(DeviceInquire.GetInstance.BottomDeviceCurrentStatuses.OrderByDescending(p => p.DeviceNum).Reverse()); | |||||
UnifordColumNum(); | |||||
//for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.ConveyerBeltCount; i++) | //for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.ConveyerBeltCount; i++) | ||||
//{ | //{ | ||||
// ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i}", Num = i++ }); | // ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i}", Num = i++ }); | ||||
@@ -60,7 +66,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
UnderDetection = GlobalDevice.PlcData.UnderDetection; | UnderDetection = GlobalDevice.PlcData.UnderDetection; | ||||
ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0; | ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0; | ||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), "输送带料仓状态监控",true); | |||||
}), "输送带料仓状态监控", true); | |||||
RecipeControlCommand = new BPARelayCommand<object>((o) => | RecipeControlCommand = new BPARelayCommand<object>((o) => | ||||
{ | { | ||||
@@ -74,7 +80,21 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
/// <summary> | |||||
/// 数组集合转换 | |||||
/// </summary> | |||||
/// <typeparam name="T"></typeparam> | |||||
/// <param name="array"></param> | |||||
/// <returns></returns> | |||||
public ObservableCollection<T> ConvertToObservableCollention<T>(IEnumerable<T> array) | |||||
{ | |||||
ObservableCollection<T> collec = new ObservableCollection<T>(); | |||||
foreach (var item in array) | |||||
{ | |||||
collec.Add(item); | |||||
} | |||||
return collec; | |||||
} | |||||
private void StatusUpdate(ObservableCollection<DeviceCurrentStatus> devices) | private void StatusUpdate(ObservableCollection<DeviceCurrentStatus> devices) | ||||
{ | { | ||||
if (devices == null) return; | if (devices == null) return; | ||||
@@ -102,7 +122,30 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
} | } | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 根据料仓数来进行uniform列划分 | |||||
/// </summary> | |||||
private void UnifordColumNum() | |||||
{ | |||||
StockNum = TopDeviceCurrentStatuses.Count >= BottomDeviceCurrentStatuses.Count ? TopDeviceCurrentStatuses.Count : BottomDeviceCurrentStatuses.Count; | |||||
//switch ((ConveryType)System.Enum.Parse(typeof(ConveryType), Json<DevicePar>.Data.BaseParModel.ConveryType)) | |||||
//{ | |||||
// case ConveryType.直线型: StockNum = Json<DevicePar>.Data.BaseParModel.StockCount; break; | |||||
// //case ConveryType.直线型: | |||||
// // if (Json<DevicePar>.Data.BaseParModel.StockCount > 0 && Json<DevicePar>.Data.BaseParModel.StockCount % 2 == 0) | |||||
// // { | |||||
// // StockNum = Json<DevicePar>.Data.BaseParModel.StockCount / 2; | |||||
// // } | |||||
// // else | |||||
// // { | |||||
// // StockNum = 8;//默认值 | |||||
// // } | |||||
// // break; | |||||
//} | |||||
} | |||||
public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } | public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } | ||||
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } | public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } | ||||
@@ -112,7 +155,11 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
public BPARelayCommand<object> ConveyerBeltControlCommand { get; set; } | public BPARelayCommand<object> ConveyerBeltControlCommand { get; set; } | ||||
public BPARelayCommand<object> RecipeControlCommand { get; set; } | public BPARelayCommand<object> RecipeControlCommand { get; set; } | ||||
/// <summary> | |||||
/// Uniford根据料仓数量来划分列数量 | |||||
/// </summary> | |||||
private int _stockNum; | |||||
public int StockNum { get { return _stockNum; } set { _stockNum = value; OnPropertyChanged(); } } | |||||
/// <summary> | /// <summary> | ||||
/// 输送带状态 | /// 输送带状态 | ||||
/// </summary> | /// </summary> | ||||
@@ -135,6 +135,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
SystemStatus = GlobalDevice.PlcData.SystemStartOrStop ? "启动" : "停止"; | SystemStatus = GlobalDevice.PlcData.SystemStartOrStop ? "启动" : "停止"; | ||||
SystemMode = GlobalDevice.PlcData.HandOrAuto ? "自动" : "手动"; | SystemMode = GlobalDevice.PlcData.HandOrAuto ? "自动" : "手动"; | ||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), "手动气缸状态监控", true); | }), "手动气缸状态监控", true); | ||||
} | } | ||||
@@ -147,7 +148,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
var res1 = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1").Content; | var res1 = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1").Content; | ||||
ModelSwitchText = res1 ? "自动" : "手动"; | ModelSwitchText = res1 ? "自动" : "手动"; | ||||
SystemStatus = res ? "自动" : "手动"; | |||||
SystemStatus = res1 ? "自动" : "手动"; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -134,6 +134,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
//配方数据写入到输送机 | //配方数据写入到输送机 | ||||
var res = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeName == CurrentRecipeName); | var res = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeName == CurrentRecipeName); | ||||
List<int> BarrelNum = new List<int>(); | List<int> BarrelNum = new List<int>(); | ||||
ConcurrentDictionary<string, int[]> values = new (); | |||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
var tInfo = res.RawMaterials.GroupBy(p => p.Loc);//获取桶号信息 | var tInfo = res.RawMaterials.GroupBy(p => p.Loc);//获取桶号信息 | ||||
@@ -151,20 +152,28 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
/*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/ | /*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/ | ||||
if (tempDevice.DeviceNum > 0) | if (tempDevice.DeviceNum > 0) | ||||
{ | { | ||||
//int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true); | |||||
//byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); | |||||
//int item = test1.ToInt(); | |||||
// //int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true); | |||||
// //byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); | |||||
// //int item = test1.ToInt(); | |||||
// int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt(); | |||||
// int item1 = SiemensDevice.GetInstance.MySiemens.Read<int>($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}").Content; | |||||
////prop1: | |||||
// var RE = SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item + item1); | |||||
// //var values = SiemensDevice.GetInstance.MySiemens.Read<int>($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}"); | |||||
// //if ((values != null && values.ToString() != (item + item1).ToString()) || values == null) | |||||
// // goto prop1; | |||||
// if (RE.IsSuccess) | |||||
// MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{(byte)tInfo.ElementAt(i).ElementAt(m).Loc}-{item + item1}-{(item + item1).ToBinString()}"); | |||||
// else | |||||
// MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} 失败"); | |||||
int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt(); | int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt(); | ||||
int item1 = SiemensDevice.GetInstance.MySiemens.Read<int>($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}").Content; | |||||
prop1: | |||||
var RE = SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item + item1); | |||||
var values = SiemensDevice.GetInstance.MySiemens.Read<int>($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}").Content; | |||||
if ((values != null && values.ToString() != (item + item1).ToString()) || values == null) | |||||
goto prop1; | |||||
if (RE.IsSuccess) | |||||
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{(byte)tInfo.ElementAt(i).ElementAt(m).Loc}-{item + item1}-{(item + item1).ToBinString()}"); | |||||
else | |||||
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} 失败"); | |||||
string tempAdd = $"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}"; | |||||
if (!values.ContainsKey(tempAdd)) values.TryAdd(tempAdd, new int[2] { 0,0}); | |||||
values[tempAdd][0] = values[tempAdd][0] + item; | |||||
values[tempAdd][1] = tInfo.ElementAt(i).ElementAt(m).Loc; | |||||
} | } | ||||
} | } | ||||
if (tInfo.ElementAt(i).ElementAt(m).Loc > 0) | if (tInfo.ElementAt(i).ElementAt(m).Loc > 0) | ||||
@@ -175,29 +184,24 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
} | } | ||||
} | } | ||||
} | } | ||||
/*recipeData.Add(data);*/ | |||||
} | } | ||||
} | } | ||||
} | } | ||||
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", BarrelNum.Count);//配方使用桶数写入 | |||||
/*if (recipeData.Count <= 0) | |||||
{ | |||||
MessageNotify.GetInstance.ShowRunLog("配方数据解析失败"); | |||||
return; | |||||
}*/ | |||||
/*int offset = 2; | |||||
//写入配方数据 | |||||
MessageNotify.GetInstance.ShowRunLog("开始写入配方数据"); | |||||
recipeData.ForEach(item => | |||||
values?.ToList().ForEach(x => | |||||
{ | { | ||||
byte[] test1 = item.ToBytes(BPA.Helper.DataFormat.ABCD); | |||||
item = test1.ToInt(); | |||||
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{offset}", item); | |||||
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{offset} :{item.ToBinString()}"); | |||||
offset = offset += 4; | |||||
});*/ | |||||
/*SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", recipeData.Count);//配方使用桶数写入*/ | |||||
SiemensDevice.GetInstance.MySiemens.Write(x.Key, x.Value[0]).OnSuccess(() => | |||||
{ | |||||
MessageNotify.GetInstance.ShowRunLog($"下发配方-{x.Key} :桶数:[{x.Value[1]}]-{x.Value[0].ToBinString()}"); | |||||
}).OnFail(s => | |||||
{ | |||||
MessageNotify.GetInstance.ShowRunLog($"下发配方-{x.Key} 失败"); | |||||
}); | |||||
}); | |||||
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", BarrelNum.Count);//配方使用桶数写入 | |||||
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX0.1", true);//配方执行启动 | SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX0.1", true);//配方执行启动 | ||||
Stopwatch sw = new Stopwatch(); | Stopwatch sw = new Stopwatch(); | ||||
var recipe = Recipes.ElementAt(index); | var recipe = Recipes.ElementAt(index); | ||||
@@ -721,7 +725,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
//} | //} | ||||
#endregion | #endregion | ||||
#region 测试版 | |||||
#region 正式版 | |||||
for (int i = 0; i < Recipes.Count; i++) | for (int i = 0; i < Recipes.Count; i++) | ||||
{ | { | ||||
for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++) | for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++) | ||||
@@ -738,19 +742,15 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count) | if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count) | ||||
{ | { | ||||
//测试使用 | //测试使用 | ||||
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; | recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; | ||||
} | } | ||||
for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++) | for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++) | ||||
{ | { | ||||
if (GlobalDevice.PlcData.IsAllowIngredients[j]) | if (GlobalDevice.PlcData.IsAllowIngredients[j]) | ||||
{ | { | ||||
int barrel = j + 1;//桶号 | int barrel = j + 1;//桶号 | ||||
int cnt = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的位置 0~6 | |||||
int cnt = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的位置 1~6 | |||||
if (RTrig.GetInstance($"a{j}").Start(GlobalDevice.PlcData.IsAllowIngredients[j])) | if (RTrig.GetInstance($"a{j}").Start(GlobalDevice.PlcData.IsAllowIngredients[j])) | ||||
{ | { | ||||
MessageNotify.GetInstance.ShowRunLog($"桶号:{barrel},位置:{cnt},允许配料"); | MessageNotify.GetInstance.ShowRunLog($"桶号:{barrel},位置:{cnt},允许配料"); | ||||
@@ -771,10 +771,8 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); | Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); | ||||
} | } | ||||
//Location2 = Location1; | |||||
} | } | ||||
} | } | ||||
if (Location1 >= 0) | if (Location1 >= 0) | ||||
{ | { | ||||
@@ -789,7 +787,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
if (loc >= 0 && RawName != null && weight >= 0) | if (loc >= 0 && RawName != null && weight >= 0) | ||||
{ | { | ||||
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); | int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); | ||||
// int materialCount = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RawMaterialName == RawName).Count(); | |||||
if (St_index < 0) //|| (StockStatus.Count < materialCount && St_index > 0) | if (St_index < 0) //|| (StockStatus.Count < materialCount && St_index > 0) | ||||
{ | { | ||||
StockStatus.Add(new StockStatusModel() | StockStatus.Add(new StockStatusModel() | ||||
@@ -800,8 +798,6 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
}); | }); | ||||
} | } | ||||
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);//&& p.IssueStatus == 0) | St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);//&& p.IssueStatus == 0) | ||||
// int St_index1 = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 1)); | |||||
if (St_index >= 0) | if (St_index >= 0) | ||||
{ | { | ||||
@@ -857,228 +853,18 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
var res = recipeProcesses.ElementAt(recIndex).RawMaterials.FirstOrDefault(p => p.Status != Status.配料完成 && p.RawMaterialName == tempRawMaterialName && p.Loc == j + 1); | var res = recipeProcesses.ElementAt(recIndex).RawMaterials.FirstOrDefault(p => p.Status != Status.配料完成 && p.RawMaterialName == tempRawMaterialName && p.Loc == j + 1); | ||||
if (res != null) | if (res != null) | ||||
res.Status = Status.配料完成; | res.Status = Status.配料完成; | ||||
//var values = SiemensDevice.GetInstance.MySiemens.Read<int>("DB4.DBD130").Content; | |||||
//if ((values != null && values.ToString() != item.ToString()) || values == null) | |||||
// goto prop1; | |||||
//SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", true).OnSuccess(() => | |||||
//{ | |||||
// MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!"); | |||||
//}).OnFail(s => | |||||
//{ | |||||
// MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入失败!{s}"); | |||||
//}); | |||||
MessageNotify.GetInstance.ShowRunLog($"设备完成执行状态:{rrr}"); | MessageNotify.GetInstance.ShowRunLog($"设备完成执行状态:{rrr}"); | ||||
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); | MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); | ||||
} | } | ||||
//测试 | |||||
//if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index1).IssueStatus == 1) | |||||
//{ | |||||
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 | |||||
// StockStatus.ElementAt(St_index1).IssueStatus = 2; | |||||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); | |||||
// int a = 0.SetBitValue((byte)(DeviceNum), true); | |||||
// byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); | |||||
// int item = test1.ToInt(); | |||||
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item); | |||||
// //MessageNotify.GetInstance.ShowRunLog($"{res}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); | |||||
//} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
//调试 | |||||
//if (Location1 >= 0) | |||||
//{ | |||||
// string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialName; | |||||
// int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName); | |||||
// int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum; | |||||
// if (DeviceNum > 0) | |||||
// { | |||||
// float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialWeight; | |||||
// //测试 | |||||
// // int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => (p.RawMaterialName == RawName)); | |||||
// if (Location1 >= 0 && RawName != null && weight >= 0) | |||||
// { | |||||
// int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); | |||||
// int materialCount = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RawMaterialName == RawName).Count(); | |||||
// if (St_index < 0 || (StockStatus.Count < materialCount && St_index > 0)) | |||||
// { | |||||
// StockStatus.Add(new StockStatusModel() | |||||
// { | |||||
// MaterialName = RawName, | |||||
// IssueWeight = weight, | |||||
// IssueStatus = 0, | |||||
// }); | |||||
// } | |||||
// St_index = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 0)); | |||||
// int St_index1 = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 1)); | |||||
// if (St_index >= 0) | |||||
// { | |||||
// if ((recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(Location1).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0))// | |||||
// { | |||||
// StockStatus.ElementAt(St_index).IssueStatus = 1; | |||||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).DeviceIp).Start(weight); | |||||
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).DeviceIp},开始出料"); | |||||
// } | |||||
// //if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) | |||||
// //{ | |||||
// // //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 | |||||
// // StockStatus.ElementAt(St_index).IssueStatus = 2; | |||||
// // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); | |||||
// // int a = 0.SetBitValue((byte)(DeviceNum), true); | |||||
// // byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); | |||||
// // int item = test1.ToInt(); | |||||
// // SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item); | |||||
// // //MessageNotify.GetInstance.ShowRunLog($"{res}"); | |||||
// // MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); | |||||
// // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); | |||||
// //} | |||||
// //测试 | |||||
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(Location1).RecipeStatus == 3 && StockStatus.ElementAt(St_index1).IssueStatus == 1) | |||||
// { | |||||
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 | |||||
// StockStatus.ElementAt(St_index1).IssueStatus = 2; | |||||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).DeviceIp).StatusReset(); | |||||
// int a = 0.SetBitValue((byte)(DeviceNum), true); | |||||
// byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); | |||||
// int item = test1.ToInt(); | |||||
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item); | |||||
// //MessageNotify.GetInstance.ShowRunLog($"{res}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).DeviceIp},出料完成,状态复位"); | |||||
// } | |||||
// } | |||||
// } | |||||
// } | |||||
//} | |||||
//if (Location1 >= 0) | |||||
//{ | |||||
// string RawName111 = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialName; | |||||
// int St_index111 = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName111); | |||||
// if (Location2 >= 0 && ((Location1 >= 0 && StockStatus.ElementAt(St_index111).IssueStatus == 2))) | |||||
// { | |||||
// string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName; | |||||
// int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName); | |||||
// int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum; | |||||
// if (DeviceNum > 0) | |||||
// { | |||||
// float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight; | |||||
// int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName); | |||||
// if (loc >= 0 && RawName != null && weight >= 0) | |||||
// { | |||||
// int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); | |||||
// if (St_index < 0) | |||||
// { | |||||
// StockStatus.Add(new StockStatusModel() | |||||
// { | |||||
// MaterialName = RawName, | |||||
// IssueWeight = weight, | |||||
// IssueStatus = 0, | |||||
// }); | |||||
// } | |||||
// St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); | |||||
// if (St_index >= 0) | |||||
// { | |||||
// if (RTrig.GetInstance($"ac{j}").Start(GlobalDevice.PlcData.IsAllowIngredients[j])) | |||||
// { | |||||
// if (StockStatus.ElementAt(St_index).IssueStatus == 2) | |||||
// StockStatus.ElementAt(St_index).IssueStatus = 0; | |||||
// } | |||||
// var rrr = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.RunStatus; | |||||
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0) | |||||
// { | |||||
// StockStatus.ElementAt(St_index).IssueStatus = 1; | |||||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); | |||||
// MessageNotify.GetInstance.ShowRunLog($"设备执行状态:{rrr}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); | |||||
// } | |||||
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) | |||||
// { | |||||
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 | |||||
// StockStatus.ElementAt(St_index).IssueStatus = 2; | |||||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); | |||||
// int a = 0.SetBitValue((byte)(DeviceNum), true); | |||||
// byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); | |||||
// int item = test1.ToInt(); | |||||
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item); | |||||
// //MessageNotify.GetInstance.ShowRunLog($"{res}"); | |||||
// //MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"设备wancheng执行状态:{rrr}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); | |||||
// } | |||||
// } | |||||
// } | |||||
// } | |||||
// } | |||||
//} | |||||
//else | |||||
//{ | |||||
// if (Location2 >= 0) | |||||
// { | |||||
// string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName; | |||||
// int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName); | |||||
// int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum; | |||||
// if (DeviceNum >= 0) | |||||
// { | |||||
// float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight; | |||||
// int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName); | |||||
// if (cnt > 0 && loc >= 0 && RawName != null && weight >= 0) | |||||
// { | |||||
// int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); | |||||
// if (St_index < 0) | |||||
// { | |||||
// StockStatus.Add(new StockStatusModel() | |||||
// { | |||||
// MaterialName = RawName, | |||||
// IssueWeight = weight, | |||||
// IssueStatus = 0, | |||||
// }); | |||||
// } | |||||
// St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); | |||||
// if (St_index >= 0) | |||||
// { | |||||
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0) | |||||
// { | |||||
// StockStatus.ElementAt(St_index).IssueStatus = 1; | |||||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); | |||||
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); | |||||
// } | |||||
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) | |||||
// { | |||||
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 | |||||
// StockStatus.ElementAt(St_index).IssueStatus = 2; | |||||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); | |||||
// int a = 0.SetBitValue((byte)(DeviceNum), true); | |||||
// byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); | |||||
// int item = test1.ToInt(); | |||||
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item); | |||||
// recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).UpLimtWeightFeedback = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.NowWeightFeedback; | |||||
// //MessageNotify.GetInstance.ShowRunLog($"{res}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); | |||||
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); | |||||
// } | |||||
// } | |||||
// } | |||||
// } | |||||
// } | |||||
//} | |||||
} | } | ||||
//508配料项目代码 | //508配料项目代码 | ||||
//if (GlobalDevice.PlcData.IsAllowIngredients[j]) | //if (GlobalDevice.PlcData.IsAllowIngredients[j]) | ||||
@@ -1164,8 +950,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
// } | // } | ||||
//} | //} | ||||
} | } | ||||
//int Finish_Count = StockStatus.Where(s => s.IssueStatus == 2).Count(); | |||||
//int Finish_Count = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RecipeStatus == 3).Count(); | |||||
if (ComCount >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && | if (ComCount >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && | ||||
{ | { | ||||
int cc = recipeProcesses.ElementAt(recIndex).RawMaterials.OrderBy(p => p.RawMaterialName).Count(); | int cc = recipeProcesses.ElementAt(recIndex).RawMaterials.OrderBy(p => p.RawMaterialName).Count(); | ||||
@@ -0,0 +1,170 @@ | |||||
using BPA.Helper; | |||||
using BPASmartClient.DosingSystem.Model; | |||||
using BPASmartClient.DosingSystem; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | |||||
public class UHardwareStatusViewModel : NotifyBase | |||||
{ | |||||
public UHardwareStatusViewModel() | |||||
{ | |||||
//TopDeviceCurrentStatuses = new ObservableCollection<DeviceCurrentStatus>(); | |||||
//TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }) ; | |||||
//TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//BottomDeviceCurrentStatuses = new ObservableCollection<DeviceCurrentStatus>(); | |||||
//BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus { DeviceNum = 1 }); | |||||
//TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; | |||||
//BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; | |||||
//2023/7/3调整 | |||||
TopDeviceCurrentStatuses= ConvertToObservableCollention(DeviceInquire.GetInstance.TopDeviceCurrentStatuses.OrderByDescending(p => p.DeviceNum).Reverse()); | |||||
BottomDeviceCurrentStatuses = ConvertToObservableCollention(DeviceInquire.GetInstance.BottomDeviceCurrentStatuses.OrderByDescending(p => p.DeviceNum).Reverse()); | |||||
UnifordColumNum(); | |||||
TaskManage.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?2: GlobalDevice.MotorControlFeedback; | |||||
Thread.Sleep(100); | |||||
}), "输送带料仓状态监控", true); | |||||
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(); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 根据料仓数来进行uniform列划分 | |||||
/// </summary> | |||||
private void UnifordColumNum() | |||||
{ | |||||
//StockNum = Json<DevicePar>.Data.BaseParModel.StockCount; | |||||
StockNum=TopDeviceCurrentStatuses.Count >= BottomDeviceCurrentStatuses.Count ? TopDeviceCurrentStatuses.Count : BottomDeviceCurrentStatuses.Count; | |||||
} | |||||
/// <summary> | |||||
/// 数组集合转换 | |||||
/// </summary> | |||||
/// <typeparam name="T"></typeparam> | |||||
/// <param name="array"></param> | |||||
/// <returns></returns> | |||||
public ObservableCollection<T> ConvertToObservableCollention<T>(IEnumerable<T> array) | |||||
{ | |||||
ObservableCollection<T> collec = new ObservableCollection<T>(); | |||||
foreach (var item in array) | |||||
{ | |||||
collec.Add(item); | |||||
} | |||||
return collec; | |||||
} | |||||
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> | |||||
/// Uniford根据料仓数量来划分列数量 | |||||
/// </summary> | |||||
private int _stockNum; | |||||
public int StockNum { get { return _stockNum; } set { _stockNum = value; OnPropertyChanged(); } } | |||||
/// <summary> | |||||
/// 输送带状态 | |||||
/// </summary> | |||||
public uint ConveyerBeltStatus { get { return _mConveyerBeltStatus; } set { _mConveyerBeltStatus = value; OnPropertyChanged(); } } | |||||
private uint _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; | |||||
} | |||||
} | |||||
@@ -164,6 +164,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.FoodStationT | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkCL", "BPASmartClient.MorkCL\BPASmartClient.MorkCL.csproj", "{918B73A6-B6FF-46FE-8C96-8474A5BD648B}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkCL", "BPASmartClient.MorkCL\BPASmartClient.MorkCL.csproj", "{918B73A6-B6FF-46FE-8C96-8474A5BD648B}" | ||||
EndProject | EndProject | ||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "阿里云IOT平台测试", "阿里云IOT平台测试\阿里云IOT平台测试.csproj", "{774286FD-0C88-4592-972C-101239F75954}" | |||||
EndProject | |||||
Global | Global | ||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
Debug|Any CPU = Debug|Any CPU | Debug|Any CPU = Debug|Any CPU | ||||
@@ -1538,6 +1540,26 @@ Global | |||||
{918B73A6-B6FF-46FE-8C96-8474A5BD648B}.Release|x64.Build.0 = Release|Any CPU | {918B73A6-B6FF-46FE-8C96-8474A5BD648B}.Release|x64.Build.0 = Release|Any CPU | ||||
{918B73A6-B6FF-46FE-8C96-8474A5BD648B}.Release|x86.ActiveCfg = Release|Any CPU | {918B73A6-B6FF-46FE-8C96-8474A5BD648B}.Release|x86.ActiveCfg = Release|Any CPU | ||||
{918B73A6-B6FF-46FE-8C96-8474A5BD648B}.Release|x86.Build.0 = Release|Any CPU | {918B73A6-B6FF-46FE-8C96-8474A5BD648B}.Release|x86.Build.0 = Release|Any CPU | ||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|ARM.Build.0 = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|ARM64.Build.0 = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|x64.ActiveCfg = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|x64.Build.0 = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|x86.ActiveCfg = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Debug|x86.Build.0 = Debug|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|ARM.ActiveCfg = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|ARM.Build.0 = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|ARM64.ActiveCfg = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|ARM64.Build.0 = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|x64.ActiveCfg = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|x64.Build.0 = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|x86.ActiveCfg = Release|Any CPU | |||||
{774286FD-0C88-4592-972C-101239F75954}.Release|x86.Build.0 = Release|Any CPU | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(SolutionProperties) = preSolution | GlobalSection(SolutionProperties) = preSolution | ||||
HideSolutionNode = FALSE | HideSolutionNode = FALSE | ||||
@@ -0,0 +1,10 @@ | |||||
namespace 阿里云IOT平台测试 | |||||
{ | |||||
internal class Program | |||||
{ | |||||
static void Main(string[] args) | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,10 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>net6.0</TargetFramework> | |||||
<ImplicitUsings>enable</ImplicitUsings> | |||||
<Nullable>enable</Nullable> | |||||
</PropertyGroup> | |||||
</Project> |