Преглед изворни кода

物料信息事件添加

样式分支
pry пре 2 година
родитељ
комит
c457f73cb9
3 измењених фајлова са 54 додато и 18 уклоњено
  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 Прегледај датотеку

@@ -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 Прегледај датотеку

@@ -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 Прегледај датотеку

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

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

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

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)
{
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)
{
@@ -56,7 +59,7 @@ namespace BPASmartClient.MorkS
});
}

private void ReadData()
private void ReadPLCData()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -127,13 +130,13 @@ namespace BPASmartClient.MorkS
//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);
//if (ResLoc != null)
@@ -145,15 +148,14 @@ namespace BPASmartClient.MorkS
//}

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

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

EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
{
if (@event == null) return;
@@ -163,8 +165,8 @@ namespace BPASmartClient.MorkS
MessageLog.GetInstance.Show($"接收到{OrderCount}次订单");
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 (ushort.TryParse(res.BatchingLoc, out ushort loc))
@@ -479,7 +481,7 @@ namespace BPASmartClient.MorkS

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>


Loading…
Откажи
Сачувај