Browse Source

上传

一拖四味魔方配料系统
yaowen liu 1 year ago
parent
commit
a924a14476
14 changed files with 1004 additions and 179 deletions
  1. +8
    -1
      DosingSystem/App.xaml.cs
  2. +47
    -0
      DosingSystem/Converter/RunStatusConvert.cs
  3. +401
    -9
      DosingSystem/ExcuteControl .cs
  4. +43
    -38
      DosingSystem/Model/DeviceInquire.cs
  5. +12
    -0
      DosingSystem/Model/Expand.cs
  6. +5
    -5
      DosingSystem/Model/RawMaterialDeviceStatus.cs
  7. +68
    -0
      DosingSystem/Model/SendCtrlModel.cs
  8. +2
    -2
      DosingSystem/Model/par/BasePar.cs
  9. +5
    -5
      DosingSystem/Model/par/DeviceParModel.cs
  10. +71
    -1
      DosingSystem/Service/SiemensDevice.cs
  11. +258
    -0
      DosingSystem/View/SendCtrlView.xaml
  12. +28
    -0
      DosingSystem/View/SendCtrlView.xaml.cs
  13. +4
    -118
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  14. +52
    -0
      DosingSystem/ViewModel/SendCtrlViewModel.cs

+ 8
- 1
DosingSystem/App.xaml.cs View File

@@ -142,6 +142,7 @@ namespace BPASmartClient.DosingSystem
Alias = "Recipe Management",
subMenumodels = RecipeManage,
});

#endregion

#region 参数设置
@@ -161,7 +162,13 @@ namespace BPASmartClient.DosingSystem
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.CommParSetView"
});

ParSet.Add(new SubMenumodel()
{
SubMenuName = "测试",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.SendCtrlView"
});
//ParSet.Add(new SubMenumodel()
//{
// SubMenuName = "出料口管理设置",


+ 47
- 0
DosingSystem/Converter/RunStatusConvert.cs View File

@@ -4,6 +4,53 @@ using System.Windows.Data;

namespace BPASmartClient.DosingSystem.Converter
{
public class AutoConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool temp)
{
if (temp)
{
return "自动";
}
else
{
return "手动";
}
}
return value;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class RunStateConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool temp)
{
if (temp)
{
return "系统启动";
}
else
{
return "系统停止";
}
}
return value;
}

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

}
public class RunStatusConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)


+ 401
- 9
DosingSystem/ExcuteControl .cs View File

@@ -101,8 +101,9 @@ namespace BPASmartClient.DosingSystem
}), "取消配方");

//AliYunInit();
RecipeRun();
BusinessExcute();
//RecipeRun();
//BusinessExcute();
MatchRun();
ConveyerPropertyReport();
ThreadTaskInit();
#if Debug
@@ -864,21 +865,24 @@ namespace BPASmartClient.DosingSystem
{
for (int i = 0; i < Recipes.ElementAt(index).RawMaterials.Count; i++)
{
string ip = Recipes.ElementAt(index).RawMaterials.ElementAt(i).DeviceIp;
var device = DeviceInquire.GetInstance.GetDevice(ip);
if (!device.IsConnected)
{
MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
return;
}
if (Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialSource == 1)
{
string ip = Recipes.ElementAt(index).RawMaterials.ElementAt(i).DeviceIp;
var device = DeviceInquire.GetInstance.GetDevice(ip);
if (ip == null && ip == "")
{
MessageNotify.GetInstance.ShowDialog($"原料 【{Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialName}】配料系统无法配料,请人工配置此原料:原料{Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialName},重量{Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialWeight}", DialogType.Information);
return;
}
if (!device.IsConnected)
{
MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
return;
}
}

}
Recipes.ElementAt(index).IsEnable = false;
@@ -1366,5 +1370,393 @@ namespace BPASmartClient.DosingSystem

}

public ConcurrentDictionary<string, int> doDeviceCount = new ConcurrentDictionary<string, int>();

int doDecipeCount = 0;
private void MatchRun()
{

recipeProcesses.Clear();

TaskManage.GetInstance.StartLong(() =>
{
SimensSend.GetInstance.SendSimens.Write("M0.0", true);
SimensSend.GetInstance.SendSimens.Write("M0.1", true);
if (RecipeNames.Count > 0)
{

for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 0)
{
if (!doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
doDeviceCount.TryAdd(DeviceInquire.GetInstance.devices[i].IpAddress, 0);
}
int index = 0;
if (doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]< RecipeNames.Count)
{
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]));

if (index > 0 && index < Recipes.Count)
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
if (UserTreeWait.Count > 0)
{
recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(0)));
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(0)));
}
}));
int maxPail = 0;
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
{
if (rawMaterial.Loc > maxPail)
{
maxPail = rawMaterial.Loc;
}
}
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);
doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]);
}
}
}
}


}
}
//if (doDeviceCount.ContainsKey("192.168.2.10")&&doDeviceCount.ContainsKey($"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"))
//{
// if (doDeviceCount[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"] > 0 && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.DoRecipeCount == doDeviceCount[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"])
// {
// App.Current.Dispatcher.Invoke(new Action(() =>
// {
// UserTreeCompelete.Insert(0, recipeProcesses.Last());
// recipeProcesses.Remove(recipeProcesses.Last());
// }));

// }
// if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.DoRecipeCount == doDeviceCount["192.168.2.10"])
// {
// App.Current.Dispatcher.Invoke(new Action(() =>
// {
// if (UserTreeWait.Count > 0)
// {
// recipeProcesses.Insert(0, UserTreeWait[0]);
// UserTreeWait.RemoveAt(0);
// }
// }));
// }
//}
}

Thread.Sleep(10);
}, "设备下发配方");

TaskManage.GetInstance.StartLong(() =>
{

for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress) && doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 && doDecipeCount > 0)
{
int doCount = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount-1));
if (doCount >= 0 && doCount < Recipes.Count)
{
var res = Recipes.ElementAt(doCount).RawMaterials?.ToList().FindAll(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
foreach (RawMaterialModel item in res)
{
if (item != null && item.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail)
{
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
if (deviceSet != null && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].IsConnected == true)
{
//开始配料信号
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
//传送带停止
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//设置下料重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.WeightSet.ToAdd(), item.RawMaterialWeight);
//设置慢加重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight);
//设置快慢加速度
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration);
//设置提前关阀重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
//设置伺服手动速度
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
//设置料仓上下限重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
////设置搅拌速度
//DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
}
}
}
}

}
}

}

Thread.Sleep(10);
}, "下发设备参数");


DeviceStatus nextDevice = new DeviceStatus();
TaskManage.GetInstance.StartLong(() =>
{

for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}")
{

ushort deviceNum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum;
string nextIp = "";
if (DeviceInquire.GetInstance.DeviceLists.TryGetValue($"{Json<DevicePar>.Data.BaseParModel.NetworkSegAddress}{(deviceNum+1) * 10}", out nextDevice)&& deviceNum!=0)
{
nextIp = DeviceInquire.GetInstance.DeviceLists.ToList().Find(q => q.Value == nextDevice).Key;
}
if ( nextIp != "")
{
//if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 3)
//{
// DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
//}
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3)
{

if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[nextIp].deviceStatus.PailArrive == 1)
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
}
else
{
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 500);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
}
}
else
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//传送带停止
}

//DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
//DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//else if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 1)
//{
// //传送带运行
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
// DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
//}

}
}
else
{
if (SimensSend.GetInstance.sendCtrlModel.SendInfo)
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
else
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 500);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
//传送带终点为3则传送带停止,小于3则按照出料状态运行
}



if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail != 0 && (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail))
{
}
}
}


Thread.Sleep(10);
}, "控制传送带");
//TaskManage.GetInstance.StartLong(() =>
//{
// if (RecipeNames.Count > 0)
// {
// SimensSend.GetInstance.SendSimens.Write("M0.0", true);
// SimensSend.GetInstance.SendSimens.Write("M0.1", true);
// if (DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.MaxPassPail != 0 && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.PassPail && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.RunStatus == 1)
// {
// recipeProcesses.Remove(recipeProcesses.Last());
// UserTreeCompelete.Insert(0, recipeProcesses.Last());

// }
// for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
// {
// if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
// {

// if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == 0 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
// {

// if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail|| recipeProcesses.Count==0)
// {
// int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0));
// if (index >= 0 && index < Recipes.Count)
// {
// App.Current.Dispatcher.Invoke(new Action(() =>
// {
// if (UserTreeWait.Count > 0)
// {
// recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(0)));
// UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(0)));
// }
// }));
// int maxPail = 0;
// foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
// {
// if (rawMaterial.Loc > maxPail)
// {
// maxPail = rawMaterial.Loc;
// }
// }
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1);
// //Thread s = new Thread(() => { mmm(); });
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);

// }
// }



// if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
// {
// int doCount = Array.FindIndex(Recipes.ToArray(), p => p.SerialNum == (int)DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount-1) ;
// if (doCount >=0)
// {
// var res = Recipes.ElementAt(doCount).RawMaterials?.ToList().FindAll(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// foreach (RawMaterialModel item in res)
// {
// if (item != null && item.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail)
// {
// DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// if (deviceSet != null)
// {
// //开始配料信号
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
// //传送带停止
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
// //设置下料重量
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.WeightSet.ToAdd(), item.RawMaterialWeight);
// //设置慢加重量
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight);
// //设置快慢加速度
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration);
// //设置提前关阀重量
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
// //设置伺服手动速度
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
// //设置料仓上下限重量
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
// ////设置搅拌速度
// //DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
// }
// }
// }
// }
// }



// }
// if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail != 0 && (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail))
// {
// string passName = RecipeNames.ElementAt(0);
// RecipeNames.TryDequeue(out passName);
// }
// if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}")
// {
// if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 3)
// {
// DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
// }
// //if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3)
// //{
// // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
// //}
// //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
// //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
// //else if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 1)
// //{
// // //传送带运行
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
// // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp);
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
// //}
// else
// {
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
// //传送带停止
// }
// }
// else
// {
// if (SimensSend.GetInstance.sendCtrlModel.Stop)
// {
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
// }
// else
// {
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
// }
// //传送带终点为3则传送带停止,小于3则按照出料状态运行
// }
// }

// }

// }

// Thread.Sleep(10);
//}, "启动配方下发", true);
}

}
}

+ 43
- 38
DosingSystem/Model/DeviceInquire.cs View File

@@ -26,7 +26,7 @@ namespace BPASmartClient.DosingSystem
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire());
private DeviceInquire() { }

string IPSegment = "192.168.0.";
string IPSegment = "192.168.2.";
public ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>();
List<string> InvalidIP = new List<string>();//无效 IP 集合
List<string> IPLists = new List<string>();//启动 Ping 任务IP集合
@@ -150,11 +150,12 @@ namespace BPASmartClient.DosingSystem
if (!string.IsNullOrEmpty(Json<DevicePar>.Data.BaseParModel.NetworkSegAddress)) IPSegment = Json<DevicePar>.Data.BaseParModel.NetworkSegAddress;
else Json<DevicePar>.Data.BaseParModel.NetworkSegAddress = IPSegment;
stockCount = Json<DevicePar>.Data.BaseParModel.StockCount;
TestData();
//TestData();
IpAddressLines();
Task.Factory.StartNew(() =>
{
SiemensDevice.GetInstance.Connect(Json<DevicePar>.Data.BaseParModel.DeviceAddress);
SimensSend.GetInstance.Connect();
//SiemensDevice.GetInstance.Connect(Json<DevicePar>.Data.BaseParModel.DeviceAddress);
});
DeviceDataInit();
TaskManage.GetInstance.StartLong(new Action(() =>
@@ -196,6 +197,7 @@ namespace BPASmartClient.DosingSystem
{
IPLists.Clear();
IPQueues.Clear();
//TestData();
/*for (int i = 1; i <= 255; i++)
{
if (!InvalidIP.Contains($"{IPSegment}{i}") && !DeviceLists.ContainsKey($"{IPSegment}{i}"))
@@ -207,7 +209,7 @@ namespace BPASmartClient.DosingSystem
}
}
}*/
for (int i = 0; i < stockCount; i++)
{
IPLists.Add($"{IPSegment}{(i + 1) * 10}");
@@ -228,6 +230,7 @@ namespace BPASmartClient.DosingSystem
if (e.Reply != null && e.Reply.Status == IPStatus.Success)
{
string ip = e.Reply.Address.ToString();
if (!DeviceLists.ContainsKey(ip))
{
DeviceStatus DS = new DeviceStatus();
@@ -236,7 +239,9 @@ namespace BPASmartClient.DosingSystem
DS.modbusTcp.Connected = new Action(() =>
{
var tt = DS.modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20);
string DeviceName = DS.modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20).Content?.Trim()?.Replace(" ", "");//读取设备名称
if (DeviceName.Length > 0)
{
DeviceLists.TryAdd(ip, DS);
@@ -369,7 +374,7 @@ namespace BPASmartClient.DosingSystem

////获取设备料仓剩余重量
var wf = this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (wf.IsSuccess) deviceStatus.WeightFeedback = (float)(wf.Content);
if (wf.IsSuccess) deviceStatus.WeightFeedback = (uint)(wf.Content);

////获取下料重量
var nwf = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
@@ -415,16 +420,16 @@ namespace BPASmartClient.DosingSystem
var ss = this.modbusTcp.Read<uint>(DeviceAddress.StirringSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (ss.IsSuccess) deviceStatus.StirringSpeed = ss.Content;
//获取桶是否到位
var pailArrive = this.modbusTcp.Read<uint>(DeviceAddress.PailArrive.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
var pailArrive = this.modbusTcp.Read<ushort>(DeviceAddress.PailArrive.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (pailArrive.IsSuccess) deviceStatus.PailArrive = pailArrive.Content;
//已通过桶数
var pass = this.modbusTcp.Read<uint>(DeviceAddress.PassPail.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
var pass = this.modbusTcp.Read<ushort>(DeviceAddress.PassPail.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (pass.IsSuccess) deviceStatus.PassPail = pass.Content;
//配料最大桶数
var max = this.modbusTcp.Read<uint>(DeviceAddress.MaxPail.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
var max = this.modbusTcp.Read<ushort>(DeviceAddress.MaxPail.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (max.IsSuccess) deviceStatus.MaxPassPail = max.Content;
//执行配方数
var doCount = this.modbusTcp.Read<uint>(DeviceAddress.DoRecipeCount.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
var doCount = this.modbusTcp.Read<ushort>(DeviceAddress.DoRecipeCount.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (doCount.IsSuccess) deviceStatus.DoRecipeCount = doCount.Content;
//this.DeviceName = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20).Content.Trim().Replace(" ", "");
//deviceStatus.RunStatus = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd()).Content; //获取设备运行状态
@@ -673,38 +678,38 @@ namespace BPASmartClient.DosingSystem
if (value8 != null && value8.ToString() != res.StirringSpeed.ToString()) goto prop8;
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成");
}
prop9:
modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}");
var value9 = modbusTcp.Read<float>(DeviceAddress.WeightSet.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if ((value9 != null && value9.ToString() != Value.ToString()) || value9 == 0) goto prop9;
//prop10:
//MessageNotify.GetInstance.ShowRunLog($"写入配方重量,值{Value}:{value9}");
//modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
//var value10 = modbusTcp.Read<ushort>(DeviceAddress.Start.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
//if ((value10 != null && value10.ToString() != 1.ToString())||value10==0) goto prop10;
//modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
Task.Run(() =>
{
while (true)
{
ushort c = modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
MessageNotify.GetInstance.ShowRunLog($"{IpAddress}:LW51,值:{modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content}");
string str = DecToBinary(c);
if (str[8].ToString() == 0.ToString())
{
modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
}
else
return;
}
//prop9:
// modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
// MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}");
// var value9 = modbusTcp.Read<float>(DeviceAddress.WeightSet.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if ((value9 != null && value9.ToString() != Value.ToString()) || value9 == 0) goto prop9;
// //prop10:
// //MessageNotify.GetInstance.ShowRunLog($"写入配方重量,值{Value}:{value9}");
// //modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
// //var value10 = modbusTcp.Read<ushort>(DeviceAddress.Start.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// //if ((value10 != null && value10.ToString() != 1.ToString())||value10==0) goto prop10;
// //modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
// modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
// Task.Run(() =>
// {
// while (true)
// {
// ushort c = modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// MessageNotify.GetInstance.ShowRunLog($"{IpAddress}:LW51,值:{modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content}");
// string str = DecToBinary(c);
// if (str[8].ToString() == 0.ToString())
// {
// modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
// }
// else
// return;
// }


});
// });

MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动配料");
// MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动配料");
}
}



+ 12
- 0
DosingSystem/Model/Expand.cs View File

@@ -1,9 +1,21 @@
using System;
using System.Windows.Forms;

namespace BPASmartClient.DosingSystem.Model
{
public static class Expand
{
public static bool Tobool(this ushort value)
{
if (value == 1)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 获取 M 区 和 VW 区的Modbus的地址
/// </summary>


+ 5
- 5
DosingSystem/Model/RawMaterialDeviceStatus.cs View File

@@ -16,7 +16,7 @@ namespace BPASmartClient.DosingSystem
/// <summary>
/// 料仓重量反馈
/// </summary>
public float WeightFeedback { get; set; }
public uint WeightFeedback { get; set; }

/// <summary>
/// 当前出料重量反馈
@@ -101,18 +101,18 @@ namespace BPASmartClient.DosingSystem
/// <summary>
/// 最大通过桶数
/// </summary>
public uint MaxPassPail { get; set; }
public ushort MaxPassPail { get; set; }
/// <summary>
/// 已通过桶数
/// </summary>
public uint PassPail { get; set; }
public ushort PassPail { get; set; }
/// <summary>
/// 到位检测 为1有桶。0无桶
/// </summary>
public uint PailArrive { get; set; }
public ushort PailArrive { get; set; }
/// <summary>
/// 设备执行配方数量
/// </summary>
public uint DoRecipeCount { get;set; }
public ushort DoRecipeCount { get;set; }
}
}

+ 68
- 0
DosingSystem/Model/SendCtrlModel.cs View File

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

namespace BPASmartClient.DosingSystem.Model
{
public class SendCtrlModel:NotifyBase
{
/// <summary>
/// T0料仓输送限制
/// </summary>
public bool SendInfo{get { return _sendInfo; }set { _sendInfo = value;OnPropertyChanged(); }}
private bool _sendInfo;
/// <summary>
/// 急停
/// </summary>
public bool Stop{get { return _stop; }set { _stop = value; OnPropertyChanged(); } }
private bool _stop;
/// <summary>
/// 出桶光电1
/// </summary>
public bool OutputOptical_1 { get { return _outputOptical_1; } set { _outputOptical_1 = value; OnPropertyChanged(); } }
private bool _outputOptical_1;
/// <summary>
/// 出桶光电2
/// </summary>
public bool OutputOptical_2 { get { return _outputOptical_2; } set { _outputOptical_2 = value; OnPropertyChanged(); } }
private bool _outputOptical_2;
/// <summary>
/// 出桶光电3
/// </summary>
public bool OutputOptical_3 { get { return _outputOptical_3; } set { _outputOptical_3 = value; OnPropertyChanged(); } }
private bool _outputOptical_3;
/// <summary>
/// 出桶光电3
/// </summary>
public bool InputOptical_1 { get { return _inputOptical_1; } set { _inputOptical_1 = value; OnPropertyChanged(); } }
private bool _inputOptical_1;
/// <summary>
/// 出桶光电3
/// </summary>
public ObservableCollection<CylinderModel> CylinderModels { get; set; } = new ObservableCollection<CylinderModel>();
}
public class CylinderModel:NotifyBase
{
/// <summary>
/// 开到位
/// </summary>
public bool OnStatus { get { return _onStatus; } set { _onStatus = value; OnPropertyChanged(); } }
private bool _onStatus;
/// <summary>
/// 关到位
/// </summary>
public bool OffStatus { get { return _offStatus; } set { _offStatus = value; OnPropertyChanged(); } }
private bool _offStatus;
/// <summary>
/// 气缸名称
/// </summary>
public string Name { get { return _name; } set { _name = value; OnPropertyChanged(); } }
private string _name;
}
}

+ 2
- 2
DosingSystem/Model/par/BasePar.cs View File

@@ -12,13 +12,13 @@ namespace BPASmartClient.DosingSystem
/// 设备扫描网段
/// </summary>
public string NetworkSegAddress { get { return _mNetworkSegAddress; } set { _mNetworkSegAddress = value; OnPropertyChanged(); } }
private string _mNetworkSegAddress = "192.168.0.";
private string _mNetworkSegAddress = "192.168.2.";

/// <summary>
/// 输送带设备 PLC IP 地址
/// </summary>
public string DeviceAddress { get { return _mDeviceAddress; } set { _mDeviceAddress = value; OnPropertyChanged(); } }
private string _mDeviceAddress = "192.168.0.15";
private string _mDeviceAddress = "192.168.2.200";


/// <summary>


+ 5
- 5
DosingSystem/Model/par/DeviceParModel.cs View File

@@ -25,14 +25,14 @@ namespace BPASmartClient.DosingSystem
/// <summary>
/// 快加速度
/// </summary>
public int RapidAcceleration { get { return _mRapidAcceleration; } set { _mRapidAcceleration = value; OnPropertyChanged(); } }
private int _mRapidAcceleration;
public float RapidAcceleration { get { return _mRapidAcceleration; } set { _mRapidAcceleration = value; OnPropertyChanged(); } }
private float _mRapidAcceleration;

/// <summary>
/// 慢加速度
/// </summary>
public int SlowAcceleration { get { return _mSlowAcceleration; } set { _mSlowAcceleration = value; OnPropertyChanged(); } }
private int _mSlowAcceleration;
public float SlowAcceleration { get { return _mSlowAcceleration; } set { _mSlowAcceleration = value; OnPropertyChanged(); } }
private float _mSlowAcceleration;

/// <summary>
/// 伺服手动速度
@@ -65,7 +65,7 @@ namespace BPASmartClient.DosingSystem
public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } }
private bool _mIsRedundant;
/// <summary>
/// 2023.10.10添加字段
/// 2023.10.10添加字段 输送速度
/// </summary>
public ushort SendSp { get { return _sendSp; } set { _sendSp = value; OnPropertyChanged(); } }
private ushort _sendSp;


+ 71
- 1
DosingSystem/Service/SiemensDevice.cs View File

@@ -1,10 +1,80 @@
using BPA.Communication;
using BPA.Helper;
using BPASmartClient.DosingSystem.Model;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;

namespace BPASmartClient.DosingSystem
{
public class SimensSend
{
private volatile static SimensSend _Instance;
public static SimensSend GetInstance => _Instance ?? (_Instance = new SimensSend());
private SimensSend() { }

static string ip = "192.168.2.200";
public ObservableCollection<SendCtrlModel> sendCtrlModels { get; set; } = new ObservableCollection<SendCtrlModel>();
public SendCtrlModel sendCtrlModel { get; set; } = new SendCtrlModel();
public Siemens SendSimens { get; set; } = new Siemens();
private bool IsConnect { get; set; }
public bool tempValue = false;
public void Connect()
{
try
{
IsConnect = SendSimens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.2.200", cpuType = BPA.Communication.CpuType.S71200, Port = 102 });

}
catch (Exception)
{

//throw;
}
TaskManage.GetInstance.StartLong(new Action(() =>
{
if (IsConnect)
{
SendSimens.Write("DB1.DBX704.0", tempValue);//设备心跳
tempValue = !tempValue;
}
Thread.Sleep(1000);
}), "设备心跳", true);
TaskManage.GetInstance.StartLong(new Action(() =>
{
//App.Current.Dispatcher.Invoke(() => {
if (IsConnect)
{
sendCtrlModel.SendInfo = SendSimens.Read<ushort>("DB1.DBX700.0").Content.Tobool();
sendCtrlModel.Stop = SendSimens.Read<ushort>("I0.0").Content.Tobool();
App.Current.Dispatcher.Invoke(() =>
{
if (sendCtrlModel.CylinderModels.Count > 0)
{
sendCtrlModel.CylinderModels.Clear();

}
sendCtrlModel.CylinderModels.Add(new CylinderModel() { Name = "气缸3", OnStatus = SendSimens.Read<ushort>("I0.1").Content.Tobool(), OffStatus = SendSimens.Read<ushort>("I0.2").Content.Tobool() });
sendCtrlModel.CylinderModels.Add(new CylinderModel() { Name = "气缸2", OnStatus = SendSimens.Read<ushort>("I0.4").Content.Tobool(), OffStatus = SendSimens.Read<ushort>("I0.3").Content.Tobool() });
sendCtrlModel.CylinderModels.Add(new CylinderModel() { Name = "气缸1", OnStatus = SendSimens.Read<ushort>("I0.6").Content.Tobool(), OffStatus = SendSimens.Read<ushort>("I0.5").Content.Tobool() });


});
sendCtrlModel.OutputOptical_1 = SendSimens.Read<ushort>("I0.7").Content.Tobool();
sendCtrlModel.OutputOptical_2 = SendSimens.Read<ushort>("I1.0").Content.Tobool();
sendCtrlModel.OutputOptical_3 = SendSimens.Read<ushort>("I1.1").Content.Tobool();
sendCtrlModel.InputOptical_1 = SendSimens.Read<ushort>("I1.2").Content.Tobool();
}
//});

Thread.Sleep(100);
}), "读取输送线设备数据", true);
}
}
public class SiemensDevice
{
private volatile static SiemensDevice _Instance;
@@ -46,7 +116,7 @@ namespace BPASmartClient.DosingSystem
};
try
{
IsConnect = MySiemens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.0.100", cpuType = BPA.Communication.CpuType.S71200, Port = 102 });
IsConnect = MySiemens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.2.200", cpuType = BPA.Communication.CpuType.S71200, Port = 102 });

}
catch (Exception)


+ 258
- 0
DosingSystem/View/SendCtrlView.xaml View File

@@ -0,0 +1,258 @@
<UserControl x:Class="BPASmartClient.DosingSystem.View.SendCtrlView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View"
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
xmlns:cv ="clr-namespace:BPASmartClient.DosingSystem.Converter"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:SendCtrlViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<cv:RunStateConvert x:Key="runStateConvert"/>
<cv:AutoConvert x:Key="autoConvert"/>
<Style x:Key="CheckState" TargetType="CheckBox">
<Setter Property="Margin" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#ddd" />
<Setter Property="VerticalContentAlignment" Value="Bottom" />
<Setter Property="Margin" Value="2,5" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="Consolas" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Border
Name="radiobutton"
Background="{TemplateBinding Background}"
CornerRadius="5"
Opacity="0.85">
<Grid>
<!--<Border
x:Name="back_border"
BorderBrush="Black"
BorderThickness="0"
CornerRadius="1">
<Border.Effect>
<BlurEffect KernelType="Gaussian" Radius="2" />
</Border.Effect>
</Border>
<Border
x:Name="fore_border"
Margin="2"
BorderBrush="White"
BorderThickness="0"
CornerRadius="{Binding ElementName=button, Path=CornerRadius}"
Opacity="0.7">
<Border.Effect>
<BlurEffect KernelType="Gaussian" Radius="2" />
</Border.Effect>
</Border>-->


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

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

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

</Trigger>

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

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

</Setter.Value>

</Setter>

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


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

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

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

</Trigger>

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

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

</Setter.Value>

</Setter>

</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="手自动控制:" Foreground="White" Style="{StaticResource TitleTextblockStyle}" FontSize="20"/>
<TextBlock Margin="10,0,0,0" Text="{Binding AutoCtrl,Converter={StaticResource autoConvert}}" Foreground="Red" Style="{StaticResource TextBlockStyle}" FontSize="18"/>
</StackPanel>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Orientation="Horizontal">
<RadioButton Margin="10" Content="手动" Style="{DynamicResource RadioState}" IsChecked="{Binding HandCtrl}"/>
<RadioButton Margin="10" Content="自动" Style="{DynamicResource RadioState}" IsChecked="{Binding AutoCtrl}"/>
</StackPanel>
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Margin="10" Content="{Binding RunState,Converter={StaticResource runStateConvert}}" Style="{StaticResource CheckState}" IsChecked="{Binding RunState}"/>
</Grid>
<Grid Grid.Row="1">
<UniformGrid Columns="2" Rows="2">
<TextBlock Text="桶到位光电状态" Foreground="White" Style="{StaticResource TitleTextblockStyle}" FontSize="20"/>
<TextBlock Text="气缸状态" Foreground="White" Style="{StaticResource TitleTextblockStyle}" FontSize="20"/>
<UniformGrid Columns="2" Rows="2">
<CheckBox Margin="5" IsEnabled="False" Content="进桶1光电" Style="{StaticResource CheckState}" IsChecked="{Binding SendCtrlModel.InputOptical_1}"/>
<CheckBox Margin="5" IsEnabled="False" Content="出桶1光电" Style="{StaticResource CheckState}" IsChecked="{Binding SendCtrlModel.OutputOptical_1}"/>
<CheckBox Margin="5" IsEnabled="False" Content="出桶2光电" Style="{StaticResource CheckState}" IsChecked="{Binding SendCtrlModel.OutputOptical_2}"/>
<CheckBox Margin="5" IsEnabled="False" Content="出桶3光电" Style="{StaticResource CheckState}" IsChecked="{Binding SendCtrlModel.OutputOptical_3}"/>
</UniformGrid>

<Grid Margin="5">
<ListBox
ItemsSource="{Binding SendCtrlModel.CylinderModels}"
Background="Transparent"
BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="3"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="10" Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Margin="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="{Binding Name}" Foreground="White" Style="{StaticResource TitleTextblockStyle}" FontSize="20"/>
<CheckBox Height="30" Margin="5" IsEnabled="false" Content="开" Style="{DynamicResource CheckState}" IsChecked="{Binding OnStatus}"/>
<CheckBox Height="30" Margin="5" Content="关" IsEnabled="false" Style="{DynamicResource CheckState}" IsChecked="{Binding OffStatus}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</UniformGrid>
</Grid>


<Grid Grid.Row="2">
</Grid>

</Grid>
</UserControl>

+ 28
- 0
DosingSystem/View/SendCtrlView.xaml.cs View File

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

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

+ 4
- 118
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -28,8 +28,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
//ChangeRecipeStateCommand = new BPARelayCommand<object>(ChangeRecipeState);
//CancelRecipeCommand = new BPARelayCommand<object>(CancelRecipe);
//RecipeRun();
RecipeStatusInquire();
MatchRun();
//RecipeStatusInquire();
StartCommand = new BPARelayCommand<object>(new Action<object>((o) => {
if (o != null && o is string recipeName)
{
@@ -122,120 +121,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
//}


private void MatchRun()
{
recipeProcesses.Clear();
TaskManage.GetInstance.StartLong(() =>
{
if (RecipeNames.Count > 0)
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices.Last().IpAddress].deviceStatus.MaxPassPail!=0 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices.Last().IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices.Last().IpAddress].deviceStatus.PassPail && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices.Last().IpAddress].deviceStatus.RunStatus == 3)
{
recipeProcesses.Remove(recipeProcesses.Last());
UserTreeCompelete.Insert(0, recipeProcesses.Last());

}
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == 0 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3)
{

if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail)
{
string passName = RecipeNames.ElementAt(0);
RecipeNames.TryDequeue(out passName);
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0));
if (index > 0 && index < Recipes.Count)
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
if (UserTreeWait.Count > 0)
{
recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(0)));
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(0)));
}
}));
int maxPail = 0;
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
{
if (rawMaterial.Loc > maxPail)
{
maxPail = rawMaterial.Loc;
}
}
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);

}
}


if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1)
{
int doCount = Array.FindIndex(Recipes.ToArray(), p => p.SerialNum == (int)DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount);
RawMaterialModel res = Recipes.ElementAt(doCount).RawMaterials?.ToList().Find(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
if (res != null && res.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail)
{
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
if (deviceSet != null)
{
//设置启动
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), 1);
//设置下料重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<uint>(DeviceAddress.WeightSet.ToAdd(), res.RawMaterialWeight);
//设置慢加重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight);
//设置快慢加速度
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration);
//设置提前关阀重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
//设置伺服手动速度
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
//设置料仓上下限重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
//设置搅拌速度
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
}
}

}


}
if (i < DeviceInquire.GetInstance.devices.Count - 1)
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 0)
{
//传送带运行
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
}
else
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//传送带停止
}
}
else
{
//传送带终点为3则传送带停止,小于3则按照出料状态运行
}
}
}
}

Thread.Sleep(100);
}, "启动配方下发", true);
}

/// <summary>
/// 配方业务执行
@@ -1139,12 +1025,12 @@ namespace BPASmartClient.DosingSystem.ViewModel
/// <summary>
/// 等待制作的配方
/// </summary>
public static ObservableCollection<RecipeModel> UserTreeWait { get; set; } = new ObservableCollection<RecipeModel>();
public static ObservableCollection<RecipeModel> UserTreeWait { get; set; } = ExcuteControl.GetInstance.UserTreeWait;

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


//private void ChangeRecipeState(object o)


+ 52
- 0
DosingSystem/ViewModel/SendCtrlViewModel.cs View File

@@ -0,0 +1,52 @@
using BPA.Helper;
using BPASmartClient.DosingSystem.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BPASmartClient.DosingSystem.ViewModel
{
public class SendCtrlViewModel:NotifyBase
{
public SendCtrlViewModel()
{
}

/// <summary>
/// 传送带状态显示
/// </summary>
public SendCtrlModel SendCtrlModel { get { return sendCtrlModel; } set { sendCtrlModel = value; OnPropertyChanged(); } }
private SendCtrlModel sendCtrlModel = SimensSend.GetInstance.sendCtrlModel;

public BPARelayCommand MyProperty { get; set; }



/// <summary>
/// 系统启停控制
/// </summary>
public bool RunState{ get { return _runState; }set { _runState = value; OnPropertyChanged(); }}
private bool _runState = false;

/// <summary>
/// 自动
/// </summary>
public bool AutoCtrl{get { return _autoCtrl; }set { _autoCtrl = value;OnPropertyChanged(); }}
private bool _autoCtrl = true;

/// <summary>
/// 手动
/// </summary>
public bool HandCtrl { get { return _handCtrl; } set { _handCtrl = value; OnPropertyChanged(); } }
private bool _handCtrl;

}
}


Loading…
Cancel
Save