RoveSoSimulator
Loading...
Searching...
No Matches
RoveCommPacketWrapper.h
1#pragma once
2
4#include "RoveCommPacket.h"
5#include "CoreMinimal.h"
6#include "UObject/NoExportTypes.h"
7#include "RoveCommPacketWrapper.generated.h"
8
9/**
10 * @brief Blueprint-friendly wrapper for RoveCommPacket.
11 */
12UCLASS(BlueprintType)
13class ROVESOSIMULATOR_API URoveCommPacketWrapper : public UObject
14{
15 GENERATED_BODY()
16
17public:
18 UPROPERTY(BlueprintReadWrite, Category = "RoveComm Packet")
19 int32 DataId;
20
21 UPROPERTY(BlueprintReadWrite, Category = "RoveComm Packet")
22 int32 DataCount;
23
24 UPROPERTY(BlueprintReadWrite, Category = "RoveComm Packet")
25 EManifestDataType DataType;
26
27 UPROPERTY(BlueprintReadWrite, Category = "RoveComm Packet")
28 TArray<float> FloatData;
29
30 UPROPERTY(BlueprintReadWrite, Category = "RoveComm Packet")
31 TArray<int32> IntData;
32
33 UPROPERTY(BlueprintReadWrite, Category = "RoveComm Packet")
34 TArray<uint8> Uint8Data;
35
36 UPROPERTY(BlueprintReadWrite, Category = "RoveComm Packet")
37 TArray<double> DoubleData;
38
39 // Blueprint-exposed function to clear the data
40 UFUNCTION(BlueprintCallable, Category = "RoveComm Packet")
41 void ClearData()
42 {
43 FloatData.Empty();
44 IntData.Empty();
45 Uint8Data.Empty();
46 DoubleData.Empty();
47 }
48
49 // Function to set the data type
50 UFUNCTION(BlueprintCallable, Category = "RoveComm Packet")
51 void SetDataType(EManifestDataType NewDataType)
52 {
53 DataType = NewDataType;
54 }
55
56 // Functions to add data depending on type
57 UFUNCTION(BlueprintCallable, Category = "RoveComm Packet")
58 void AddFloatData(float Value)
59 {
60 if (DataType == EManifestDataType::FLOAT)
61 {
62 FloatData.Add(Value);
63 DataCount = FloatData.Num();
64 }
65 }
66
67 UFUNCTION(BlueprintCallable, Category = "RoveComm Packet")
68 void AddIntData(int32 Value)
69 {
70 if (DataType == EManifestDataType::INT32)
71 {
72 IntData.Add(Value);
73 DataCount = IntData.Num();
74 }
75 }
76
77 UFUNCTION(BlueprintCallable, Category = "RoveComm Packet")
78 void AddUint8Data(uint8 Value)
79 {
80 if (DataType == EManifestDataType::UINT8)
81 {
82 Uint8Data.Add(Value);
83 DataCount = Uint8Data.Num();
84 }
85 }
86
87 UFUNCTION(BlueprintCallable, Category = "RoveComm Packet")
88 void AddDoubleData(double Value)
89 {
90 if (DataType == EManifestDataType::DOUBLE)
91 {
92 DoubleData.Add(Value);
93 DataCount = DoubleData.Num();
94 }
95 }
96};