mirror of
https://github.com/Mukheem/TwinTurbine.git
synced 2025-04-23 01:00:34 +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 string unit;
|
||||||
private GameObject webSocketController;
|
private GameObject webSocketController;
|
||||||
private WebSocketController webSocketControllerScript;
|
private WebSocketController webSocketControllerScript;
|
||||||
|
private bool isButtonPressed = false; // Boolean to keep voltage updated as long as the turbine is rotating
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -54,6 +55,14 @@ public class API : MonoBehaviour
|
|||||||
EmergencyButtonClick();
|
EmergencyButtonClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (isButtonPressed)
|
||||||
|
{
|
||||||
|
voltageValue.text = webSocketControllerScript.voltageValue.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OnButtonClick()
|
public void OnButtonClick()
|
||||||
{
|
{
|
||||||
webSocketController = GameObject.FindGameObjectWithTag("WebController");
|
webSocketController = GameObject.FindGameObjectWithTag("WebController");
|
||||||
@ -62,6 +71,7 @@ public class API : MonoBehaviour
|
|||||||
}
|
}
|
||||||
public void EmergencyButtonClick()
|
public void EmergencyButtonClick()
|
||||||
{
|
{
|
||||||
|
isButtonPressed = false;
|
||||||
loc.SetText("----");
|
loc.SetText("----");
|
||||||
windDirValue.SetText("----");
|
windDirValue.SetText("----");
|
||||||
temperatureValue.SetText("----");
|
temperatureValue.SetText("----");
|
||||||
@ -96,6 +106,8 @@ public class API : MonoBehaviour
|
|||||||
|
|
||||||
public void ExtractDataFromJson(string json)
|
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);
|
ApiResponse response = JsonUtility.FromJson<ApiResponse>(json);
|
||||||
//Debug.Log("Api response worked!!!!");
|
//Debug.Log("Api response worked!!!!");
|
||||||
|
|
||||||
@ -109,7 +121,7 @@ public void ExtractDataFromJson(string json)
|
|||||||
for (int i = 0; i < dataPoints.Count; i++)
|
for (int i = 0; i < dataPoints.Count; i++)
|
||||||
{
|
{
|
||||||
DataPoint point = dataPoints[i];
|
DataPoint point = dataPoints[i];
|
||||||
voltageValue.text = webSocketControllerScript.voltageValue.ToString();
|
|
||||||
loc.SetText("Kista");
|
loc.SetText("Kista");
|
||||||
if (point.name == "wd")
|
if (point.name == "wd")
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user