Skip to content

Commit

Permalink
config nodes and GetProperty, naming cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtttt committed May 31, 2024
1 parent 6747478 commit 4cf2692
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 127 deletions.
254 changes: 154 additions & 100 deletions help/Explanation Overview.vl

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/Acquisition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using peak.core;
using peak.core.nodes;
using peak.ipl;
using System.Net.WebSockets;
using System.Text;
using VL.Lib.Basics.Resources;
using VL.Lib.Basics.Video;
Expand Down
36 changes: 36 additions & 0 deletions src/AvailableProperties.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Extensions.Logging;
using System.Reactive.Disposables;
using System.Reactive.Linq;

namespace VL.Devices.IDS
{
[ProcessNode(Name = "AvailableProperties")]
public class AvailableProperties : IDisposable
{
private readonly ILogger logger;
private readonly SerialDisposable serialDisposable = new();

public AvailableProperties([Pin(Visibility = Model.PinVisibility.Hidden)] NodeContext nodeContext)
{
logger = nodeContext.GetLogger();
}

public void Update(
VideoIn? input,
out Spread<string> properties)
{
if (input is null)
{
properties = Spread<string>.Empty;
return;
}
properties = input.PropertyInfos.Select(x => x.Name).ToSpread();
return;
}

public void Dispose()
{
serialDisposable.Dispose();
}
}
}
17 changes: 10 additions & 7 deletions src/FileConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
using peak.core;
/*using peak.core;
using Path = VL.Lib.IO.Path;
namespace VL.Devices.IDS
{
[ProcessNode(Name = "FromFile")]
[ProcessNode(Name = "ConfigReader")]
public class FileConfigurationNode
{
IConfiguration? configuration;
Path? file;
public IConfiguration Update(Path file)
[return: Pin(Name = "Output")]
public IConfiguration Update(
Path filePath,
bool read)
{
if (file != this.file)
if (read)
{
this.file = file;
configuration = new FileConfiguration(file);

this.file = filePath;
configuration = new FileConfiguration(filePath);
}
return configuration!;
}
Expand All @@ -40,3 +42,4 @@ public void Configure(NodeMap nodeMap)
}
}
}
*/
37 changes: 37 additions & 0 deletions src/GetProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.Extensions.Logging;
using System.Reactive.Disposables;
using System.Reactive.Linq;

namespace VL.Devices.IDS
{
[ProcessNode(Name = "GetProperty")]
public class GetProperty : IDisposable
{
private readonly ILogger logger;
private readonly SerialDisposable serialDisposable = new();

public GetProperty([Pin(Visibility = Model.PinVisibility.Hidden)] NodeContext nodeContext)
{
logger = nodeContext.GetLogger();
}

public void Update(
VideoIn? input,
string name,
out PropertyInfo? propertyInfo)
{
if (input is null)
{
propertyInfo = null;
return;
}
propertyInfo = input.PropertyInfos.FirstOrDefault(x => x.Name == name);
return;
}

public void Dispose()
{
serialDisposable.Dispose();
}
}
}
15 changes: 8 additions & 7 deletions src/InMemoryConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

namespace VL.Devices.IDS
{
[ProcessNode(Name = "SetProperty")]
[ProcessNode(Name = "ConfigProperty")]
public class ConfigNode<T> : IConfiguration
{
private readonly ILogger logger;

IConfiguration? input;
string? key;
string? name;
T? value;
FreshConfig? output;

Expand All @@ -20,12 +20,13 @@ public ConfigNode([Pin(Visibility = Model.PinVisibility.Hidden)] NodeContext nod
this.logger = nodeContext.GetLogger();
}

public IConfiguration Update(IConfiguration input, string key, T value)
[return: Pin(Name = "Output")]
public IConfiguration Update(IConfiguration input, string name, T value)
{
if (input != this.input || key != this.key || !EqualityComparer<T>.Default.Equals(value, this.value))
if (input != this.input || name != this.name || !EqualityComparer<T>.Default.Equals(value, this.value))
{
this.input = input;
this.key = key;
this.name = name;
this.value = value;
output = new FreshConfig(this);
}
Expand All @@ -36,10 +37,10 @@ void IConfiguration.Configure(NodeMap nodeMap)
{
input?.Configure(nodeMap);

Node p = nodeMap.FindNode(key);
Node p = nodeMap.FindNode(name);
if (p is null)
{
logger.LogError("Property with name {key} not found.", key);
logger.LogError("Property with name {name} not found.", name);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"vvvv gamma 5.3": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\vvvv\\vvvv_gamma_6.3-0015-gd6867805c4\\vvvv.exe",
"executablePath": "C:\\Program Files\\vvvv\\vvvv_gamma_6.5-0016-gb5aa8f6e58\\vvvv.exe",
"commandLineArgs": "--package-repositories \"C:\\Users\\alex\\Documents\\libs\" --editable-packages VL.Devices.IDS -o \"C:\\Users\\alex\\Documents\\libs\\VL.Devices.IDS\\help\\Explanation Overview.vl\""
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/SaveConfigToFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace VL.Devices.IDS
{
[ProcessNode]
[ProcessNode(Name = "ConfigWriter")]
public class SaveConfigToFile : IDisposable
{
private readonly ILogger logger;
Expand All @@ -16,20 +16,20 @@ public SaveConfigToFile([Pin(Visibility = Model.PinVisibility.Hidden)] NodeConte
logger = nodeContext.GetLogger();
}

public void Update(VideoIn? videoIn, Path path, bool save)
public void Update(VideoIn? videoIn, Path filePath, bool write)
{
if (videoIn is null)
return;

if (save)
if (write)
{
serialDisposable.Disposable = videoIn.AcquisitionStarted.Take(1)
.Subscribe(a =>
{
try
{
//a.NodeMap.StoreToFile(path.ToString());
a.NodeMap.FindNodeString("UEyeParametersetPath").SetValue(path.ToString());
//a.NodeMap.StoreToFile(filePath.ToString());
a.NodeMap.FindNodeString("UEyeParametersetPath").SetValue(filePath.ToString());
a.NodeMap.FindNodeCommand("UEyeParametersetSave").Execute();
}
catch (Exception e)
Expand Down
9 changes: 3 additions & 6 deletions src/VideoIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using VL.Model;
using System.Reactive.Subjects;
using System.Reactive.Linq;
using Microsoft.Extensions.Configuration;

namespace VL.Devices.IDS
{
Expand Down Expand Up @@ -35,22 +34,20 @@ public VideoIn([Pin(Visibility = PinVisibility.Hidden)] NodeContext nodeContext)
public VideoIn Update(
IDSDevice? device,
[DefaultValue("640, 480")] Int2 resolution,
[DefaultValue("30")] int fps,
[DefaultValue("30")] int FPS,
IConfiguration configuration,
out Spread<PropertyInfo> PropertyInfos,
out string Info)
{
// By comparing the descriptor we can be sure that on re-connect of the device we see the change
if (device?.Tag != _device || resolution != _resolution || fps != _fps || configuration != _configuration)
if (device?.Tag != _device || resolution != _resolution || FPS != _fps || configuration != _configuration)
{
_device = device?.Tag as DeviceDescriptor;
_resolution = resolution;
_fps = fps;
_fps = FPS;
_configuration = configuration;
_changedTicket++;
}

PropertyInfos = this.PropertyInfos;
Info = this.Info;

return this;
Expand Down

0 comments on commit 4cf2692

Please sign in to comment.