Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
selinal committed May 22, 2024
2 parents f7368e0 + 8481e05 commit 1d848e8
Show file tree
Hide file tree
Showing 165 changed files with 135,065 additions and 25,334 deletions.
20 changes: 20 additions & 0 deletions Assets/CLAWS/0-Backend/EventSystem/EventTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class GeosamplesDeletedEvent

public GeosamplesDeletedEvent(List<Geosample> deletedGeosamples)
{
Debug.Log("Geosample deleted event");
DeletedGeosamples = deletedGeosamples;
}
}
Expand All @@ -144,6 +145,7 @@ public class GeosamplesEditedEvent

public GeosamplesEditedEvent(List<Geosample> editedGeosamples)
{
Debug.Log("Geosample edited event");
EditedGeosamples = editedGeosamples;
}
}
Expand All @@ -154,6 +156,7 @@ public class GeosamplesAddedEvent

public GeosamplesAddedEvent(List<Geosample> newAddedGeosamples)
{
Debug.Log("Geosample added event");
NewAddedGeosamples = newAddedGeosamples;
}
}
Expand Down Expand Up @@ -676,5 +679,22 @@ public FellowIMUChanged(IMUData d)
}
}

public class StartTranscription
{
public StartTranscription()
{

}
}

public class PlayAudio
{
public string audioName;

public PlayAudio(string name)
{
audioName = name;
}
}


2 changes: 1 addition & 1 deletion Assets/CLAWS/0-Backend/GPS/FakeTSSMessageSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private void Start()
GameObject mainCameraHolder = GameObject.Find("MixedRealityPlayspace");
mainCamera = mainCameraHolder.transform.Find("Main Camera").gameObject;
Fake_SetGPS();
Fake_Vitals();
//Fake_Vitals();
StartCoroutine(AddFake());
//StartCoroutine(WebConnect());
}
Expand Down
74 changes: 73 additions & 1 deletion Assets/CLAWS/0-Backend/WebSocket/WebSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ public void HandleJsonMessage(string jsonData)
AudioData audioData = JsonUtility.FromJson<AudioData>(jsonData);
dataHandler.HandleAudioData(audioData.data, audioData.use);
break;
case "AUDIO_PROCESSED":
AudioData audioData1 = JsonUtility.FromJson<AudioData>(jsonData);
dataHandler.HandleOrocessedAudioData(audioData1.data, audioData1.use);
break;
case "UIAIMAGE_PROCESSED":
UIAData uiaData= JsonUtility.FromJson<UIAData>(jsonData);
dataHandler.HandleUIAData(uiaData.data, uiaData.use);
break;
// Handle other message types similarly
default:
Debug.LogWarning("Unknown message type: " + messageType);
Expand Down Expand Up @@ -402,11 +410,13 @@ public class VegaAudio
{
public string base_64_audio;
public string text_from_VEGA;
public bool classify;

public VegaAudio(string a, string s)
public VegaAudio(string a, string s, bool c)
{
base_64_audio = a;
text_from_VEGA = s;
classify = c;
}
}

Expand All @@ -417,4 +427,66 @@ public class AudioData
public string type;
public string use;
public VegaAudio data;
}


[Serializable]
public class UIAData
{
public int id;
public string type;
public string use;
public UIAImage data;
}

[Serializable]
public class UIAImage
{
public string base_64_image;
public string[] points;
public string position;
public string rotation;

public UIAImage(string a, string[] s, string p, string r)
{
base_64_image = a;
points = s;
position = p;
rotation = r;
}

}

[Serializable]
public class GeosampleImage
{
public string base_64_image;
public string[] points;
public string position;
public string rotation;
public string color;
public string description;
public string shape;
public string roughness;

public GeosampleImage(string a, string[] s, string p, string r, string color_in, string description_in, string shape_in, string roughness_in)
{
base_64_image = a;
points = s;
position = p;
rotation = r;
color = color_in;
description = description_in;
shape = shape_in;
roughness = roughness_in;
}
}

[Serializable]
public class GeosampleData
{
public int id;
public string type;
public string use;
public GeosampleImage data;
}
133 changes: 123 additions & 10 deletions Assets/CLAWS/0-Backend/WebSocket/WebsocketDataHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,9 @@ public void HandleTaskListData(TaskList data, string use)
{
editedTasks.Add(newTask);

if (newTask.isEmergency)
{
EventBus.Publish<CreateAlert>(new CreateAlert(AlertEnum.TaskList_EmergencyTask, "Emergency Task Updated", newTask.title));
if (newTask.isEmergency)
{
EventBus.Publish<CreateAlert>(new CreateAlert(AlertEnum.TaskList_EmergencyTask, "Emergency Task Updated", newTask.title));
}
}
break;
Expand Down Expand Up @@ -532,13 +532,13 @@ public void HandleTaskListData(TaskList data, string use)
{
newAddedTasks.Add(newTask);

if (!newTask.isEmergency)
{
EventBus.Publish<CreateAlert>(new CreateAlert(AlertEnum.TaskList_NewTask, "New Task Added", newTask.title));
if (!newTask.isEmergency)
{
EventBus.Publish<CreateAlert>(new CreateAlert(AlertEnum.TaskList_NewTask, "New Task Added", newTask.title));
}
else
{
EventBus.Publish<CreateAlert>(new CreateAlert(AlertEnum.TaskList_EmergencyTask, "New Emergency Task", newTask.title));
else
{
EventBus.Publish<CreateAlert>(new CreateAlert(AlertEnum.TaskList_EmergencyTask, "New Emergency Task", newTask.title));
}
}
}
Expand Down Expand Up @@ -772,7 +772,6 @@ public void HandleAudioData(VegaAudio _data, string use)

// Convert the vitals data to JSON format and send to WebSocket client
string jsonData = JsonUtility.ToJson(combinedData);
Debug.Log(jsonData);

wsClient.SendJsonData(jsonData);

Expand All @@ -788,6 +787,112 @@ public void HandleAudioData(VegaAudio _data, string use)

}

public void HandleOrocessedAudioData(VegaAudio _data, string use)
{

if (use == "GET")
{
if (debugMode) Debug.Log("(PUT) WebsocketDataHandler.cs: Sending Audio");

// Create a new CombinedData instance
AudioData combinedData = new AudioData
{
id = AstronautInstance.User.id,
type = "AUDIO",
use = "PUT",
data = _data
};

// Convert the vitals data to JSON format and send to WebSocket client
string jsonData = JsonUtility.ToJson(combinedData);

wsClient.SendJsonData(jsonData);

}
else if (use == "PUT")
{
EventBus.Publish(new SpeechToText(_data.text_from_VEGA));
//EventBus.Publish(new VEGACommand(_data.));
}
else
{
Debug.Log("Invalid use case from server");
}

}
public void HandleUIAData(UIAImage _data, string use)
{

if (use == "GET")
{
if (debugMode) Debug.Log("(PUT) WebsocketDataHandler.cs: Sending UIA");

// Create a new CombinedData instance
UIAData combinedData = new UIAData
{
id = AstronautInstance.User.id,
type = "UIAIMAGE",
use = "PUT",
data = _data
};

// Convert the vitals data to JSON format and send to WebSocket client
string jsonData = JsonUtility.ToJson(combinedData);
Debug.Log(jsonData);

wsClient.SendJsonData(jsonData);

}
else if (use == "PUT")
{
// EventBus.Publish(new SpeechToText(_data.points));
Debug.Log(_data.points);
GameObject.Find("UIA").GetComponent<imageCapture>().processUIAwebsocket(_data.position, _data.rotation, _data.points);
}
else
{
Debug.Log("Invalid use case from server");
}


}

public void HandleGeosampleData(GeosampleImage _data, string use)
{

if (use == "GET")
{
if (debugMode) Debug.Log("(PUT) WebsocketDataHandler.cs: Sending geosample image");

// Create a new CombinedData instance
GeosampleData combinedData = new GeosampleData
{
id = AstronautInstance.User.id,
type = "GEOSAMPLEIMAGE",
use = "PUT",
data = _data
};

// Convert the vitals data to JSON format and send to WebSocket client
string jsonData = JsonUtility.ToJson(combinedData);
Debug.Log(jsonData);

wsClient.SendJsonData(jsonData);

}
else if (use == "PUT")
{
// EventBus.Publish(new SpeechToText(_data.points));
GameObject.Find("UIA").GetComponent<imageCapture>().processGeosampleWebsocket(_data.position, _data.rotation, _data.points, _data.description, _data.color, _data.roughness, _data.shape);
}
else
{
Debug.Log("Invalid use case from server");
}


}

// Public functions for to call to send data
public void SendInitialData(string color, string name, int _id)
{
Expand Down Expand Up @@ -860,4 +965,12 @@ public void SendAudio(VegaAudio data)
HandleAudioData(data, "GET");
}

public void SendUIA(UIAImage data)
{
HandleUIAData(data, "GET");
}
public void SendGeosample(GeosampleImage data)
{
HandleGeosampleData(data, "GET");
}
}
Loading

0 comments on commit 1d848e8

Please sign in to comment.