77 lines
2.3 KiB
C#
77 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using WI;
|
|
using TMPro;
|
|
using static MQTT;
|
|
using System;
|
|
|
|
public class UI_MachineStatus : UIBase
|
|
{
|
|
public TextMeshProUGUI worknm;
|
|
public TextMeshProUGUI status;
|
|
public TextMeshProUGUI itemcd;
|
|
public TextMeshProUGUI itemdesc;
|
|
public TextMeshProUGUI wordno;
|
|
public TextMeshProUGUI goalqty;
|
|
public TextMeshProUGUI workqty;
|
|
public TextMeshProUGUI goodqty;
|
|
public TextMeshProUGUI badqty;
|
|
public TextMeshProUGUI efficiency;
|
|
public TextMeshProUGUI goaltime;
|
|
public Image UI_StatusItem;
|
|
|
|
public void SetStatusData(CompleteInfo completeInfo,Color color)
|
|
{
|
|
UI_StatusItem = GetComponent<Image>();
|
|
worknm.SetText(completeInfo.worknm);
|
|
status.SetText(completeInfo.statusnm);
|
|
SetStatusColor(completeInfo.statusnm);
|
|
itemcd.SetText(completeInfo.itemcd);
|
|
itemdesc.SetText(completeInfo.itemdesc);
|
|
wordno.SetText(completeInfo.wordno);
|
|
goaltime.SetText(completeInfo.goaltime);
|
|
|
|
goalqty.SetText(RoundToIntData(completeInfo.goalqty));
|
|
workqty.SetText(RoundToIntData(completeInfo.workqty));
|
|
goodqty.SetText(RoundToIntData(completeInfo.goodqty));
|
|
badqty.SetText(RoundToIntData(completeInfo.badqty));
|
|
|
|
efficiency.SetText(RoundToFloatData(completeInfo.efficiency));
|
|
UI_StatusItem.color = color;
|
|
}
|
|
public string RoundToIntData(string data)
|
|
{
|
|
var floatData = float.Parse(data);
|
|
var intData = Mathf.RoundToInt(floatData);
|
|
|
|
return intData.ToString();
|
|
}
|
|
public string RoundToFloatData(string data)
|
|
{
|
|
var floatData = float.Parse(data);
|
|
var truncateData = Math.Truncate(floatData * 10) / 10;
|
|
|
|
return truncateData.ToString();
|
|
}
|
|
void SetStatusColor(string stat)
|
|
{
|
|
switch (stat)
|
|
{
|
|
case "°ĄľżÁß":
|
|
status.color = new Color(0, 1f, 0.3568628f);
|
|
break;
|
|
case "şń°Ąľż":
|
|
status.color = new Color(1f, 0, 0);
|
|
break;
|
|
case "°čČšÁ¤Áö":
|
|
status.color = new Color(1f, 1f, 1f);
|
|
break;
|
|
default:
|
|
status.color = new Color(1f, 0.3411765f, 0);
|
|
break;
|
|
}
|
|
}
|
|
}
|