Kaynağa Gözat

吉香居小料站代码更新

样式分支
pengliangyang 2 yıl önce
ebeveyn
işleme
5b7f1976b6
35 değiştirilmiş dosya ile 2028 ekleme ve 554 silme
  1. +2
    -2
      BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs
  2. +34
    -9
      BPASmartClient.JXJFoodSmallStation/App.xaml.cs
  3. +27
    -0
      BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
  4. +31
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs
  5. +68
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs
  6. +135
    -46
      BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs
  7. +3
    -3
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  8. +48
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs
  9. +57
    -61
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs
  10. +4
    -1
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs
  11. +15
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs
  12. +75
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs
  13. +15
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs
  14. +3
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs
  15. +17
    -2
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs
  16. +0
    -1
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs
  17. +40
    -26
      BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml
  18. +369
    -0
      BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml
  19. +28
    -0
      BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml.cs
  20. +170
    -279
      BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml
  21. +175
    -0
      BPASmartClient.JXJFoodSmallStation/View/NewMaterialView.xaml
  22. +35
    -0
      BPASmartClient.JXJFoodSmallStation/View/NewMaterialView.xaml.cs
  23. +17
    -3
      BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml
  24. +288
    -4
      BPASmartClient.JXJFoodSmallStation/View/RecipeControlView.xaml
  25. +29
    -1
      BPASmartClient.JXJFoodSmallStation/View/RecipeControlView.xaml.cs
  26. +11
    -69
      BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml
  27. +19
    -0
      BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml.cs
  28. +3
    -3
      BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs
  29. +4
    -1
      BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs
  30. +69
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceMaterialParViewModel.cs
  31. +5
    -11
      BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs
  32. +58
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/NewMaterialViewModel.cs
  33. +65
    -27
      BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs
  34. +98
    -3
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs
  35. +11
    -2
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeSettingsViewModel.cs

+ 2
- 2
BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs Dosyayı Görüntüle

@@ -64,8 +64,8 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
}
});

AlarmInfos = MessageLog.GetInstance.alarmLogs;
//AlarmInfos = MessageLog.GetInstance.alarmLogs;
AlarmInfos = AlarmHelper<AlarmInfo>.Alarms;
}

private void GetHistoryAlarm()


+ 34
- 9
BPASmartClient.JXJFoodSmallStation/App.xaml.cs Dosyayı Görüntüle

@@ -56,21 +56,21 @@ namespace BPASmartClient.JXJFoodSmallStation

#region 配方管理菜单
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
/*RecipeManage.Add(new SubMenumodel()
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.RecipeSettingsView"
});*/
});

/*RecipeManage.Add(new SubMenumodel()
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方下发",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.RecipeControlView"
});*/
});
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "服务配方管理",
@@ -87,6 +87,24 @@ namespace BPASmartClient.JXJFoodSmallStation
});
#endregion

#region 参数设置
ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
ParSet.Add(new SubMenumodel()
{
SubMenuName = "原料参数设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.DeviceMaterialParView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe62d;",
MainMenuName = "参数设置",
Alias = "Parameter Set",
subMenumodels = ParSet,
});
#endregion

#region 消息日志
ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
InfoLog.Add(new SubMenumodel()
@@ -174,14 +192,21 @@ namespace BPASmartClient.JXJFoodSmallStation
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.PasswordChangeView"
});

/* UserManager.Add(new SubMenumodel()
UserManager.Add(new SubMenumodel()
{
SubMenuName = "NFC登录设置",
SubMenuName = "用户管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.NfcSetView"
});*/
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()
{


+ 27
- 0
BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj Dosyayı Görüntüle

@@ -19,4 +19,31 @@
<ProjectReference Include="..\BPASmartClient.S7Net\BPASmartClient.S7Net.csproj" />
</ItemGroup>

<ItemGroup>
<Page Update="View\ChangeDeviceNameView.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\NewMaterialView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\NewRecipeView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\RecipeControlView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\RecipeSettingsView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>

</Project>

+ 31
- 0
BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs Dosyayı Görüntüle

@@ -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.JXJFoodSmallStation.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();
}
}
}

+ 68
- 0
BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs Dosyayı Görüntüle

@@ -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.JXJFoodSmallStation.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();
}
}

}

+ 135
- 46
BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs Dosyayı Görüntüle

@@ -12,6 +12,8 @@ using System.Threading;
using System.Threading.Tasks;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.Pages.Model;
using System.Collections.ObjectModel;
using BPASmartClient.Model;

namespace BPASmartClient.JXJFoodSmallStation.Model
{
@@ -27,10 +29,46 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
List<string> InvalidIP = new List<string>();//无效 IP 集合
List<string> IPLists = new List<string>();//启动 Ping 任务IP集合
ConcurrentQueue<string> IPQueues = new ConcurrentQueue<string>();//pincomplete 完成队列
ConcurrentDictionary<int, DeviceStatus> DeviceLocation = new ConcurrentDictionary<int, DeviceStatus>();

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);
if (deviceIndex >= 0 && deviceIndex < devices.Count)
{
devices.ElementAt(i).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName;
}
}
Thread.Sleep(200);
}), "设备状态监听");
}

public void Init()
{
devices.Add(new Devices() { DeviceName = "测试", IpAddress = "192.168.0.1" });
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (IPQueues.Count >= IPLists.Count)
@@ -54,14 +92,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
return new DeviceStatus();
}

public DeviceStatus GetDeviceObject(int location)
public List<DeviceStatus> GetDevice()
{
if (location >= 1 && location <= 15)
List<DeviceStatus> deviceStatuses = new List<DeviceStatus>();
foreach (var device in DeviceLists)
{
var res = DeviceLists.Values.FirstOrDefault(p => p.RawMaterialLocation == location);
if (res != null) return res;
deviceStatuses.Add(device.Value);
}
return new DeviceStatus();
return deviceStatuses;
}

private void IpAddressLines()
@@ -96,20 +134,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

DS.modbusTcp.ConnectOk = new Action(() =>
{
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20);//读取设备名称
int rawMaterialLocation = DS.modbusTcp.GetAddress(DeviceAddress.Location);
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");//读取设备名称
if (DeviceName.Length > 0)
{
DeviceLists.TryAdd(ip, DS);
DeviceLists[ip].Init(DeviceName, rawMaterialLocation);
DeviceLists[ip].Init(DeviceName);
DeviceLists[ip].modbusTcp.IsReconnect = false;
App.Current.Dispatcher.Invoke(new Action(() =>
{
DeviceListViewModel.devices.Add(new Devices()
{
DeviceName = DeviceName,
IpAddress = ip
});//加入连接的(有名称的)设备列表
//DeviceListViewModel.devices.Add(new Devices()
//{
// DeviceName = DeviceName,
// IpAddress = ip
//});//加入连接的(有名称的)设备列表

devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip });

if (TopDeviceCurrentStatuses.Count <= 8)
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName });
else
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName });


for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++)
{
@@ -118,12 +163,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip)
{
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName;
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMateriaLocation = rawMaterialLocation;
}
}
}
if (!NewRecipeViewModel.RawMaterialNames.Contains(DeviceName))
NewRecipeViewModel.RawMaterialNames.Add(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
@@ -141,14 +195,25 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
DS.modbusTcp.Disconnect = new Action(() =>
{
if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip);
var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip);
if (res != null && DeviceListViewModel.devices.Contains(res))
//var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip);
var res = devices.FirstOrDefault(P => P.IpAddress == ip);
//if (res != null && DeviceListViewModel.devices.Contains(res))
if (res != null && devices.Contains(res))
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
DeviceListViewModel.devices.Remove(res);
if (NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName))
NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName);
//DeviceListViewModel.devices.Remove(res);
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();
});

@@ -166,35 +231,51 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

public class DeviceStatus
{

#region 对象属性声明
public string DeviceName = String.Empty;
public string IpAddress => modbusTcp.IPAdress;
public bool IsConnected => modbusTcp.Connected;
public int RawMaterialLocation { get; set; }

/// <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,int rawMaterialLocation)

public void Init(string DeviceName)
{
this.DeviceName = DeviceName;
this.RawMaterialLocation = rawMaterialLocation;
AlarmHelper<AlarmInfo>.Init();
if (modbusTcp.Connected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//获取设备运行状态
var res = this.modbusTcp.Read(DeviceAddress.RunStatus);
if (res != null && res is ushort[] ushortValue)
{
if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
}
//获取设备料仓剩余重量
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);
deviceStatus.CutWeightFeedback = this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback);
deviceStatus.RawMaterialType =(ushort) this.modbusTcp.GetUint(DeviceAddress.RawMaterialType);
//var res = this.modbusTcp.Read(DeviceAddress.RunStatus);
//if (res != null && res is ushort[] ushortValue)
//{
// if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
//}


this.DeviceName = modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");
deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态
deviceStatus.WeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量
deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码

AlarmHelper<AlarmInfo>.Alarm.EStop1 = deviceStatus.DeviceAlarmCode.Get16bitValue(1);
AlarmHelper<AlarmInfo>.Alarm.Servo = deviceStatus.DeviceAlarmCode.Get16bitValue(2);
AlarmHelper<AlarmInfo>.Alarm.Inverter = deviceStatus.DeviceAlarmCode.Get16bitValue(3);
AlarmHelper<AlarmInfo>.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7);
AlarmHelper<AlarmInfo>.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8);
AlarmHelper<AlarmInfo>.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9);
Thread.Sleep(100);
}), $"{DeviceName} 开始监听", true);
}
@@ -205,28 +286,36 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
this.modbusTcp.Write(DeviceAddress.DeviceName, new ushort[20]);
this.modbusTcp.SetString(DeviceAddress.DeviceName, name);
}

public void StatusReset()
{
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);//OutRawMaterialFinish复位出料完成信号
}
public void OutRawMaterialReset()
{
this.modbusTcp.Write(DeviceAddress.OutRawMaterialFinish, (ushort)0);
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);
}

public void Dispose()
{
ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听");
}
/// <summary>
/// 设置出料重量,触发出料信号
/// </summary>
/// <param name="Value"></param>
public void Start(uint Value)

public void Start(float Value)
{
if (modbusTcp.Connected)
{
modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)
{
modbusTcp.SetReal(DeviceAddress.SlowlyAddWeight, res.SlowlyAddWeight);
modbusTcp.SetReal(DeviceAddress.PreCloseValveWeight, res.PreCloseValveWeight);
modbusTcp.SetUint(DeviceAddress.RapidAcceleration, (uint)res.RapidAcceleration);
modbusTcp.SetUint(DeviceAddress.SlowAcceleration, (uint)res.SlowAcceleration);
modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed);
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight);
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo);
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed);
}
}
}
}


+ 3
- 3
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs Dosyayı Görüntüle

@@ -247,13 +247,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
double weight = SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
//DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.StockStateSignReset();
}
}
}
if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool))
/*if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool))
{
HKDevice.SingleDosing((uint)SmallStation.StockInIsWork);
DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).OutRawMaterialReset();
@@ -263,7 +263,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
HKDevice.RecipeDosingFinishReset();
SmallStation.RecipeQueue.TryDequeue(out code);
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
}*/
}
}
}


+ 48
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs Dosyayı Görüntüle

@@ -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.JXJFoodSmallStation.Model
{
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; }
}
}

+ 57
- 61
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs Dosyayı Görüntüle

@@ -8,95 +8,91 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class DeviceAddress
{
#region 源地址
///// <summary>
///// 设备名称起始地址
///// </summary>
//public static string DeviceName { get; set; } = "LW0";

///// <summary>
///// 料仓重量反馈起始地址
///// </summary>
//public static string WeightFeedback { get; set; } = "LW52";//LW204
/// <summary>
/// 设备名称起始地址
/// </summary>
public static string DeviceName { get; set; } = "LW0";

///// <summary>
///// 重量设置地址
///// </summary>
//public static string WeightSet { get; set; } = "LW21";//LW200
/// <summary>
/// 料仓重量反馈起始地址
/// </summary>
public static string WeightFeedback { get; set; } = "LW52";

///// <summary>
///// 启动信号地址
///// </summary>
//public static string Start { get; set; } = "LW20";//LW210
/// <summary>
/// 重量设置地址
/// </summary>
public static string WeightSet { get; set; } = "LW21";

///// <summary>
///// 下料重量反馈地址
///// </summary>
//public static string CutWeightFeedback { get; set; } = "LW54";//LW202
/// <summary>
/// 启动信号地址
/// </summary>
public static string Start { get; set; } = "LW20";

///// <summary>
///// 设备运行状态地址
///// </summary>
//public static string RunStatus { get; set; } = "LW55";//LW206
/// <summary>
/// 下料重量反馈地址
/// </summary>
public static string CutWeightFeedback { get; set; } = "LW54";

///// <summary>
///// 料仓的位置
///// </summary>
//public static string Location { get; set; } = "LW53";
#endregion
/// <summary>
/// 设备编号
/// </summary>
public static string DeviceNum { get; set; } = "LW57";

#region 上位机下发
/// <summary>
/// 原料出料重量
/// 设备故障编码
/// </summary>
public static string WeightSet { get; set; } = "LW11";
public static string DeviceAlarmCode { get; set; } = "LW51";

/// <summary>
/// 启动开始配料
/// 原料设备类型
/// 1:膏体,2:液体,3:粉体
/// </summary>
public static string Start { get; set; } = "LW12";
#endregion
#region 上位机读取
public static string MaterialDeviceType { get; set; } = "LW56";

/// <summary>
/// 设备运行状态地址
/// </summary>
public static string RunStatus { get; set; } = "LW50";
public static string RunStatus { get; set; } = "LW60";

/// <summary>
/// 报警字
/// 慢加重量
/// </summary>
public static string AlarmInfo { get; set; } = "LW51";
public static string SlowlyAddWeight { get; set; } = "LW23";

/// <summary>
/// 原料名称
/// 提前关阀重量
/// </summary>
public static string DeviceName { get; set; } = "LW52";
public static string PreCloseValveWeight { get; set; } = "LW25";

/// <summary>
/// 料仓的位置
/// 快加速度
/// </summary>
public static string Location { get; set; } = "LW53";
public static string RapidAcceleration { get; set; } = "LW27";

/// <summary>
/// 原料类型
/// 慢加速度
/// </summary>
public static string RawMaterialType { get; set; } = "LW54";
public static string SlowAcceleration { get; set; } = "LW29";

/// <summary>
/// 出料完成信号
/// 伺服手动速度
/// </summary>
public static string OutRawMaterialFinish { get; set; } = "LW55";
public static string ServoManualSpeed { get; set; } = "LW31";

/// <summary>
/// 料仓重量反馈起始地址
/// 料仓上限重量
/// </summary>
public static string WeightFeedback { get; set; } = "LW56";
public static string SiloUpperLimitWeight { get; set; } = "LW33";

/// <summary>
/// 料重量反馈地址
/// 料仓下限重量
/// </summary>
public static string CutWeightFeedback { get; set; } = "LW57";
#endregion



public static string LowerLimitWeightOfSilo { get; set; } = "LW35";

/// <summary>
/// 搅拌速度
/// </summary>
public static string StirringSpeed { get; set; } = "LW37";
}




BPASmartClient.JXJFoodSmallStation/Model/DeviceCurrentStatus.cs → BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs Dosyayı Görüntüle

@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.JXJFoodSmallStation.Model
namespace BPASmartClient.JXJFoodSmallStation
{
public class DeviceCurrentStatus : ObservableObject
{
@@ -18,6 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
private bool _mRunStatus;


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;


+ 15
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs Dosyayı Görüntüle

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;

namespace BPASmartClient.JXJFoodSmallStation
{
public class DevicePar
{
public ObservableCollection<DeviceParModel> deviceParModels { get; set; } = new ObservableCollection<DeviceParModel>();
}
}

+ 75
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs Dosyayı Görüntüle

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.JXJFoodSmallStation
{
public class DeviceParModel : ObservableObject
{
/// <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;


}
}

+ 15
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs Dosyayı Görüntüle

@@ -0,0 +1,15 @@
using BPASmartClient.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class GlobalData
{
}
}

+ 3
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs Dosyayı Görüntüle

@@ -5,11 +5,14 @@ using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using BPASmartClient.JXJFoodSmallStation.ViewModel;
using BPASmartClient.Model;

namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class LocaPar
{
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();

}
}

+ 17
- 2
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs Dosyayı Görüntüle

@@ -11,8 +11,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

/// <summary>
/// 原料类型
/// 1:
/// 2:
/// 1:
/// 2:
/// 3:粉体
/// </summary>
public ushort RawMaterialType { get; set; }
@@ -39,7 +39,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

/// <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
- 1
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs Dosyayı Görüntüle

@@ -5,7 +5,6 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BPASmartClient.JXJFoodSmallStation.ViewModel;
using BPASmartClient.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;



+ 40
- 26
BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml Dosyayı Görüntüle

@@ -44,15 +44,7 @@
</Style>
</UserControl.Resources>

<Grid>

<!--<pry:Bottle
Width="80"
Height="500"
CurrentValue="50" />-->

<!--<pry:MotorBottle IsRun="True" CurrentValue="100"/>-->

<Grid Margin="-5,0,5,0">

<Grid>
<ListView
@@ -79,19 +71,16 @@
Height="150"
VerticalAlignment="Top"
BorderBrush="#00BEFA"
BorderThickness="2"
BorderThickness="0"
ClipToBounds="True"
CornerRadius="8">
<Border.Effect>
<DropShadowEffect
BlurRadius="18"
ShadowDepth="0"
Color="#00BEFA" />
</Border.Effect>
CornerRadius="0">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/蓝色背景.png" />
</Border.Background>

<Grid Margin="20,0,20,0">

<Grid.RowDefinitions>
<!--<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
@@ -99,36 +88,57 @@
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>-->

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Grid.Row="0"
Grid.ColumnSpan="2"
VerticalAlignment="Bottom"
FontSize="40"
Margin="0,10,0,0"
VerticalAlignment="Center"
FontSize="20"
Foreground="#00BEFA"
Text="{Binding DeviceName}" />

<StackPanel
Grid.Row="1"
Grid.ColumnSpan="2"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Grid.Row="1"
FontSize="14"
Foreground="Aqua"
Foreground="#aa00BEFA"
Text="设备IP:" />
<TextBlock
Grid.Row="1"
FontSize="14"
Foreground="Aqua"
Foreground="#aa00BEFA"
Text="{Binding IpAddress}" />
</StackPanel>

<Button
Grid.Row="2"
Width="130"
Height="30"
VerticalAlignment="Top"
Margin="0,0,0,0"
Command="{Binding DataContext.ChangeNameCommand, 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"
@@ -136,8 +146,12 @@
VerticalAlignment="Bottom"
Command="{Binding DataContext.ChangeNameCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding IpAddress}"
Content="修改设备名称"
IsEnabled="{Binding IsEnable}" />
Content="修改原料名称"
IsEnabled="{Binding IsEnable}">
<Button.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/系统名称.png" />
</Button.Background>
</Button>-->


</Grid>


+ 369
- 0
BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml Dosyayı Görüntüle

@@ -0,0 +1,369 @@
<UserControl
x:Class="BPASmartClient.JXJFoodSmallStation.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.JXJFoodSmallStation.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.JXJFoodSmallStation.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.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" />
<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>

+ 28
- 0
BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml.cs Dosyayı Görüntüle

@@ -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.JXJFoodSmallStation.View
{
/// <summary>
/// DeviceMaterialParView.xaml 的交互逻辑
/// </summary>
public partial class DeviceMaterialParView : UserControl
{
public DeviceMaterialParView()
{
InitializeComponent();
}
}
}

+ 170
- 279
BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml Dosyayı Görüntüle

@@ -17,298 +17,189 @@
</UserControl.DataContext>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*" />
<RowDefinition />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>



<!--#region 测试-->
<ListView
Height="150"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding TopDeviceCurrentStatuses}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid
HorizontalAlignment="Center"
VerticalAlignment="Center"
Columns="10" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border Background="Transparent">
<Grid Height="100">
<pry:MotorBottle
Height="100"
CurrentValue="{Binding Weight}"
IsRun="{Binding RunStatus}"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!--#region 顶部料仓-->
<Grid Name="TopGrid">
<ListView
Height="{Binding ElementName=TopGrid, Path=ActualHeight}"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding TopDeviceCurrentStatuses}"
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 Height="220">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Margin="0,0,0,35"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />

<StackPanel
Grid.Row="1"
Margin="0,25,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,70,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding DeviceNum}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text=" 号仓" />
</StackPanel>

<Image
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />

</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<!--#endregion-->








<UniformGrid Columns="10" Visibility="Collapsed">

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="66"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="40"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="88"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="25"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="97"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="10"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="60"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="96"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

</UniformGrid>

<Grid x:Name="gr" Grid.Row="1">

<pry:ConveyorBelt
Grid.Row="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="0,0,400,0"
Margin="10,0,400,0"
ConveyorBeltWidth="70"
Direction="1"
StrokeBrush="Red"
Direction="0"
StrokeBrush="#00BEFA"
StrokeDashArray="1.5 1.5"
StrokeFillBrush="Red"
StrokeFillBrush="#00BEFA"
StrokeThickness="2" />
</Grid>

<UniformGrid Grid.Row="2" Columns="10">

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="89"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="270" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="13"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="270" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="31"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="270" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="96"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="270" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="80"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="270" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="26"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="270" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="20"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="270" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="100"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="270" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>

</UniformGrid>
<!--#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="220">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Margin="0,0,0,35"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />

<StackPanel
Grid.Row="1"
Margin="0,25,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,70,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding DeviceNum}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text=" 号仓" />
</StackPanel>

<Image
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />

</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<!--#endregion-->

<Grid.RowDefinitions>
<RowDefinition Height="0.5*" />
<RowDefinition />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>
</Grid>
</UserControl>

+ 175
- 0
BPASmartClient.JXJFoodSmallStation/View/NewMaterialView.xaml Dosyayı Görüntüle

@@ -0,0 +1,175 @@
<Window
x:Class="BPASmartClient.JXJFoodSmallStation.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.JXJFoodSmallStation.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel"
Title="NewMateritalView"
Width="600"
Height="600"
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>

<!--#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/bg.png" />
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5" />
<RowDefinition Height="*" />
<RowDefinition Height="40" />
<RowDefinition Height="5" />
<RowDefinition Height="5*" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="1"
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="10"
FontSize="16"
Text="{Binding MaterialName}" />

<Button
Width="80"
Height="30"
Margin="10"
Command="{Binding SaveCommand}"
Content="保存"
Cursor="Hand" />
<Button
Name="btClose"
Width="80"
Height="30"
Margin="10"
Click="btClose_Click"
Content="取消" />

</StackPanel>
<TextBlock
Grid.Row="2"
Margin="0,0,5,0"
HorizontalAlignment="Center"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />
<Grid Grid.Row="4">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock
HorizontalAlignment="Center"
FontSize="25"
Foreground="#FF2AB2E7"
Text="本地原料" />
<Border
Grid.Row="1"
Margin="100,10"
BorderBrush="#FF2AB2E7"
BorderThickness="1">
<ScrollViewer
Grid.Row="1"
BorderBrush="#FF2AB2E7"
BorderThickness="1">
<ItemsControl Margin="10" ItemsSource="{Binding Materials}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton GroupName="all">
<RadioButton.Template>
<ControlTemplate TargetType="RadioButton">
<Grid Name="gr" Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Name="tb"
Grid.Column="0"
Width="150"
Height="29"
Margin="3,1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
Text="{Binding RawMaterialName}" />

<Button
Grid.Column="1"
Margin="10,0,10,0"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialId}"
Content="删除" />
</Grid>


</ControlTemplate>
</RadioButton.Template>
</RadioButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
</Grid>

</Grid>

</Border>
</Window>

+ 35
- 0
BPASmartClient.JXJFoodSmallStation/View/NewMaterialView.xaml.cs Dosyayı Görüntüle

@@ -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.JXJFoodSmallStation.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();
}
}
}

+ 17
- 3
BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml Dosyayı Görüntüle

@@ -52,11 +52,20 @@
</ResourceDictionary>
</Window.Resources>

<Border Name="br" BorderThickness="1">
<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 />
@@ -134,7 +143,11 @@

</StackPanel>

<ScrollViewer Grid.Row="2" Margin="5">
<ScrollViewer
Grid.Row="2"
Margin="5"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding RawMaterials}">
<ItemsControl.ItemTemplate>
<DataTemplate>
@@ -201,7 +214,8 @@

<Button
Grid.Column="2"
Margin="10,0,10,0"
Width="80"
Margin="25,0,0,0"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialId}"
Content="删除" />


+ 288
- 4
BPASmartClient.JXJFoodSmallStation/View/RecipeControlView.xaml Dosyayı Görüntüle

@@ -2,6 +2,7 @@
x:Class="BPASmartClient.JXJFoodSmallStation.View.RecipeControlView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:con="clr-namespace:BPASmartClient.JXJFoodSmallStation.Converter"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.JXJFoodSmallStation.View"
@@ -13,10 +14,15 @@
mc:Ignorable="d">

<UserControl.DataContext>
<vm:RecipeControlViewModel />
<vm:RecipeControlViewModel x:Name="bingSource" />
</UserControl.DataContext>

<UserControl.Resources>

<con:RunStatusConvert x:Key="RunStatusConvert" />
<con:EnbleConvert x:Key="EnbleConvert"/>
<con:IntToSourceConvert x:Key="IntToSourceConvert"/>

<Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem">
<Style.Resources>
<!-- SelectedItem with focus -->
@@ -42,11 +48,205 @@
</Trigger>
</Style.Triggers>
</Style>

<Style x:Key="RadioState" TargetType="RadioButton">
<Setter Property="Margin" Value="1"/>
<Setter Property="Background" Value="#002060" />
<Setter Property="Foreground" Value="White" />
<Setter Property="VerticalContentAlignment" Value="Bottom"/>
<Setter Property="Margin" Value="2,5"/>
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="Consolas" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border CornerRadius="5" Background="{TemplateBinding Background}" Name="radiobutton" >
<Grid>
<Border x:Name="back_border" BorderThickness="0" BorderBrush="Black" CornerRadius="1">
<Border.Effect>
<BlurEffect Radius="2" KernelType="Gaussian"/>
</Border.Effect>
</Border>
<Border x:Name="fore_border" BorderThickness="0" BorderBrush="White" Margin="2" Opacity="0.7" CornerRadius="{Binding ElementName=button, Path=CornerRadius}">
<Border.Effect>
<BlurEffect Radius="2" KernelType="Gaussian"/>
</Border.Effect>
</Border>
<ContentPresenter TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.Foreground="{TemplateBinding Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"></ContentPresenter>
</Grid>
</Border>

<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="back_border" Property="BorderThickness" Value="1,0,1,1"/>
<Setter TargetName="back_border" Property="CornerRadius" Value="5"/>
<Setter TargetName="fore_border" Property="BorderThickness" Value="0,2,0,0"/>
<Setter Property="Background" Value=" #4169E1"/>

</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="back_border" Value="white"/>
<Setter TargetName="back_border" Property="BorderThickness" Value="1,1,1,1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

</Setter.Value>

</Setter>

</Style>
<Style TargetType="Button" x:Key="materialMakingButton">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="#CD5555"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border x:Name="brState" BorderBrush="White" BorderThickness="0" Padding="2">
<TextBlock x:Name="txState" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="1"
Text="{Binding RecipeStatus, Converter={StaticResource RunStatusConvert} }" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter TargetName="brState" Property="BorderThickness" Value="0" />
<Setter TargetName="brState" Property="CornerRadius" Value="5" />
<Setter TargetName="brState" Property="Background" Value="#F0FFFF"/>
<Setter TargetName="txState" Property="Foreground" Value="#CD5555"/>
</Trigger>
<DataTrigger Binding="{Binding RecipeStatus}" Value="3">
<Setter TargetName="brState" Property="Background" Value="#F0FFFF"/>
<Setter TargetName="txState" Property="Foreground" Value="#3CB371"/>
</DataTrigger>
<DataTrigger Binding="{Binding RecipeStatus}" Value="2">
<Setter TargetName="txState" Property="Foreground" Value="Aqua"/>
</DataTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="IsEnabled" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="FontSize" TargetName="txState" Value="17 "/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
</Style.Triggers>

</Style>

<DataTemplate x:Key="TreeItemTemplate" DataType="TreeViewItem">
<Grid Margin="50,0,0,0" Height="28">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="原料:" Foreground="Aqua" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0"/>
<TextBlock Grid.Column="1" Text="{Binding RawMaterialName}" Foreground="Aqua" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0"/>
</Grid>
</DataTemplate>
<Style TargetType="TreeViewItem" x:Key="recipeTreeItem">
<Setter Property="Background" Value="Transparent" />
<Setter Property="IsExpanded" Value="True"></Setter>
<Setter Property="HeaderTemplate">
<Setter.Value>
<HierarchicalDataTemplate ItemsSource="{Binding RawMaterials,Mode=TwoWay}" ItemTemplate="{StaticResource TreeItemTemplate}">
<StackPanel Orientation="Horizontal" Height="28" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="配方:" Margin="5,0,0,0" FontSize="15" VerticalAlignment="Center" Foreground="White"/>
<TextBlock Text="{Binding RecipeName}" Margin="5,0,0,0" FontSize="15" VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</HierarchicalDataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Selected">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" >
<EasingColorKeyFrame KeyTime="0" Value="Transparent" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>

<VisualState x:Name="Unselected" />
<VisualState x:Name="SelectedInactive">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="0" Value="Transparent" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="ExpansionStates">
<VisualState x:Name="Expanded">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ItemsHost">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Collapsed" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="Bd" Grid.Column="0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
<ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Border>
<ItemsPresenter x:Name="ItemsHost" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Visibility="Collapsed" />
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader" Value="false" />
<Condition Property="Width" Value="Auto" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_Header" Property="MinWidth" Value="75" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader" Value="false" />
<Condition Property="Height" Value="Auto" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_Header" Property="MinHeight" Value="19" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</UserControl.Resources>

<Grid Margin="20">

<ScrollViewer>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="0.2*" />
</Grid.ColumnDefinitions>

<ScrollViewer Grid.Column="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">

<ListView
Margin="5"
@@ -60,13 +260,13 @@
<UniformGrid
HorizontalAlignment="Left"
VerticalAlignment="Top"
Columns="8" />
Columns="6" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border Margin="5" Background="LightSkyBlue">
<Border Margin="5" Background="LightSkyBlue" Width="210">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
@@ -258,5 +458,89 @@
</ItemsControl.ItemTemplate>
</ItemsControl>-->
</ScrollViewer>

<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<RadioButton Content="等待中"
Style="{DynamicResource RadioState}"
GroupName="state"
IsChecked="True"
Command="{Binding ChangeRecipeStateCommand}"
Click="RadioButtonWait_Click"/>
<RadioButton Grid.Column="1"
Content="执行中"
Style="{DynamicResource RadioState}"
GroupName="state"
Click="RadioButtonMaking_Click"/>
<RadioButton Grid.Column="2"
Content="已完成"
Style="{DynamicResource RadioState}"
GroupName="state"
Click="RadioButtonCompelete_Click"/>
</Grid>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" >
<Border Background="Transparent" BorderThickness="1" BorderBrush="White">
<Grid Grid.Row="1">
<Grid x:Name="repiceListMaking" Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding CurrentRecipeName}" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0"/>
<ItemsControl Grid.Row="1" ItemsSource="{Binding recipeProcesses}" Margin="50,0" Background="Transparent" BorderThickness="0">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="16"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding RawMaterialName}"
Foreground="Aqua"
FontSize="15"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="10,0,5,0"
ToolTip="{Binding RawMaterialSource,Converter={StaticResource IntToSourceConvert}}" />
<TextBlock Grid.Column="1" Text=":" Foreground="Aqua" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,5,0"/>
<Button Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center"
Content="{Binding RecipeStatus, Converter={StaticResource RunStatusConvert}}"
IsEnabled="{Binding RawMaterialSource, Converter={StaticResource EnbleConvert}}"
Style="{StaticResource materialMakingButton}"
Command="{Binding DataContext.ChangeRecipeStateCommand,RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialId}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<!--<TreeView x:Name="repiceListMaking" ItemsSource="{Binding RecipeProcesse}"
ScrollViewer.VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" Background="Wheat" ItemContainerStyle="{StaticResource recipeTreeItem}">
</TreeView>-->

<!--等待和已完成-->
<TreeView x:Name="repiceList" ItemsSource="{Binding UserTreeWait}"
ScrollViewer.VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" Background="Transparent" ItemContainerStyle="{StaticResource recipeTreeItem}">
</TreeView>


</Grid>
</Border>
</ScrollViewer>
</Grid>

</Grid>
</UserControl>

+ 29
- 1
BPASmartClient.JXJFoodSmallStation/View/RecipeControlView.xaml.cs Dosyayı Görüntüle

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.JXJFoodSmallStation.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -23,6 +24,33 @@ namespace BPASmartClient.JXJFoodSmallStation.View
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;


}

private void RadioButtonWait_Click(object sender, RoutedEventArgs e)
{
repiceList.ItemsSource = RecipeControlViewModel.UserTreeWait;
repiceList.Visibility = Visibility.Visible;
repiceListMaking.Visibility = Visibility.Hidden;
}

private void RadioButtonMaking_Click(object sender, RoutedEventArgs e)
{
repiceListMaking.Visibility = Visibility.Visible;
repiceList.Visibility = Visibility.Hidden;
}
}
}

+ 11
- 69
BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml Dosyayı Görüntüle

@@ -52,6 +52,17 @@

<!--#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="&#xe626;"
Style="{StaticResource IcoButtonStyle}" />
<pry:IcoButton
Grid.Column="3"
Width="140"
@@ -79,75 +90,6 @@
</StackPanel>
<!--#endregion-->

<!--#region 表格标题栏设置-->
<!--<Grid Grid.Row="1" Background="#dd2AB2E7">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="序号" />

<Grid Grid.Column="1">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="配方名称" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
</Grid>

<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="编码" />

<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="结束时间" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
</Grid>

<Grid Grid.Column="5">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="制作状态" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="0,0,1,0" />
</Grid>

<TextBlock
Grid.Column="6"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="完成时间" />

</Grid>-->
<!--#endregion-->

<ScrollViewer Grid.Row="2">
<ListView
Margin="5"


+ 19
- 0
BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml.cs Dosyayı Görüntüle

@@ -24,6 +24,25 @@ namespace BPASmartClient.JXJFoodSmallStation.View
public RecipeSettingsView()
{
InitializeComponent();
//SetAlignment();
}

//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;
// }
//}
}
}

+ 3
- 3
BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs Dosyayı Görüntüle

@@ -7,6 +7,7 @@ using BPASmartClient.Helper;
using BPASmartClient.JXJFoodSmallStation.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.CustomResource.Pages.Model;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
@@ -34,10 +35,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
ErrorInfo = "设备名称已存在";
else
{
NewRecipeViewModel.RawMaterialNames.Remove(DeviceListViewModel.devices.ElementAt(index).DeviceName);
NewRecipeViewModel.RawMaterialNames.Add(DeviceName);
var res = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceListViewModel.devices.ElementAt(index).DeviceName);
res.RawMaterialName = DeviceName;
DeviceListViewModel.devices.ElementAt(index).DeviceName = DeviceName;

DeviceInquire.GetInstance.GetDevice(IpAddress).SetDeviceName(DeviceName);//设置PLC名称
for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++)
{


+ 4
- 1
BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs Dosyayı Görüntüle

@@ -10,6 +10,7 @@ using System.Windows;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.JXJFoodSmallStation.View;
using BPASmartClient.JXJFoodSmallStation.Model;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
@@ -26,11 +27,13 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
cdn.ShowDialog();
}
});
devices = DeviceInquire.GetInstance.devices;
}

public RelayCommand<object> ChangeNameCommand { get; set; }

public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>();
//public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>();
public static ObservableCollection<Devices> devices { get; set; }
}

public class Devices : ObservableObject


+ 69
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceMaterialParViewModel.cs Dosyayı Görüntüle

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using BPASmartClient.JXJFoodSmallStation.Model;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.UserControls;
using System.Diagnostics;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public class DeviceMaterialParViewModel : ObservableObject
{
public DeviceMaterialParViewModel()
{
deviceParModels = Json<DevicePar>.Data.deviceParModels;
RemoveCommand = new RelayCommand<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 RelayCommand(() => { deviceParModels.Add(new DeviceParModel()); });
SaveCommand = new RelayCommand(() =>
{
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 RelayCommand<object> RemoveCommand { get; set; }

public RelayCommand AddCommand { get; set; }
public RelayCommand SaveCommand { get; set; }

}
}

+ 5
- 11
BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs Dosyayı Görüntüle

@@ -17,18 +17,12 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public HardwareStatusViewModel()
{
for (int i = 0; i < 8; i++)
{
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
RunStatus = false,
Weight = new Random().Next(0, 100)
});
}
TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses;
BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses;
}

public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; }

public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; }
}
}

+ 58
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/NewMaterialViewModel.cs Dosyayı Görüntüle

@@ -0,0 +1,58 @@
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.JXJFoodSmallStation.Model;
using BPASmartClient.Helper;
using BPASmartClient.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel;

public class NewMaterialViewModel:ObservableObject
{
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 RelayCommand<object> RemoveCommand { get; set; }

public RelayCommand 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();
MessageLog.GetInstance.ShowUserLog($"删除原料--{res.RawMaterialName}");
}
}

public NewMaterialViewModel()
{
RemoveCommand = new RelayCommand<object>(Remove);

SaveCommand = new RelayCommand(() =>
{
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();
MessageLog.GetInstance.ShowUserLog($"添加原料--{MaterialName}");
});
}
}

+ 65
- 27
BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs Dosyayı Görüntüle

@@ -49,16 +49,28 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
if (obj is string rm)
{
var res = RawMaterials.FirstOrDefault(p => p.RawMaterialId == rm);
if (res != null) RawMaterials.Remove(res);
if (res != null) Global.DeviceRawMaterials.Remove(res);
}
});

SaveCommand = new RelayCommand(() =>
{
ErrorInfo = String.Empty;
if (RecipeName == String.Empty) { ErrorInfo = "配方名称未填写"; return; }
for (int i = 0; i < RawMaterials.Count; i++)
{
var res = DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName);
if (res != null) RawMaterials.ElementAt(i).DeviceIp = res.IpAddress;//根据设备名称和原料名称的唯一匹配关系,给原料配置IP
if (res != null)
{
RawMaterials.ElementAt(i).DeviceIp = res.IpAddress;//根据设备名称和原料名称的唯一匹配关系,给原料配置IP
RawMaterials.ElementAt(i).RawMaterialSource = 1;
}
var su = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == RawMaterials.ElementAt(i).RawMaterialName);
if(su != null)
{
RawMaterials.ElementAt(i).RawMaterialSource = su.RawMaterialSource;
}

}

if (RecipCode.Length <= 0)//新建配方
@@ -87,9 +99,53 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
}
}
}

ActionManage.GetInstance.Send("CloseNewRecipeView");
});

//RawMaterialNames.Add("乳化剂");
//RawMaterialNames.Add("酶制剂");
//RawMaterialNames.Add("增味剂");


//RawMaterialNames.Add("营养强化剂");
//RawMaterialNames.Add("抗结剂");
//RawMaterialNames.Add("消泡剂");
//RawMaterialNames.Add("膨松剂");
//RawMaterialNames.Add("防腐剂");
//RawMaterialNames.Add("着色剂");
//RawMaterialNames.Add("甜味剂");
//RawMaterialNames.Add("酸味剂");
//RawMaterialNames.Add("增白剂");
//RawMaterialNames.Add("香料");
//RawMaterialNames.Add("抗氧化剂");
//RawMaterialNames.Add("食用香料");
//RawMaterialNames.Add("增稠剂");

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()
@@ -101,37 +157,18 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
{
SerialNum = Json<LocaPar>.Data.Recipes.Count + 1,
RawMaterials = Global.DeviceRawMaterials,
RawMaterials = RawMaterials,
RecipCode = sb.ToString(),
RecipeName = RecipeName,
});
}

static NewRecipeViewModel()
{
RawMaterialNames.Clear();
//RawMaterialNames.Add("乳化剂");
//RawMaterialNames.Add("酶制剂");
//RawMaterialNames.Add("增味剂");
RawMaterialNames.Add("营养强化剂");
//RawMaterialNames.Add("抗结剂");
//RawMaterialNames.Add("消泡剂");
//RawMaterialNames.Add("膨松剂");
//RawMaterialNames.Add("防腐剂");
//RawMaterialNames.Add("着色剂");
RawMaterialNames.Add("甜味剂");
//RawMaterialNames.Add("酸味剂");
//RawMaterialNames.Add("增白剂");
//RawMaterialNames.Add("香料");
RawMaterialNames.Add("抗氧化剂");
RawMaterialNames.Add("食用香料");
//RawMaterialNames.Add("增稠剂");
}


private string RecipCode = string.Empty;

public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName;
private string _mRecipeName = string.Empty;

public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
private string _mErrorInfo;
@@ -142,8 +179,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel

public RelayCommand SaveCommand { get; set; }

public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>();
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel> ();


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

+ 98
- 3
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs Dosyayı Görüntüle

@@ -14,6 +14,8 @@ using System.Threading;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.Model.柔性味魔方;
using BPASmartClient.Model;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
@@ -23,7 +25,6 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel

public RecipeControlViewModel()
{
Recipes = Json<LocaPar>.Data.Recipes;
StartCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is string deviceName)
@@ -35,28 +36,57 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
}
MessageLog.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 });
}


NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!");
MessageLog.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}");
});

ChangeRecipeStateCommand = new RelayCommand<object>(ChangeRecipeState);



ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (devices.Count > 0)
{
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == devices.ElementAt(0));///???????
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == devices.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
{
Recipes.ElementAt(index).Are.Reset();
Recipes.ElementAt(index).IsEnable = false;
App.Current.Dispatcher.Invoke(new Action(() =>
{
recipeProcesses.Clear();
UserTreeWait.RemoveAt(0);
}));
CurrentRecipeName = Recipes.ElementAt(index).RecipeName;
foreach (var item in Recipes.ElementAt(index).RawMaterials)
{
DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量
App.Current.Dispatcher.Invoke(new Action(() =>
{
recipeProcesses.Add(new RawMaterialModel()
{
RawMaterialName = item.RawMaterialName,
RecipeStatus = item.RecipeStatus,
RawMaterialSource = item.RawMaterialSource,
RawMaterialId = item.RawMaterialId,
});
}));

}
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成
devices.TryDequeue(out string deviceName);
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));//完成后清空当前配方
}

}
Thread.Sleep(100);
}), "启动配方下发");
@@ -69,6 +99,19 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
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 deviceName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName;
int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName);

if (index >= 0 && index < recipeProcesses.Count)
{
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RecipeStatus = RunStatus; }));
}
}

Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus;
var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList();
if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料
@@ -76,6 +119,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++)
{
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
}
Recipes.ElementAt(i).IsEnable = true;
Recipes.ElementAt(i).Are.Set();
@@ -84,9 +128,60 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
}
Thread.Sleep(100);
}), "RecipeControlViewModelStatusInquire");
//测试数据
RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" };
RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" };
RawMaterialModel rawMaterial_3 = new RawMaterialModel { RawMaterialName = "香料_3" };
RawMaterialModel rawMaterial_4 = new RawMaterialModel { RawMaterialName = "香料_4" };
ObservableCollection<RawMaterialModel> rawMaterials = new ObservableCollection<RawMaterialModel> { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 };
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials });
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });

}

public RelayCommand<object> StartCommand { get; set; }
public ObservableCollection<RecipeModel> Recipes { get; set; }

public RelayCommand<object> ChangeRecipeStateCommand { get; set; }

public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;

public string CurrentRecipeName { get { return _RecipeName; }set { _RecipeName = value; OnPropertyChanged(); } }
private static string _RecipeName;

/// <summary>
/// 当前正在制作的配方
/// </summary>

public static ObservableCollection<RawMaterialModel> recipeProcesses { get; set; } = new ObservableCollection<RawMaterialModel>();
/// <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 res = recipeProcesses.FirstOrDefault(p => p.RawMaterialId == id);
if (res != null)
{
if(res.RecipeStatus == 3)
{
res.RecipeStatus = 1;
}else
{
res.RecipeStatus = 3;
}
}
}
}
}


}

+ 11
- 2
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeSettingsViewModel.cs Dosyayı Görüntüle

@@ -17,6 +17,7 @@ using BPASmartClient.CustomResource.UserControls.Enum;
using System.Windows.Media;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Model;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
@@ -24,8 +25,13 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public RecipeSettingsViewModel()
{
//Json<LocaPar>.Read();
Recipes = Json<LocaPar>.Data.Recipes;

NewMaterital = new RelayCommand(() =>
{
NewMaterialView newMateritalView = new NewMaterialView();
newMateritalView.ShowDialog();
});
NewRecipe = new RelayCommand(() =>
{
NewRecipeView nrv = new NewRecipeView();
@@ -55,13 +61,16 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
ActionManage.GetInstance.CancelRegister("Details");
NewRecipeView nrv = new NewRecipeView();
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
ActionManage.GetInstance.Send("Details",res);
ActionManage.GetInstance.Send("Details", res);
nrv.ShowDialog();
MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
}
});

}

public RelayCommand NewMaterital { get; set; }

public RelayCommand NewRecipe { get; set; }

public RelayCommand SaveRecipe { get; set; }


Yükleniyor…
İptal
Kaydet