sync simulator state with widget

This commit is contained in:
wonkyhonky2024
2025-05-13 19:02:19 +01:00
parent 042fa652b7
commit 1ae087703d
7 changed files with 92 additions and 48 deletions

View File

@ -23,3 +23,4 @@ PackConstructorInitializers: Never
PointerAlignment: Middle
QualifierAlignment: Right
ShortNamespaceLines: 0
SortIncludes: Never

BIN
Content/LinacLab/MyMyUserWidget.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/LinacLab/vt100_Blueprint.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -1,23 +1,19 @@
{
"FileVersion": 3,
"EngineAssociation": "5.5",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "MyProject",
"Type": "Runtime",
"LoadingPhase": "Default"
}
],
"Plugins": [
{
"Name": "ModelingToolsEditorMode",
"Enabled": true
}
],
"TargetPlatforms": [],
"AdditionalRootDirectories": [],
"AdditionalPluginDirectories": [],
"EpicSampleNameHash": ""
"FileVersion": 3,
"EngineAssociation": "5.5",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "MyProject",
"Type": "Runtime",
"LoadingPhase": "Default"
}
],
"Plugins": [
{
"Name": "ModelingToolsEditorMode",
"Enabled": true
}
]
}

View File

@ -1,3 +1,4 @@
#pragma once
#include <HsFFI.h>
typedef enum ExtCallType {

View File

@ -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);
}
}

View File

@ -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();
// 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;
// Called every frame
virtual void TickComponent(
float DeltaTime,
ELevelTick TickType,
FActorComponentTickFunction * ThisTickFunction
) override;
};