Skip to content

Commit c645500

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents 46d2d77 + d83d44f commit c645500

File tree

21 files changed

+93
-73
lines changed

21 files changed

+93
-73
lines changed

.build/Common.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Project>
22

33
<PropertyGroup>
4-
<AssemblyVersion>0.0.0</AssemblyVersion>
4+
<AssemblyVersion>8.0.0</AssemblyVersion>
55
<AssemblyVersion Condition="'$(MORYX_ASSEMBLY_VERSION)'!=''">$(MORYX_ASSEMBLY_VERSION)</AssemblyVersion>
66

7-
<FileVersion>0.0.0.0</FileVersion>
7+
<FileVersion>8.0.0.0</FileVersion>
88
<FileVersion Condition="'$(MORYX_FILE_VERSION)'!=''">$(MORYX_FILE_VERSION)</FileVersion>
99

10-
<InformationalVersion>0.0.0.0</InformationalVersion>
10+
<InformationalVersion>8.0.0.0</InformationalVersion>
1111
<InformationalVersion Condition="'$(MORYX_INFORMATIONAL_VERSION)'!=''">$(MORYX_INFORMATIONAL_VERSION)</InformationalVersion>
1212

13-
<PackageVersion>0.0.0</PackageVersion>
13+
<PackageVersion>8.0.0</PackageVersion>
1414
<PackageVersion Condition="'$(MORYX_PACKAGE_VERSION)'!=''">$(MORYX_PACKAGE_VERSION)</PackageVersion>
1515

1616
<Authors>PHOENIXCONTACT</Authors>

MORYX-Framework.sln

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ EndProject
6060
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DFC092A6-B935-4D19-A564-9AEDEEF999B9}"
6161
ProjectSection(SolutionItems) = preProject
6262
Build.ps1 = Build.ps1
63+
.build\Common.props = .build\Common.props
6364
Directory.build.props = Directory.build.props
6465
Directory.Build.targets = Directory.Build.targets
6566
LICENSE = LICENSE
@@ -118,9 +119,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moryx.Runtime.Endpoints.Tes
118119
EndProject
119120
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moryx.Runtime.Endpoints.IntegrationTests", "src\Tests\Moryx.Runtime.Endpoints.IntegrationTests\Moryx.Runtime.Endpoints.IntegrationTests.csproj", "{4FFB98A7-9A4C-476F-8BCC-C19B7F757BF8}"
120121
EndProject
121-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.TestTools.NUnit", "src\Moryx.TestTools.NUnit\Moryx.TestTools.NUnit.csproj", "{6FF878E0-AF61-4C3A-9B9C-71C35A949E51}"
122+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moryx.TestTools.NUnit", "src\Moryx.TestTools.NUnit\Moryx.TestTools.NUnit.csproj", "{6FF878E0-AF61-4C3A-9B9C-71C35A949E51}"
122123
EndProject
123-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.TestTools.IntegrationTest", "src\Moryx.TestTools.IntegrationTest\Moryx.TestTools.IntegrationTest.csproj", "{C949164C-0345-4893-9E4C-A79BC1F93F85}"
124+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moryx.TestTools.IntegrationTest", "src\Moryx.TestTools.IntegrationTest\Moryx.TestTools.IntegrationTest.csproj", "{C949164C-0345-4893-9E4C-A79BC1F93F85}"
124125
EndProject
125126
Global
126127
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -356,8 +357,8 @@ Global
356357
{C949164C-0345-4893-9E4C-A79BC1F93F85} = {953AAE25-26C8-4A28-AB08-61BAFE41B22F}
357358
EndGlobalSection
358359
GlobalSection(ExtensibilityGlobals) = postSolution
359-
RESX_ShowErrorsInErrorList = True
360-
RESX_TaskErrorCategory = Message
361360
SolutionGuid = {36EFC961-F4E7-49DC-A36A-99594FFB8243}
361+
RESX_TaskErrorCategory = Message
362+
RESX_ShowErrorsInErrorList = True
362363
EndGlobalSection
363364
EndGlobal

src/Moryx.AbstractionLayer.Resources.Endpoints/Moryx.AbstractionLayer.Resources.Endpoints.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<Description>REST Api in order to interact with the resource management</Description>
77
<PackageTags>MORYX;IIoT;IoT;Resource</PackageTags>
8+
<IsPackable>true</IsPackable>
89
</PropertyGroup>
910

1011
<ItemGroup>

src/Moryx.AbstractionLayer.Resources.Endpoints/ResourceManagementController.cs

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Moryx.Runtime.Modules;
1818
using Moryx.Configuration;
1919
using System.Runtime.Serialization;
20+
using System.ComponentModel.DataAnnotations;
2021

2122
namespace Moryx.AbstractionLayer.Resources.Endpoints
2223
{
@@ -32,8 +33,8 @@ public class ResourceModificationController : ControllerBase
3233
private readonly IResourceTypeTree _resourceTypeTree;
3334
private readonly ResourceSerialization _serialization;
3435

35-
public ResourceModificationController(IResourceManagement resourceManagement,
36-
IResourceTypeTree resourceTypeTree,
36+
public ResourceModificationController(IResourceManagement resourceManagement,
37+
IResourceTypeTree resourceTypeTree,
3738
IModuleManager moduleManager,
3839
IServiceProvider serviceProvider)
3940
{
@@ -121,7 +122,7 @@ public ActionResult<Entry> InvokeMethod(long id, string method, Entry parameters
121122
return true;
122123
});
123124
}
124-
catch(MissingMethodException)
125+
catch (MissingMethodException)
125126
{
126127
return BadRequest("Method could not be invoked. Please check spelling and access modifier (has to be `public` or `internal`).");
127128
}
@@ -142,30 +143,48 @@ public ActionResult<Entry> InvokeMethod(long id, string method, Entry parameters
142143
public ActionResult<ResourceModel> ConstructWithParameters(string type, string method = null, [FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] Entry arguments = null)
143144
{
144145
var trustedType = WebUtility.HtmlEncode(type);
145-
146-
return method == null ? Construct(trustedType, null)
147-
: Construct(trustedType, new MethodEntry { Name = method, Parameters = arguments });
146+
if (method is null)
147+
return Construct(trustedType);
148+
else
149+
return Construct(trustedType, new MethodEntry { Name = method, Parameters = arguments });
148150
}
149151

150-
private ActionResult<ResourceModel> Construct(string type, MethodEntry method)
152+
private ActionResult<ResourceModel> Construct(string type)
151153
{
152-
var resource = (Resource)Activator.CreateInstance(_resourceTypeTree[type].ResourceType);
153-
if (resource is null)
154+
Resource resource;
155+
try
156+
{
157+
resource = (Resource)Activator.CreateInstance(_resourceTypeTree[type].ResourceType);
158+
}
159+
catch (Exception)
160+
{
154161
return NotFound(new MoryxExceptionResponse { Title = Strings.RESOURCE_NOT_FOUND });
162+
}
155163

156164
ValueProviderExecutor.Execute(resource, new ValueProviderExecutorSettings()
157165
.AddFilter(new DataMemberAttributeValueProviderFilter(false))
158166
.AddDefaultValueProvider());
159167

160-
if (method != null)
161-
EntryConvert.InvokeMethod(resource, method, _serialization);
162-
163168
var model = new ResourceToModelConverter(_resourceTypeTree, _serialization).GetDetails(resource);
164169
model.Methods = Array.Empty<MethodEntry>(); // Reset methods because they can not be invoked on new objects
165-
166170
return model;
167171
}
168172

173+
private ActionResult<ResourceModel> Construct(string type, MethodEntry method)
174+
{
175+
try
176+
{
177+
var id = _resourceManagement.Create(_resourceTypeTree[type].ResourceType, r => EntryConvert.InvokeMethod(r, method, _serialization));
178+
return GetDetails(id);
179+
}
180+
catch (Exception e)
181+
{
182+
if (e is ArgumentException or SerializationException or ValidationException)
183+
return BadRequest(e.Message);
184+
throw;
185+
}
186+
}
187+
169188
[HttpPost]
170189
[ProducesResponseType(StatusCodes.Status200OK)]
171190
[ProducesResponseType(StatusCodes.Status409Conflict)]
@@ -185,11 +204,11 @@ public ActionResult<ResourceModel> Save(ResourceModel model)
185204
resourcesToSave.Skip(1).ForEach(id => _resourceManagement.Modify(id, r => true));
186205
});
187206

188-
return Ok(GetDetails(id));
207+
return GetDetails(id);
189208
}
190209
catch (Exception e)
191210
{
192-
if (e is ArgumentException or SerializationException)
211+
if (e is ArgumentException or SerializationException or ValidationException)
193212
return BadRequest(e.Message);
194213
throw;
195214
}
@@ -323,7 +342,7 @@ private void UpdateReferences(Resource instance, HashSet<long> resourcesToSave,
323342
[Authorize(Policy = ResourcePermissions.CanEdit)]
324343
public ActionResult<ResourceModel> Update(long id, ResourceModel model)
325344
{
326-
if (_resourceManagement.GetAllResources<IResource>(r=>r.Id == id) is null)
345+
if (_resourceManagement.GetAllResources<IResource>(r => r.Id == id) is null)
327346
return NotFound(new MoryxExceptionResponse { Title = string.Format(Strings.ResourceNotFoundException_ById_Message, id) });
328347

329348
try
@@ -339,7 +358,7 @@ public ActionResult<ResourceModel> Update(long id, ResourceModel model)
339358
}
340359
catch (Exception e)
341360
{
342-
if (e is ArgumentException or SerializationException)
361+
if (e is ArgumentException or SerializationException or ValidationException)
343362
return BadRequest(e.Message);
344363
throw;
345364
}

src/Moryx.AbstractionLayer/Drivers/Camera/ICameraDriver.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Moryx.AbstractionLayer.Drivers;
2+
using System;
23
using System.Threading.Tasks;
34

45
namespace Moryx.Drivers.Camera.Interfaces
@@ -9,15 +10,9 @@ namespace Moryx.Drivers.Camera.Interfaces
910
public interface ICameraDriver<TImage> : IDriver where TImage : class
1011
{
1112
/// <summary>
12-
/// Registers an ICameraDriverListener that should be provided
13-
/// with images.
13+
/// Eventhandler to continously provide images from a camera
1414
/// </summary>
15-
void Register(ICameraDriverListener<TImage> listener);
16-
17-
/// <summary>
18-
/// Unregisters an ICameraDriverListener
19-
/// </summary>
20-
void Unregister(ICameraDriverListener<TImage> listener);
15+
event EventHandler<TImage> CapturedImage;
2116

2217
/// <summary>
2318
/// Capture a single image from the camera

src/Moryx.AbstractionLayer/Drivers/Camera/ICameraDriverListener.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Moryx.AbstractionLayer/Moryx.AbstractionLayer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<Description>Domain model types and definitions of Cyber-physical systems in IIoT projects.</Description>
77
<PackageTags>MORYX;IIoT;IoT;Hardware;Communication;Manufacturing;Industrial;Abstraction;Realtime</PackageTags>
8+
<IsPackable>true</IsPackable>
89
</PropertyGroup>
910

1011
<ItemGroup>

src/Moryx.Asp.Extensions/Moryx.Asp.Extensions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<Description>Extensions for the Integration of MORYX in ASP.NET Core</Description>
66
<PackageTags>MORYX;ASP</PackageTags>
7+
<IsPackable>true</IsPackable>
78
</PropertyGroup>
89

910
<ItemGroup>

src/Moryx.Container/Moryx.Container.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<Description>MORYX container functionality based on Castle.Windsor.</Description>
77
<PackageTags>MORYX;Container;IoC</PackageTags>
8+
<IsPackable>true</IsPackable>
89
</PropertyGroup>
910

1011
<ItemGroup>

src/Moryx.Model.InMemory/Moryx.Model.InMemory.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<Description>InMemory extension for unit tests referencing Moryx.Model</Description>
77
<PackageTags>MORYX;Entity;Framework;EntityFramework;DataModel;Model;Database;InMemory;Effort</PackageTags>
8+
<IsPackable>true</IsPackable>
89
</PropertyGroup>
910

1011
<ItemGroup>

0 commit comments

Comments
 (0)