Browse Source

调试

一拖四味魔方配料系统
ZhaoGang 11 months ago
parent
commit
4137e39045
4 changed files with 95 additions and 36 deletions
  1. +15
    -15
      DosingSystem/App.xaml.cs
  2. +35
    -11
      DosingSystem/ExcuteControl .cs
  3. +39
    -7
      DosingSystem/Model/DeviceInquire.cs
  4. +6
    -3
      DosingSystem/ViewModel/DeviceListViewModel.cs

+ 15
- 15
DosingSystem/App.xaml.cs View File

@@ -171,13 +171,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 = "测试",
// SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
// AssemblyName = "BPASmartClient.DosingSystem",
// ToggleWindowPath = "View.SendCtrlView"
//});
//ParSet.Add(new SubMenumodel()
//{
// SubMenuName = "出料口管理设置",
@@ -229,14 +229,14 @@ namespace BPASmartClient.DosingSystem
// AssemblyName = "BPASmartClient.DosingSystem",
// ToggleWindowPath = "View.StockControlView"
//});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "",
MainMenuName = "手动控制",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "Parameter Set",
subMenumodels = ManualControl,
});
//MenuManage.GetInstance.menuModels.Add(new MenuModel()
//{
// MainMenuIcon = "",
// MainMenuName = "手动控制",
// MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
// Alias = "Parameter Set",
// subMenumodels = ManualControl,
//});
#endregion

#region 消息日志


+ 35
- 11
DosingSystem/ExcuteControl .cs View File

@@ -404,6 +404,7 @@ namespace BPASmartClient.DosingSystem
{
SimensSend.GetInstance.SendSimens.Write("M0.0", true);
SimensSend.GetInstance.SendSimens.Write("M0.1", true);
//遍历每一个味魔方。
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
//判断IP是否在列表中
@@ -412,12 +413,13 @@ namespace BPASmartClient.DosingSystem
//只有设备在等待配料状态才能下发数据
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
{
//判断
//判断MaxPassPail--配方的最大桶数,小于已经通过的桶数。
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))
{
int index = 0;
// 该味魔方已经完成的配方数目。
int recipeNameNum = doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress];
//设备已执行的配方必须小于已经下发的配方。所以每次开启软件时 必须清零设备上的数据。
if (recipeNameNum == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount && recipeNameNum < RecipeNames.Count)
@@ -441,7 +443,7 @@ namespace BPASmartClient.DosingSystem
doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, recipeNameNum + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]);

App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方{RecipeNames.ElementAt(recipeNameNum)}{recipeNameNum}下发到设备{DeviceInquire.GetInstance.devices[i].DeviceName}"); });
//必须等第一台设备下发成功了,才算正在进行。
if (doDeviceCount.ContainsKey("192.168.2.10") && UserTreeWait.Count > 0 && doDeviceCount["192.168.2.10"] > recipeProcesses.Count)
{
App.Current.Dispatcher.Invoke(() =>
@@ -450,6 +452,7 @@ namespace BPASmartClient.DosingSystem
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
});
}
//
if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.180" && recipeNameNum > 1 && recipeProcesses.Count > 0)
{
App.Current.Dispatcher.Invoke(() =>
@@ -532,20 +535,31 @@ namespace BPASmartClient.DosingSystem
var deviceModbus = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp;
//传送带停止
deviceModbus.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
Thread.Sleep(50);
//设置下料重量
deviceModbus.Write<float>(DeviceAddress.WeightSet.ToAdd(), item.RawMaterialWeight);
Thread.Sleep(50);
//设置慢加重量
deviceModbus.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight);
//设置快慢加速度
deviceModbus.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration);
deviceModbus.Write<float>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration);
Thread.Sleep(50);
//设置提前关阀重量
deviceModbus.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
Thread.Sleep(50);

//设置快慢加速度
deviceModbus.Write<int>(DeviceAddress.SlowAcceleration.ToAdd(), (int)deviceSet.SlowAcceleration);
Thread.Sleep(50);
deviceModbus.Write<int>(DeviceAddress.RapidAcceleration.ToAdd(), (int)deviceSet.RapidAcceleration);
Thread.Sleep(50);
//设置伺服手动速度
deviceModbus.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
deviceModbus.Write<int>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
Thread.Sleep(50);
//设置料仓上下限重量
deviceModbus.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
deviceModbus.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
deviceModbus.Write<int>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
Thread.Sleep(50);
deviceModbus.Write<int>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
Thread.Sleep(50);
//开始配料信号
deviceModbus.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
////设置搅拌速度
@@ -637,10 +651,13 @@ namespace BPASmartClient.DosingSystem
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
}

}
else
}
else
{
var runstatus = DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.RunStatus;
if (runstatus == 1 || runstatus == 3)
{
if (SimensSend.GetInstance.sendCtrlModel.SendInfo && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1)
if ((SimensSend.GetInstance.sendCtrlModel.SendInfo && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1))
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
@@ -650,8 +667,15 @@ namespace BPASmartClient.DosingSystem
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);

}

}
}
}
Thread.Sleep(10);


+ 39
- 7
DosingSystem/Model/DeviceInquire.cs View File

@@ -35,6 +35,11 @@ namespace BPASmartClient.DosingSystem
List<string> IPLists = new List<string>();//启动 Ping 任务IP集合
ConcurrentQueue<string> IPQueues = new ConcurrentQueue<string>();//pincomplete 完成队列

/// <summary>
/// 记录每个IP对应的设备是否已经执行数据清零,避免重连后再次清零。
/// </summary>
private ConcurrentDictionary<string, bool> IsClearData = new();

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>();
@@ -217,6 +222,13 @@ namespace BPASmartClient.DosingSystem
{
IPLists.Add($"{IPSegment}{(i + 1) * 10}");
//IPLists.Add($"{IPSegment}{this.devices[i].DeviceNum}");

//2023-11-23:根据IP添加到记录字典。
var ip = $"{IPSegment}{(i + 1) * 10}";
if (!IsClearData.ContainsKey(ip))
{
IsClearData.TryAdd($"{IPSegment}{(i + 1) * 10}", false);
}
}

IPLists.ForEach((item) =>
@@ -250,6 +262,18 @@ namespace BPASmartClient.DosingSystem
DeviceLists.TryAdd(ip, DS);
DeviceLists[ip].Init(DeviceName);
DeviceLists[ip].modbusTcp.IsReconnect = false;

#region 2023-11-23修改:在该IP第一次连接时清除设备的数据,后续重连时不清除。
if (IsClearData.ContainsKey(ip) && IsClearData[ip] == false)
{
if (DS.ClearData())
{
//清除成功就置位。
IsClearData[ip] = true;
}
}
#endregion

App.Current.Dispatcher.Invoke(new Action(() =>
{
devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip });
@@ -365,13 +389,6 @@ namespace BPASmartClient.DosingSystem
AlarmHelper<AlarmInfo>.Init();
if (IsConnected)
{
#region 2023-11-20-17新增:在软件重启时,自动清零设备上的配方执行数量等数据。
modbusTcp.Write<ushort>(DeviceAddress.ZeroRecipeCount.ToAdd(), 1);
Thread.Sleep(500);
modbusTcp.Write<ushort>(DeviceAddress.ZeroRecipeCount.ToAdd(), 0);
#endregion


TaskManage.GetInstance.StartLong(new Action(() =>
{
var dn = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20);
@@ -459,6 +476,21 @@ namespace BPASmartClient.DosingSystem
}), $"{DeviceName} 开始监听", true);
}
}

public bool ClearData()
{
if (IsConnected)
{
#region 2023-11-20-17新增:在软件重启时,自动清零设备上的配方执行数量等数据。
var result1= modbusTcp.Write<ushort>(DeviceAddress.ZeroRecipeCount.ToAdd(), 1).IsSuccess;
Thread.Sleep(500);
var result2= modbusTcp.Write<ushort>(DeviceAddress.ZeroRecipeCount.ToAdd(), 0).IsSuccess;

return result1 && result2;
#endregion
}
return false;
}
public void SetDeviceName(string name,int index)
{
this.modbusTcp.Write(DeviceAddress.DeviceName.ToAdd(), new ushort[20]);


+ 6
- 3
DosingSystem/ViewModel/DeviceListViewModel.cs View File

@@ -1,4 +1,5 @@
using BPA.Helper;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.DosingSystem.View;
using System;
using System.Collections.Generic;
@@ -16,9 +17,11 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
if (o != null && o is string str)
{
ChangeDeviceNameView cdn = new ChangeDeviceNameView();
ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str);
cdn.ShowDialog();
//2023-11-23:删除原因:软件不支持该功能。
//ChangeDeviceNameView cdn = new ChangeDeviceNameView();
//ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str);
//cdn.ShowDialog();
MessageNotify.GetInstance.ShowDialog("该软件仅可从设备读取物料名称,不支持修改。");
}
});
//devices = DeviceInquire.GetInstance.devices;


Loading…
Cancel
Save