Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/migrations/v6_to_v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ Removed all overrides of the obsolete method `Exception.GetObjectData(Serializat
The following classes are affected by this change
- MissingFacadeException
- HealthStateException
- InvalidConfigException
- InvalidConfigException

## Driver APIs
The APIs for MessageDriver and InOutDriver with their generics, channels and different variants was too complicated and all known usages simply used objects and root members instead of channels and different argument types. So we simplified the APIs, which also improves exhangeability of different drivers and simplifies Simulator implementations.

To adjust your usages, simply remove all generic arguments. If you used channels, please define payload objects that contain the relevant routing information like topics or target device identifiers.
23 changes: 5 additions & 18 deletions src/Moryx.AbstractionLayer/Drivers/InOut/IInOutDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,19 @@
namespace Moryx.AbstractionLayer.Drivers.InOut
{
/// <summary>
/// Interface for drivers that offer data input
/// Most basic driver interface for input and output of data
/// This can be used to create less specific dependencies or simply as an additional interface
/// </summary>
public interface IInputDriver<out TIn> : IDriver
public interface IInOutDriver : IDriver
{
/// <summary>
/// Access to input values and events
/// </summary>
IInput<TIn> Input { get; }
}
IInput Input { get; }

/// <summary>
/// Interface for drivers that offer data output
/// </summary>
public interface IOutputDriver<TOut> : IDriver
{
/// <summary>
/// Access to data output
/// </summary>
IOutput<TOut> Output { get; }
}

/// <summary>
/// Most basic driver interface for input and output of data
/// This can be used to create less specific dependencies or simply as an additional interface
/// </summary>
public interface IInOutDriver<out TIn, TOut> : IInputDriver<TIn>, IOutputDriver<TOut>
{
IOutput Output { get; }
}
}
8 changes: 4 additions & 4 deletions src/Moryx.AbstractionLayer/Drivers/InOut/IInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Moryx.AbstractionLayer.Drivers.InOut
/// <summary>
/// Interface for reading input
/// </summary>
public interface IInput<out TIn>
public interface IInput
{
/// <summary>
/// Access flags for the input
Expand All @@ -19,19 +19,19 @@ public interface IInput<out TIn>
/// Single value input
/// Only available for <see cref="SupportedAccess.Single"/>
/// </summary>
TIn Value { get; }
object Value { get; }

/// <summary>
/// Index based input
/// Only available for <see cref="SupportedAccess.Index"/>
/// </summary>
TIn this[int index] { get; }
object this[int index] { get; }

/// <summary>
/// Key based input
/// Only available for <see cref="SupportedAccess.Key"/>
/// </summary>
TIn this[string key] { get; }
object this[string key] { get; }

/// <summary>
/// Event raised when any input value changed
Expand Down
8 changes: 4 additions & 4 deletions src/Moryx.AbstractionLayer/Drivers/InOut/IOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Moryx.AbstractionLayer.Drivers.InOut
/// <summary>
/// Interface for writing output
/// </summary>
public interface IOutput<TOut>
public interface IOutput
{
/// <summary>
/// Access flags for the output
Expand All @@ -17,18 +17,18 @@ public interface IOutput<TOut>
/// Single value output
/// Only available for <see cref="SupportedAccess.Single"/>
/// </summary>
TOut Value { get; set; }
object Value { get; set; }

/// <summary>
/// Index based output
/// Only available for <see cref="SupportedAccess.Index"/>
/// </summary>
TOut this[int index] { get; set; }
object this[int index] { get; set; }

/// <summary>
/// Key based output
/// Only available for <see cref="SupportedAccess.Key"/>
/// </summary>
TOut this[string key] { get; set; }
object this[string key] { get; set; }
}
}
14 changes: 0 additions & 14 deletions src/Moryx.AbstractionLayer/Drivers/Message/IIdentifierMessage.cs

This file was deleted.

52 changes: 0 additions & 52 deletions src/Moryx.AbstractionLayer/Drivers/Message/IMessageChannel.cs

This file was deleted.

17 changes: 10 additions & 7 deletions src/Moryx.AbstractionLayer/Drivers/Message/IMessageDriver.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0

using System.Threading.Tasks;
using System;

namespace Moryx.AbstractionLayer.Drivers.Message
{
/// <summary>
/// Multi-purpose driver that exchanges information with a device
/// </summary>
public interface IMessageDriver<TMessage> : IDriver, IMessageChannel<TMessage>
public interface IMessageDriver : IDriver
{
/// <summary>
/// Flag if the drivers supports identified channels or topics
/// Send message through the driver
/// </summary>
bool HasChannels { get; }
void Send(object payload);

/// <summary>
/// Get channel using specialized API
/// Send data async through channel
/// </summary>
IMessageChannel<TChannel> Channel<TChannel>(string identifier);
Task SendAsync(object payload);

/// <summary>
/// Get channel using specialized API
/// Event raised when the driver receives a message
/// </summary>
IMessageChannel<TSend, TReceive> Channel<TSend, TReceive>(string identifier);
event EventHandler<object> Received;
}
}
2 changes: 1 addition & 1 deletion src/Moryx.Resources.Samples/MountingCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MountingCell : Cell
public string OutfeedMessage { get; set; }

[ResourceReference(ResourceRelationType.Driver)]
public IMessageDriver<object> Driver { get; set; }
public IMessageDriver Driver { get; set; }

protected override void OnInitialize()
{
Expand Down