Upgrade structure of code base
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
using Enigmos.Cables;
|
||||
using Enigmos.Modules;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Enigmos.Modules.TerminalModules;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Boards;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.GlobalManagement.Controls;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Nocturnis.Inventories.Items;
|
||||
using Nocturnis.Inventories.Items.Items;
|
||||
using Nocturnis.UIElements;
|
||||
using Nocturnis.UIElements.Layers;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Controls;
|
||||
|
||||
namespace Enigmos.Boards;
|
||||
|
||||
@@ -57,10 +54,10 @@ public abstract partial class BaseBoard : Panel, IBaseBoard
|
||||
Modules
|
||||
.OfType<ProgrammableModule>();
|
||||
|
||||
public IEnumerable<TerminalModule> TerminalModules() =>
|
||||
public IEnumerable<ITerminalModule> TerminalModules =>
|
||||
Modules
|
||||
.OfType<TerminalModule>()
|
||||
.Union(ProgrammableModules().SelectMany(module => module.UnderlyingBoard.TerminalModules()));
|
||||
.OfType<ITerminalModule>()
|
||||
.Union(ProgrammableModules().SelectMany(module => module.UnderlyingBoard!.TerminalModules));
|
||||
|
||||
protected HashSet<IBasePort> Ports => Modules.SelectMany(module => module.Ports).ToHashSet();
|
||||
public IPanelViewer? PanelViewer { get; set; }
|
||||
@@ -103,6 +100,15 @@ public abstract partial class BaseBoard : Panel, IBaseBoard
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
foreach (ISourceModule sm in Modules.OfType<ISourceModule>())
|
||||
sm.Reset();
|
||||
foreach (IProgrammableModule pm in Modules.OfType<IProgrammableModule>())
|
||||
pm.Board!.Reset();
|
||||
foreach (IControllingModule cm in Modules.OfType<IControllingModule>())
|
||||
cm.Visited = false;
|
||||
|
||||
|
||||
/*
|
||||
foreach (IBaseModule module in Modules)
|
||||
{
|
||||
if (module is RootModule rootModule)
|
||||
@@ -120,13 +126,13 @@ public abstract partial class BaseBoard : Panel, IBaseBoard
|
||||
|
||||
if (module is ProgrammableModule programmableModule)
|
||||
{
|
||||
programmableModule.UnderlyingBoard.Reset();
|
||||
foreach (DataOutPort outPort in programmableModule.ExplicitPorts().OfType<DataOutPort>())
|
||||
programmableModule.UnderlyingBoard!.Reset();
|
||||
foreach (DataOutPort outPort in programmableModule.ExplicitPorts.OfType<DataOutPort>())
|
||||
outPort.DataUpdated = false;
|
||||
foreach (DataOutPort outPort in programmableModule.ImplicitPorts().OfType<DataOutPort>())
|
||||
foreach (DataOutPort outPort in programmableModule.ImplicitPorts.OfType<DataOutPort>())
|
||||
outPort.DataUpdated = false;
|
||||
}
|
||||
if (module is ControllingModule controllingModule)
|
||||
if (module is PiplineModule controllingModule)
|
||||
controllingModule.Visited = false;
|
||||
if (module is TerminalModule terminalModule)
|
||||
terminalModule.Finished = false;
|
||||
@@ -134,7 +140,7 @@ public abstract partial class BaseBoard : Panel, IBaseBoard
|
||||
foreach (DataOutPort port in module.Ports.OfType<DataOutPort>())
|
||||
port.DataUpdated = false;
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||||
|
||||
25
Boards/FilterModuleBoard.cs
Normal file
25
Boards/FilterModuleBoard.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Enigmos.Modules.InterlayerModules;
|
||||
using Enigmos.Modules.Other;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Boards;
|
||||
public partial class FilterModuleBoard : BaseBoard
|
||||
{
|
||||
public IInterlayerDataOutModule[] Outputs { get; set; } = Array.Empty<IInterlayerDataOutModule>();
|
||||
public IterativeOutputModule? IterativeOutput { get; set; }
|
||||
public IndicateInputModule? Indicate { get; set; }
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Outputs = new IInterlayerDataOutModule[3];
|
||||
for (int i = 1; i <= 3; i++)
|
||||
Outputs[i-1] = GetModule<InterlayerDataOutModule>($"IO{i}");
|
||||
base.Init();
|
||||
IterativeOutput = GetModule<IterativeOutputModule>("IterativeOutput");
|
||||
Indicate = GetModule<IndicateInputModule>("Indicate");
|
||||
Indicate.Input!.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
}
|
||||
|
||||
}
|
||||
28
Boards/FunctionModuleBoard.cs
Normal file
28
Boards/FunctionModuleBoard.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Enigmos.Modules.InterlayerModules;
|
||||
|
||||
namespace Enigmos.Boards;
|
||||
|
||||
public partial class FunctionModuleBoard : BaseBoard
|
||||
{
|
||||
public InterlayerDataInModule[] DataIns { get; set; } = Array.Empty<InterlayerDataInModule>();
|
||||
public InterlayerDataOutModule[] DataOuts { get; set; } = Array.Empty<InterlayerDataOutModule>();
|
||||
public InterlayerSignalInModule[] SignalIns { get; set; } = Array.Empty<InterlayerSignalInModule>();
|
||||
public InterlayerSignalOutModule[] SignalOuts { get; set; } = Array.Empty<InterlayerSignalOutModule>();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
DataIns = new InterlayerDataInModule[4];
|
||||
DataOuts = new InterlayerDataOutModule[4];
|
||||
SignalIns = new InterlayerSignalInModule[4];
|
||||
SignalOuts = new InterlayerSignalOutModule[4];
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
DataIns[i - 1] = GetModule<InterlayerDataInModule>($"II{i}");
|
||||
DataOuts[i - 1] = GetModule<InterlayerDataOutModule>($"IO{i}");
|
||||
SignalIns[i - 1] = GetModule<InterlayerSignalInModule>($"ISI{i}");
|
||||
SignalOuts[i - 1] = GetModule<InterlayerSignalOutModule>($"ISO{i}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
24
Boards/OptimizationModuleBoard.cs
Normal file
24
Boards/OptimizationModuleBoard.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Enigmos.Modules.InterlayerModules;
|
||||
using Enigmos.Modules.Other;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Boards;
|
||||
|
||||
public partial class OptimizationModuleBoard : BaseBoard
|
||||
{
|
||||
public IterativeOutputModule? IterOut { get; set; }
|
||||
public OptimizationValueInputModule? ValueIn { get; set; }
|
||||
public InterlayerDataOutModule[] ImplicitDataOuts { get; set; } = Array.Empty<InterlayerDataOutModule>();
|
||||
public override void Init()
|
||||
{
|
||||
|
||||
ImplicitDataOuts = new InterlayerDataOutModule[3];
|
||||
base.Init();
|
||||
for (int i = 0; i < 3; i++)
|
||||
ImplicitDataOuts[i] = GetModule<InterlayerDataOutModule>($"IO{i + 1}");
|
||||
IterOut = GetModule<IterativeOutputModule>("IterOut");
|
||||
ValueIn = GetModule<OptimizationValueInputModule>("ValueIn");
|
||||
IterOut.Output!.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
ValueIn.DataIn.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
}
|
||||
}
|
||||
52
Boards/PrimaryModuleBoard.cs
Normal file
52
Boards/PrimaryModuleBoard.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.TerminalModules;
|
||||
using Nocturnis.Creatures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Controls;
|
||||
|
||||
namespace Enigmos.Boards;
|
||||
|
||||
public partial class PrimaryModuleBoard : BaseBoard
|
||||
{
|
||||
private IBaseCreature? ManagedBy { get; set; }
|
||||
public IRootModule? Root { get; set; }
|
||||
public EngineModule? Engine { get; set; }
|
||||
|
||||
|
||||
public void Init(IBaseCreature manager)
|
||||
{
|
||||
Init();
|
||||
Root = GetModule<RootModule>("Root");
|
||||
Engine = GetModule<EngineModule>("Engine");
|
||||
Root.ManagedBy = manager;
|
||||
ManagedBy = manager;
|
||||
}
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (!Root!.ActionFinished)
|
||||
return;
|
||||
//Root.Timer = Stopwatch.StartNew();
|
||||
Engine!.Drain();
|
||||
if (EnigmosControl.Instance.Energy < EnigmosConstant.IdlePower)
|
||||
{
|
||||
Root!.ActionFinished = true;
|
||||
EnigmosControl.Instance.ShutDownEngine();
|
||||
return;
|
||||
}
|
||||
Root.Start();
|
||||
foreach (ITerminalModule tm in TerminalModules)
|
||||
{
|
||||
tm.Consume();
|
||||
}
|
||||
|
||||
|
||||
//Root.RouteWithTimeoutHandle(Root);
|
||||
//Root.Timer.Reset();
|
||||
//foreach (TerminalModule module in TerminalModules())
|
||||
// module.ConsumeWithTimeoutHandle(Root);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using Enigmos.Modules.Extensions;
|
||||
using Godot;
|
||||
using Nocturnis.Communicators;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
|
||||
@@ -2,7 +2,7 @@ using Enigmos.Modules.ProgrammableModules;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ using Godot;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Enigmos.Ports;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
@@ -19,18 +18,18 @@ public partial class PortMaintenanceTab : Panel, IModuleManualTab
|
||||
}
|
||||
|
||||
public string FullName() => "Maintenance";
|
||||
private static readonly PackedScene PortFixerScene = GlobalProvider.SceneProvider.AssetMapper<PortFixer>();
|
||||
private static readonly PackedScene PortFixerScene = GlobalProvider.SceneProvider!.AssetMapper<PortFixer>();
|
||||
/// <summary>
|
||||
/// Should Be Assigned Before This Tab Been Added As Child To Tab Container
|
||||
/// </summary>
|
||||
public IBaseModule Module { get; set; }
|
||||
private VBoxContainer Ports { get; set; }
|
||||
public IBaseModule? Module { get; set; }
|
||||
private VBoxContainer? Ports { get; set; }
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
throw new Exception("TODO - NEED INIT");
|
||||
Ports = GetNode<VBoxContainer>("ScrolledItems/Ports");
|
||||
foreach (IBasePort port in Module.Ports)
|
||||
foreach (IBasePort port in Module!.Ports)
|
||||
{
|
||||
PortFixer fixer = PortFixerScene.Instantiate<PortFixer>();
|
||||
fixer.Init(port);
|
||||
@@ -40,7 +39,7 @@ public partial class PortMaintenanceTab : Panel, IModuleManualTab
|
||||
if (Module is ProgrammableModule programmableModule)
|
||||
{
|
||||
HashSet<string> used = new HashSet<string>();
|
||||
foreach (BasePort port in programmableModule.ExplicitPorts())
|
||||
foreach (IBasePort port in programmableModule.ExplicitPorts)
|
||||
{
|
||||
int i = 0;
|
||||
while (used.Contains("Exterior" + port.Name + $"#{i}"))
|
||||
@@ -51,7 +50,7 @@ public partial class PortMaintenanceTab : Panel, IModuleManualTab
|
||||
fixer.Init(port);
|
||||
Ports.AddChild(fixer);
|
||||
}
|
||||
foreach (BasePort port in programmableModule.ImplicitPorts())
|
||||
foreach (IBasePort port in programmableModule.ImplicitPorts)
|
||||
{
|
||||
string baseName = port.Name.ToString().Replace("Empty", "Interior");
|
||||
int i = 0;
|
||||
@@ -68,5 +67,4 @@ public partial class PortMaintenanceTab : Panel, IModuleManualTab
|
||||
Name = "Main";
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
@@ -17,9 +17,9 @@ public partial class PortTypeSelector : Control
|
||||
/// <summary>
|
||||
/// Underlying Group must be set before _Ready
|
||||
/// </summary>
|
||||
public IDataPortGroup UnderlyingGroup { get; set; }
|
||||
private Label Description { get; set; }
|
||||
private OptionButton TypeOptions { get; set; }
|
||||
public IDataPortGroup? UnderlyingGroup { get; set; }
|
||||
private Label? Description { get; set; }
|
||||
private OptionButton? TypeOptions { get; set; }
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!InitFlag)
|
||||
@@ -27,15 +27,15 @@ public partial class PortTypeSelector : Control
|
||||
Description = GetNode<Label>("Description");
|
||||
TypeOptions = GetNode<OptionButton>("TypeOptions");
|
||||
TypeOptions.Clear();
|
||||
for (int idx = 0; idx < UnderlyingGroup.TypeOptions.Length; idx++)
|
||||
TypeOptions.AddIconItem(GlobalProvider.EnigmosProvider.DataPortTypeMap[UnderlyingGroup.TypeOptions[idx]], "", idx);
|
||||
for (int idx = 0; idx < UnderlyingGroup!.TypeOptions.Length; idx++)
|
||||
TypeOptions.AddIconItem(GlobalProvider.EnigmosProvider!.DataPortTypeMap[UnderlyingGroup.TypeOptions[idx]], "", idx);
|
||||
Description.Text = UnderlyingGroup.Description;
|
||||
TypeOptions.Select(Array.IndexOf(UnderlyingGroup.TypeOptions, UnderlyingGroup.SelectedType));
|
||||
}
|
||||
|
||||
private void SetType(int index)
|
||||
{
|
||||
UnderlyingGroup.SelectedType = UnderlyingGroup.TypeOptions[index];
|
||||
UnderlyingGroup!.SelectedType = UnderlyingGroup.TypeOptions[index];
|
||||
UnderlyingGroup.Inference();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.ModuleManuals;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Manual;
|
||||
|
||||
public partial class ProgrammableModuleSettingTab : Panel, IModuleManualTab
|
||||
{
|
||||
private ProgrammableModule Module { get; set; }
|
||||
private ProgrammableModule? Module { get; set; }
|
||||
|
||||
private Button EditModule { get; set; }
|
||||
private Button? EditModule { get; set; }
|
||||
|
||||
public void Init(ProgrammableModule module)
|
||||
{
|
||||
@@ -27,6 +27,6 @@ public partial class ProgrammableModuleSettingTab : Panel, IModuleManualTab
|
||||
|
||||
private void EnterProgrammableBoard()
|
||||
{
|
||||
GlobalProvider.SceneProvider.RootScene.ChangeScene(Module.UnderlyingBoard);
|
||||
GlobalProvider.SceneProvider!.RootScene.ChangeScene(Module!.UnderlyingBoard);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using Enigmos.Exceptions;
|
||||
using Enigmos.Manual;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
@@ -8,8 +7,8 @@ using Nocturnis.Enigmos.Boards;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Nocturnis.UIElements;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Modules;
|
||||
|
||||
@@ -18,8 +17,9 @@ public abstract partial class BaseModule : TextureRect, IBaseModule
|
||||
[Export] private int PresetPortQuality { get; set; }
|
||||
[Export] private int PresetPortCondition { get; set; }
|
||||
[Export] protected bool UsingPreset { get; set; }
|
||||
[Export] public IPresetModuleConnection[] PresetConnections { get; set; }
|
||||
[Export] public IPresetModuleConnection[] PresetConnections { get; set; } = Array.Empty<IPresetModuleConnection>();
|
||||
[Export] public string LabelString { get; set; } = "";
|
||||
|
||||
public virtual Vector2 PositionToBoard => Position;
|
||||
protected virtual bool Draggable => true;
|
||||
protected virtual bool HasManual => true;
|
||||
@@ -38,6 +38,8 @@ public abstract partial class BaseModule : TextureRect, IBaseModule
|
||||
port.Quality = PresetPortQuality;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
@@ -49,7 +51,6 @@ public abstract partial class BaseModule : TextureRect, IBaseModule
|
||||
Label.Position = new Vector2(0, -25);
|
||||
Label.Text = LabelString;
|
||||
AddChild(Label.AsNode);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,12 +103,12 @@ public abstract partial class BaseModule : TextureRect, IBaseModule
|
||||
}
|
||||
|
||||
|
||||
protected T GetPort<T>(string path) where T : BasePort
|
||||
/*protected T GetPort<T>(string path) where T : BasePort
|
||||
{
|
||||
T res = GetNode<T>(path);
|
||||
res.Init();
|
||||
return res;
|
||||
}
|
||||
}*/
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class AdditionModule : BinaryComputationalModule, IPolymorphismModule
|
||||
public partial class AdditionModule : BinaryComputationalModule, IPolymorphismModule, IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup? InputGroup { 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 })!;
|
||||
private IDataInGroup? InputGroup { get; set; }
|
||||
private IDataOutGroup? OutputGroup { get; set; }
|
||||
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public override double MaintenanceAlpha => 0.19572021d;
|
||||
public override double MaintenanceBeta => 0.20151779d;
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
@@ -26,21 +22,18 @@ public partial class AdditionModule : BinaryComputationalModule, IPolymorphismMo
|
||||
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);
|
||||
|
||||
InputGroup = GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
InputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1, Input2 },
|
||||
DataInPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyTensor
|
||||
@@ -49,15 +42,13 @@ public partial class AdditionModule : BinaryComputationalModule, IPolymorphismMo
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider!.Add(input1, input2, OutputGroup!.SelectedType);
|
||||
foreach (IDataPort port in OutputGroup)
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
|
||||
public override string GetDescription => GlobalProvider.EnigmosProvider.ModuleDescription<AdditionModule>();
|
||||
public override string GetDescription => GlobalProvider.EnigmosProvider!.ModuleDescription<AdditionModule>();
|
||||
public override void Define()
|
||||
{
|
||||
(object, StringName) Proxy(CacheItem cache) =>
|
||||
GlobalProvider.PolymorphismProvider!.Add(this.X(cache), this.Y(cache));
|
||||
this.Define(Proxy);
|
||||
}
|
||||
}
|
||||
|
||||
17
Modules/ComputationalModules/Binary/BinaryLogicModule.cs
Normal file
17
Modules/ComputationalModules/Binary/BinaryLogicModule.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public abstract partial class BinaryLogicModule:BinaryComputationalModule,ILogicModule, IDuplicateOutputModule
|
||||
{
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.DataOutInit("Output", 1);
|
||||
this.LogicModuleInit();
|
||||
PostInit();
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,41 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
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.Binary;
|
||||
|
||||
public partial class ComparisionModule : BinaryComputationalModule, IParameterizedModule
|
||||
public partial class ComparisionModule : BinaryComputationalModule,
|
||||
IParameterizedModule,
|
||||
IDuplicateOutputModule,
|
||||
IOperationModule
|
||||
{
|
||||
|
||||
private DataOutPort? Output { get; set; }
|
||||
private IBoolParameter Greater { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output });
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; }
|
||||
private IBoolParameter? Greater { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; } = new();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Greater = GlobalProvider.DataStructureProvider.NewBoolParameter("Method", "gt", "lt", true);
|
||||
this.DataOutInit("Output",1);
|
||||
this.SetInputType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Real);
|
||||
Greater = GlobalProvider.DataStructureProvider!.NewBoolParameter("Method", "gt", "lt", true);
|
||||
ConfigurableParameters = new HashSet<IConfigurableParameter>() { Greater };
|
||||
Output = GetPort<DataOutPort>("Output");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Output.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
Output!.ResultData.Bit = !(Greater.ParameterValue ^ (input1.Real > input2.Real));
|
||||
this.Define(
|
||||
cache => (
|
||||
!(Greater!.ParameterValue ^ (this.X(cache).Double > this.Y(cache).Double)),
|
||||
EnigmosConstant.DataPortTypes.Bit
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +1,48 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class ControlledOutputModule : BinaryComputationalModule, IPolymorphismModule
|
||||
public partial class ControlledOutputModule : BinaryComputationalModule, IPolymorphismModule, IDuplicateOutputModule
|
||||
{
|
||||
[Export] private StringName PresetDataType { get; set; }
|
||||
private DataOutPort Output1 { get; set; }
|
||||
private DataOutPort Output2 { get; set; }
|
||||
private DataOutPort Output3 { get; set; }
|
||||
private DataOutPort Output4 { get; set; }
|
||||
private IDataPortGroup OutputGroup { get; set; }
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 });
|
||||
public void Inference() => Input2.SetDataType(OutputGroup.SelectedType);
|
||||
[Export] private StringName? PresetDataType { get; set; }
|
||||
private IDataOutGroup? OutputGroup { get; set; }
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public void Inference() => DataInPorts[1].SetDataType(OutputGroup!.SelectedType);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider!.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"Output Data Type",
|
||||
UsingPreset ? PresetDataType : EnigmosConstant.DataPortTypes.Real,
|
||||
UsingPreset ? PresetDataType! : EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
);
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { OutputGroup };
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
DataInPorts[0].SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
DataInPorts[1].SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
if (input1.Bit)
|
||||
foreach (DataOutPort port in OutputGroup.OfType<DataOutPort>())
|
||||
port.ResultData.Assign(input2, OutputGroup.SelectedType);
|
||||
else
|
||||
foreach (DataOutPort port in OutputGroup.OfType<DataOutPort>())
|
||||
port.ResultData.Assign(
|
||||
GlobalProvider.DataStructureProvider.DefaultDataPackage,
|
||||
OutputGroup.SelectedType
|
||||
);
|
||||
(object, StringName) Func(CacheItem cache)
|
||||
{
|
||||
if (this.X(cache).Bit)
|
||||
return (this.Y(cache).Data!, this.Y(cache).Type!);
|
||||
return (0, EnigmosConstant.DataPortTypes.Null);
|
||||
}
|
||||
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +1,37 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class DivisionModule : BinaryComputationalModule, IPolymorphismModule
|
||||
public partial class DivisionModule : BinaryComputationalModule,
|
||||
IPolymorphismModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup? InputGroup { 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 })!;
|
||||
private IDataInGroup? InputGroup { get; set; }
|
||||
private IDataOutGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
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");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
InputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1, Input2 },
|
||||
DataInPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.NumericTypes
|
||||
@@ -45,17 +40,14 @@ public partial class DivisionModule : BinaryComputationalModule, IPolymorphismMo
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider.Div(input1, input2, OutputGroup.SelectedType);
|
||||
foreach (DataPort port in OutputGroup)
|
||||
{
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
//(port as DataOutPort)!.DataUpdated = true;
|
||||
}
|
||||
(object, StringName) Func(CacheItem cache) =>
|
||||
GlobalProvider.PolymorphismProvider!.Div(this.X(cache), this.Y(cache));
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
|
||||
public void Inference() => InputGroup.SelectedType = OutputGroup.SelectedType;
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
|
||||
}
|
||||
@@ -1,42 +1,36 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class DotProductModule : BinaryComputationalModule, IPolymorphismModule
|
||||
public partial class DotProductModule : BinaryComputationalModule, IPolymorphismModule, IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup? VectorInputGroup { 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 })!;
|
||||
private IDataInGroup? VectorInputGroup { get; set; }
|
||||
private IDataOutGroup? OutputGroup { get; set; }
|
||||
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
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");
|
||||
VectorInputGroup = GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
VectorInputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1, Input2 },
|
||||
DataInPorts,
|
||||
"Vector Input Type",
|
||||
EnigmosConstant.DataPortTypes.R2,
|
||||
EnigmosConstant.DataPortTypes.VectorTypes
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
@@ -45,14 +39,12 @@ public partial class DotProductModule : BinaryComputationalModule, IPolymorphism
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider!.Dot(input1, input2, VectorInputGroup!.SelectedType);
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
|
||||
(object, StringName) Func(CacheItem cache) =>
|
||||
GlobalProvider.PolymorphismProvider!.Dot(this.X(cache), this.Y(cache));
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
|
||||
public void Inference()
|
||||
{
|
||||
|
||||
@@ -1,28 +1,17 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class LogicalAlternativeDenialModule : BinaryComputationalModule
|
||||
public partial class LogicalAlternativeDenialModule : BinaryLogicModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
public override void Define()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
(object, StringName) Func(CacheItem cache) =>
|
||||
(!this.X(cache).Bit | !this.Y(cache).Bit, EnigmosConstant.DataPortTypes.Bit);
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
//Output1.DataUpdated = true;
|
||||
Output1.ResultData.Bit = !input1.Bit | !input2.Bit;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,19 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class LogicalBiconditionalModule : BinaryComputationalModule
|
||||
public partial class LogicalBiconditionalModule : BinaryLogicModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
public override void Define()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
(object, StringName) Func(CacheItem cache) =>
|
||||
(!(this.X(cache).Bit ^ this.Y(cache).Bit), EnigmosConstant.DataPortTypes.Bit);
|
||||
|
||||
this.Define(Func);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
//Output1.DataUpdated = true;
|
||||
Output1.ResultData.Bit = !(input1.Bit ^ input2.Bit);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,21 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class LogicalConjunctionModule : BinaryComputationalModule
|
||||
public partial class LogicalConjunctionModule : BinaryLogicModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
|
||||
|
||||
public override void Define()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
var x = DataOutPorts.Length;
|
||||
|
||||
(object, StringName) Func(CacheItem cache) =>
|
||||
(this.X(cache).Bit & this.Y(cache).Bit, EnigmosConstant.DataPortTypes.Bit);
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
//Output1.DataUpdated = true;
|
||||
Output1.ResultData.Bit = input1.Bit & input2.Bit;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,18 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class LogicalDisjunctionModule : BinaryComputationalModule
|
||||
public partial class LogicalDisjunctionModule : BinaryLogicModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
|
||||
public override void Define()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
(object, StringName) Func(CacheItem x) =>
|
||||
(this.X(x).Bit | this.Y(x).Bit, EnigmosConstant.DataPortTypes.Bit);
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
//Output1.DataUpdated = true;
|
||||
Output1.ResultData.Bit = input1.Bit | input2.Bit;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,17 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class LogicalExclusiveDisjunctionModule : BinaryComputationalModule
|
||||
public partial class LogicalExclusiveDisjunctionModule : BinaryLogicModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
public override void Define()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
//Output1.DataUpdated = true;
|
||||
Output1.ResultData.Bit = input1.Bit ^ input2.Bit;
|
||||
(object, StringName) Func(CacheItem cache)
|
||||
=> (this.X(cache).Bit ^ this.Y(cache).Bit, EnigmosConstant.DataPortTypes.Bit);
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +1,14 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class LogicalImplicationModule : BinaryComputationalModule
|
||||
public partial class LogicalImplicationModule : BinaryLogicModule
|
||||
{
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
public override void Define()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
//Output1.DataUpdated = true;
|
||||
Output1.ResultData.Bit = !input1.Bit | input2.Bit;
|
||||
this.Define(
|
||||
x => (!this.X(x).Bit | this.Y(x).Bit, EnigmosConstant.DataPortTypes.Bit)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,18 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class LogicalJointDenialModule : BinaryComputationalModule
|
||||
public partial class LogicalJointDenialModule : BinaryLogicModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
//Output1.DataUpdated = true;
|
||||
Output1.ResultData.Bit = !input1.Bit & !input2.Bit;
|
||||
}
|
||||
public override void Define()
|
||||
{
|
||||
this.Define(
|
||||
x =>
|
||||
(
|
||||
!this.X(x).Bit & !this.Y(x).Bit,
|
||||
EnigmosConstant.DataPortTypes.Bit
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,17 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class LogicalNonimplicationModule : BinaryComputationalModule
|
||||
public partial class LogicalNonimplicationModule : BinaryLogicModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
public override void Define()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
//Output1.DataUpdated = true;
|
||||
Output1.ResultData.Bit = input1.Bit & !input2.Bit;
|
||||
(object, StringName) Func(CacheItem cache) =>
|
||||
(this.X(cache).Bit & !this.Y(cache).Bit, EnigmosConstant.DataPortTypes.Bit);
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +1,32 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class MaxModule : BinaryComputationalModule
|
||||
public partial class MaxModule : BinaryComputationalModule, IOperationModule, IDuplicateOutputModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
private DataOutPort Output2 { get; set; }
|
||||
private DataOutPort Output3 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3 });
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Output2.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Output3.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.DataOutInit("Output", 3);
|
||||
this.SetInputType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Real);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
if (input1.Real > input2.Real)
|
||||
(object, StringName) Func(CacheItem cache)
|
||||
{
|
||||
Output1.ResultData.Real = input1.Real;
|
||||
Output2.ResultData.Real = input1.Real;
|
||||
Output3.ResultData.Real = input1.Real;
|
||||
if (this.X(cache).Double > this.Y(cache).Double)
|
||||
return (this.X(cache), EnigmosConstant.DataPortTypes.Real);
|
||||
return (this.Y(cache), EnigmosConstant.DataPortTypes.Real);
|
||||
}
|
||||
else
|
||||
{
|
||||
Output1.ResultData.Real = input2.Real;
|
||||
Output2.ResultData.Real = input2.Real;
|
||||
Output3.ResultData.Real = input2.Real;
|
||||
}
|
||||
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +1,31 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class MinModule : BinaryComputationalModule
|
||||
public partial class MinModule : BinaryComputationalModule, IDuplicateOutputModule, IOperationModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
private DataOutPort Output2 { get; set; }
|
||||
private DataOutPort Output3 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3 });
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Output2.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Output3.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.DataOutInit("Output", 3);
|
||||
this.SetInputType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Real);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
if (input1.Real < input2.Real)
|
||||
(object, StringName) Func(CacheItem cache)
|
||||
{
|
||||
Output1.ResultData.Real = input1.Real;
|
||||
Output2.ResultData.Real = input1.Real;
|
||||
Output3.ResultData.Real = input1.Real;
|
||||
if (this.X(cache).Double < this.Y(cache).Double)
|
||||
return (this.X(cache).Data!, this.X(cache).Type!);
|
||||
return (this.Y(cache).Data!, this.Y(cache).Type!);
|
||||
}
|
||||
else
|
||||
{
|
||||
Output1.ResultData.Real = input2.Real;
|
||||
Output2.ResultData.Real = input2.Real;
|
||||
Output3.ResultData.Real = input2.Real;
|
||||
}
|
||||
|
||||
this.Define(Func);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,37 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
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;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class MultiplicationModule : BinaryComputationalModule, IPolymorphismModule
|
||||
public partial class MultiplicationModule : BinaryComputationalModule, IPolymorphismModule, IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup InputGroup { 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 HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; }
|
||||
private IDataPortGroup? InputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
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");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
|
||||
InputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new DataPort[] { Input1, Input2 },
|
||||
DataInPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new DataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.NumericTypes
|
||||
@@ -44,13 +40,13 @@ public partial class MultiplicationModule : BinaryComputationalModule, IPolymorp
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider.Mul(input1, input2, OutputGroup.SelectedType);
|
||||
foreach (DataPort port in OutputGroup)
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
(object, StringName) Func(CacheItem cache) =>
|
||||
GlobalProvider.PolymorphismProvider!.Mul(this.X(cache), this.Y(cache));
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup.SelectedType = OutputGroup.SelectedType;
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
|
||||
}
|
||||
@@ -1,43 +1,37 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class PowerModule : BinaryComputationalModule, IPolymorphismModule
|
||||
public partial class PowerModule : BinaryComputationalModule, IPolymorphismModule, IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup? TensorInputGroup { 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 IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
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");
|
||||
TensorInputGroup = GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
TensorInputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1 },
|
||||
new IDataInPort[] { DataInPorts[0] },
|
||||
"Base Tensor Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.NumericTypes
|
||||
);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Complex);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
DataInPorts[1].SetDataType(EnigmosConstant.DataPortTypes.Complex);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
@@ -46,18 +40,13 @@ public partial class PowerModule : BinaryComputationalModule, IPolymorphismModul
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider!.Pow(input1, input2, TensorInputGroup!.SelectedType);
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
{
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
//(port as DataOutPort)!.DataUpdated = true;
|
||||
}
|
||||
(object, StringName) Func(CacheItem cache) => GlobalProvider.PolymorphismProvider!.Pow(this.X(cache), this.Y(cache));
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference() =>
|
||||
OutputGroup!.SelectedType = GlobalProvider.DataPackageTypeProvider!.ComplexVersionOf(TensorInputGroup.SelectedType);
|
||||
OutputGroup!.SelectedType = GlobalProvider.DataPackageTypeProvider!.ComplexVersionOf(TensorInputGroup!.SelectedType);
|
||||
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class ScalarDivisionModule : BinaryComputationalModule, IPolymorphismModule, IErrorHandlerModule
|
||||
public partial class ScalarDivisionModule : BinaryComputationalModule,
|
||||
IPolymorphismModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup? ScalarInputGroup { get; set; }
|
||||
private IDataPortGroup? TensorInputGroup { 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 IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public override double MaintenanceAlpha => 0.77852142d;
|
||||
public override double MaintenanceBeta => 0.9544432d;
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
@@ -26,27 +25,24 @@ public partial class ScalarDivisionModule : BinaryComputationalModule, IPolymorp
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
TensorInputGroup = GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
TensorInputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1 },
|
||||
new IDataInPort[] { DataInPorts[0] },
|
||||
"Tensor Input Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.VectorTypes
|
||||
);
|
||||
ScalarInputGroup =GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
ScalarInputGroup =GlobalProvider.DataStructureProvider.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input2 },
|
||||
new IDataInPort[] { DataInPorts[1] },
|
||||
"Scalar Input Type",
|
||||
EnigmosConstant.DataPortTypes.R2,
|
||||
EnigmosConstant.DataPortTypes.VectorTypes
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
@@ -56,68 +52,21 @@ public partial class ScalarDivisionModule : BinaryComputationalModule, IPolymorp
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
{
|
||||
try
|
||||
{
|
||||
IDataPackage res =
|
||||
GlobalProvider.PolymorphismProvider!.ScalarDiv(
|
||||
input1,
|
||||
input2,
|
||||
TensorInputGroup!.SelectedType,
|
||||
ScalarInputGroup!.SelectedType
|
||||
);
|
||||
foreach (IDataPort port in OutputGroup)
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ErrorHandler(e, SelectedOption);
|
||||
}
|
||||
|
||||
|
||||
public override void Define()
|
||||
{
|
||||
(object, StringName) Func(CacheItem cache) => GlobalProvider.PolymorphismProvider!.ScalarDiv(this.X(cache), this.Y(cache));
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference()
|
||||
{
|
||||
if (GlobalProvider.DataPackageTypeProvider.IsComplexTensorType(ScalarInputGroup.SelectedType))
|
||||
OutputGroup.SelectedType = GlobalProvider.DataPackageTypeProvider.ComplexVersionOf(TensorInputGroup.SelectedType);
|
||||
if (GlobalProvider.DataPackageTypeProvider!.IsComplexTensorType(ScalarInputGroup!.SelectedType))
|
||||
OutputGroup!.SelectedType = GlobalProvider.DataPackageTypeProvider.ComplexVersionOf(TensorInputGroup!.SelectedType);
|
||||
else
|
||||
OutputGroup.SelectedType = TensorInputGroup.SelectedType;
|
||||
OutputGroup!.SelectedType = TensorInputGroup!.SelectedType;
|
||||
}
|
||||
|
||||
public void ErrorHandler(Exception error, int idx)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
(port as DataOutPort)!.ResultData
|
||||
.Assign(GlobalProvider.DataStructureProvider!.DefaultDataPackage, OutputGroup.SelectedType);
|
||||
break;
|
||||
case 1:
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
(port as DataOutPort)!.ResultData
|
||||
.Assign(GlobalProvider.DataStructureProvider!.DefaultDataPackage, OutputGroup.SelectedType);
|
||||
break;
|
||||
case 2:
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
(port as DataOutPort)!.ResultData
|
||||
.Assign(GlobalProvider.DataStructureProvider!.DefaultDataPackage, OutputGroup.SelectedType);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] HandlingOptions() =>
|
||||
new[]
|
||||
{
|
||||
"Reset Circuit State",
|
||||
"Return Previous Valid Value",
|
||||
"Return Default Value"
|
||||
};
|
||||
|
||||
|
||||
public int SelectedOption { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,50 +1,47 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class ScalarMultiplicationModule : BinaryComputationalModule, IPolymorphismModule
|
||||
public partial class ScalarMultiplicationModule :
|
||||
BinaryComputationalModule,
|
||||
IPolymorphismModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup? ScalarInputGroup { get; set; }
|
||||
private IDataPortGroup? TensorInputGroup { 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 IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
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.DataOutInit("Output",4);
|
||||
ScalarInputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1 },
|
||||
new IDataInPort[] { DataInPorts[0] },
|
||||
"Scalar Input Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.NumericTypes
|
||||
);
|
||||
TensorInputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
TensorInputGroup = GlobalProvider.DataStructureProvider.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input2 },
|
||||
new IDataInPort[] { DataInPorts[1] },
|
||||
"Tensor Input Type",
|
||||
EnigmosConstant.DataPortTypes.R2,
|
||||
EnigmosConstant.DataPortTypes.VectorTypes
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
@@ -53,14 +50,12 @@ public partial class ScalarMultiplicationModule : BinaryComputationalModule, IPo
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
|
||||
public override void Define()
|
||||
{
|
||||
IDataPackage res =
|
||||
GlobalProvider.PolymorphismProvider!
|
||||
.ScalarMul(input1, input2, ScalarInputGroup!.SelectedType, TensorInputGroup!.SelectedType);
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
|
||||
(object, StringName) Func(CacheItem cache) =>
|
||||
GlobalProvider.PolymorphismProvider!.ScalarMul(this.X(cache), this.Y(cache));
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference()
|
||||
@@ -73,5 +68,5 @@ public partial class ScalarMultiplicationModule : BinaryComputationalModule, IPo
|
||||
else
|
||||
OutputGroup!.SelectedType = TensorInputGroup.SelectedType;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +1,38 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Binary;
|
||||
|
||||
public partial class SubtractionModule : BinaryComputationalModule, IPolymorphismModule
|
||||
public partial class SubtractionModule : BinaryComputationalModule,
|
||||
IPolymorphismModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup InputGroup { 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 HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; }
|
||||
private IDataPortGroup? InputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
|
||||
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");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
InputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1, Input2 },
|
||||
DataInPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyTensor
|
||||
@@ -46,13 +41,12 @@ public partial class SubtractionModule : BinaryComputationalModule, IPolymorphis
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider.Sub(input1, input2, OutputGroup.SelectedType);
|
||||
foreach (DataPort port in OutputGroup)
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
(object, StringName) Func(CacheItem cache) => GlobalProvider.PolymorphismProvider!.Sub(this.X(cache), this.Y(cache));
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup.SelectedType = OutputGroup.SelectedType;
|
||||
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
|
||||
}
|
||||
@@ -1,17 +1,21 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
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
|
||||
public partial class V2Module : BinaryComputationalModule,
|
||||
IPolymorphismModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
private IDataPortGroup? ScalarInputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
@@ -19,7 +23,7 @@ public partial class V2Module : BinaryComputationalModule, IPolymorphismModule
|
||||
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 IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public override double MaintenanceAlpha => 0.77852142d;
|
||||
public override double MaintenanceBeta => 0.9544432d;
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
@@ -27,20 +31,17 @@ public partial class V2Module : BinaryComputationalModule, IPolymorphismModule
|
||||
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.DataOutInit("Output", 4);
|
||||
ScalarInputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1, Input2 },
|
||||
DataInPorts,
|
||||
"Scalar Input Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.NumericTypes
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.R2,
|
||||
Array.Empty<StringName>()
|
||||
@@ -49,17 +50,18 @@ public partial class V2Module : BinaryComputationalModule, IPolymorphismModule
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2)
|
||||
public override void Define()
|
||||
{
|
||||
R2 v2R = new R2(input1.Real, input2.Real);
|
||||
C2 v2C = new C2(input1.Complex, input2.Complex);
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
(object, StringName) Func(CacheItem cache)
|
||||
{
|
||||
if (ScalarInputGroup!.SelectedType == EnigmosConstant.DataPortTypes.Real)
|
||||
(port as DataOutPort)!.ResultData.R2 = v2R;
|
||||
else
|
||||
(port as DataOutPort)!.ResultData.C2 = v2C;
|
||||
IData x = this.X(cache);
|
||||
IData y = this.Y(cache);
|
||||
|
||||
if (x.Type == EnigmosConstant.DataPortTypes.Complex || y.Type == EnigmosConstant.DataPortTypes.Complex)
|
||||
return (new C2(x.Complex, y.Complex), EnigmosConstant.DataPortTypes.C2);
|
||||
return (new R2(x.Double, y.Double), EnigmosConstant.DataPortTypes.Real);
|
||||
}
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference()
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public abstract partial class BinaryComputationalModule : ComputationalModule
|
||||
public abstract partial class BinaryComputationalModule : ComputationalModule, IBinaryComputationalModule
|
||||
{
|
||||
protected DataInPort Input1 { get; set; }
|
||||
protected DataInPort Input2 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { Input1, Input2 };
|
||||
public override IEnumerable<IBasePort> Ports => DataInPorts;
|
||||
public IDataInPort[] DataInPorts { get; set; } = new IDataInPort[2];
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Input1 = GetPort<DataInPort>("Input1");
|
||||
Input2 = GetPort<DataInPort>("Input2");
|
||||
this.BinaryInit();
|
||||
}
|
||||
|
||||
|
||||
protected abstract void Compute(IDataPackage input1, IDataPackage input2);
|
||||
protected override void Compute(IRootModule root) => Compute(Input1.GetData(root), Input2.GetData(root));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,13 @@
|
||||
using Enigmos.Exceptions;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public abstract partial class ComputationalModule : BaseModule
|
||||
public abstract partial class ComputationalModule : BaseModule, IComputationalModule
|
||||
{
|
||||
protected override void TimeoutHandler(ModuleExecutionTimeout timeout)
|
||||
{
|
||||
foreach (DataOutPort port in Ports.OfType<DataOutPort>())
|
||||
port.DataUpdated = false;
|
||||
base.TimeoutHandler(timeout);
|
||||
}
|
||||
public IDataOutPort[] DataOutPorts { get; set; } = Array.Empty<IDataOutPort>();
|
||||
public abstract void Define();
|
||||
|
||||
protected abstract void Compute(IRootModule root);
|
||||
public void ComputeWithTimeoutHandle(IRootModule root)
|
||||
{
|
||||
foreach (DataOutPort port in Ports.OfType<DataOutPort>())
|
||||
port.DataUpdated = true;
|
||||
try
|
||||
{
|
||||
Compute(root);
|
||||
}
|
||||
catch (ModuleExecutionTimeout timeOut)
|
||||
{
|
||||
TimeoutHandler(timeOut);
|
||||
}
|
||||
TimeoutCheck(root);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
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.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Nullary;
|
||||
public partial class KeyListenerModule : NullaryComputationalModule, IParameterizedModule, IKeyListenerModule
|
||||
public partial class KeyListenerModule : NullaryComputationalModule,
|
||||
IParameterizedModule,
|
||||
IKeyListenerModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
[Export] private StringName? PresetActionName { get; set; }
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
@@ -18,22 +22,11 @@ public partial class KeyListenerModule : NullaryComputationalModule, IParameteri
|
||||
public bool Pressed { get; set; }
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; } = new();
|
||||
public override IEnumerable<BasePort> Ports => new[] { Output1, Output2, Output3 }!;
|
||||
protected override void Compute(IRootModule root)
|
||||
{
|
||||
Output1!.ResultData.Bit = Pressed;
|
||||
Output2!.ResultData.Bit = Pressed;
|
||||
Output3!.ResultData.Bit = Pressed;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output3.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
this.DataOutInit("Output", 3);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Bit);
|
||||
ListeningKey = GlobalProvider.DataStructureProvider!.NewKeyParameter(
|
||||
"Listening Key",
|
||||
UsingPreset && (PresetActionName != null) ? PresetActionName : "KeyListenAction"
|
||||
@@ -48,4 +41,10 @@ public partial class KeyListenerModule : NullaryComputationalModule, IParameteri
|
||||
GlobalProvider.SceneProvider!.RootScene.KeyListener.Register(this);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public override void Define()
|
||||
{
|
||||
(object item, StringName type) Func(CacheItem cache) => (Pressed, EnigmosConstant.DataPortTypes.Bit);
|
||||
this.Define(Func);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.Utils.RandomEngines;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Nullary;
|
||||
|
||||
public partial class NormalDistributionModule : NullaryComputationalModule, IParameterizedModule
|
||||
public partial class NormalDistributionModule : NullaryComputationalModule,
|
||||
IParameterizedModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
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 })!;
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
private IDoubleParameter? Mu { get; set; }
|
||||
private IDoubleParameter? Sigma { get; set; }
|
||||
|
||||
@@ -25,27 +28,24 @@ public partial class NormalDistributionModule : NullaryComputationalModule, IPar
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
|
||||
OutputGroup = new HashSet<DataOutPort>(new[] { Output1, Output2, Output3, Output4 });
|
||||
foreach (DataOutPort port in OutputGroup)
|
||||
port.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.DataOutInit("Output", 4);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Real);
|
||||
Mu = GlobalProvider.DataStructureProvider!.NewDoubleParameter("mu", -1, 1, 0);
|
||||
Sigma = GlobalProvider.DataStructureProvider.NewDoubleParameter("sigma", 0, 2, 1);
|
||||
ConfigurableParameters = new HashSet<IConfigurableParameter> { Mu, Sigma };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IRootModule root)
|
||||
public override void Define()
|
||||
{
|
||||
foreach (DataOutPort port in OutputGroup)
|
||||
foreach (IDataOutPort op in DataOutPorts)
|
||||
{
|
||||
port.ResultData.Real = Normal.Get() * Sigma.ParameterValue - Mu.ParameterValue;
|
||||
op.OutData.UpdateCalculation(x =>
|
||||
(Normal.Get() * Sigma!.ParameterValue - Mu!.ParameterValue, EnigmosConstant.DataPortTypes.Real)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; } = new();
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public abstract partial class NullaryComputationalModule : ComputationalModule
|
||||
public abstract partial class NullaryComputationalModule : ComputationalModule, ISourceModule
|
||||
{
|
||||
public override IEnumerable<BasePort> Ports => Array.Empty<BasePort>();
|
||||
public override IEnumerable<IBasePort> Ports => Array.Empty<BasePort>();
|
||||
}
|
||||
@@ -1,43 +1,48 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Ternary;
|
||||
|
||||
public partial class SelectorModule : TernaryComputationalModule, IPolymorphismModule
|
||||
public partial class SelectorModule : TernaryComputationalModule,
|
||||
ITernaryComputationalModule,
|
||||
IPolymorphismModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private IDataPortGroup? DataTypeGroup { get; set; }
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3 })!;
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
DataTypeGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 3);
|
||||
DataTypeGroup = GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
this,
|
||||
new DataPort[] { Input2, Input3, Output1, Output2, Output3 },
|
||||
new IDataPort[]{DataInPorts[1], DataInPorts[2]}.Union(DataOutPorts).ToArray(),
|
||||
"Data Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
);
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
|
||||
DataInPorts[0].SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1, IDataPackage input2, IDataPackage input3)
|
||||
public override void Define()
|
||||
{
|
||||
|
||||
Output1!.ResultData.Assign(input1.Bit ? input2 : input3, DataTypeGroup.SelectedType);
|
||||
Output2!.ResultData.Assign(input1.Bit ? input2 : input3, DataTypeGroup.SelectedType);
|
||||
Output3!.ResultData.Assign(input1.Bit ? input2 : input3, DataTypeGroup.SelectedType);
|
||||
(object, StringName) Func(CacheItem cache)
|
||||
{
|
||||
if (this.X(cache).Bit)
|
||||
return (this.Y(cache).Data!, this.Y(cache).Type!);
|
||||
return (this.Z(cache).Data!, this.Z(cache).Type!);
|
||||
}
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference()
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public abstract partial class TernaryComputationalModule : ComputationalModule
|
||||
public abstract partial class TernaryComputationalModule : ComputationalModule, IParameterModule
|
||||
{
|
||||
protected DataInPort? Input1 { get; set; }
|
||||
protected DataInPort? Input2 { get; set; }
|
||||
protected DataInPort? Input3 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { Input1, Input2, Input3 }!;
|
||||
public IDataInPort[] DataInPorts { get; set; } = new IDataInPort[3];
|
||||
public override IEnumerable<IBasePort> Ports => DataInPorts;
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Input1 = GetPort<DataInPort>("Input1");
|
||||
Input2 = GetPort<DataInPort>("Input2");
|
||||
Input3 = GetPort<DataInPort>("Input3");
|
||||
this.DataInInit("Input", 3);
|
||||
}
|
||||
|
||||
protected abstract void Compute(IDataPackage input1, IDataPackage input2, IDataPackage input3);
|
||||
|
||||
protected override void Compute(IRootModule root) =>
|
||||
Compute(Input1.GetData(root), Input2.GetData(root), Input3.GetData(root));
|
||||
}
|
||||
@@ -1,40 +1,35 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
public partial class CopyModule : UnaryComputationalModule, IPolymorphismModule
|
||||
public partial class CopyModule : UnaryComputationalModule,
|
||||
IPolymorphismModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private DataOutPort? Output4 { get; set; }
|
||||
private IDataPortGroup? InputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 })!;
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
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");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
InputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] {Input1},
|
||||
DataInPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
@@ -42,15 +37,12 @@ public partial class CopyModule : UnaryComputationalModule, IPolymorphismModule
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { OutputGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
public override void Define()
|
||||
{
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
(port as DataOutPort)!.ResultData.Assign(input1, OutputGroup.SelectedType);
|
||||
|
||||
(object, StringName) Func(CacheItem cache) => (this.X(cache).Data, this.X(cache).Type)!;
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class LogicalNegationModule : UnaryComputationalModule
|
||||
public partial class LogicalNegationModule : UnaryComputationalModule, IDuplicateOutputModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
this.DataOutInit("Output", 1);
|
||||
this.SetInputType(EnigmosConstant.DataPortTypes.Bit);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
|
||||
public override void Define()
|
||||
{
|
||||
Output1.ResultData.Bit = !input1.Bit;
|
||||
(object, StringName) Func(CacheItem cache) => (!this.X(cache).Bit, EnigmosConstant.DataPortTypes.Bit);
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +1,40 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class NegationModule : UnaryComputationalModule, IPolymorphismModule
|
||||
public partial class NegationModule : UnaryComputationalModule, IPolymorphismModule, IDuplicateOutputModule
|
||||
{
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private DataOutPort? Output4 { get; set; }
|
||||
private IDataPortGroup? InputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 })!;
|
||||
private IDataInGroup? InputGroup { get; set; }
|
||||
private IDataOutGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts)!;
|
||||
|
||||
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");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
InputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] {Input1},
|
||||
DataInPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyTensor
|
||||
@@ -46,13 +44,12 @@ public partial class NegationModule : UnaryComputationalModule, IPolymorphismMod
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
public override void Define()
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider.Neg(input1, OutputGroup.SelectedType);
|
||||
foreach (IDataPort port in OutputGroup)
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
|
||||
(object, StringName) Func(CacheItem c) =>
|
||||
GlobalProvider.PolymorphismProvider!.Neg(this.X(c));
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup.SelectedType = OutputGroup.SelectedType;
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
}
|
||||
@@ -1,43 +1,35 @@
|
||||
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class SquareModule : UnaryComputationalModule, IPolymorphismModule
|
||||
public partial class SquareModule : UnaryComputationalModule, IPolymorphismModule, IDuplicateOutputModule
|
||||
{
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private DataOutPort? Output4 { get; set; }
|
||||
private IDataPortGroup? InputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 })!;
|
||||
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
|
||||
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");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this.DataOutInit("Output", 4);
|
||||
InputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] {Input1},
|
||||
DataInPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new DataPort[] { Output1, Output2, Output3, Output4 },
|
||||
DataOutPorts,
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.NumericTypes
|
||||
@@ -45,14 +37,11 @@ public partial class SquareModule : UnaryComputationalModule, IPolymorphismModul
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { OutputGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
public override void Define()
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider.Square(input1, OutputGroup.SelectedType);
|
||||
foreach (DataOutPort port in OutputGroup.OfType<DataOutPort>())
|
||||
port.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
|
||||
(object, StringName) Func(CacheItem c) => GlobalProvider.PolymorphismProvider!.Square(this.X(c));
|
||||
this.Define(Func);
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
|
||||
@@ -1,39 +1,38 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class V2ComponentModule : UnaryComputationalModule, IPolymorphismModule
|
||||
public partial class V2ComponentModule : UnaryComputationalModule, IPolymorphismModule, IDuplicateOutputModule
|
||||
{
|
||||
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 override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
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.DataOutInit("Output", 2);
|
||||
VectorInputGroup = GlobalProvider.DataStructureProvider!.NewDataInGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1 },
|
||||
DataInPorts,
|
||||
"Vector Input Type",
|
||||
EnigmosConstant.DataPortTypes.R2,
|
||||
EnigmosConstant.DataPortTypes.VectorTypes
|
||||
);
|
||||
ScalarOutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
ScalarOutputGroup = GlobalProvider.DataStructureProvider.NewDataOutGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2 },
|
||||
DataOutPorts,
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
@@ -42,20 +41,29 @@ public partial class V2ComponentModule : UnaryComputationalModule, IPolymorphism
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
public override void Define()
|
||||
{
|
||||
if (VectorInputGroup!.SelectedType == EnigmosConstant.DataPortTypes.R2)
|
||||
(object, StringName) Func1(CacheItem c)
|
||||
{
|
||||
Output1!.ResultData.Real = input1.R2[1];
|
||||
Output2!.ResultData.Real = input1.R2[2];
|
||||
IData v = this.X(c);
|
||||
if (v.Type == EnigmosConstant.DataPortTypes.R2)
|
||||
return (v.R2[1], EnigmosConstant.DataPortTypes.Real);
|
||||
return (v.C2[1], EnigmosConstant.DataPortTypes.Complex);
|
||||
}
|
||||
else
|
||||
(object, StringName) Func2(CacheItem c)
|
||||
{
|
||||
Output1!.ResultData.Complex = input1.C2[1];
|
||||
Output2!.ResultData.Complex = input1.C2[2];
|
||||
IData v = this.X(c);
|
||||
if (v.Type == EnigmosConstant.DataPortTypes.R2)
|
||||
return (v.R2[2], EnigmosConstant.DataPortTypes.Real);
|
||||
return (v.C2[2], EnigmosConstant.DataPortTypes.Complex);
|
||||
}
|
||||
DataOutPorts[0].OutData.UpdateCalculation(Func1);
|
||||
DataOutPorts[1].OutData.UpdateCalculation(Func2);
|
||||
|
||||
}
|
||||
|
||||
public void Inference() =>
|
||||
ScalarOutputGroup!.SelectedType = GlobalProvider.DataPackageTypeProvider!.GetBaseField(VectorInputGroup.SelectedType);
|
||||
ScalarOutputGroup!.SelectedType = GlobalProvider.DataPackageTypeProvider!
|
||||
.GetBaseField(VectorInputGroup!.SelectedType);
|
||||
|
||||
}
|
||||
@@ -1,21 +1,18 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public abstract partial class UnaryComputationalModule : ComputationalModule
|
||||
public abstract partial class UnaryComputationalModule : ComputationalModule, IUnaryComputationalModule
|
||||
{
|
||||
protected DataInPort? Input1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { Input1 }!;
|
||||
public IDataInPort[] DataInPorts { get; set; } = new IDataInPort[1];
|
||||
public override IEnumerable<IBasePort> Ports => DataInPorts;
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Input1 = GetPort<DataInPort>("Input1");
|
||||
this.DataInInit("Input", 1);
|
||||
}
|
||||
|
||||
protected abstract void Compute(IDataPackage input1);
|
||||
protected override void Compute(IRootModule root) => Compute(Input1.GetData(root));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.ControllingModules.ActionModules;
|
||||
|
||||
public abstract partial class ActionModule : ControllingModule
|
||||
public abstract partial class ActionModule : BaseModule, IActionModule
|
||||
{
|
||||
protected abstract void Execute(IRootModule root);
|
||||
protected override void Route(IRootModule root)
|
||||
{
|
||||
if(!root.ActionFinished)
|
||||
Execute(root);
|
||||
root.ActionFinished = true;
|
||||
}
|
||||
public abstract void Act();
|
||||
public ISignalInPort[] SignalInPorts { get; set; } = Array.Empty<ISignalInPort>();
|
||||
public void Execute() => Act();
|
||||
public bool Visited { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Enigmos.Ports.SignalPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Controls;
|
||||
|
||||
namespace Enigmos.Modules.ControllingModules.ActionModules;
|
||||
public partial class AttackActionModule : ActionModule
|
||||
public partial class AttackActionModule : ActionModule, ITerminalModule
|
||||
{
|
||||
private SignalInPort SignalIn1 { get; set; }
|
||||
private SignalInPort SignalIn2 { get; set; }
|
||||
private SignalInPort SignalIn3 { get; set; }
|
||||
private SignalInPort SignalIn4 { get; set; }
|
||||
|
||||
private DataInPort Input1 { get; set; }
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
public void Drain()
|
||||
{
|
||||
foreach (IDataInPort ip in DataInPorts)
|
||||
_ = ip.GetData.Get;
|
||||
}
|
||||
|
||||
public override IEnumerable<BasePort> Ports =>
|
||||
new BasePort[] { SignalIn1, SignalIn2, SignalIn3, SignalIn4, Input1 };
|
||||
public override IEnumerable<IBasePort> Ports => SignalInPorts.Union(DataInPorts.Cast<IBasePort>()).ToArray();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
SignalIn1 = GetNode<SignalInPort>("SignalIn1");
|
||||
SignalIn2 = GetNode<SignalInPort>("SignalIn2");
|
||||
SignalIn3 = GetNode<SignalInPort>("SignalIn3");
|
||||
SignalIn4 = GetNode<SignalInPort>("SignalIn4");
|
||||
Input1 = GetNode<DataInPort>("Input1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.R2);
|
||||
this.SignalInInit("SignalIn", 4);
|
||||
this.DataInInit("Input", 1);
|
||||
DataInPorts[0].SetDataType(EnigmosConstant.DataPortTypes.R2);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public override void Act()
|
||||
{
|
||||
CreatureControl.Instance.CurrentCharacter!.Action.Attack(DataInPorts[0].GetData.Get!.R2);
|
||||
}
|
||||
|
||||
protected override void Execute(IRootModule root) =>
|
||||
root.ManagedBy.Action.Attack(Input1.GetData(root).R2);
|
||||
}
|
||||
|
||||
@@ -1,42 +1,39 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Enigmos.Ports.SignalPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Skeleton.Algebra;
|
||||
using Skeleton.Algebra.DimensionProviders;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Controls;
|
||||
|
||||
namespace Enigmos.Modules.ControllingModules.ActionModules;
|
||||
using R2 = CategoryOf<IDim2>.OnField<double>.FVector;
|
||||
public partial class MoveActionModule : ActionModule
|
||||
|
||||
public partial class MoveActionModule : ActionModule, ITerminalModule
|
||||
{
|
||||
|
||||
private DataInPort? Input1 { get; set; }
|
||||
private SignalInPort? SignalIn1 { get; set; }
|
||||
private SignalInPort? SignalIn2 { get; set; }
|
||||
private SignalInPort? SignalIn3 { get; set; }
|
||||
private SignalInPort? SignalIn4 { get; set; }
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
public void Drain()
|
||||
{
|
||||
foreach (IDataInPort ip in DataInPorts)
|
||||
_ = ip.GetData.Get;
|
||||
}
|
||||
|
||||
public override IEnumerable<BasePort> Ports => new BasePort[] { Input1, SignalIn1, SignalIn2, SignalIn3, SignalIn4 };
|
||||
public override IEnumerable<IBasePort> Ports => DataInPorts.Union(SignalInPorts.Cast<IBasePort>());
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Input1 = GetPort<DataInPort>("Input1");
|
||||
SignalIn1 = GetPort<SignalInPort>("SignalIn1");
|
||||
SignalIn2 = GetPort<SignalInPort>("SignalIn2");
|
||||
SignalIn3 = GetPort<SignalInPort>("SignalIn3");
|
||||
SignalIn4 = GetPort<SignalInPort>("SignalIn4");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.R2);
|
||||
this.DataInInit("Input", 1);
|
||||
this.SignalInInit("SignalIn", 4);
|
||||
DataInPorts[0].SetDataType(EnigmosConstant.DataPortTypes.R2);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
public override string GetDescription => "";
|
||||
|
||||
protected override void Execute(IRootModule root)
|
||||
public override void Act()
|
||||
{
|
||||
R2 direction = Input1.GetData(root).R2;
|
||||
root.ManagedBy.Action.Move(direction);
|
||||
CreatureControl.Instance.CurrentCharacter!.Action.Attack(DataInPorts[0].GetData.Get!.R2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using Enigmos.Exceptions;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
|
||||
namespace Enigmos.Modules.ControllingModules;
|
||||
|
||||
public abstract partial class ControllingModule : BaseModule, IControllingModule
|
||||
{
|
||||
|
||||
protected abstract void Route(IRootModule root);
|
||||
public bool Visited { get; set; }
|
||||
protected override void TimeoutHandler(ModuleExecutionTimeout timeout)
|
||||
{
|
||||
Visited = false;
|
||||
base.TimeoutHandler(timeout);
|
||||
}
|
||||
|
||||
public void RouteWithTimeoutHandle(IRootModule root)
|
||||
{
|
||||
if (Visited)
|
||||
return;
|
||||
TimeoutCheck(root);
|
||||
try
|
||||
{
|
||||
Route(root);
|
||||
}
|
||||
catch (ModuleExecutionTimeout timeOut)
|
||||
{
|
||||
TimeoutHandler(timeOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Modules/ControllingModules/PiplineModule.cs
Normal file
16
Modules/ControllingModules/PiplineModule.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.ControllingModules;
|
||||
|
||||
public abstract partial class PiplineModule : BaseModule,
|
||||
IControllingModule,
|
||||
IRoutingModule
|
||||
{
|
||||
public ISignalInPort[] SignalInPorts { get; set; } = Array.Empty<ISignalInPort>();
|
||||
public ISignalOutPort[] SignalOutPorts { get; set; } = Array.Empty<ISignalOutPort>();
|
||||
public abstract void Execute();
|
||||
public bool Visited { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -1,35 +1,32 @@
|
||||
using System.Diagnostics;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.SignalPorts;
|
||||
using Nocturnis.Creatures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.ControllingModules;
|
||||
public partial class RootModule : ControllingModule, IRootModule
|
||||
public partial class RootModule : BaseModule, IRootModule
|
||||
{
|
||||
public bool ActionFinished { get; set; }
|
||||
public IBaseCreature? ManagedBy { get; set; }
|
||||
public void Start()
|
||||
{
|
||||
SignalOutPorts[0].Route();
|
||||
}
|
||||
|
||||
protected override bool Draggable => false;
|
||||
private SignalOutPort? SignalOut1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { SignalOut1 }!;
|
||||
public ISignalOutPort[] SignalOutPorts { get; set; } = Array.Empty<ISignalOutPort>();
|
||||
public override IEnumerable<IBasePort> Ports => SignalOutPorts;
|
||||
public Stopwatch? Timer { get; set; }
|
||||
public bool Visited { get; set; }
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
ActionFinished = true;
|
||||
SignalOut1 = GetPort<SignalOutPort>("SignalOut1");
|
||||
Visited = false;
|
||||
this.SignalOutInit("SignalOut", 1);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Route(IRootModule r)
|
||||
{
|
||||
if(!SignalOut1!.Connected)
|
||||
{
|
||||
ActionFinished = true;
|
||||
return;
|
||||
}
|
||||
Visited = true;
|
||||
SignalOut1.ConnectedPort!.Module.RouteWithTimeoutHandle(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,47 +1,50 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Enigmos.Ports.SignalPorts;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Controls;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Modules.ControllingModules;
|
||||
|
||||
public partial class SinglePoleDoubleThrowSwitchModule : ControllingModule, IParameterizedModule
|
||||
public partial class SinglePoleDoubleThrowSwitchModule : PiplineModule, IParameterizedModule, ITerminalModule
|
||||
{
|
||||
private DataInPort ControlInput { get; set; }
|
||||
private SignalInPort SignalIn { get; set; }
|
||||
private SignalOutPort SignalOut1 { get; set; }
|
||||
private SignalOutPort SignalOut2 { get; set; }
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; }
|
||||
private IBoolParameter LeftPortForTrue { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new BasePort[] { SignalIn, SignalOut1, SignalOut2, ControlInput };
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; } = new();
|
||||
private IBoolParameter? LeftPortForTrue { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports =>
|
||||
SignalInPorts.Union(SignalOutPorts.Cast<IBasePort>()).Union(DataInPorts).ToArray();
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
public void Drain()
|
||||
{
|
||||
foreach (IDataInPort ip in DataInPorts)
|
||||
_ = ip.GetData.Get;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
SignalIn = GetPort<SignalInPort>("SignalIn");
|
||||
SignalOut1 = GetPort<SignalOutPort>("SignalOut1");
|
||||
SignalOut2 = GetPort<SignalOutPort>("SignalOut2");
|
||||
ControlInput = GetPort<DataInPort>("ControlInput");
|
||||
this.SignalInInit("SignalIn", 1);
|
||||
this.SignalOutInit("SignalOut", 2);
|
||||
this.DataInInit("Input", 1);
|
||||
LeftPortForTrue =
|
||||
GlobalProvider.DataStructureProvider.NewBoolParameter("Redirect to:", "Left", "Right", true);
|
||||
ControlInput.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
GlobalProvider.DataStructureProvider!.NewBoolParameter("Redirect to:", "Left", "Right", true);
|
||||
DataInPorts[0].SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
ConfigurableParameters = new HashSet<IConfigurableParameter> { LeftPortForTrue };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Route(IRootModule root)
|
||||
public override void Execute()
|
||||
{
|
||||
Visited = true;
|
||||
SignalOutPort selectedPort = (LeftPortForTrue.ParameterValue && ControlInput.GetData(root).Bit)
|
||||
? SignalOut1
|
||||
: SignalOut2;
|
||||
ISignalOutPort selectedPort = (LeftPortForTrue!.ParameterValue && DataInPorts[0].GetData.Get!.Bit)
|
||||
? SignalOutPorts[0]
|
||||
: SignalOutPorts[1];
|
||||
if (selectedPort.Connected)
|
||||
selectedPort.ConnectedPort.Module.RouteWithTimeoutHandle(root);
|
||||
selectedPort.Route();
|
||||
else
|
||||
root.ActionFinished = true;
|
||||
EnigmosControl.Instance.RootModule.ActionFinished = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,36 +1,40 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Enigmos.Ports.SignalPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Controls;
|
||||
|
||||
namespace Enigmos.Modules.ControllingModules;
|
||||
|
||||
public partial class SinglePoleSingleThrowSwitchModule : ControllingModule
|
||||
public partial class SinglePoleSingleThrowSwitchModule : PiplineModule, ITerminalModule
|
||||
{
|
||||
private SignalInPort SignalIn { get; set; }
|
||||
private SignalOutPort SignalOut { get; set; }
|
||||
private DataInPort ControlInput { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new BasePort[] { SignalIn, SignalOut, ControlInput };
|
||||
public override IEnumerable<IBasePort> Ports =>
|
||||
SignalInPorts.Union(SignalOutPorts.Cast<IBasePort>()).Union(DataInPorts);
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
|
||||
public void Drain()
|
||||
{
|
||||
foreach (IDataInPort ip in DataInPorts)
|
||||
_ = ip.GetData.Get;
|
||||
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
SignalIn = GetPort<SignalInPort>("SignalIn");
|
||||
SignalOut = GetPort<SignalOutPort>("SignalOut");
|
||||
ControlInput = GetPort<DataInPort>("ControlInput");
|
||||
ControlInput.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
this.DataInInit("Input", 1);
|
||||
this.SignalInInit("SignalIn", 1);
|
||||
this.SignalOutInit("SignalOut", 1);
|
||||
DataInPorts[0].SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void Route(IRootModule root)
|
||||
public override void Execute()
|
||||
{
|
||||
Visited = true;
|
||||
if (ControlInput.GetData(root).Bit && SignalOut.Connected)
|
||||
SignalOut.ConnectedPort.Module.RouteWithTimeoutHandle(root);
|
||||
if (DataInPorts[0].GetData.Get!.Bit && SignalOutPorts[0].Connected)
|
||||
SignalOutPorts[0].Route();
|
||||
else
|
||||
root.ActionFinished = true;
|
||||
EnigmosControl.Instance.RootModule.ActionFinished = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
|
||||
using Nocturnis.Communicators;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using TabulaSmaragdina.Controls;
|
||||
|
||||
namespace Enigmos.Modules.Extensions;
|
||||
|
||||
public static class CommunicateModuleExtension
|
||||
{
|
||||
public static bool Paired(this ICommunicateModule module) => module.PairedCommunicator != null;
|
||||
|
||||
/// <summary>
|
||||
/// Determine if the module can be paired with given communicator
|
||||
/// </summary>
|
||||
public static bool IsMatch(this ICommunicateModule module, IBaseCommunicator communicator) =>
|
||||
module.CommunicationDataType == communicator.CommunicationDataType &&
|
||||
GlobalProvider.EnigmosProvider.CommunicationDirectionCompatible(
|
||||
module.CommunicationDirection,
|
||||
communicator.CommunicationDirection
|
||||
);
|
||||
/// <summary>
|
||||
/// Pair the module with given communicator
|
||||
/// </summary>
|
||||
public static void Pair(this ICommunicateModule module, IBaseCommunicator communicator)
|
||||
{
|
||||
if(module.Paired())
|
||||
module.Unpair();
|
||||
module.PairedCommunicator = communicator;
|
||||
communicator.PairedModule = module;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unpair the module with its paired communicator
|
||||
/// </summary>
|
||||
public static void Unpair(this ICommunicateModule module)
|
||||
{
|
||||
if (!module.Paired())
|
||||
return;
|
||||
module.PairedCommunicator.PairedModule = null;
|
||||
module.PairedCommunicator = null;
|
||||
}
|
||||
|
||||
public static void SendData(this ICommunicateModule module)
|
||||
{
|
||||
if (!module.Paired() || module.CommunicationDirection == EnigmosConstant.CommunicationDirections.Receive)
|
||||
return;
|
||||
module.PairedCommunicator.DataBuffer.Assign(module.DataBuffer, module.CommunicationDataType);
|
||||
}
|
||||
|
||||
|
||||
public static void ReceiveData(this ICommunicateModule module)
|
||||
{
|
||||
if (!module.Paired() || module.CommunicationDirection == EnigmosConstant.CommunicationDirections.Send)
|
||||
return;
|
||||
module.DataBuffer.Assign(module.PairedCommunicator.DataBuffer, module.CommunicationDataType);
|
||||
}
|
||||
|
||||
public static IBaseCommunicator[] CompatibleCommunicators(this ICommunicateModule module) =>
|
||||
CreatureControl.Instance.CurrentCharacter!.DashboardTab.AllCommunicators
|
||||
.Where(module.IsMatch)
|
||||
.ToArray();
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
namespace Enigmos.Modules.InterlayerModules;
|
||||
|
||||
public partial class FilterOutputModule : NullaryComputationalModule, IInterlayerModule
|
||||
{
|
||||
@@ -19,19 +18,26 @@ public partial class FilterOutputModule : NullaryComputationalModule, IInterlaye
|
||||
get => (ParentModule as IFilterModule)!;
|
||||
set => ParentModule = value;
|
||||
}
|
||||
public DataOutPort Output { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { Output };
|
||||
public IDataOutPort? Output { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => new[] { Output! };
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output = GetPort<DataOutPort>("Output");
|
||||
this.DataOutInit("Output", 1);
|
||||
Output = DataOutPorts[0];
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IRootModule root) => FilterModule.FilterWithTimeoutHandle(root);
|
||||
public IBasePort UnderlyingPort => Output;
|
||||
public override void Define()
|
||||
{
|
||||
FilterModule.Filter();
|
||||
Output!.OutData.UpdateCalculation(
|
||||
cache => (FilterModule.CachedResult, EnigmosConstant.DataPortTypes.AnyArrayType)
|
||||
);
|
||||
}
|
||||
|
||||
public IBasePort UnderlyingPort => Output!;
|
||||
public IProgrammableModule? ParentModule { get; set; }
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.InterlayerModules;
|
||||
public partial class InterlayerDataInModule : BaseModule, IInterlayerDataInModule
|
||||
@@ -14,11 +15,14 @@ public partial class InterlayerDataInModule : BaseModule, IInterlayerDataInModul
|
||||
public IInterlayerDataOutModule? DualModule { get; set; }
|
||||
public IDataInPort? DataIn { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => new[] { DataIn }!;
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
DataIn = GetPort<DataInPort>("DataIn");
|
||||
this.DataInInit("DataIn", 1);
|
||||
DataIn = DataInPorts[0];
|
||||
PostInit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.InterlayerModules;
|
||||
|
||||
@@ -21,12 +23,14 @@ public partial class InterlayerDataOutModule : ComputationalModule, IInterlayerD
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
DataOut = GetPort<DataOutPort>("DataOut");
|
||||
this.DataOutInit("DataOut", 1);
|
||||
DataOut = DataOutPorts[0];
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IRootModule root)
|
||||
public override void Define()
|
||||
{
|
||||
DataOut!.ResultData = DualModule!.DataIn!.GetData(root);
|
||||
DataOut!.OutData = DualModule!.DataIn!.GetData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports.SignalPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.InterlayerModules;
|
||||
|
||||
public partial class InterlayerSignalInModule : ControllingModule, IInterlayerSignalInModule
|
||||
public partial class InterlayerSignalInModule : BaseModule, IInterlayerSignalInModule
|
||||
{
|
||||
public override Vector2 PositionToBoard => base.PositionToBoard + (ParentModule?.PositionToBoard ?? Vector2.Zero);
|
||||
public IProgrammableModule? ParentModule { get; set; }
|
||||
@@ -16,13 +16,16 @@ public partial class InterlayerSignalInModule : ControllingModule, IInterlayerSi
|
||||
public IInterlayerSignalOutModule? DualModule { get; set; }
|
||||
public ISignalInPort? SignalIn { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => new[] { SignalIn }!;
|
||||
public ISignalInPort[] SignalInPorts { get; set; } = Array.Empty<ISignalInPort>();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
SignalIn = GetPort<SignalInPort>("SignalIn");
|
||||
this.SignalInInit("SignalIn", 1);
|
||||
SignalIn = SignalInPorts[0];
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Route(IRootModule root) => DualModule!.SignalOut!.Module.RouteWithTimeoutHandle(root);
|
||||
public void Execute() => DualModule!.SignalOut!.Route();
|
||||
public bool Visited { get; set; }
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.SignalPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.InterlayerModules;
|
||||
|
||||
public partial class InterlayerSignalOutModule : ControllingModule, IInterlayerSignalOutModule
|
||||
public partial class InterlayerSignalOutModule : BaseModule, IInterlayerSignalOutModule
|
||||
{
|
||||
public override Vector2 PositionToBoard => base.PositionToBoard + (ParentModule?.PositionToBoard ?? Vector2.Zero);
|
||||
public override Vector2 PositionToBoard =>
|
||||
base.PositionToBoard + (ParentModule?.PositionToBoard ?? Vector2.Zero);
|
||||
public IProgrammableModule? ParentModule { get; set; }
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
@@ -20,17 +18,16 @@ public partial class InterlayerSignalOutModule : ControllingModule, IInterlayerS
|
||||
public ISignalOutPort? SignalOut { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => new[] { SignalOut }!;
|
||||
|
||||
public ISignalOutPort[] SignalOutPorts { get; set; } = Array.Empty<ISignalOutPort>();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
SignalOut = GetPort<SignalOutPort>("SignalOut");
|
||||
this.SignalOutInit("SignalOut", 1);
|
||||
SignalOut = SignalOutPorts[0];
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Route(IRootModule root)
|
||||
{
|
||||
if (!SignalOut!.Connected)
|
||||
return;
|
||||
SignalOut.ConnectedPort!.Module.RouteWithTimeoutHandle(root);
|
||||
}
|
||||
public bool Visited { get; set; }
|
||||
|
||||
}
|
||||
39
Modules/InterlayerModules/IterativeOutputModule.cs
Normal file
39
Modules/InterlayerModules/IterativeOutputModule.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.InterlayerModules;
|
||||
|
||||
public partial class IterativeOutputModule : NullaryComputationalModule, IInterlayerModule, IDuplicateOutputModule
|
||||
{
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
public IDataOutPort? Output { get; set; }
|
||||
|
||||
public override IEnumerable<IBasePort> Ports => new[] { Output }!;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.DataOutInit("DataOut", 1);
|
||||
Output = DataOutPorts[0];
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public override void Define()
|
||||
{
|
||||
if (ParentModule is IOptimizationModule opm)
|
||||
this.Define(cache => (opm.CachedResult.Data, opm.CachedResult.Type)!);
|
||||
if (ParentModule is IFilterModule fm)
|
||||
this.Define(cache => (fm.CachedResult, EnigmosConstant.DataPortTypes.AnyArrayType));
|
||||
|
||||
}
|
||||
|
||||
//protected override void Compute(IRootModule root) => throw new Exception("Should be Handled by Other Module");
|
||||
public IBasePort UnderlyingPort => Output!;
|
||||
public IProgrammableModule? ParentModule { get; set; }
|
||||
}
|
||||
42
Modules/InterlayerModules/OptimizationItemOutputModule.cs
Normal file
42
Modules/InterlayerModules/OptimizationItemOutputModule.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.InterlayerModules;
|
||||
|
||||
public partial class OptimizationItemOutputModule : NullaryComputationalModule, IInterlayerModule
|
||||
{
|
||||
public override Vector2 PositionToBoard =>
|
||||
base.PositionToBoard + (OptimizationModule?.PositionToBoard ?? Vector2.Zero);
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
|
||||
public IOptimizationModule OptimizationModule
|
||||
{
|
||||
get => (ParentModule as IOptimizationModule)!;
|
||||
set => ParentModule = value;
|
||||
}
|
||||
public IDataOutPort DataOut { get; set; }
|
||||
|
||||
public override IEnumerable<IBasePort> Ports => new[] { DataOut };
|
||||
//protected override void Compute(IRootModule root) => OptimizationModule.OptimizeWithTimeoutHandle(root);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.DataOutInit("DataOut", 1);
|
||||
DataOut = DataOutPorts[0];
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public IBasePort UnderlyingPort => DataOut;
|
||||
public IProgrammableModule? ParentModule { get; set; }
|
||||
public override void Define()
|
||||
{
|
||||
IOptimizationModule im = (ParentModule as IOptimizationModule)!;
|
||||
DataOut.OutData.UpdateCalculation(cache => (im.CachedResult.Data, im.CachedResult.Type)!);
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,16 @@ using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
namespace Enigmos.Modules.InterlayerModules;
|
||||
|
||||
public partial class OptimizationValueOutputModule : NullaryComputationalModule, IInterlayerModule
|
||||
public partial class OptimizationValueOutputModule : NullaryComputationalModule,
|
||||
IInterlayerModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
public override Vector2 PositionToBoard =>
|
||||
base.PositionToBoard + (OptimizationModule?.PositionToBoard ?? Vector2.Zero);
|
||||
@@ -25,13 +29,15 @@ public partial class OptimizationValueOutputModule : NullaryComputationalModule,
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
DataOut = GetPort<DataOutPort>("DataOut");
|
||||
this.DataOutInit("DataOut", 1);
|
||||
DataOut.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IRootModule root) =>
|
||||
OptimizationModule.OptimizeWithTimeoutHandle(root);
|
||||
public override void Define()
|
||||
{
|
||||
this.Define(cache => (OptimizationModule.CachedResult.Data, OptimizationModule.CachedResult.Type) );
|
||||
}
|
||||
|
||||
public IBasePort UnderlyingPort => DataOut;
|
||||
public IProgrammableModule? ParentModule { get; set; }
|
||||
@@ -1,53 +0,0 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Inventories.ItemSlots.ItemSlots;
|
||||
using Skeleton.Algebra.Extensions;
|
||||
using Skeleton.Utils.Helpers;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
public partial class EngineControllingModule : BaseModule
|
||||
{
|
||||
protected override bool Draggable => false;
|
||||
public DataInPort Throttle { get; set; }
|
||||
public IChemicalItemSlot FuelTank { get; set; }
|
||||
private double MaxPumpSpeed => 2d;
|
||||
private double EnergyConversionEfficiency => 0.5d;
|
||||
public override IEnumerable<BasePort> Ports => new[] { Throttle };
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Throttle = GetPort<DataInPort>("Throttle");
|
||||
Throttle.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
FuelTank = GetNode<IChemicalItemSlot>("FuelTank");
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public double Combust(RootModule root)
|
||||
{
|
||||
if (FuelTank.Item == null)
|
||||
return 0d;
|
||||
if (FuelTank.Item.Amount <= 0)
|
||||
return 0d;
|
||||
double fuelAmount = Mathf.Min(
|
||||
FuelTank.Item.BottomAmount,
|
||||
Throttle.GetData(root).Real.DoubleCut() * MaxPumpSpeed * (1 - FuelTank.Item.BottomViscosity)
|
||||
);
|
||||
if (fuelAmount == 0)
|
||||
{
|
||||
//TODO Drain fuel from pipeline
|
||||
}
|
||||
|
||||
double res =
|
||||
fuelAmount * FuelTank.Item.ContentMaterial.LayerOrder.Last.Value.Energy * EnergyConversionEfficiency;
|
||||
FuelTank.Item.ConsumeFromBottom(fuelAmount);
|
||||
if (FuelTank.Item.Amount.IsEqualApprox(0d))
|
||||
{
|
||||
//TODO Try get fuel
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,22 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
|
||||
public partial class IndicateInputModule : BaseModule
|
||||
public partial class IndicateInputModule : BaseModule, IParameterModule
|
||||
{
|
||||
public DataInPort Input { get; set; }
|
||||
public IDataInPort? Input { get; set; }
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
public override IEnumerable<BasePort> Ports => new[] { Input };
|
||||
public override IEnumerable<IBasePort> Ports => new[] { Input! };
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Input = GetPort<DataInPort>("Input");
|
||||
this.DataInInit("Input", 1);
|
||||
Input = DataInPorts[0];
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
|
||||
public partial class IterativeOutputModule : NullaryComputationalModule, IInterlayerModule
|
||||
{
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
public DataOutPort? Output { get; set; }
|
||||
|
||||
public override IEnumerable<BasePort> Ports => new[] { Output }!;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output = GetPort<DataOutPort>("DataOut");
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IRootModule root) => throw new Exception("Should be Handled by Other Module");
|
||||
public IBasePort UnderlyingPort => Output!;
|
||||
public IProgrammableModule? ParentModule { get; set; }
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.ProgrammableModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
|
||||
public partial class OptimizationItemOutputModule : NullaryComputationalModule, IInterlayerModule
|
||||
{
|
||||
public override Vector2 PositionToBoard =>
|
||||
base.PositionToBoard + (OptimizationModule?.PositionToBoard ?? Vector2.Zero);
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
|
||||
public IOptimizationModule OptimizationModule
|
||||
{
|
||||
get => ParentModule as IOptimizationModule;
|
||||
set => ParentModule = value;
|
||||
}
|
||||
public DataOutPort DataOut { get; set; }
|
||||
|
||||
public override IEnumerable<BasePort> Ports => new[] { DataOut };
|
||||
protected override void Compute(IRootModule root) => OptimizationModule.OptimizeWithTimeoutHandle(root);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
DataOut = GetPort<DataOutPort>("DataOut");
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public IBasePort UnderlyingPort => DataOut;
|
||||
public IProgrammableModule? ParentModule { get; set; }
|
||||
}
|
||||
@@ -1,20 +1,23 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
|
||||
public partial class OptimizationValueInputModule : BaseModule
|
||||
public partial class OptimizationValueInputModule : BaseModule, IParameterModule
|
||||
{
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
public DataInPort DataIn { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { DataIn };
|
||||
public IDataInPort? DataIn { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => new[] { DataIn! };
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
DataIn = GetPort<DataInPort>("DataIn");
|
||||
base.Init();
|
||||
this.DataInInit("DataIn", 1);
|
||||
DataIn = DataInPorts[0];
|
||||
DataIn.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
DataIn.Module = this;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
|
||||
@@ -13,16 +14,22 @@ public partial class OutputSubModule : NullaryComputationalModule
|
||||
base.PositionToBoard + (ParentModule?.PositionToBoard ?? Vector2.Zero);
|
||||
protected override bool Draggable => false;
|
||||
protected override bool HasManual => false;
|
||||
public override IEnumerable<BasePort> Ports => new[] { DataOut };
|
||||
public IComputationalCompositeModule ParentModule { get; set; }
|
||||
public DataOutPort DataOut { get; set; }
|
||||
protected override void Compute(IRootModule root) => ParentModule.Compute(root);
|
||||
public override IEnumerable<IBasePort> Ports => new[] { DataOut };
|
||||
public IComputationalCompositeModule? ParentModule { get; set; }
|
||||
public IDataOutPort? DataOut { get; set; }
|
||||
|
||||
public override void Define()
|
||||
{
|
||||
//DataOut = ParentModule
|
||||
}
|
||||
|
||||
//protected override void Compute(IRootModule root) => ParentModule.Compute(root);
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
DataOut = GetPort<DataOutPort>("DataOut");
|
||||
this.DataOutInit("DataOut", 1);
|
||||
DataOut = DataOutPorts[0];
|
||||
DataOut.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
140
Modules/ProgrammableModules/FilterModule.cs
Normal file
140
Modules/ProgrammableModules/FilterModule.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using Enigmos.Boards;
|
||||
using Enigmos.Exceptions;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.InterlayerModules;
|
||||
using Enigmos.Modules.Other;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Modules.ProgrammableModules;
|
||||
|
||||
public partial class FilterModule : ProgrammableModule, IPolymorphismModule, IFilterModule
|
||||
{
|
||||
|
||||
private IDataInPort? Input { get; set; }
|
||||
private IInterlayerDataInModule[] ExplicitInputs { get; set; } = Array.Empty<IInterlayerDataInModule>();
|
||||
private FilterOutputModule? Output { get; set; }
|
||||
private IterativeOutputModule? IterativeOutput { get; set; }
|
||||
private IndicateInputModule? Indicate { get; set; }
|
||||
private IDataPortGroup[] InterLayerGroups { get; set; } = Array.Empty<IDataPortGroup>();
|
||||
private IDataPortGroup? ArrayGroup { get; set; }
|
||||
private bool FilterEnded { get; set; }
|
||||
private IData[] CachedInputArray { get; set; } = Array.Empty<IData>();
|
||||
public IData[] CachedResult { get; set; } = Array.Empty<IData>();
|
||||
|
||||
private List<IData> CachedListResult { get; set; } = new();
|
||||
|
||||
//private List<IData> CachedResult { get; set; } = new();
|
||||
private int CachedIndex { get; set; }
|
||||
|
||||
public new FilterModuleBoard UnderlyingBoard
|
||||
{
|
||||
get => (base.UnderlyingBoard as FilterModuleBoard)!;
|
||||
set => base.UnderlyingBoard = value;
|
||||
}
|
||||
|
||||
public override IEnumerable<IBasePort> Ports => new[] { Input! };
|
||||
|
||||
public override IBaseModule[] SubModules() => ExplicitInputs.Union<IBaseModule>(new[] { Output! }).ToArray();
|
||||
|
||||
public override IEnumerable<IBasePort> ExplicitPorts =>
|
||||
new IBasePort[] { Output!.Output! }
|
||||
.Union(ExplicitInputs.Select(c => c.DataIn))!
|
||||
.ToArray<IBasePort>();
|
||||
|
||||
public override IEnumerable<IBasePort> ImplicitPorts =>
|
||||
new IBasePort[] { IterativeOutput!.Output!, Indicate!.Input! }
|
||||
.Union(UnderlyingBoard.Outputs.Select(c => c.DataOut))
|
||||
.ToArray()!;
|
||||
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
|
||||
public void Inference() => IterativeOutput!.Output!
|
||||
.SetDataType(GlobalProvider.DataStructureProvider!.ArrayToElement(ArrayGroup!.SelectedType));
|
||||
|
||||
|
||||
public void Filter()
|
||||
{
|
||||
if (FilterEnded)
|
||||
{
|
||||
CachedInputArray = Input!.GetData.Get!.Array;
|
||||
CachedIndex = 0;
|
||||
CachedListResult = new List<IData>();
|
||||
}
|
||||
|
||||
while (CachedIndex < CachedInputArray.Length)
|
||||
{
|
||||
SoftReset();
|
||||
IterativeOutput!.Output!.OutData.UpdateCalculation(cache =>
|
||||
(CachedInputArray[CachedIndex].Data, IterativeOutput.Output.DataType)!);
|
||||
IterativeOutput.Output.OutData.Expire();
|
||||
if(Indicate!.Input!.GetData.Get!.Bit)
|
||||
CachedListResult.Add(CachedInputArray[CachedIndex]);
|
||||
CachedIndex += 1;
|
||||
}
|
||||
|
||||
CachedResult = CachedListResult.ToArray();
|
||||
FilterEnded = true;
|
||||
}
|
||||
|
||||
private void SoftReset() => UnderlyingBoard.Reset();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
UnderlyingBoard = GlobalProvider.SceneProvider!
|
||||
.AssetMapper<FilterModuleBoard>()
|
||||
.Instantiate<FilterModuleBoard>();
|
||||
UnderlyingBoard.Init();
|
||||
ExplicitInputs = new InterlayerDataInModule[3];
|
||||
InterLayerGroups = new IDataPortGroup[3];
|
||||
IterativeOutput = UnderlyingBoard.IterativeOutput;
|
||||
IterativeOutput.Output.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Indicate = UnderlyingBoard.Indicate;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
ExplicitInputs[i] = GetModule<InterlayerDataInModule>($"EI{i + 1}");
|
||||
ExplicitInputs[i].DualModule = UnderlyingBoard.Outputs[i];
|
||||
UnderlyingBoard.Outputs[i].DualModule = ExplicitInputs[i];
|
||||
}
|
||||
|
||||
FilterEnded = true;
|
||||
|
||||
Input = this.GetPort<DataInPort>("Input");
|
||||
Output = GetModule<FilterOutputModule>("Output");
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
InterLayerGroups[i] = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { ExplicitInputs[i].DataIn, UnderlyingBoard.Outputs[i].DataOut },
|
||||
$"Exterior In -> Interior Out{i}",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
);
|
||||
ExplicitInputs[i].Board = Board;
|
||||
}
|
||||
|
||||
ArrayGroup = GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Input, Output.Output! },
|
||||
"Array Type",
|
||||
EnigmosConstant.DataPortTypes.RealArray,
|
||||
EnigmosConstant.DataPortTypes.AnyArray
|
||||
);
|
||||
|
||||
ConfigurablePortGroups = InterLayerGroups.Union(new[] { ArrayGroup }).ToHashSet();
|
||||
|
||||
PostInit();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
111
Modules/ProgrammableModules/FunctionModule.cs
Normal file
111
Modules/ProgrammableModules/FunctionModule.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using Enigmos.Boards;
|
||||
using Enigmos.Modules.InterlayerModules;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Modules.ProgrammableModules;
|
||||
public partial class FunctionModule : ProgrammableModule, IPolymorphismModule
|
||||
{
|
||||
private IDataPortGroup[] ExteriorToInterior { get; set; } = Array.Empty<IDataPortGroup>();
|
||||
private IDataPortGroup[] InteriorToExterior { get; set; } = Array.Empty<IDataPortGroup>();
|
||||
public void Inference(){}
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
|
||||
public override IEnumerable<IBasePort> ExplicitPorts =>
|
||||
ExplicitDataInModules
|
||||
.SelectMany(module => module.Ports)
|
||||
.Union(ExplicitDataOutModules.SelectMany(module => module.Ports))
|
||||
.Union(ExplicitSignalInModules.SelectMany(module => module.Ports))
|
||||
.Union(ExplicitSignalOutModules.SelectMany(module => module.Ports));
|
||||
|
||||
public override IEnumerable<IBasePort> ImplicitPorts =>
|
||||
UnderlyingBoard.DataIns
|
||||
.SelectMany(module => module.Ports)
|
||||
.Union(UnderlyingBoard.DataOuts.SelectMany(module => module.Ports))
|
||||
.Union(UnderlyingBoard.SignalIns.SelectMany(module => module.Ports))
|
||||
.Union(UnderlyingBoard.SignalOuts.SelectMany(module => module.Ports));
|
||||
|
||||
|
||||
private static readonly PackedScene FunctionModuleBoardScene = GlobalProvider.SceneProvider!
|
||||
.AssetMapper<FunctionModuleBoard>();
|
||||
|
||||
public override BaseModule[] SubModules() =>
|
||||
ExplicitDataInModules
|
||||
.Union<BaseModule>(ExplicitDataOutModules)
|
||||
.Union(ExplicitSignalInModules)
|
||||
.Union(ExplicitSignalOutModules)
|
||||
.ToArray();
|
||||
|
||||
private InterlayerDataInModule[] ExplicitDataInModules { get; set; } = Array.Empty<InterlayerDataInModule>();
|
||||
private InterlayerDataOutModule[] ExplicitDataOutModules { get; set; } = Array.Empty<InterlayerDataOutModule>();
|
||||
private InterlayerSignalInModule[] ExplicitSignalInModules { get; set; } = Array.Empty<InterlayerSignalInModule>();
|
||||
|
||||
private InterlayerSignalOutModule[] ExplicitSignalOutModules { get; set; } =
|
||||
Array.Empty<InterlayerSignalOutModule>();
|
||||
|
||||
protected new FunctionModuleBoard UnderlyingBoard
|
||||
{
|
||||
get => (base.UnderlyingBoard as FunctionModuleBoard)!;
|
||||
set => base.UnderlyingBoard = value;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
UnderlyingBoard = FunctionModuleBoardScene.Instantiate<FunctionModuleBoard>();
|
||||
UnderlyingBoard.Init();
|
||||
ExteriorToInterior = new IDataPortGroup[4];
|
||||
InteriorToExterior = new IDataPortGroup[4];
|
||||
ExplicitDataInModules = new InterlayerDataInModule[4];
|
||||
ExplicitDataOutModules = new InterlayerDataOutModule[4];
|
||||
ExplicitSignalInModules = new InterlayerSignalInModule[4];
|
||||
ExplicitSignalOutModules = new InterlayerSignalOutModule[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ExplicitDataInModules[i] = GetModule<InterlayerDataInModule>($"EI{i + 1}");
|
||||
ExplicitDataOutModules[i] = GetModule<InterlayerDataOutModule>($"EO{i + 1}");
|
||||
ExplicitSignalInModules[i] = GetModule<InterlayerSignalInModule>($"ESI{i + 1}");
|
||||
ExplicitSignalOutModules[i] = GetModule<InterlayerSignalOutModule>($"ESO{i + 1}");
|
||||
|
||||
ExplicitDataInModules[i].DualModule = UnderlyingBoard.DataOuts[i];
|
||||
ExplicitDataOutModules[i].DualModule = UnderlyingBoard.DataIns[i];
|
||||
ExplicitSignalInModules[i].DualModule = UnderlyingBoard.SignalOuts[i];
|
||||
ExplicitSignalOutModules[i].DualModule = UnderlyingBoard.SignalIns[i];
|
||||
|
||||
UnderlyingBoard.DataOuts[i].DualModule = ExplicitDataInModules[i];
|
||||
UnderlyingBoard.DataIns[i].DualModule = ExplicitDataOutModules[i];
|
||||
UnderlyingBoard.SignalOuts[i].DualModule = ExplicitSignalInModules[i];
|
||||
UnderlyingBoard.SignalIns[i].DualModule = ExplicitSignalOutModules[i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ExteriorToInterior[i] = GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { ExplicitDataInModules[i].DataIn, UnderlyingBoard.DataOuts[i].DataOut },
|
||||
$"Exterior In -> Interior Out{i + 1}",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
);
|
||||
InteriorToExterior[i] = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { UnderlyingBoard.DataIns[i].DataIn, ExplicitDataOutModules[i].DataOut },
|
||||
$"Interior In -> Exterior Out{i + 1}",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
);
|
||||
}
|
||||
|
||||
ConfigurablePortGroups = ExteriorToInterior.Union(InteriorToExterior).ToHashSet();
|
||||
PostInit();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
186
Modules/ProgrammableModules/OptimizationModule.cs
Normal file
186
Modules/ProgrammableModules/OptimizationModule.cs
Normal file
@@ -0,0 +1,186 @@
|
||||
using Enigmos.Boards;
|
||||
using Enigmos.Exceptions;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.InterlayerModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Modules.ProgrammableModules;
|
||||
|
||||
public partial class OptimizationModule : ProgrammableModule,
|
||||
IPolymorphismModule,
|
||||
IParameterizedModule,
|
||||
IOptimizationModule
|
||||
{
|
||||
private bool OptimizationEnded { get; set; }
|
||||
private double? CachedOptimizeValue { get; set; }
|
||||
public IDataInPort? InternalIterOut { get; set; }
|
||||
public IDataOutPort? InternalArrayIn { get; set; }
|
||||
|
||||
public IData CachedResult { get; set; } =
|
||||
GlobalProvider.DataStructureProvider!.NewData(0, EnigmosConstant.DataPortTypes.Null);
|
||||
|
||||
private IData[] CachedInput { get; set; } = Array.Empty<IData>();
|
||||
private int ProcessingIndex { get; set; }
|
||||
|
||||
private IBoolParameter? UsingMax { get; set; }
|
||||
private IDataPortGroup[] InterlayerGroups { get; set; } = Array.Empty<IDataPortGroup>();
|
||||
private IDataPortGroup? OptimizationGroup { get; set; }
|
||||
private DataInPort? ArrayInput { get; set; }
|
||||
private InterlayerDataInModule[] ExplicitInputs { get; set; } = Array.Empty<InterlayerDataInModule>();
|
||||
private OptimizationItemOutputModule? ItemOut { get; set; }
|
||||
private OptimizationValueOutputModule? ValueOut { get; set; }
|
||||
|
||||
public override IEnumerable<IBasePort> Ports => new[] { ArrayInput! };
|
||||
|
||||
public new OptimizationModuleBoard UnderlyingBoard
|
||||
{
|
||||
get => (base.UnderlyingBoard as OptimizationModuleBoard)!;
|
||||
set => base.UnderlyingBoard = value;
|
||||
}
|
||||
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; } = new();
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
|
||||
public override IEnumerable<IBasePort> ExplicitPorts =>
|
||||
new IBasePort[] { ItemOut!.DataOut, ValueOut!.DataOut! }
|
||||
.Union<IBasePort>(ExplicitInputs.Select(c => c.DataIn)!);
|
||||
|
||||
public override BaseModule[] SubModules() =>
|
||||
ExplicitInputs
|
||||
.Union(new BaseModule[] { ItemOut, ValueOut })
|
||||
.ToArray();
|
||||
|
||||
public override IEnumerable<IBasePort> ImplicitPorts =>
|
||||
new IBasePort[] { UnderlyingBoard.IterOut.Output, UnderlyingBoard.ValueIn.DataIn }
|
||||
.Union(UnderlyingBoard.ImplicitDataOuts.Select(c => c.DataOut));
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
UnderlyingBoard = GlobalProvider.SceneProvider!
|
||||
.AssetMapper<OptimizationModuleBoard>()
|
||||
.Instantiate<OptimizationModuleBoard>();
|
||||
UnderlyingBoard.Init();
|
||||
InterlayerGroups = new IDataPortGroup[3];
|
||||
ExplicitInputs = new InterlayerDataInModule[3];
|
||||
InternalIterOut = this.GetPort<IDataInPort>("InternalIterOut");
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
ExplicitInputs[i] = GetModule<InterlayerDataInModule>($"EI{i + 1}");
|
||||
ExplicitInputs[i].DualModule = UnderlyingBoard.ImplicitDataOuts[i];
|
||||
UnderlyingBoard.ImplicitDataOuts[i].DualModule = ExplicitInputs[i];
|
||||
}
|
||||
|
||||
OptimizationEnded = true;
|
||||
CachedInput = Array.Empty<IData>();
|
||||
//CachedArray = Array.Empty<DataPackage>();
|
||||
ProcessingIndex = 0;
|
||||
CachedResult = GlobalProvider.DataStructureProvider!.NullData;
|
||||
CachedOptimizeValue = null;
|
||||
|
||||
ArrayInput = this.GetPort<DataInPort>("ArrayInput");
|
||||
ItemOut = GetModule<OptimizationItemOutputModule>("ItemOut");
|
||||
ValueOut = GetModule<OptimizationValueOutputModule>("ValueOut");
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
InterlayerGroups[i] = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { ExplicitInputs[i].DataIn!, UnderlyingBoard.ImplicitDataOuts[i].DataOut! },
|
||||
$"Exterior In -> Interior Out{i}",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
);
|
||||
ExplicitInputs[i].Board = Board;
|
||||
}
|
||||
|
||||
OptimizationGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { ArrayInput },
|
||||
"Array Input Type",
|
||||
EnigmosConstant.DataPortTypes.AnyArrayType,
|
||||
EnigmosConstant.DataPortTypes.AnyArray
|
||||
);
|
||||
UsingMax = GlobalProvider.DataStructureProvider.NewBoolParameter(
|
||||
"Method",
|
||||
"Max",
|
||||
"Min",
|
||||
true
|
||||
);
|
||||
ItemOut.DataOut.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
ValueOut.DataOut!.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
ConfigurableParameters = new HashSet<IConfigurableParameter> { UsingMax };
|
||||
ConfigurablePortGroups =
|
||||
InterlayerGroups.Union(new[] { OptimizationGroup }).ToHashSet();
|
||||
PostInit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Inference()
|
||||
{
|
||||
StringName elementType = GlobalProvider.DataPackageTypeProvider!.ToElement(OptimizationGroup!.SelectedType);
|
||||
ItemOut!.DataOut.SetDataType(elementType);
|
||||
UnderlyingBoard.IterOut!.Output!.SetDataType(elementType);
|
||||
}
|
||||
|
||||
private void SoftReset() => UnderlyingBoard.Reset();
|
||||
|
||||
public void Optimize()
|
||||
{
|
||||
if (OptimizationEnded)
|
||||
{
|
||||
CachedOptimizeValue = null;
|
||||
CachedInput = InternalArrayIn!.OutData.Get!.Array;
|
||||
CachedResult = GlobalProvider.DataStructureProvider.NewData(0, EnigmosConstant.DataPortTypes.Null);
|
||||
ProcessingIndex = 0;
|
||||
}
|
||||
|
||||
while (ProcessingIndex < CachedInput.Length)
|
||||
{
|
||||
SoftReset();
|
||||
UnderlyingBoard.IterOut!.Output!.OutData.UpdateCalculation(
|
||||
cache =>
|
||||
(CachedInput[ProcessingIndex].Data, CachedInput[ProcessingIndex].Type)!
|
||||
);
|
||||
UnderlyingBoard.IterOut.Output.OutData.Expire();
|
||||
double currentValue = UnderlyingBoard.ValueIn!.DataIn!.GetData.Get!.Double;
|
||||
IData currentOut = InternalIterOut!.GetData.Get!;
|
||||
if (UsingMax!.ParameterValue)
|
||||
{
|
||||
if (CachedOptimizeValue == null || (CachedOptimizeValue < currentValue))
|
||||
{
|
||||
CachedOptimizeValue = currentValue;
|
||||
CachedResult.Assign(currentOut.Data!, currentOut.Type!);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CachedOptimizeValue == null || CachedOptimizeValue > currentValue)
|
||||
{
|
||||
CachedOptimizeValue = currentValue;
|
||||
CachedResult.Assign(currentOut.Data!, currentOut.Type!);
|
||||
}
|
||||
}
|
||||
ProcessingIndex++;
|
||||
|
||||
}
|
||||
ValueOut!.Define();
|
||||
OptimizationEnded = true;
|
||||
}
|
||||
|
||||
public bool Calculated { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
using Enigmos.Boards;
|
||||
using Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Modules.ProgrammableModules;
|
||||
|
||||
public abstract partial class ProgrammableModule : BaseModule, ICompositeModule, IProgrammableModule
|
||||
{
|
||||
public BaseBoard UnderlyingBoard { get; set; }
|
||||
public BaseBoard? UnderlyingBoard { get; set; }
|
||||
public abstract IBaseModule[] SubModules();
|
||||
public void EnterProgrammableBoard() => GlobalProvider.SceneProvider.RootScene.ChangeScene(UnderlyingBoard);
|
||||
public abstract IEnumerable<BasePort> ExplicitPorts();
|
||||
public abstract IEnumerable<BasePort> ImplicitPorts();
|
||||
public void EnterProgrammableBoard() => GlobalProvider.SceneProvider!.RootScene.ChangeScene(UnderlyingBoard!);
|
||||
public abstract IEnumerable<IBasePort> ExplicitPorts { get; }
|
||||
public abstract IEnumerable<IBasePort> ImplicitPorts { get; }
|
||||
public override void UpdateCables()
|
||||
{
|
||||
foreach (BasePort port in ExplicitPorts())
|
||||
foreach (IBasePort port in ExplicitPorts)
|
||||
{
|
||||
if(!Board.CablePairing.ContainsKey(port) )
|
||||
if(!Board!.CablePairing.ContainsKey(port) )
|
||||
continue;
|
||||
Board.CablePairing[port].LineUpdate();
|
||||
}
|
||||
|
||||
41
Modules/TerminalModules/EngineModule.cs
Normal file
41
Modules/TerminalModules/EngineModule.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Controls;
|
||||
using Nocturnis.Inventories.ItemSlots.ItemSlots;
|
||||
using Skeleton.Utils.Helpers;
|
||||
using VirtualChemistry.Chemistry.Mixtures.Implements;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules;
|
||||
public partial class EngineModule : TerminalModule
|
||||
{
|
||||
protected override bool Draggable => false;
|
||||
public DataInPort? Throttle { get; set; }
|
||||
public IChemicalItemSlot? FuelTank { get; set; }
|
||||
private double MaxPumpSpeed => 2d;
|
||||
private double EnergyConversionEfficiency => 0.5d;
|
||||
public override IEnumerable<IBasePort> Ports => new[] { Throttle! };
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Throttle!.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
FuelTank = GetNode<IChemicalItemSlot>("FuelTank");
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public override void Drain()
|
||||
{
|
||||
base.Drain();
|
||||
if (FuelTank!.Item!.ContentMaterial.Layers.Count == 0)
|
||||
{
|
||||
EnigmosControl.Instance.Energy = 0;
|
||||
return;
|
||||
}
|
||||
HomogeneousMixture bottom = FuelTank.Item.ContentMaterial.LayerOrder.Last.Value;
|
||||
double consumption = Math.Min(bottom.Amount, Throttle!.GetData.Get!.Double.DoubleCut() * bottom.CombustRate);
|
||||
EnigmosControl.Instance.Energy = consumption * bottom.Energy;
|
||||
bottom.Amount -= consumption;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +1,42 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.Other;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules;
|
||||
|
||||
public partial class MemoryModule : TerminalModule, IPolymorphismModule, IComputationalCompositeModule
|
||||
public partial class MemoryModule : BaseModule, ITerminalModule, ISourceModule, IDuplicateOutputModule
|
||||
{
|
||||
private DataInPort? Input1 { get; set; }
|
||||
private DataInPort? Input2 { get; set; }
|
||||
private DataInPort? Input3 { get; set; }
|
||||
private IDataPackage? Memory { get; set; }
|
||||
private IData? Memory { get; set; }
|
||||
private IDataPortGroup? MemoryPortGroup { get; set; }
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
private OutputSubModule? Output1 { get; set; }
|
||||
private OutputSubModule? Output2 { get; set; }
|
||||
private OutputSubModule? Output3 { get; set; }
|
||||
private OutputSubModule? Output4 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new BasePort[] { Input1!, Input2!, Input3! };
|
||||
public IBaseModule[] SubModules() => new IBaseModule[] { Output1!, Output2!, Output3!, Output4! };
|
||||
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
public IDataOutPort[] DataOutPorts { get; set; } = Array.Empty<IDataOutPort>();
|
||||
public override IEnumerable<IBasePort> Ports => DataInPorts.Union<IBasePort>(DataOutPorts);
|
||||
|
||||
|
||||
protected OutputSubModule GetOutputModule(string path)
|
||||
{
|
||||
OutputSubModule res = GetNode<OutputSubModule>(path);
|
||||
res.Init();
|
||||
res.ParentModule = this;
|
||||
res.Board = Board;
|
||||
return res;
|
||||
}
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Memory = GlobalProvider.DataStructureProvider!.NewDataPackage();
|
||||
Input1 = GetPort<DataInPort>("Input1");
|
||||
Input2 = GetPort<DataInPort>("Input2");
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input3 = GetPort<DataInPort>("Input3");
|
||||
Input3.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1 = GetOutputModule("Output1");
|
||||
Output2 = GetOutputModule("Output2");
|
||||
Output3 = GetOutputModule("Output3");
|
||||
Output4 = GetOutputModule("Output4");
|
||||
Memory = GlobalProvider.DataStructureProvider!.NewData(0, EnigmosConstant.DataPortTypes.Null);
|
||||
this.DataInInit("Input", 3);
|
||||
this.DataOutInit("Output", 4);
|
||||
DataInPorts[1].SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
DataInPorts[2].SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
|
||||
MemoryPortGroup =GlobalProvider.DataStructureProvider!.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1, Output1.DataOut, Output2.DataOut, Output3.DataOut, Output4.DataOut },
|
||||
new IDataPort[] { DataInPorts[0] }.Union(DataOutPorts).ToArray(),
|
||||
"Memory Data Type:",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
);
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup>() { MemoryPortGroup };
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { MemoryPortGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
@@ -62,30 +44,27 @@ public partial class MemoryModule : TerminalModule, IPolymorphismModule, IComput
|
||||
{
|
||||
}
|
||||
|
||||
public void Compute(IRootModule root)
|
||||
|
||||
public void Define()
|
||||
{
|
||||
Output1!.DataOut.ResultData.Assign(Memory!, MemoryPortGroup!.SelectedType);
|
||||
Output2!.DataOut.ResultData.Assign(Memory!, MemoryPortGroup.SelectedType);
|
||||
Output3!.DataOut.ResultData.Assign(Memory!, MemoryPortGroup.SelectedType);
|
||||
Output4!.DataOut.ResultData.Assign(Memory!, MemoryPortGroup.SelectedType);
|
||||
this.Define(cache => (Memory!.Data, Memory.Type)!);
|
||||
}
|
||||
|
||||
protected override void Consume(RootModule root)
|
||||
public void Drain()
|
||||
{
|
||||
bool setValue = Input2!.GetData(root).Bit;
|
||||
bool resetValue = Input3!.GetData(root).Bit;
|
||||
if (setValue)
|
||||
Memory!.Assign(Input1!.GetData(root), MemoryPortGroup!.SelectedType);
|
||||
else if(resetValue)
|
||||
Memory!.Assign(GlobalProvider.DataStructureProvider!.DefaultDataPackage, MemoryPortGroup!.SelectedType);
|
||||
Finished = true;
|
||||
}
|
||||
|
||||
public override void UpdateCables()
|
||||
{
|
||||
base.UpdateCables();
|
||||
foreach (BaseModule subModule in SubModules())
|
||||
subModule.UpdateCables();
|
||||
bool setValue = DataInPorts[1].GetData.Get!.Bit;
|
||||
bool resetValue = DataInPorts[2].GetData.Get!.Bit;
|
||||
if(resetValue)
|
||||
{
|
||||
Memory!.Assign(0, MemoryPortGroup!.SelectedType);
|
||||
Define();
|
||||
}
|
||||
else if (setValue)
|
||||
{
|
||||
Memory!.Assign(DataInPorts[1].GetData.Get!, MemoryPortGroup!.SelectedType);
|
||||
Define();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +1,27 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Modules.Other;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules;
|
||||
|
||||
public partial class SRLatchModule : TerminalModule, IComputationalCompositeModule
|
||||
public partial class SRLatchModule : BaseModule,
|
||||
ITerminalModule,
|
||||
ISourceModule,
|
||||
IDuplicateOutputModule,
|
||||
IOperationModule
|
||||
{
|
||||
private DataInPort? Input1 { get; set; }
|
||||
private DataInPort? Input2 { get; set; }
|
||||
public OutputSubModule? Output1 { get; set; }
|
||||
public OutputSubModule? Output2 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { Input1, Input2 }!;
|
||||
public IDataOutPort[] DataOutPorts { get; set; } = Array.Empty<IDataOutPort>();
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
public override IEnumerable<IBasePort> Ports => DataInPorts.Union<IBasePort>(DataOutPorts);
|
||||
|
||||
private bool State { get; set; }
|
||||
public IBaseModule[] SubModules() => new IBaseModule[] { Output1, Output2 };
|
||||
public void Compute(IRootModule root)
|
||||
{
|
||||
Output1!.DataOut.ResultData.Bit = State;
|
||||
Output2!.DataOut.ResultData.Bit = State;
|
||||
}
|
||||
|
||||
protected override void Consume(RootModule root)
|
||||
public void Drain()
|
||||
{
|
||||
bool set = Input1!.GetData(root).Bit;
|
||||
bool reset = Input2!.GetData(root).Bit;
|
||||
bool set = DataInPorts[0].GetData.Get!.Bit;
|
||||
bool reset = DataInPorts[1].GetData.Get!.Bit;
|
||||
if (set && reset)
|
||||
State = false;
|
||||
else if (set)
|
||||
@@ -34,33 +29,18 @@ public partial class SRLatchModule : TerminalModule, IComputationalCompositeModu
|
||||
else if (reset)
|
||||
State = false;
|
||||
}
|
||||
protected OutputSubModule GetOutputModule(string path)
|
||||
{
|
||||
OutputSubModule res = GetNode<OutputSubModule>(path);
|
||||
res.Init();
|
||||
res.ParentModule = this;
|
||||
res.Board = Board;
|
||||
return res;
|
||||
}
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Input1 = GetPort<DataInPort>("Input1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Input2 = GetPort<DataInPort>("Input2");
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1 = GetOutputModule("Output1");
|
||||
Output1.DataOut.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output2 = GetOutputModule("Output2");
|
||||
Output2.DataOut.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
this.DataInInit("Input",2);
|
||||
this.DataOutInit("Output", 2);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Bit);
|
||||
this.SetInputType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public override void UpdateCables()
|
||||
|
||||
public void Define()
|
||||
{
|
||||
base.UpdateCables();
|
||||
foreach (IBaseModule subModule in SubModules())
|
||||
subModule.UpdateCables();
|
||||
|
||||
this.Define(cache => (State, EnigmosConstant.DataPortTypes.Bit));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,13 @@
|
||||
using Enigmos.Exceptions;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules;
|
||||
|
||||
public abstract partial class TerminalModule : BaseModule
|
||||
public abstract partial class TerminalModule : BaseModule, ITerminalModule
|
||||
{
|
||||
public bool Finished { get; set; }
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
|
||||
protected virtual void Consume(RootModule root)
|
||||
{
|
||||
foreach (DataInPort port in Ports.OfType<DataInPort>())
|
||||
port.GetData(root);
|
||||
Finished = true;
|
||||
}
|
||||
public virtual void Drain() => Finished = true;
|
||||
}
|
||||
|
||||
public void ConsumeWithTimeoutHandle(RootModule root)
|
||||
{
|
||||
try
|
||||
{
|
||||
Finished = true;
|
||||
Consume(root);
|
||||
}
|
||||
catch (ModuleExecutionTimeout timeout)
|
||||
{
|
||||
TimeoutHandler(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void TimeoutHandler(ModuleExecutionTimeout timeout)
|
||||
{
|
||||
Finished = false;
|
||||
base.TimeoutHandler(timeout);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules.TestingModules;
|
||||
|
||||
public partial class LightEmittingDiodeModule : TerminalModule
|
||||
{
|
||||
private Sprite2D LightEmittingDiode { get; set; }
|
||||
private DataInPort Input { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => new[] { Input };
|
||||
private Sprite2D? LightEmittingDiode { get; set; }
|
||||
private IDataInPort? Input { get; set; }
|
||||
public override IEnumerable<IBasePort> Ports => new[] { Input! };
|
||||
|
||||
private static readonly Texture2D TrueTexture =
|
||||
ResourceLoader.Load<Texture2D>("res://Resources/Circuits/Modules/Terminal/Testing/LEDBubble-T.png");
|
||||
@@ -22,17 +23,17 @@ public partial class LightEmittingDiodeModule : TerminalModule
|
||||
base.Init();
|
||||
Finished = true;
|
||||
LightEmittingDiode = GetNode<Sprite2D>("LightEmittingDiode");
|
||||
Input = GetPort<DataInPort>("Input");
|
||||
Input = this.GetPort<DataInPort>("Input");
|
||||
Input.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Consume(RootModule root)
|
||||
public override void Drain()
|
||||
{
|
||||
if (Input.GetData(root).Bit)
|
||||
LightEmittingDiode.Texture = TrueTexture;
|
||||
if (Input!.GetData.Get!.Bit)
|
||||
LightEmittingDiode!.Texture = TrueTexture;
|
||||
else
|
||||
LightEmittingDiode.Texture = FalseTexture;
|
||||
LightEmittingDiode!.Texture = FalseTexture;
|
||||
Finished = true;
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,11 @@ namespace Enigmos.Modules.TerminalModules.TestingModules;
|
||||
|
||||
public partial class R2Reader : Control
|
||||
{
|
||||
private AnimatedSprite2D Direction { get; set; }
|
||||
private AnimatedSprite2D Magnitude { get; set; }
|
||||
public R2 UnderlyingVector { get; set; }
|
||||
private double TargetPhase() => Math.Atan2(UnderlyingVector[2], UnderlyingVector[1]);
|
||||
private double TargetLength() => UnderlyingVector.Magnitude;
|
||||
private AnimatedSprite2D? Direction { get; set; }
|
||||
private AnimatedSprite2D? Magnitude { get; set; }
|
||||
public R2? UnderlyingVector { get; set; }
|
||||
private double TargetPhase() => Math.Atan2(UnderlyingVector![2], UnderlyingVector![1]);
|
||||
private double TargetLength() => UnderlyingVector!.Magnitude;
|
||||
|
||||
private int TargetPhaseFrame =>
|
||||
Mathf.FloorToInt((TargetPhase() % (2d * Math.PI) + 2d * Math.PI) % (2d * Math.PI) * 44d / (2d * Math.PI));
|
||||
@@ -19,8 +19,8 @@ public partial class R2Reader : Control
|
||||
Mathf.FloorToInt(TargetLength().DoubleCut() * 9d);
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
Magnitude.SpeedScale = (TargetLengthFrame - Magnitude.Frame) / 7f;
|
||||
var debug = new[] { TargetPhaseFrame - Direction.Frame, TargetPhaseFrame + 44 - Direction.Frame };
|
||||
Magnitude!.SpeedScale = (TargetLengthFrame - Magnitude.Frame) / 7f;
|
||||
var debug = new[] { TargetPhaseFrame - Direction!.Frame, TargetPhaseFrame + 44 - Direction.Frame };
|
||||
Direction.SpeedScale = debug.MinBy(Math.Abs) / 25f;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using TabulaSmaragdina.Constants;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules.TestingModules;
|
||||
|
||||
public partial class R2ReaderModule : TerminalModule
|
||||
{
|
||||
private DataInPort DataIn { get; set; }
|
||||
private R2Reader R2Reader { get; set; }
|
||||
private DataInPort? DataIn { get; set; }
|
||||
private R2Reader? R2Reader { get; set; }
|
||||
|
||||
public override IEnumerable<BasePort> Ports => new[] { DataIn };
|
||||
public override IEnumerable<BasePort> Ports => new[] { DataIn! };
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
DataIn = GetPort<DataInPort>("DataIn");
|
||||
DataIn = this.GetPort<DataInPort>("DataIn");
|
||||
DataIn.SetDataType(EnigmosConstant.DataPortTypes.R2);
|
||||
R2Reader = GetNode<R2Reader>("R2Reader");
|
||||
R2Reader.Init();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Consume(RootModule root)
|
||||
public override void Drain()
|
||||
{
|
||||
R2Reader.UnderlyingVector = DataIn.GetData(root).R2;
|
||||
R2Reader!.UnderlyingVector = DataIn!.GetData.Get!.R2;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,38 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.Utils.Helpers;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules.TestingModules;
|
||||
|
||||
public partial class RealReaderModule : TerminalModule
|
||||
public partial class RealReaderModule : BaseModule, ITerminalModule, IOperationModule
|
||||
{
|
||||
private DataInPort Input1 { get; set; }
|
||||
private DataInPort Input2 { get; set; }
|
||||
private DataInPort Input3 { get; set; }
|
||||
private AnimatedSprite2D RealReader { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { Input1, Input2, Input3 };
|
||||
private AnimatedSprite2D? RealReader { get; set; }
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
public override IEnumerable<IBasePort> Ports => DataInPorts;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Input1 = GetPort<DataInPort>("Input1");
|
||||
Input2 = GetPort<DataInPort>("Input2");
|
||||
Input3 = GetPort<DataInPort>("Input3");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Input3.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.DataInInit("Input", 3);
|
||||
this.SetInputType(EnigmosConstant.DataPortTypes.Real);
|
||||
RealReader = GetNode<AnimatedSprite2D>("RealReader");
|
||||
RealReader.SpeedScale = 0;
|
||||
RealReader.Play();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Consume(RootModule root)
|
||||
public void Drain()
|
||||
{
|
||||
double max = Input1.GetData(root).Real;
|
||||
double min = Input3.GetData(root).Real;
|
||||
double value = Input2.GetData(root).Real;
|
||||
//DebugToolWindow.FreeInfo = $"{value}";
|
||||
double max = DataInPorts[0].GetData.Get!.Double;
|
||||
double min = DataInPorts[2].GetData.Get!.Double;
|
||||
double value = DataInPorts[1].GetData.Get!.Double;
|
||||
double range = max - min;
|
||||
double percentage = (range == 0 ? 0d : value / range).DoubleCut();
|
||||
int frame = Mathf.FloorToInt(percentage * 122);
|
||||
RealReader.SpeedScale = (frame - RealReader.Frame) / 60f;
|
||||
Finished = true;
|
||||
RealReader!.SpeedScale = (frame - RealReader.Frame) / 60f;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
using Enigmos.Cables;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Inventories.Items.Items;
|
||||
using VirtualChemistry.Chemistry.Mixtures.Implements;
|
||||
|
||||
namespace Enigmos.Ports;
|
||||
|
||||
public abstract partial class BasePort : TextureButton, IBasePort
|
||||
{
|
||||
public virtual Vector2 PositionToBoard() => Position + PivotOffset + Module?.PositionToBoard ?? Vector2.Zero;
|
||||
public virtual Vector2 PositionToBoard => Position + PivotOffset + Module?.PositionToBoard ?? Vector2.Zero;
|
||||
/// <summary>
|
||||
/// When Condition is Equal to 0, Port is Disabled
|
||||
/// </summary>
|
||||
@@ -20,77 +17,10 @@ public abstract partial class BasePort : TextureButton, IBasePort
|
||||
/// </summary>
|
||||
public int Quality { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Increase Condition
|
||||
/// Modify Quality base on property of material
|
||||
/// </summary>
|
||||
public void FixWith(IBaseChemicalItem c)
|
||||
{
|
||||
if (c.ContentMaterial.Amount == 0)
|
||||
return;
|
||||
HeterogeneousMixture material = c.ContentMaterial;
|
||||
double s = 1; //material.LayerOrder.Last.Value.CayleyValue();
|
||||
double u = 1;//material.LayerOrder.Last.Value.EuclidValue();
|
||||
double usedAmount = Math.Min(1d, material.LayerOrder.Last.Value.Amount);
|
||||
double dCond = usedAmount * (Module.MaintenanceAlpha * s - Module.MaintenanceBeta * u);
|
||||
double dQuality = usedAmount * (Math.Pow(Module.MaintenanceBeta, 2) * s - Module.MaintenanceAlpha * u);
|
||||
c.ConsumeFromBottom(usedAmount);
|
||||
Condition = Mathf.FloorToInt(Math.Max(0, Math.Min(100, Condition + dCond)));
|
||||
Quality = Mathf.FloorToInt(Math.Max(0, Math.Min(20000, Quality + dQuality)));
|
||||
}
|
||||
|
||||
public IBaseModule? Module { get; set; }
|
||||
public abstract bool IsMatch(IBasePort oth);
|
||||
public IBasePort? ConnectedPort { get; set; }
|
||||
public bool Connected => ConnectedPort != null;
|
||||
/// <summary>
|
||||
/// Try to Connect two Ports
|
||||
/// if this port is Connected already, it will disconnect first
|
||||
/// </summary>
|
||||
public void Connect()
|
||||
{
|
||||
if(Connected)
|
||||
Disconnect();
|
||||
if (Module.Board.ConnectPending == null)
|
||||
{
|
||||
SetStatusPending();
|
||||
Module.Board.ConnectPending = this;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Module.Board.ConnectPending.IsMatch(this))
|
||||
{
|
||||
ConnectedPort = Module.Board.ConnectPending;
|
||||
Module.Board.ConnectPending.ConnectedPort = this;
|
||||
BaseCable cable = MakeCable(Module.Board.ConnectPending);
|
||||
Module.Board.CablePairing[this] = cable;
|
||||
Module.Board.CablePairing[Module.Board.ConnectPending] = cable;
|
||||
Module.Board.AddCable(cable);
|
||||
cable.LineUpdate();
|
||||
SetStatusConnected();
|
||||
Module.Board.ConnectPending.SetStatusConnected();
|
||||
Module.Board.ConnectPending = null;
|
||||
return;
|
||||
}
|
||||
Module.Board.ConnectPending.SetStatusNormal();
|
||||
Module.Board.ConnectPending = null;
|
||||
}
|
||||
|
||||
protected virtual void Disconnect()
|
||||
{
|
||||
if (!Connected)
|
||||
return;
|
||||
IBaseCable cable = Module.Board.CablePairing[this];
|
||||
Module.Board.CablePairing.Remove(ConnectedPort);
|
||||
Module.Board.FocusedCables.Remove(Module.Board.CablePairing[this]);
|
||||
Module.Board.CablePairing.Remove(this);
|
||||
|
||||
cable.Free();
|
||||
ConnectedPort.SetStatusNormal();
|
||||
ConnectedPort.ConnectedPort = null;
|
||||
SetStatusNormal();
|
||||
ConnectedPort = null;
|
||||
}
|
||||
|
||||
public abstract void SetStatusPending();
|
||||
public abstract void SetStatusConnected();
|
||||
@@ -98,7 +28,7 @@ public abstract partial class BasePort : TextureButton, IBasePort
|
||||
/// <summary>
|
||||
/// Determine whether this port can be connected with given port
|
||||
/// </summary>
|
||||
public abstract BaseCable MakeCable(IBasePort other);
|
||||
public abstract IBaseCable MakeCable(IBasePort other);
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
using Enigmos.Cables;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
public partial class DataInPort : DataPort, IDataInPort
|
||||
{
|
||||
public new DataOutPort ConnectedPort
|
||||
public new IDataOutPort? ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataOutPort;
|
||||
get => (base.ConnectedPort as IDataOutPort)!;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
|
||||
public override bool IsMatch(IBasePort other) =>
|
||||
other is DataOutPort dataOut &&
|
||||
GlobalProvider.DataPackageTypeProvider.DataPortTypeCompatible(DataType, dataOut.DataType);
|
||||
|
||||
GlobalProvider.DataPackageTypeProvider!.DataPortTypeCompatible(DataType!, dataOut.DataType!);
|
||||
|
||||
public IDataPackage GetData(IRootModule root)
|
||||
public DataCache GetData => Connected ? ConnectedPort!.OutData : DataCache.Null;
|
||||
|
||||
/*public IDataPackage GetData(IRootModule root)
|
||||
{
|
||||
if (!Connected)
|
||||
return GlobalProvider.DataStructureProvider.DefaultDataPackage;
|
||||
return GlobalProvider.DataStructureProvider!.DefaultDataPackage;
|
||||
if(!ConnectedPort.DataUpdated)
|
||||
ConnectedPort.DataUpdateRequest(root);
|
||||
return ConnectedPort.ResultData;
|
||||
}
|
||||
return ConnectedPort!.ResultData;
|
||||
}*/
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
public override IBaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = base.MakeCable(other);
|
||||
IBaseCable res = base.MakeCable(other);
|
||||
res.PortFrom = this;
|
||||
res.PortTo = other;
|
||||
return res;
|
||||
|
||||
@@ -1,47 +1,40 @@
|
||||
using Enigmos.Cables;
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
|
||||
public partial class DataOutPort : DataPort, IDataOutPort
|
||||
{
|
||||
public bool DataUpdated { get; set; }
|
||||
|
||||
public new ComputationalModule Module
|
||||
public new IComputationalModule Module
|
||||
{
|
||||
get => base.Module as ComputationalModule;
|
||||
get => (base.Module as IComputationalModule)!;
|
||||
set => base.Module = value;
|
||||
}
|
||||
|
||||
public void DataUpdateRequest(IRootModule root) => Module.ComputeWithTimeoutHandle(root);
|
||||
//public void DataUpdateRequest(IRootModule root) => Module.ComputeWithTimeoutHandle(root);
|
||||
|
||||
|
||||
public DataOutPort()
|
||||
public new IDataInPort? ConnectedPort
|
||||
{
|
||||
DataUpdated = false;
|
||||
ResultData = GlobalProvider.DataStructureProvider.NewDataPackage();
|
||||
}
|
||||
|
||||
public new DataInPort ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataInPort;
|
||||
get => (base.ConnectedPort as IDataInPort)!;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
|
||||
public override bool IsMatch(IBasePort other) =>
|
||||
other is DataInPort inPort &&
|
||||
GlobalProvider.DataPackageTypeProvider.DataPortTypeCompatible(inPort.DataType, DataType);
|
||||
public IDataPackage ResultData { get; set; }
|
||||
GlobalProvider.DataPackageTypeProvider!.DataPortTypeCompatible(inPort.DataType!, DataType!);
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
public override IBaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = base.MakeCable(other);
|
||||
IBaseCable res = base.MakeCable(other);
|
||||
res.PortFrom = other;
|
||||
res.PortTo = this;
|
||||
return res;
|
||||
}
|
||||
|
||||
public DataCache OutData { get; set; } = new(x => (0, ""));
|
||||
}
|
||||
|
||||
@@ -1,54 +1,53 @@
|
||||
using Enigmos.Cables;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
|
||||
public abstract partial class DataPort : BasePort, IDataPort
|
||||
{
|
||||
public new DataPort ConnectedPort
|
||||
public new IDataPort? ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataPort;
|
||||
get => (base.ConnectedPort as IDataPort)!;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
protected Sprite2D DataTypeTexture { get; set; }
|
||||
public StringName DataType { get; set; }
|
||||
protected Sprite2D? DataTypeTexture { get; set; }
|
||||
public StringName? DataType { get; set; }
|
||||
public override void Init()
|
||||
{
|
||||
Console.WriteLine("XY");
|
||||
DataTypeTexture = GetNode<Sprite2D>("DataTypeTexture");
|
||||
DataTypeTexture.Visible = false;
|
||||
base.Init();
|
||||
}
|
||||
|
||||
|
||||
public void SetDataType(StringName val)
|
||||
{
|
||||
if(Connected && val != ConnectedPort.DataType)
|
||||
Disconnect();
|
||||
if(Connected && val != ConnectedPort!.DataType)
|
||||
this.Disconnect();
|
||||
DataType = val;
|
||||
DataTypeTexture.Texture = GlobalProvider.EnigmosProvider.DataPortTypeMap[val];
|
||||
DataTypeTexture!.Texture = GlobalProvider.EnigmosProvider!.DataPortTypeMap[val];
|
||||
}
|
||||
|
||||
private void MouseEnterHandler() => DataTypeTexture.Visible = true;
|
||||
private void MouseExitHandler() => DataTypeTexture.Visible = false;
|
||||
private void MouseEnterHandler() => DataTypeTexture!.Visible = true;
|
||||
private void MouseExitHandler() => DataTypeTexture!.Visible = false;
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
public override IBaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = GlobalProvider.EnigmosProvider.DataCableScene.Instantiate<BaseCable>();
|
||||
BaseCable res = GlobalProvider.EnigmosProvider!.DataCableScene.Instantiate<BaseCable>();
|
||||
res.Init();
|
||||
return res;
|
||||
}
|
||||
|
||||
public override void SetStatusNormal() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusNormal;
|
||||
TextureNormal = GlobalProvider.EnigmosProvider!.DataPortStatusNormal;
|
||||
|
||||
public override void SetStatusPending() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusPending;
|
||||
TextureNormal = GlobalProvider.EnigmosProvider!.DataPortStatusPending;
|
||||
|
||||
public override void SetStatusConnected() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusConnected;
|
||||
TextureNormal = GlobalProvider.EnigmosProvider!.DataPortStatusConnected;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,19 +2,20 @@ using Enigmos.Cables;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||
|
||||
namespace Enigmos.Ports.SignalPorts;
|
||||
public partial class SignalInPort : SignalPort, ISignalInPort
|
||||
{
|
||||
public new IControllingModule Module
|
||||
{
|
||||
get => (base.Module as ControllingModule)!;
|
||||
get => (base.Module as PiplineModule)!;
|
||||
set => base.Module = value;
|
||||
}
|
||||
|
||||
public new SignalOutPort? ConnectedPort
|
||||
public new ISignalOutPort? ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as SignalOutPort;
|
||||
get => base.ConnectedPort as ISignalOutPort;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
|
||||
@@ -27,4 +28,5 @@ public partial class SignalInPort : SignalPort, ISignalInPort
|
||||
res.PortTo = other;
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
using Enigmos.Cables;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||
|
||||
namespace Enigmos.Ports.SignalPorts;
|
||||
|
||||
public partial class SignalOutPort : SignalPort, ISignalOutPort
|
||||
{
|
||||
public new IControllingModule Module
|
||||
public new IRoutingModule Module
|
||||
{
|
||||
get => (base.Module as ControllingModule)!;
|
||||
get => (base.Module as IRoutingModule)!;
|
||||
set => base.Module = value;
|
||||
}
|
||||
|
||||
|
||||
public new ISignalInPort? ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as SignalInPort;
|
||||
get => base.ConnectedPort as ISignalInPort;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
|
||||
@@ -29,4 +29,12 @@ public partial class SignalOutPort : SignalPort, ISignalOutPort
|
||||
res.PortTo = this;
|
||||
return res;
|
||||
}
|
||||
|
||||
public void Route()
|
||||
{
|
||||
if (!Connected)
|
||||
return;
|
||||
ConnectedPort!.Module.Execute();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
using Enigmos.Cables;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.Enigmos.Ports.SignalPorts;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Ports.SignalPorts;
|
||||
|
||||
public abstract partial class SignalPort : BasePort, ISignalInPort
|
||||
public abstract partial class SignalPort : BasePort, ISignalPort
|
||||
{
|
||||
public new IControllingModule Module
|
||||
{
|
||||
get => (base.Module as IControllingModule)!;
|
||||
set => base.Module = value;
|
||||
}
|
||||
protected AnimatedSprite2D SignalDirection { get; set; }
|
||||
|
||||
protected AnimatedSprite2D? SignalDirection { get; set; }
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
@@ -21,8 +17,8 @@ public abstract partial class SignalPort : BasePort, ISignalInPort
|
||||
SignalDirection.Visible = false;
|
||||
}
|
||||
|
||||
private void MouseEnteredHandler() => SignalDirection.Visible = true;
|
||||
private void MouseExitedHandler() => SignalDirection.Visible = false;
|
||||
private void MouseEnteredHandler() => SignalDirection!.Visible = true;
|
||||
private void MouseExitedHandler() => SignalDirection!.Visible = false;
|
||||
|
||||
public override void SetStatusConnected() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider!.SignalPortStatusConnected;
|
||||
@@ -39,4 +35,10 @@ public abstract partial class SignalPort : BasePort, ISignalInPort
|
||||
res.Init();
|
||||
return res;
|
||||
}
|
||||
|
||||
public new ISignalPort? ConnectedPort
|
||||
{
|
||||
get => (base.ConnectedPort as ISignalPort)!;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user