mirror of
https://github.com/Mukheem/TwinTurbine.git
synced 2025-04-14 13:30:33 +02:00
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:
parent
753f185f2b
commit
a168fd6a21
BIN
Assets/.DS_Store
vendored
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")
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user