sync simulator state with widget
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
#include <HsFFI.h>
|
||||
|
||||
typedef enum ExtCallType {
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <Internationalization/Text.h>
|
||||
#include <Misc/MessageDialog.h>
|
||||
#include <Therac.h>
|
||||
#include <map>
|
||||
#include <Logging/StructuredLog.h>
|
||||
|
||||
#define LOCTEXT_NAMESPACE "TheracAdapter"
|
||||
|
||||
@ -16,7 +18,7 @@ UTheracAdapterComponent::UTheracAdapterComponent() {
|
||||
// Set this component to be initialized when the game starts, and to be ticked
|
||||
// every frame. You can turn these features off to improve performance if you
|
||||
// don't need them.
|
||||
// PrimaryComponentTick.bCanEverTick = true;
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
@ -34,11 +36,18 @@ void UTheracAdapterComponent::BeginPlay() {
|
||||
: nullptr;
|
||||
*/
|
||||
Super::BeginPlay();
|
||||
wrappedComms = start_machine();
|
||||
auto si = FText::FromString(StaticCast<char *>(
|
||||
request_state_info(wrappedComms, RequestActiveSubsystem)
|
||||
));
|
||||
FMessageDialog::Open(EAppMsgType::Ok, si);
|
||||
wrappedComms = start_machine();
|
||||
std::map<FText *, StateInfoRequest> hng = {
|
||||
{&TreatmentOutcome, RequestTreatmentOutcome},
|
||||
{&ActiveSubsystem, RequestActiveSubsystem},
|
||||
{&TreatmentState, RequestTreatmentState},
|
||||
{&Reason, RequestReason},
|
||||
{&BeamMode, RequestBeamMode},
|
||||
{&BeamEnergy, RequestBeamEnergy}
|
||||
};
|
||||
for (auto & [hnng, hnnng] : hng) {
|
||||
compMap.Add(hnng, hnnng);
|
||||
}
|
||||
// ...
|
||||
}
|
||||
|
||||
@ -50,6 +59,15 @@ void UTheracAdapterComponent::TickComponent(
|
||||
) {
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
auto rsi = [&](FText * f) {
|
||||
return FText::FromString(
|
||||
StaticCast<char *>(request_state_info(wrappedComms, *compMap.Find(f)))
|
||||
);
|
||||
};
|
||||
|
||||
for (auto & [f, _] : compMap) {
|
||||
// UE_LOGFMT(LogTemp, Warning, "what {dildo}", rsi(f).ToString());
|
||||
*f = rsi(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,31 +2,59 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "CoreMinimal.h"
|
||||
#include <HsFFI.h>
|
||||
#include <Therac.h>
|
||||
#include <Internationalization/Text.h>
|
||||
#include "TheracAdapterComponent.generated.h"
|
||||
|
||||
UCLASS(
|
||||
BlueprintType,
|
||||
ClassGroup = (Custom),
|
||||
meta = (BlueprintSpawnableComponent)
|
||||
)
|
||||
class HSTHERAC25_API UTheracAdapterComponent : public UActorComponent {
|
||||
|
||||
GENERATED_BODY()
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class HSTHERAC25_API UTheracAdapterComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
HsStablePtr wrappedComms;
|
||||
|
||||
HsStablePtr wrappedComms;
|
||||
TMap<FText *, StateInfoRequest> compMap;
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UTheracAdapterComponent();
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UTheracAdapterComponent();
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FText TreatmentOutcome;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FText ActiveSubsystem;
|
||||
|
||||
// TPhase
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FText TreatmentState;
|
||||
|
||||
// TreatmentOutcome
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FText Reason;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FText BeamMode;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FText BeamEnergy;
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(
|
||||
float DeltaTime,
|
||||
ELevelTick TickType,
|
||||
FActorComponentTickFunction * ThisTickFunction
|
||||
) override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user