Unreal SDK  v1.2.0
Loading...
Searching...
No Matches
WeArtController.h
Go to the documentation of this file.
1#pragma once
2
3#include "CoreMinimal.h"
4#include "Sockets.h"
9#include "GameFramework/Actor.h"
10#include "Kismet/GameplayStatics.h"
11#include "WeArtStatusTracker.h"
12#include "WeArtCalibrationUX.h"
13#include <string>
14#include "Containers/Ticker.h"
16
18{
20};
21
23{
25};
26
27static char messagesSeparator = '~';
28
32UCLASS()
33class WEARTPLUGIN_API UWeArtController : public UGameInstanceSubsystem, public FTickableGameObject
34{
35 GENERATED_BODY()
36
37public:
38
41
45
46 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
47 virtual void Deinitialize() override;
48
49 UFUNCTION(BlueprintCallable)
50 void PauseController();
51 UFUNCTION(BlueprintCallable)
52 void UnpauseController();
53 UFUNCTION(BlueprintCallable)
54 void StartCalibration();
55 UFUNCTION(BlueprintCallable)
56 void StopCalibration();
57 UFUNCTION(BlueprintCallable)
58 bool GetIsAutoCalibrationOn();
59 UFUNCTION(BlueprintCallable)
60 bool GetIsAutoRawDataOn();
61 UFUNCTION(BlueprintCallable)
62 void RequestMiddlewareStatus();
63
64 void ScheduleController();
65
66 void SendMessage(WeArtMessage* message);
67 bool ReceiveMessages(std::vector<WeArtMessage*>& messages);
68
69 void OnMessageReceived(WeArtMessage* msg);
70 void StopConnection();
71
72 void LogMessage(WeArtMessageType type, FString& message);
73 void LogError(WeArtError error, FString& message);
74
75 void HandleReceivedMessage(FString& message);
76 // We are keeping track of attached thimble tracking objects,
77 // so we can forward received messages to them. Usually
78 // that could be solved via delegates, but native C++
79 // has no support for those, and UE4 delegates would require
80 // the WeArtMessage object to be an UCLASS for some reason.
81 TArray<UWeArtThimbleTrackingObject*> thimbleTrackingObjects;
82 TArray<UWeArtThimbleSensorObject*> thimbleSensorObjects;
83
84protected:
85 UPROPERTY()
86 int ClientPort;
87
88 UPROPERTY()
89 bool DebugMessages;
90
91 UPROPERTY()
92 bool ControllerAutoStart;
93
94 UPROPERTY()
95 bool CalibrationAutoStart;
96
97 UPROPERTY()
98 bool RawDataAutoStart;
99
100 bool initialized = false;
101 bool foundTrackingCalibration = false;
102 bool foundCalibrationUX = false;
103 bool foundStatusTracker = false;
104 bool isCancellationRequested = false;
105 FSocket* socket;
106 WeArtMessageSerializer messageSerializer;
107 uint8* messageReceivedBuffer[1024];
108 std::string trailingText;
109 bool IsConnected = false;
110 bool IsPaused = false;
111
112 void Tick(float DeltaTime) override;
113 bool IsTickable() const override;
114 bool IsTickableInEditor() const override;
115 bool IsTickableWhenPaused() const override;
116 TStatId GetStatId() const override;
117 UWorld* GetWorld() const override;
118};
#define WEARTPLUGIN_API
Definition: Definitions.WEARTPlugin.h:292
WeArtError
Definition: WeArtController.h:23
@ ConnectionError
Definition: WeArtController.h:24
@ SendMessageError
Definition: WeArtController.h:24
@ ReceiveMessageError
Definition: WeArtController.h:24
WeArtMessageType
Definition: WeArtController.h:18
@ MessageReceived
Definition: WeArtController.h:19
@ MessageSent
Definition: WeArtController.h:19
Contains the declaration of the AWeArtTrackingCalibration class.
Definition: WeArtCalibrationUX.h:18
Tracks the status of connected devices and middleware.
Definition: WeArtStatusTracker.h:107
Calibration status/result observer.
Definition: WeArtTrackingCalibration.h:23
Weart controller, used to connect to the Weart middleware, perform operations and receive messages.
Definition: WeArtController.h:34
TArray< UWeArtThimbleSensorObject * > thimbleSensorObjects
Definition: WeArtController.h:82
AWeArtCalibrationUX * CalibrationUX
Definition: WeArtController.h:43
AWeArtTrackingCalibration * TrackingCalibration
Definition: WeArtController.h:42
TArray< UWeArtThimbleTrackingObject * > thimbleTrackingObjects
Definition: WeArtController.h:81
AWeArtStatusTracker * StatusTracker
Definition: WeArtController.h:44
Generic Weart message.
Definition: WeArtMessages.h:178
Serializer for communication with the middleware.
Definition: WeArtMessageSerializer.h:10
Definition: json.hpp:5292