project update
This commit is contained in:
70
Modules/ComputationalModules/Binary/V2Module.cs
Normal file
70
Modules/ComputationalModules/Binary/V2Module.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
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;
|
||||
using R2 = Skeleton.Algebra.CategoryOf<Skeleton.Algebra.DimensionProviders.IDim2>.OnField<double>.FVector;
|
||||
using C2 = Skeleton.Algebra.CategoryOf<Skeleton.Algebra.DimensionProviders.IDim2>.OnField<System.Numerics.Complex>.FVector;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class V2Module : BinaryComputationalModule, IPolymorphismModule
|
||||
{
|
||||
private IDataPortGroup? ScalarInputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private DataOutPort? Output4 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 })!;
|
||||
public override double MaintenanceAlpha => 0.77852142d;
|
||||
public override double MaintenanceBeta => 0.9544432d;
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
ScalarInputGroup = GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1, Input2 },
|
||||
"Scalar Input Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.NumericTypes
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.R2,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { ScalarInputGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
R2 v2R = new R2(input1.Real, input2.Real);
|
||||
C2 v2C = new C2(input1.Complex, input2.Complex);
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
{
|
||||
if (ScalarInputGroup!.SelectedType == EnigmosConstant.DataPortTypes.Real)
|
||||
(port as DataOutPort)!.ResultData.R2 = v2R;
|
||||
else
|
||||
(port as DataOutPort)!.ResultData.C2 = v2C;
|
||||
}
|
||||
}
|
||||
|
||||
public void Inference()
|
||||
{
|
||||
OutputGroup!.SelectedType = GlobalProvider.DataPackageTypeProvider!.BuildType(OutputGroup.SelectedType, 1, 2);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user