83 lines
2.4 KiB
C#
83 lines
2.4 KiB
C#
using Adam;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using ttpData;
|
||
using UnityEngine;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author YangHua
|
||
//@create 20230915
|
||
//@company QianHuo
|
||
//
|
||
//@description: 三相_有互感器_无光伏
|
||
//============================================================
|
||
namespace Views
|
||
{
|
||
public class ThreeTransformerPhotovoltaicView : MonoBehaviour
|
||
{
|
||
public string url = "http://111.229.30.246:10013/Handler/Taiqu.ashx?action=rdjdydl&bianhao=";
|
||
public string trainStateUrl;
|
||
public SpriteRenderer spriteRenderer;
|
||
public TextMesh textMesh;
|
||
public string isFD;
|
||
public Sprite[] sprites;
|
||
public List<string> infos = new List<string>();
|
||
// Use this for initialization
|
||
private async void Start()
|
||
{
|
||
string _url = url + GlobalFlag.userId;
|
||
string trainUrl = trainStateUrl + GlobalFlag.userId;
|
||
Debug.Log(_url);
|
||
ThreeTransformerPhotovoltaicData ttpData = await AsyncWebReq.Get<ThreeTransformerPhotovoltaicData>(_url);
|
||
infos = ttpData.data.rdj.ToList();
|
||
TrainState trainData = await AsyncWebReq.Get<TrainState>(trainUrl);
|
||
if (trainData.message == "正常")
|
||
{
|
||
infos.Add(ttpData.data.qxA);
|
||
infos.Add(ttpData.data.qxB);
|
||
infos.Add(ttpData.data.qxC);
|
||
infos.Add(ttpData.data.qyA);
|
||
infos.Add(ttpData.data.qyB);
|
||
infos.Add(ttpData.data.qyC);
|
||
}
|
||
else
|
||
{
|
||
foreach (string info in ExamusersController.Instance.GetABCcurrentAndvoltage())
|
||
{
|
||
infos.Add(info);
|
||
}
|
||
}
|
||
}
|
||
|
||
public int index = 0;
|
||
|
||
public void OnUp()
|
||
{
|
||
index++;
|
||
if (index >= sprites.Length - 1)
|
||
{
|
||
index = sprites.Length - 1;
|
||
}
|
||
SetValue(index);
|
||
}
|
||
|
||
public void OnDown()
|
||
{
|
||
index--;
|
||
if (index < 0)
|
||
{
|
||
index = 0;
|
||
}
|
||
SetValue(index);
|
||
}
|
||
|
||
private void SetValue(int index)
|
||
{
|
||
spriteRenderer.sprite = sprites[index];
|
||
textMesh.text = infos[index];
|
||
}
|
||
}
|
||
|
||
}
|