132 lines
3.2 KiB
C++
132 lines
3.2 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Actor.h"
|
|
#include "ENACSVReader.generated.h"
|
|
|
|
// 센서 데이터 구조체.
|
|
USTRUCT(BlueprintType)
|
|
struct FSensorData
|
|
{
|
|
GENERATED_USTRUCT_BODY()
|
|
|
|
// timestamp.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SensorData")
|
|
FString Timestamp;
|
|
|
|
// bead quality class.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SensorData")
|
|
int32 BeadQualityClass;
|
|
|
|
// score.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SensorData")
|
|
float Score;
|
|
|
|
FSensorData()
|
|
{
|
|
Timestamp = FString::Printf(TEXT(""));
|
|
BeadQualityClass = 0;
|
|
Score = 0.0f;
|
|
}
|
|
|
|
FSensorData(FString Timestamp, int32 BeadQualityClass, float Score)
|
|
{
|
|
this->Timestamp = Timestamp;
|
|
this->BeadQualityClass = BeadQualityClass;
|
|
this->Score = Score;
|
|
}
|
|
|
|
};
|
|
|
|
// 라벨 데이터 구조체.
|
|
USTRUCT(BlueprintType)
|
|
struct FLabelData
|
|
{
|
|
GENERATED_USTRUCT_BODY()
|
|
|
|
// timestamp.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "LabelData")
|
|
FString Timestamp;
|
|
|
|
// current.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "LabelData")
|
|
float Current;
|
|
|
|
// voltage.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "LabelData")
|
|
float Voltage;
|
|
|
|
// speed.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "LabelData")
|
|
float Speed;
|
|
|
|
// temperature.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "LabelData")
|
|
float Temperature;
|
|
|
|
FLabelData()
|
|
{
|
|
Timestamp = FString::Printf(TEXT(""));
|
|
Current = 0.0f;
|
|
Voltage = 0.0f;
|
|
Speed = 0.0f;
|
|
Temperature = 0.0f;
|
|
}
|
|
|
|
FLabelData(FString Timestamp, float Current, float Voltage, float Speed, float Temperature)
|
|
{
|
|
this->Timestamp = Timestamp;
|
|
this->Current = Current;
|
|
this->Voltage = Voltage;
|
|
this->Speed = Speed;
|
|
this->Temperature = Temperature;
|
|
}
|
|
};
|
|
|
|
UCLASS(Blueprintable)
|
|
class ENAROBOT_API AENACSVReader : public AActor
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
// Sets default values for this actor's properties
|
|
AENACSVReader();
|
|
|
|
protected:
|
|
// Called when the game starts or when spawned
|
|
virtual void BeginPlay() override;
|
|
|
|
public:
|
|
// Called every frame
|
|
virtual void Tick(float DeltaTime) override;
|
|
|
|
// 센서 데이터 배열.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "ENACSVReader")
|
|
TArray<FSensorData> SensorDataRef;
|
|
|
|
// 라벨 데이터 배열.
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "ENACSVReader")
|
|
TArray<FLabelData> LabelDataRef;
|
|
|
|
// 센서 데이터 처리 관련.
|
|
// CSV 파일을 읽고, 파일 내용 반환.
|
|
UFUNCTION(BlueprintCallable, Category = "ENACSVReader")
|
|
TArray<FString> SensorReadCSVFile(FString FileName);
|
|
|
|
// 읽은 데이터 항목별로 분리.
|
|
UFUNCTION(BlueprintCallable, Category = "ENACSVReader")
|
|
TArray<FSensorData> SensorParseCSVData(TArray<FString> FileContents);
|
|
|
|
// 라벨 데이터 처리 관련.
|
|
// CSV 파일을 읽고, 파일 내용 반환.
|
|
UFUNCTION(BlueprintCallable, Category = "ENACSVReader")
|
|
TArray<FString> LabelReadCSVFile(FString FileName);
|
|
|
|
// 읽은 데이터 항목별로 분리.
|
|
UFUNCTION(BlueprintCallable, Category = "ENACSVReader")
|
|
TArray<FLabelData> LabelParseCSVData(TArray<FString> FileContents);
|
|
|
|
};
|