Upgrade structure of code base
This commit is contained in:
@@ -1,39 +1,27 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Nullary;
|
||||
|
||||
public partial class ConstantModule : NullaryComputationalModule, IParameterizedModule
|
||||
public partial class ConstantModule : NullaryComputationalModule, IParameterizedModule, IDuplicateOutputModule
|
||||
{
|
||||
|
||||
[Export] private double PresetConstantValue { get; set; }
|
||||
|
||||
private HashSet<DataOutPort> OutputGroup { get; set; } = new();
|
||||
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 })!;
|
||||
private IDoubleParameter ConstValue { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
private IDoubleParameter? ConstValue { get; set; }
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
this.DataOutInit("Output", 4);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Real);
|
||||
|
||||
OutputGroup = new HashSet<DataOutPort>(new[] { Output1, Output2, Output3, Output4 });
|
||||
foreach (DataOutPort port in OutputGroup)
|
||||
port.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
ConstValue =
|
||||
GlobalProvider.DataStructureProvider.NewDoubleParameter(
|
||||
GlobalProvider.DataStructureProvider!.NewDoubleParameter(
|
||||
"Constant Value",
|
||||
-1,
|
||||
1,
|
||||
@@ -43,11 +31,11 @@ public partial class ConstantModule : NullaryComputationalModule, IParameterized
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IRootModule root)
|
||||
public override void Define()
|
||||
{
|
||||
foreach (DataOutPort port in OutputGroup)
|
||||
port.ResultData.Real = ConstValue.ParameterValue;
|
||||
|
||||
this.Define(cache =>
|
||||
(ConstValue!.ParameterValue, EnigmosConstant.DataPortTypes.Real)
|
||||
);
|
||||
}
|
||||
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; } = new();
|
||||
|
||||
Reference in New Issue
Block a user