TuBiao.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using XCharts.Runtime;
  6. using static GameManager;
  7. using static Manager;
  8. public class TuBiao : UpdateManager
  9. {
  10. public TuBiaoType type;
  11. public Toggle ritoggle;
  12. public Toggle zhoutoggle;
  13. public Toggle yuetoggle;
  14. public LineChart lc;
  15. override public void updateData()
  16. {
  17. base.updateData();
  18. switch(type)
  19. {
  20. case TuBiaoType.科技设备利用率:
  21. DeMaDataManager.Instance.GetKeJiZaiXian("/digital-twin/v1/device/ratio/run",(data) => {
  22. setLineData(lc, data);
  23. },index,1);
  24. break;
  25. case TuBiaoType.科技设备在线率:
  26. DeMaDataManager.Instance.GetKeJiZaiXian("/digital-twin/v1/device/ratio/online",(data) => {
  27. setLineData(lc, data);
  28. },index,1);
  29. break;
  30. case TuBiaoType.今日燃气流量:
  31. DeMaDataManager.Instance.GetJinRiRanQi((data) => {
  32. setLineData(lc, data);
  33. });
  34. break;
  35. case TuBiaoType.工业设备利用率:
  36. DeMaDataManager.Instance.GetKeJiZaiXian("/digital-twin/v1/device/ratio/run",(data) => {
  37. setLineData(lc, data);
  38. },index,2);
  39. break;
  40. case TuBiaoType.工业设备在线率:
  41. DeMaDataManager.Instance.GetKeJiZaiXian("/digital-twin/v1/device/ratio/online",(data) => {
  42. setLineData(lc, data);
  43. },index,2);
  44. break;
  45. case TuBiaoType.总用电量:
  46. DeMaDataManager.Instance.GetZongyongdianData((data) => {
  47. setLineData(lc, data);
  48. },index);
  49. break;
  50. case TuBiaoType.设备报警率:
  51. DeMaDataManager.Instance.GetGaoJingData((data) => {
  52. setLineData(lc, data);
  53. },index,0);
  54. break;
  55. case TuBiaoType.累计燃气用量:
  56. DeMaDataManager.Instance.GetLeiJiRanqi((data) => {
  57. setLineData(lc, data);
  58. });
  59. break;
  60. }
  61. }
  62. int index=1;
  63. private void Awake() {
  64. ritoggle?.onValueChanged.AddListener((b)=>{
  65. if(b)
  66. {
  67. index=1;
  68. updateData();
  69. }
  70. });
  71. zhoutoggle?.onValueChanged.AddListener((b)=>{
  72. if(b)
  73. {
  74. index=2;
  75. updateData();
  76. }
  77. });
  78. yuetoggle?.onValueChanged.AddListener((b)=>{
  79. if(b)
  80. {
  81. index=3;
  82. updateData();
  83. }
  84. });
  85. }
  86. }