Skip to content

Commit

Permalink
[ifm] Fixes & persistent app (#231)
Browse files Browse the repository at this point in the history
* [ifm] Fixes related to CameraSettingsControl.

* readonly params: backgrounddistance & integrationtimemode

* keep using existing MetriCam App & add exposure ratio property (only works in moderate exposure mode)

* fix header offsets for newest ifm firmware & change ip address property to be more consistent with other camera implementations

* all properties other than IP immutable when not connected & fix IP property desc

* set parameters in connect impl only when creating a new application

* throw exceptions when accessing properties when not connected

Co-authored-by: sisiplac <simon.placht@metrilus.de>
  • Loading branch information
jangernert and sisiplac committed Feb 19, 2020
1 parent 49ccd81 commit 40c7d71
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 88 deletions.
278 changes: 220 additions & 58 deletions BetaCameras/ifm/O3D3xx.cs

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions BetaCameras/ifm/O3D3xxEnums.cs
@@ -0,0 +1,76 @@
using System;
using System.ComponentModel;
using System.Reflection;

namespace MetriCam2.Cameras
{
/// <summary>
/// ifm O3D3xx Trigger Modes
/// </summary>
public enum O3D3xxTriggerMode
{
FreeRun = 1,
ProcessInterface = 2,
PositiveEdge = 3,
NegatigeEdge = 4,
PositiveAndNegativeEdge = 5,
}

public enum O3D3xxIntegrationMode
{
[Description("low")]
SingleIntegrationTime = 0,
[Description("moderate")]
TwoIntegrationTimes = 1,
[Description("high")]
ThreeIntegrationTimes = 2,
}

public enum NonAmbiguityRange
{
[Description("lessthan5m")]
LessThan5 = 0,
[Description("upto30m")]
UpTo30 = 1,
[Description("morethan30m")]
MoreThan30 = 2,
}

public static class EnumUtils
{
public static string GetDescription(this Enum value)
{
Type type = value.GetType();
string name = Enum.GetName(type, value);
if (name != null)
{
FieldInfo field = type.GetField(name);
if (field != null)
{
DescriptionAttribute attr =
Attribute.GetCustomAttribute(field,
typeof(DescriptionAttribute)) as DescriptionAttribute;
if (attr != null)
{
return attr.Description;
}
}
}
return null;
}

public static object GetEnum(Type type, string description)
{
Array allValues = Enum.GetValues(type);
foreach (Enum value in allValues)
{
if(description == GetDescription(value))
{
return Enum.Parse(type, value.ToString());
}
}

return null;
}
}
}
20 changes: 0 additions & 20 deletions BetaCameras/ifm/O3D3xxTriggerMode.cs

This file was deleted.

17 changes: 17 additions & 0 deletions MetriCam2/Exceptions/NotConnectedException.cs
@@ -0,0 +1,17 @@
// Copyright (c) Metrilus GmbH
// MetriCam 2 is licensed under the MIT license. See License.txt for full license text.

using System;

namespace MetriCam2.Exceptions
{
public class NotConnectedException : MetriCam2Exception
{
public NotConnectedException(string message)
: base(message)
{ }
public NotConnectedException(string message, Exception innerException)
: base(message, innerException)
{ }
}
}
6 changes: 3 additions & 3 deletions Samples/SimpleViewer/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Samples/SimpleViewer/Properties/Settings.settings
Expand Up @@ -6,7 +6,7 @@
<Value Profile="(Default)">Distance</Value>
</Setting>
<Setting Name="PreConnectParameters" Type="System.String" Scope="User">
<Value Profile="(Default)">IPAddress=192.168.1.159;Port=554;Username=admin;Password=MetriX123;</Value>
<Value Profile="(Default)">CameraIP=192.168.1.78</Value>
</Setting>
<Setting Name="MinDepthToDisplay" Type="System.Single" Scope="User">
<Value Profile="(Default)">0</Value>
Expand All @@ -15,10 +15,10 @@
<Value Profile="(Default)">3</Value>
</Setting>
<Setting Name="CameraDLLPath" Type="System.String" Scope="User">
<Value Profile="(Default)">MetriCam2.Cameras.Hikvision.dll</Value>
<Value Profile="(Default)">MetriCam2.Cameras.ifm.dll</Value>
</Setting>
<Setting Name="CameraName" Type="System.String" Scope="User">
<Value Profile="(Default)">MetriCam2.Cameras.Hikvision</Value>
<Value Profile="(Default)">MetriCam2.Cameras.O3D3xx</Value>
</Setting>
</Settings>
</SettingsFile>
2 changes: 1 addition & 1 deletion Samples/SimpleViewer/SimpleViewer.csproj
Expand Up @@ -51,7 +51,7 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BetaCameras\Hikvision\Hikvision.csproj" />
<ProjectReference Include="..\..\BetaCameras\ifm\ifm.csproj" />
<ProjectReference Include="..\..\MetriCam2\MetriCam2.csproj" />
<ProjectReference Include="..\..\MetriCam2.Controls\MetriCam2.Controls.csproj" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Samples/SimpleViewer/app.config
Expand Up @@ -11,7 +11,7 @@
<value>Distance</value>
</setting>
<setting name="PreConnectParameters" serializeAs="String">
<value>IPAddress=192.168.1.159;Port=554;Username=admin;Password=MetriX123;</value>
<value>CameraIP=192.168.1.78</value>
</setting>
<setting name="MinDepthToDisplay" serializeAs="String">
<value>0</value>
Expand All @@ -20,10 +20,10 @@
<value>3</value>
</setting>
<setting name="CameraDLLPath" serializeAs="String">
<value>MetriCam2.Cameras.Hikvision.dll</value>
<value>MetriCam2.Cameras.ifm.dll</value>
</setting>
<setting name="CameraName" serializeAs="String">
<value>MetriCam2.Cameras.Hikvision</value>
<value>MetriCam2.Cameras.O3D3xx</value>
</setting>
</MetriCam2.Samples.SimpleViewer.Properties.Settings>
</userSettings>
Expand Down

0 comments on commit 40c7d71

Please sign in to comment.