72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using WI;
|
|
using static MQTT;
|
|
|
|
namespace CHN
|
|
{
|
|
public class ProductionStatusManager : MonoBehaviour, ISingle
|
|
{
|
|
public Building building;
|
|
|
|
public Dictionary<string,CompleteInfo> firstFloorInfo = new Dictionary<string, CompleteInfo>();
|
|
public Dictionary<string, CompleteInfo> secondFloorInfo = new Dictionary<string, CompleteInfo>();
|
|
|
|
public Action<List<CompleteInfo>> onFirstFloorInfo;
|
|
public Action<List<CompleteInfo>> onSecondFloorInfo;
|
|
|
|
public Action onActiveFirstBoard;
|
|
public Action onActiveSecondBoard;
|
|
|
|
public override void AfterAwake()
|
|
{
|
|
building = FindSingle<Building>();
|
|
}
|
|
|
|
public void SetFloorProductionStatus(List<CompleteInfo> completeInfos)
|
|
{
|
|
foreach(var completeInfo in completeInfos)
|
|
{
|
|
SetFloorInfo(building.floors[0], completeInfo, firstFloorInfo);
|
|
SetFloorInfo(building.floors[1], completeInfo, secondFloorInfo);
|
|
}
|
|
onFirstFloorInfo?.Invoke(firstFloorInfo.Values.ToList());
|
|
onSecondFloorInfo?.Invoke(secondFloorInfo.Values.ToList());
|
|
}
|
|
public void SetFloorInfo(Floor floor, CompleteInfo completeInfo, Dictionary<string, CompleteInfo> floorInfo)
|
|
{
|
|
foreach (var machine in floor.machines)
|
|
{
|
|
if (machine.code == completeInfo.workcd)
|
|
{
|
|
if (!floorInfo.ContainsKey(completeInfo.workcd))
|
|
{
|
|
floorInfo.Add(completeInfo.workcd, completeInfo);
|
|
|
|
}
|
|
else
|
|
{
|
|
floorInfo[completeInfo.workcd] = completeInfo;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public void ActiveBoardToType(BoardType boardType)
|
|
{
|
|
switch (boardType)
|
|
{
|
|
case BoardType.Injection:
|
|
onActiveFirstBoard?.Invoke();
|
|
break;
|
|
case BoardType.Assembly:
|
|
onActiveSecondBoard?.Invoke();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|