project update
This commit is contained in:
61
Modules/ComputationalModules/Unary/V2ComponentModule.cs
Normal file
61
Modules/ComputationalModules/Unary/V2ComponentModule.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class V2ComponentModule : UnaryComputationalModule, IPolymorphismModule
|
||||
{
|
||||
private IDataPortGroup? VectorInputGroup { get; set; }
|
||||
private IDataPortGroup? ScalarOutputGroup { get; set; }
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2 })!;
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
VectorInputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1 },
|
||||
"Vector Input Type",
|
||||
EnigmosConstant.DataPortTypes.R2,
|
||||
EnigmosConstant.DataPortTypes.VectorTypes
|
||||
);
|
||||
ScalarOutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2 },
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { VectorInputGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
{
|
||||
if (VectorInputGroup!.SelectedType == EnigmosConstant.DataPortTypes.R2)
|
||||
{
|
||||
Output1!.ResultData.Real = input1.R2[1];
|
||||
Output2!.ResultData.Real = input1.R2[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
Output1!.ResultData.Complex = input1.C2[1];
|
||||
Output2!.ResultData.Complex = input1.C2[2];
|
||||
}
|
||||
}
|
||||
public void Inference() =>
|
||||
ScalarOutputGroup!.SelectedType = GlobalProvider.DataPackageTypeProvider!.GetBaseField(VectorInputGroup.SelectedType);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user