71 lines
1.9 KiB
C#
71 lines
1.9 KiB
C#
using AZTECHWB.Constants;
|
|
using Cysharp.Threading.Tasks;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UVC.UI.Loading;
|
|
|
|
namespace AZTECHWB.Management
|
|
{
|
|
public class AISimulationManager : Manager
|
|
{
|
|
public List<EquipmentSimulation> equipmentResults = new();
|
|
|
|
public override async UniTask Init()
|
|
{
|
|
var simulationData = Resources.Load<TextAsset>($"{ResourceURL.dataFolderPath}Test_AISimulation").text;
|
|
equipmentResults = JsonConvert.DeserializeObject<List<EquipmentSimulation>>(simulationData);
|
|
|
|
await UniTask.CompletedTask;
|
|
}
|
|
|
|
public async UniTask<EquipmentSimulation> SetSimulationResult(Machine machine)
|
|
{
|
|
// 1. Loading ON
|
|
UILoading.Show();
|
|
|
|
// 2. AI 시뮬레이션 수행
|
|
// 실제로는 여기서 서버 요청, AI 연산 등을 수행
|
|
await UniTask.Delay(3000);
|
|
var currentEquipmentData = GetEquipment(machine.machineName);
|
|
|
|
// 3. Loading OFF
|
|
UILoading.Hide();
|
|
|
|
// 4. 결과 전달
|
|
return currentEquipmentData;
|
|
}
|
|
|
|
public EquipmentSimulation GetEquipment(string machineName)
|
|
{
|
|
foreach (var e in equipmentResults)
|
|
{
|
|
if (e.equipmentName == machineName)
|
|
return e;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class EquipmentSimulation
|
|
{
|
|
public string equipmentId;
|
|
public string equipmentName;
|
|
public string processType;
|
|
public string overallStatus;
|
|
public float healthScore;
|
|
public Prediction prediction;
|
|
}
|
|
|
|
[Serializable]
|
|
public class Prediction
|
|
{
|
|
public float failureProbability;
|
|
public string estimatedFailureDate;
|
|
public string recommendedAction;
|
|
}
|
|
}
|
|
|