UNtested - Changed Voltage value now should update continuously as soon as the green button is pressed and stops when red is pressed

This commit is contained in:
Abdul Mukheem Shaik 2024-05-24 00:26:28 +02:00
parent 753f185f2b
commit a168fd6a21
2 changed files with 14 additions and 2 deletions
Assets
.DS_Store
SharedSpatialAnchors/Scripts

BIN
Assets/.DS_Store vendored

Binary file not shown.

@ -46,7 +46,8 @@ public class API : MonoBehaviour
private string unit;
private GameObject webSocketController;
private WebSocketController webSocketControllerScript;
private bool isButtonPressed = false; // Boolean to keep voltage updated as long as the turbine is rotating
void Start()
{
@ -54,6 +55,14 @@ public class API : MonoBehaviour
EmergencyButtonClick();
}
private void Update()
{
if (isButtonPressed)
{
voltageValue.text = webSocketControllerScript.voltageValue.ToString();
}
}
public void OnButtonClick()
{
webSocketController = GameObject.FindGameObjectWithTag("WebController");
@ -62,6 +71,7 @@ public class API : MonoBehaviour
}
public void EmergencyButtonClick()
{
isButtonPressed = false;
loc.SetText("----");
windDirValue.SetText("----");
temperatureValue.SetText("----");
@ -96,6 +106,8 @@ public class API : MonoBehaviour
public void ExtractDataFromJson(string json)
{
isButtonPressed = true; // Boolean to keep voltage updated as long as the turbine is rotating
ApiResponse response = JsonUtility.FromJson<ApiResponse>(json);
//Debug.Log("Api response worked!!!!");
@ -109,7 +121,7 @@ public void ExtractDataFromJson(string json)
for (int i = 0; i < dataPoints.Count; i++)
{
DataPoint point = dataPoints[i];
voltageValue.text = webSocketControllerScript.voltageValue.ToString();
loc.SetText("Kista");
if (point.name == "wd")
{