DaoNiaoShu_Dog/Assets/SenSorSystem/ZhuSheQi_20SenSor.cs
2025-11-26 17:26:00 +08:00

68 lines
1.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DongWuYiXue.DaoNiaoShu;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 20ml注射器对接硬件脚本
/// </summary>
public class ZhuSheQi_20SenSor : Sensor
{
/// <summary>
/// 进度值
/// </summary>
[HideInInspector]
public float progressValue;
[SerializeField]
Text txt;
[HideInInspector]
public bool isOpen;
private void Start()
{
//transform.parent.GetComponent<SensorManager>().SendFunction("+++");
GameManager.Instance.senSor.SendFunction("+++");
}
public override void ReceiveData(string datas)
{
base.ReceiveData(datas);
if (!datas.Split('%')[0].Split("ID:")[1].Split(',')[0].Equals("ZSQ20"))
{
//progressValue = 0;
return;
}
lastTime = time;
//this.Error(datas);
progressValue = ((Convert.ToInt32(datas.Split("%")[0].Split("LEVEL:")[1])) - 1) / 9.0f;
//this.Error($"当前20ml注射器的进度为{progressValue}");
}
float time;
float lastTime;
private void Update()
{
time += Time.deltaTime;
if (time - lastTime < 1.0f)
{
isOpen = true;
}
else
{
isOpen = false;
//progressValue = 0;
}
txt.text = $"20ml注射器开启:{isOpen}拉取进度:{progressValue}";
}
public override void Display(string datas)
{
base.Display(datas);
}
}