Commit 2435ab67 张东亮

共享通道、io检测负载、开关大料架任务

1 个父辈 ca2d1cd2
正在显示 62 个修改的文件 包含 205 行增加23 行删除
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectView>ProjectFiles</ProjectView> <ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
\ No newline at end of file \ No newline at end of file
...@@ -260,13 +260,15 @@ namespace AGVDispatch ...@@ -260,13 +260,15 @@ namespace AGVDispatch
LogUtil.Error($"表格式异常:{e.RowIndex},{e.ColumnIndex},{e.Exception.Message}"); LogUtil.Error($"表格式异常:{e.RowIndex},{e.ColumnIndex},{e.Exception.Message}");
} }
object locObj = new object(); object locObj = new object();
bool OpenBigShelf = AppConfigSetting.GetBoolVal(Setting_Str.OpenBigShelf, false);
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
if (Monitor.TryEnter(locObj)) if (Monitor.TryEnter(locObj))
{ {
List<ClientNode> nodes = NodeManager.GetClientNodes(); List<ClientNode> nodes = NodeManager.GetClientNodes();
OrderManager.AutoGenerateOrder(nodes); OrderManager.AutoGenerateOrder(nodes);
OrderManager.GenerateShelfOrder(nodes); if (OpenBigShelf)
OrderManager.GenerateShelfOrder(nodes);
Monitor.Exit(locObj); Monitor.Exit(locObj);
} }
} }
......
...@@ -2,4 +2,7 @@ ...@@ -2,4 +2,7 @@
<config ver="10"> <config ver="10">
<item key="WebApiPort" ver="10" value="8088" /> <item key="WebApiPort" ver="10" value="8088" />
<item key="HttpServer" ver="10" value="http://localhost:8001/smf-core" /> <item key="HttpServer" ver="10" value="http://localhost:8001/smf-core" />
<item key="SharedLine" ver="10" value="A05-2FSMT-06S,A05-2FSMT-16S;A05-2FSMT-07S,A05-2FSMT-17S;A05-3FSMT-05S,A05-3FSMT-15S" />
<item key="OpenBigShelf" ver="10" value="False" />
<item key="OpenCheckLoadIO" ver="10" value="True" />
</config> </config>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<config ver="10"> <config ver="10">
<item key="WebApiPort" ver="10" value="8088" /> <item key="WebApiPort" ver="10" value="8088" />
<item key="HttpServer" ver="10" value="http://localhost:8001/smf-core" />
<item key="SharedLine" ver="10" value="A05-2FSMT-06S,A05-2FSMT-16S;A05-2FSMT-07S,A05-2FSMT-17S;A05-3FSMT-05S,A05-3FSMT-15S" />
<item key="OpenBigShelf" ver="10" value="False" />
</config> </config>
\ No newline at end of file \ No newline at end of file
[2022-11-22 18:02:37,033][1]INFO AGVServer 【12000】服务启动 [2022-12-14 14:45:28,380][1]INFO AGVServer 【12000】服务启动
[2022-11-22 18:02:37,036][1]INFO Server start listen : 12000 [2022-12-14 14:45:28,382][1]INFO Server start listen : 12000
[2022-11-22 18:02:37,043][1]INFO 本机IP:[ 192.168.0.105 192.168.64.1 192.168.153.1 172.20.192.1] [2022-12-14 14:45:28,391][1]INFO 本机IP:[ 192.168.101.37 192.168.64.1 192.168.153.1 172.28.128.1]
[2022-12-14 14:50:22,311][1]INFO AGVServer 【12000】服务启动
[2022-12-14 14:50:22,313][1]INFO Server start listen : 12000
[2022-12-14 14:50:22,416][1]INFO 本机IP:[ 192.168.101.37 192.168.64.1 192.168.153.1 172.28.128.1]
[2022-12-14 15:26:45,217][1]INFO AGVServer 【12000】服务启动
[2022-12-14 15:26:45,221][1]INFO Server start listen : 12000
[2022-12-14 15:26:45,228][1]INFO 本机IP:[ 192.168.101.37 192.168.64.1 192.168.153.1 172.28.128.1]
[2022-12-14 15:27:58,961][1]INFO AGVServer 【12000】服务启动
[2022-12-14 15:27:58,965][1]INFO Server start listen : 12000
[2022-12-14 15:27:58,990][1]INFO 本机IP:[ 192.168.101.37 192.168.64.1 192.168.153.1 172.28.128.1]
[2022-12-14 15:29:02,890][1]INFO AGVServer 【12000】服务启动
[2022-12-14 15:29:02,893][1]INFO Server start listen : 12000
[2022-12-14 15:29:02,901][1]INFO 本机IP:[ 192.168.101.37 192.168.64.1 192.168.153.1 172.28.128.1]
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<appSettings> <appSettings>
<add key="ProName" value="AGVDispatch-混料问题修复" /> <add key="ProName" value="AGVDispatch-在共享通道冲突问题优化" />
</appSettings> </appSettings>
</configuration> </configuration>
\ No newline at end of file \ No newline at end of file
...@@ -49,5 +49,8 @@ namespace Common ...@@ -49,5 +49,8 @@ namespace Common
public const string WebApiPort = "WebApiPort"; public const string WebApiPort = "WebApiPort";
public const string App_Title = "App_Title"; public const string App_Title = "App_Title";
public const string ShelfPlace = "ShelfPlace"; public const string ShelfPlace = "ShelfPlace";
public const string SharedLine = "SharedLine";
public const string OpenBigShelf = "OpenBigShelf";
public const string OpenCheckLoadIO = "OpenCheckLoadIO";
} }
} }
...@@ -130,6 +130,7 @@ ...@@ -130,6 +130,7 @@
<Compile Include="model\agv\mission\MissionState.cs" /> <Compile Include="model\agv\mission\MissionState.cs" />
<Compile Include="model\agv\node\ClientNode.cs" /> <Compile Include="model\agv\node\ClientNode.cs" />
<Compile Include="model\agv\node\NodeJobState.cs" /> <Compile Include="model\agv\node\NodeJobState.cs" />
<Compile Include="model\agv\node\SharedNode.cs" />
<Compile Include="model\agv\order\Order.cs" /> <Compile Include="model\agv\order\Order.cs" />
<Compile Include="model\agv\order\OrderState.cs" /> <Compile Include="model\agv\order\OrderState.cs" />
<Compile Include="model\agv\order\OrderType.cs" /> <Compile Include="model\agv\order\OrderType.cs" />
......
...@@ -56,7 +56,7 @@ namespace DeviceLib.BLL ...@@ -56,7 +56,7 @@ namespace DeviceLib.BLL
SetOrderState(JobParam.OrderId, 4); SetOrderState(JobParam.OrderId, 4);
break; break;
case RunStep.ToStore_07_CheckIsNeedToShelfPlace: case RunStep.ToStore_07_CheckIsNeedToShelfPlace:
if (NeedToShelfPlace(robot,JobParam.FullBoxId, out string targetLines)) if (NeedToShelfPlace(robot, JobParam.FullBoxId, out string targetLines))
{ {
JobParam.LineNode = NodeManager.GetLineNodeByName(targetLines); JobParam.LineNode = NodeManager.GetLineNodeByName(targetLines);
if (JobParam.LineNode != null) if (JobParam.LineNode != null)
...@@ -64,7 +64,9 @@ namespace DeviceLib.BLL ...@@ -64,7 +64,9 @@ namespace DeviceLib.BLL
ToNextStep(RunStep.ToStore_08_ToShelfPlace, $"有料架任务,去料架处。目的产线:{targetLines}"); ToNextStep(RunStep.ToStore_08_ToShelfPlace, $"有料架任务,去料架处。目的产线:{targetLines}");
JobParam.JobGoal = JobGoal.Send; JobParam.JobGoal = JobGoal.Send;
JobParam.TargetNodes.Clear(); JobParam.TargetNodes.Clear();
JobParam.TargetNodes.AddRange(NodeManager.GetNodesState(AppConfigSetting.GetStrVal(Setting_Str.ShelfPlace, "B-1-1"))); bool OpenBigShelf = AppConfigSetting.GetBoolVal(Setting_Str.OpenBigShelf, false);
if (OpenBigShelf)
JobParam.TargetNodes.AddRange(NodeManager.GetNodesState(AppConfigSetting.GetStrVal(Setting_Str.ShelfPlace, "B-1-1")));
JobParam.TargetNodes.AddRange(NodeManager.GetLineNodesState(targetLines)); JobParam.TargetNodes.AddRange(NodeManager.GetLineNodesState(targetLines));
} }
else else
......
...@@ -24,6 +24,10 @@ namespace DeviceLib.BLL ...@@ -24,6 +24,10 @@ namespace DeviceLib.BLL
{ {
return false; return false;
} }
if (NodeManager.ChecStoreIsOccupied(2))
{
return false;
}
return true; return true;
} }
} }
...@@ -44,6 +48,10 @@ namespace DeviceLib.BLL ...@@ -44,6 +48,10 @@ namespace DeviceLib.BLL
{ {
return null; return null;
} }
if (NodeManager.ChecStoreIsOccupied(2))
{
return null;
}
OrderManager.SetOccupiedAgv(order.id, robot); OrderManager.SetOccupiedAgv(order.id, robot);
Context.SetNodeOccupied(robot.id, order.id); Context.SetNodeOccupied(robot.id, order.id);
List<NodeJobState> source = new List<NodeJobState>(); List<NodeJobState> source = new List<NodeJobState>();
......
...@@ -80,7 +80,7 @@ namespace DeviceLib.BLL ...@@ -80,7 +80,7 @@ namespace DeviceLib.BLL
//HttpClient httpClient = new HttpClient(baseUrl); //HttpClient httpClient = new HttpClient(baseUrl);
Dictionary<string, string> queryStr = new Dictionary<string, string>(); Dictionary<string, string> queryStr = new Dictionary<string, string>();
queryStr.Add("rfid", rfid); queryStr.Add("rfid", rfid);
string json = httpClient.Get("/service/store/innerBox/getBoxStatusInfo", queryStr); string json = httpClient.Get("/service/store/innerBox/boxToAgv", queryStr);
RtnData rtnData = JsonHelper.DeserializeJsonToObject<RtnData>(json); RtnData rtnData = JsonHelper.DeserializeJsonToObject<RtnData>(json);
LogUtil.Info($"料箱送入agv:【{rfid}】【{agvName}】【{json}】"); LogUtil.Info($"料箱送入agv:【{rfid}】【{agvName}】【{json}】");
if (rtnData != null) if (rtnData != null)
......
...@@ -16,8 +16,19 @@ namespace DeviceLib.BLL ...@@ -16,8 +16,19 @@ namespace DeviceLib.BLL
public delegate void ClientNodeChangedEventHandler(List<ClientNode> nodes); public delegate void ClientNodeChangedEventHandler(List<ClientNode> nodes);
public static event ClientNodeChangedEventHandler NodeChanged; public static event ClientNodeChangedEventHandler NodeChanged;
static List<ClientNode> clientNodes; static List<ClientNode> clientNodes;
/// <summary>
/// 待机点
/// </summary>
public static int standby_node_type = 1; public static int standby_node_type = 1;
/// <summary>
/// 充电点
/// </summary>
public static int charge_node_type = 2; public static int charge_node_type = 2;
/// <summary>
/// 点位
/// </summary>
public static int node_type = 0;
static List<SharedNode> sharedNodes = new List<SharedNode>();
public static void Load(bool manual = false) public static void Load(bool manual = false)
{ {
clientNodes = ConfigOperation.GetNodes() ?? new List<ClientNode>(); clientNodes = ConfigOperation.GetNodes() ?? new List<ClientNode>();
...@@ -25,8 +36,38 @@ namespace DeviceLib.BLL ...@@ -25,8 +36,38 @@ namespace DeviceLib.BLL
LogUtil.Info("手动加载节点配置!"); LogUtil.Info("手动加载节点配置!");
else else
LogUtil.Info("节点配置加载成功!"); LogUtil.Info("节点配置加载成功!");
loadSharedNode();
} }
static void loadSharedNode()
{
try
{
string[] nodes = AppConfigSetting.GetStrVal(Setting_Str.SharedLine,
"A05-2FSMT-06S,A05-2FSMT-16S;A05-2FSMT-07S,A05-2FSMT-17S;A05-3FSMT-05S,A05-3FSMT-15S").Split(';');
if (nodes != null && nodes.Length > 0)
{
foreach (var item in nodes)
{
SharedNode sharedNode = new SharedNode();
foreach (var item1 in item.Split(','))
{
ClientNode node = GetLineNodeByName(item1);
if(node!=null)
{
sharedNode.Nodes.Add(node);
}
}
sharedNodes.Add(sharedNode);
}
LogUtil.Info($"加载共享通道配置完成");
}
}
catch (Exception ex)
{
LogUtil.Error("加载共享通道配置异常", ex);
}
}
public static List<ClientNode> GetClientNodes() public static List<ClientNode> GetClientNodes()
{ {
return clientNodes; return clientNodes;
...@@ -175,7 +216,7 @@ namespace DeviceLib.BLL ...@@ -175,7 +216,7 @@ namespace DeviceLib.BLL
/// <returns></returns> /// <returns></returns>
public static ClientNode GetLineNodeByName(string name) public static ClientNode GetLineNodeByName(string name)
{ {
return GetClientNodes().Find(s => s.name.Equals(name) && s.type == 0); return GetClientNodes().Find(s => s.name.Equals(name) && s.type == node_type);
} }
public static ClientNode GetClientNode(int id, string name) public static ClientNode GetClientNode(int id, string name)
{ {
...@@ -531,6 +572,22 @@ namespace DeviceLib.BLL ...@@ -531,6 +572,22 @@ namespace DeviceLib.BLL
public static bool CheckNodeIsOccupied(ClientNode clientNode) public static bool CheckNodeIsOccupied(ClientNode clientNode)
{ {
if (clientNode == null) return false; if (clientNode == null) return false;
try
{
foreach (var item in sharedNodes)
{
int idx = item.Nodes.FindIndex(s => s.name.Equals(clientNode.name));
if(idx>-1)
{
idx = item.Nodes.FindIndex(s => s.occupiedAgv != 0);
return idx > -1;
}
}
}catch(Exception ex)
{
LogUtil.Error($"检查共享通道是否占用异常:{clientNode.name}",ex);
}
return clientNode.occupiedAgv != 0; return clientNode.occupiedAgv != 0;
} }
public static bool ChecStoreIsOccupied(int storeId = 1) public static bool ChecStoreIsOccupied(int storeId = 1)
......
...@@ -199,30 +199,30 @@ namespace DeviceLib.BLL ...@@ -199,30 +199,30 @@ namespace DeviceLib.BLL
if (!CheckIfExist(id)) if (!CheckIfExist(id))
{ {
msg = $"order ({id}) do not exist. please make sure id is correct."; msg = $"order ({id}) do not exist. please make sure id is correct.";
LogUtil.Warn($"单删除失败:{msg}"); LogUtil.Warn($"运输单删除失败:{msg}");
return false; return false;
} }
else if (force) else if (force)
{ {
bool rtn1 = ConfigOperation.Del_Order(id); bool rtn1 = ConfigOperation.Del_Order(id);
if (rtn1) if (rtn1)
LogUtil.Info($"单强制删除成功:{id}"); LogUtil.Info($"运输单强制删除成功:{id}");
else else
LogUtil.Error($"单强制删除失败:{id}"); LogUtil.Error($"运输单强制删除失败:{id}");
OrderStateChanged?.Invoke(getOrders()); OrderStateChanged?.Invoke(getOrders());
return rtn1; return rtn1;
} }
else if (CheckOrderIsRunning(id)) else if (CheckOrderIsRunning(id))
{ {
msg = $"order ({id}) has been running.Deletion is prohibited."; msg = $"order ({id}) has been running.Deletion is prohibited.";
LogUtil.Warn($"单删除失败:{msg}"); LogUtil.Warn($"运输单删除失败:{msg}");
return false; return false;
} }
bool rtn = ConfigOperation.Del_Order(id); bool rtn = ConfigOperation.Del_Order(id);
if (rtn) if (rtn)
LogUtil.Info($"单删除成功:{id}"); LogUtil.Info($"运输单删除成功:{id}");
else else
LogUtil.Error($"单删除失败:{id}"); LogUtil.Error($"运输单删除失败:{id}");
OrderStateChanged?.Invoke(getOrders()); OrderStateChanged?.Invoke(getOrders());
return rtn; return rtn;
} }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLib.Model.AGV
{
public class SharedNode
{
public List<ClientNode> Nodes { get; set; } = new List<ClientNode>();
}
}
a50a0eea5cb577d2dc281ec57e1298fd790c9e1c 8d183136b591a057ed2e5caff0de5c89de6c1433
...@@ -153,6 +153,7 @@ namespace UControl.UC ...@@ -153,6 +153,7 @@ namespace UControl.UC
{ {
this.Invoke(new Action(() => this.Invoke(new Action(() =>
{ {
负载信息ToolStripMenuItem.Enabled = !robot.auto;
SetTitle(); SetTitle();
updateRunMode(); updateRunMode();
updateShelfSett(); updateShelfSett();
...@@ -311,11 +312,88 @@ namespace UControl.UC ...@@ -311,11 +312,88 @@ namespace UControl.UC
#region 设置 #region 设置
private void menuItemOpenAuto_Click(object sender, EventArgs e) private void menuItemOpenAuto_Click(object sender, EventArgs e)
{ {
robot.auto = true; if (checkState())
enableEdit(); {
LogUtil.Info($"{robot?.name ?? ""}机器人手动操作:打开自动模式"); robot.auto = true;
} enableEdit();
LogUtil.Info($"{robot?.name ?? ""}机器人手动操作:打开自动模式");
}
}
bool checkState()
{
try
{
bool OpenCheckLoadIO = AppConfigSetting.GetBoolVal(Setting_Str.OpenCheckLoadIO, true);
if (!OpenCheckLoadIO) return true;
if (robot.io_modules != null && robot.io_modules.Count == 2)
{
if (robot.io_modules[0].status?.input_state != null
&& robot.io_modules[0].status?.input_state.Count == 4
&& robot.io_modules[1].status?.input_state != null
&& robot.io_modules[1].status?.input_state.Count == 4)
{
if ((robot.io_modules[0].status?.input_state[1]??false)
&& (robot.io_modules[1].status?.input_state[1] ?? false))
{
MessageBox.Show("检测到左右两侧均有容器,请拿走一个!");
return false;
}
else if (!(robot.io_modules[0].status?.input_state[1] ?? false)
&& !(robot.io_modules[1].status?.input_state[1] ?? false))
{
MessageBox.Show("检测到左右两侧无容器,请放一个到AGV上!");
return false;
}
else if ((robot.io_modules[0].status?.input_state[1] ?? false)
&& !(robot.io_modules[1].status?.input_state[1] ?? false))//左侧有,右侧无
{
LoadInfo loadInfo = getLoadInfo(posLeft);
if (loadInfo != null)
{
loadInfo.shelf_type = ShelfType.Empty;
}
LoadInfo loadInfo1 = getLoadInfo(posRight);
if (loadInfo1 != null)
{
loadInfo1.shelf_type = ShelfType.None;
loadInfo1.shelf_id = "";
}
setRobot();
LogUtil.Info("切换为自动时,AGV负载状态:左侧有空容器,右侧无容器");
return true;
}
else if (!(robot.io_modules[0].status?.input_state[1] ?? false)
&& (robot.io_modules[1].status?.input_state[1] ?? false))//左侧无,右侧有
{
LoadInfo loadInfo = getLoadInfo(posLeft);
if (loadInfo != null)
{
loadInfo.shelf_type = ShelfType.None;
loadInfo.shelf_id = "";
}
LoadInfo loadInfo1 = getLoadInfo(posRight);
if (loadInfo1 != null)
{
loadInfo1.shelf_type = ShelfType.Empty;
}
setRobot();
LogUtil.Info("切换为自动时,AGV负载状态:左侧无容器,右侧有空容器");
return true;
}
}
else
{
MessageBox.Show("获取车上负载状态异常!");
}
}
}
catch (Exception ex)
{
LogUtil.Error("检查小车负载异常", ex);
}
return false;
}
private void menuItemCloseAuto_Click(object sender, EventArgs e) private void menuItemCloseAuto_Click(object sender, EventArgs e)
{ {
if (robot.auto) if (robot.auto)
...@@ -327,7 +405,7 @@ namespace UControl.UC ...@@ -327,7 +405,7 @@ namespace UControl.UC
if (!string.IsNullOrEmpty(robot?.job?.JobParam?.OrderId ?? "")) if (!string.IsNullOrEmpty(robot?.job?.JobParam?.OrderId ?? ""))
OrderManager.DeleteOrderById(robot.job.JobParam.OrderId, out string msg, true); OrderManager.DeleteOrderById(robot.job.JobParam.OrderId, out string msg, true);
Context.SetNodeOccupied(robot.id); Context.SetNodeOccupied(robot.id);
LogUtil.Info($"{robot?.name ?? ""}机器人手动操作:关闭自动模式。中断运输单:{robot?.job?.JobParam?.OrderId}"); LogUtil.Info($"{robot?.name ?? ""}机器人手动操作:关闭自动模式。中断运输单:{robot?.job?.JobParam?.OrderId}");
robot.job = null; robot.job = null;
MissionManager.Init(robot); MissionManager.Init(robot);
} }
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
<data name="robotSetting.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="robotSetting.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIHSURBVFhH7davThxRFMfxlTUVPENVm2BA1VXxBlUNCkMI YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIHSURBVFhH7davThxRFMfxlTUVPENVm2BA1VXxBlUNCkMI
htSAah1P0NqqVtQQDJZHIMGRYJs0GJpg6uj5zMzJ3p1Mdu8sS9V+k1/2/jlzcu/M+bOTNWuW4FXoXTuc htSAah1P0NqqVtQQDJZHIMGRYJs0GJpg6uj5zMzJ3p1Mdu8sS9V+k1/2/jlzcu/M+bOTNWuW4FXoXTuc
wZq9Z2M3dB567LQfSoxznQ3bleJ2nN+FjkNfuvltJ2Nr9tiYD72lpckDbDezlg+hb52MEzYrP8DnEKcb wZq9Z2M3dB567LQfSoxznQ3bleJ2nN+FjkNfuvltJ2Nr9tiYD72lpckDbDezlg+hb52MEzYrP8DnEKcb
zWw+bNh65km4AX0KcXgaquUi5BnPpp9R7IU4oF+h/m22QgIvP4GxtZJ8ayk+q7kMfQ+9Cb2wUHAY+hu6 zWw+bNh65km4AX0KcXgaquUi5BnPpp9R7IU4oF+h/m22QgIvP4GxtZJ8ayk+q7kMfQ+9Cb2wUHAY+hu6
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!