Browse Source

物料信息事件添加

样式分支
pry 2 years ago
parent
commit
c457f73cb9
3 changed files with 54 additions and 18 deletions
  1. +17
    -0
      BPASmartClient.Model/物料数据/MaterialDeliveryEvent.cs
  2. +17
    -0
      BPASmartClient.Model/物料数据/RecipeBomEvent.cs
  3. +20
    -18
      BPASmartClient.MorkS/Control.cs

+ 17
- 0
BPASmartClient.Model/物料数据/MaterialDeliveryEvent.cs View File

@@ -0,0 +1,17 @@
using BPA.Message;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model.物料数据
{
public class MaterialDeliveryEvent : BaseEvent
{
/// <summary>
/// 物料信息
/// </summary>
public OrderMaterialDelivery orderMaterialDelivery { get; set; } = new OrderMaterialDelivery();
}
}

+ 17
- 0
BPASmartClient.Model/物料数据/RecipeBomEvent.cs View File

@@ -0,0 +1,17 @@
using BPA.Message;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model.物料数据
{
public class RecipeBomEvent : BaseEvent
{
/// <summary>
/// 配方数据
/// </summary>
public RecipeBoms recipeBoms { get; set; } = new RecipeBoms();
}
}

+ 20
- 18
BPASmartClient.MorkS/Control.cs View File

@@ -23,16 +23,19 @@ namespace BPASmartClient.MorkS
/// <summary> /// <summary>
/// 订单物料信息 /// 订单物料信息
/// </summary> /// </summary>
public OrderMaterialDelivery orderMaterialDelivery { get; set; } = new OrderMaterialDelivery();
private OrderMaterialDelivery orderMaterialDelivery { get; set; } = new OrderMaterialDelivery();
/// <summary> /// <summary>
/// 配方数据信息 /// 配方数据信息
/// </summary> /// </summary>
public RecipeBoms recipeBoms { get; set; } = new RecipeBoms();
private RecipeBoms recipeBoms { get; set; } = new RecipeBoms();
int OrderCount; int OrderCount;
bool Initing; bool Initing;
public override void StartMain() public override void StartMain()
{ {

DataParse();
ReadPLCData();
Main();
//初始化中
} }


public override void Stop() public override void Stop()
@@ -42,12 +45,12 @@ namespace BPASmartClient.MorkS


private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
{ {
//EventBus.EventBus.GetInstance().Publish(new);
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Id = DeviceId, Status = oRDER_STATUS, SubOrderId = subid });
} }


private void ReadData(string address, ushort len = 1, Action<bool[]> action = null) private void ReadData(string address, ushort len = 1, Action<bool[]> action = null)
{ {
EventBus.EventBus.GetInstance().Publish(new ReadModel() { Address = address, Length = len }, (o) =>
EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = address, Length = len }, (o) =>
{ {
if (o != null && o.Length > 0 && o[0] is bool[] bools) if (o != null && o.Length > 0 && o[0] is bool[] bools)
{ {
@@ -56,7 +59,7 @@ namespace BPASmartClient.MorkS
}); });
} }


private void ReadData()
private void ReadPLCData()
{ {
ThreadManage.GetInstance().StartLong(new Action(() => ThreadManage.GetInstance().StartLong(new Action(() =>
{ {
@@ -127,13 +130,13 @@ namespace BPASmartClient.MorkS
//alarm.RobotSelfInException = bools[15]; //alarm.RobotSelfInException = bools[15];
})); }));


EventBus.EventBus.GetInstance().Publish(new ReadModel() { Address = "VW372", Length = 1 }, (o) =>
EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = "VW372", Length = 1 }, (o) =>
{
if (o != null && o.Length > 0 && o[0] is ushort value)
{ {
if (o != null && o.Length > 0 && o[0] is ushort value)
{
mORKS.TurntableFeedbackloc = value;
}
});
mORKS.TurntableFeedbackloc = value;
}
});


//var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters); //var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters);
//if (ResLoc != null) //if (ResLoc != null)
@@ -145,15 +148,14 @@ namespace BPASmartClient.MorkS
//} //}


Thread.Sleep(500); Thread.Sleep(500);
}), "ReadPLCData");
}), "ReadPLCData", true);
} }


/// <summary> /// <summary>
/// 数据解析 /// 数据解析
/// </summary> /// </summary>
public void DataParse<T>(T order)
private void DataParse()
{ {

EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
{ {
if (@event == null) return; if (@event == null) return;
@@ -163,8 +165,8 @@ namespace BPASmartClient.MorkS
MessageLog.GetInstance.Show($"接收到{OrderCount}次订单"); MessageLog.GetInstance.Show($"接收到{OrderCount}次订单");
foreach (var item in order.MorkOrder.GoodBatchings) foreach (var item in order.MorkOrder.GoodBatchings)
{ {
//var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
//var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
if (res != null) if (res != null)
{ {
if (ushort.TryParse(res.BatchingLoc, out ushort loc)) if (ushort.TryParse(res.BatchingLoc, out ushort loc))
@@ -479,7 +481,7 @@ namespace BPASmartClient.MorkS


private void WriteData(string address, object value) private void WriteData(string address, object value)
{ {
EventBus.EventBus.GetInstance().Publish(new WriteModel() { Address = address, Value = value });
EventBus.EventBus.GetInstance().Publish(new WriteModel() { Id = DeviceId, Address = address, Value = value });
} }


/// <summary> /// <summary>


Loading…
Cancel
Save