From 7b0855a776c33d7028a1502dcc49697a409971f7 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Tue, 7 Mar 2023 17:14:07 +0100 Subject: [PATCH 1/2] Prepare public APIs for factory modelling --- MoryxFactory.sln | 10 +++- .../EntryVisualizationAttribute.cs | 28 ++++++++++ src/Moryx.Factory/ILocation.cs | 32 +++++++++++ src/Moryx.Factory/IMachineGroup.cs | 15 +++++ src/Moryx.Factory/IMachineLocation.cs | 20 +++++++ src/Moryx.Factory/IManufacturingFactory.cs | 15 +++++ src/Moryx.Factory/ITransportPath.cs | 26 +++++++++ src/Moryx.Factory/MachineGroup.cs | 16 ++++++ src/Moryx.Factory/MachineLocation.cs | 55 +++++++++++++++++++ src/Moryx.Factory/ManufacturingFactory.cs | 14 +++++ src/Moryx.Factory/Moryx.Factory.csproj | 16 ++++++ src/Moryx.Factory/Position.cs | 17 ++++++ src/Moryx.Factory/SwitchPoint.cs | 36 ++++++++++++ src/Moryx.Factory/TransportPath.cs | 23 ++++++++ 14 files changed, 321 insertions(+), 2 deletions(-) create mode 100644 src/Moryx.Factory/EntryVisualizationAttribute.cs create mode 100644 src/Moryx.Factory/ILocation.cs create mode 100644 src/Moryx.Factory/IMachineGroup.cs create mode 100644 src/Moryx.Factory/IMachineLocation.cs create mode 100644 src/Moryx.Factory/IManufacturingFactory.cs create mode 100644 src/Moryx.Factory/ITransportPath.cs create mode 100644 src/Moryx.Factory/MachineGroup.cs create mode 100644 src/Moryx.Factory/MachineLocation.cs create mode 100644 src/Moryx.Factory/ManufacturingFactory.cs create mode 100644 src/Moryx.Factory/Moryx.Factory.csproj create mode 100644 src/Moryx.Factory/Position.cs create mode 100644 src/Moryx.Factory/SwitchPoint.cs create mode 100644 src/Moryx.Factory/TransportPath.cs diff --git a/MoryxFactory.sln b/MoryxFactory.sln index c9b7eab..ee11436 100644 --- a/MoryxFactory.sln +++ b/MoryxFactory.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29215.179 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moryx.ControlSystem", "src\Moryx.ControlSystem\Moryx.ControlSystem.csproj", "{DF4730D4-5DB2-46A5-9F2B-C7B22E61268B}" EndProject @@ -28,6 +28,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moryx.ProcessData", "src\Mo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moryx.ProcessData.Tests", "src\Tests\Moryx.ProcessData.Tests\Moryx.ProcessData.Tests.csproj", "{8E9609B6-9AF6-4F8E-A8DD-0B98E8B3B587}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.Factory", "src\Moryx.Factory\Moryx.Factory.csproj", "{4B1C8062-EF37-4880-AFDF-2C3CCEE3A848}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moryx.Simulation", "src\Moryx.Simulation\Moryx.Simulation.csproj", "{23B4A0C7-6F13-4FBB-998C-CD56DCF6D775}" EndProject Global @@ -60,6 +62,10 @@ Global {8E9609B6-9AF6-4F8E-A8DD-0B98E8B3B587}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E9609B6-9AF6-4F8E-A8DD-0B98E8B3B587}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E9609B6-9AF6-4F8E-A8DD-0B98E8B3B587}.Release|Any CPU.Build.0 = Release|Any CPU + {4B1C8062-EF37-4880-AFDF-2C3CCEE3A848}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B1C8062-EF37-4880-AFDF-2C3CCEE3A848}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B1C8062-EF37-4880-AFDF-2C3CCEE3A848}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B1C8062-EF37-4880-AFDF-2C3CCEE3A848}.Release|Any CPU.Build.0 = Release|Any CPU {23B4A0C7-6F13-4FBB-998C-CD56DCF6D775}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23B4A0C7-6F13-4FBB-998C-CD56DCF6D775}.Debug|Any CPU.Build.0 = Debug|Any CPU {23B4A0C7-6F13-4FBB-998C-CD56DCF6D775}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/Moryx.Factory/EntryVisualizationAttribute.cs b/src/Moryx.Factory/EntryVisualizationAttribute.cs new file mode 100644 index 0000000..f4ffba5 --- /dev/null +++ b/src/Moryx.Factory/EntryVisualizationAttribute.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Moryx.Factory +{ + /// + /// Attribute for a visual representation of the current property inside the Factory monitor UI + /// + public class EntryVisualizationAttribute : Attribute + { + public EntryVisualizationAttribute(string unit, string icon) + { + Unit = unit; + Icon = icon; + } + + /// + /// Unit of the value for the current property (Ex. Kw/h) + /// + public string Unit { get; } + + /// + /// Icon to display for this property inside the Factory Monitor UI + /// + public string Icon { get; } + } +} diff --git a/src/Moryx.Factory/ILocation.cs b/src/Moryx.Factory/ILocation.cs new file mode 100644 index 0000000..40c0ac2 --- /dev/null +++ b/src/Moryx.Factory/ILocation.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Collections.Specialized; +using Moryx.AbstractionLayer.Resources; + +namespace Moryx.Factory +{ + /// + /// Location inside the factory + /// + public interface ILocation : IResource + { + /// + /// Image of the location + /// + string Image { get; set; } + + /// + /// Position of the location + /// + Position Position { get; set; } + + /// + /// Transport paths that are going out of this location + /// + IEnumerable Origins { get; } + + /// + /// Transport paths that are coming to this location + /// + IEnumerable Destinations { get; } + } +} \ No newline at end of file diff --git a/src/Moryx.Factory/IMachineGroup.cs b/src/Moryx.Factory/IMachineGroup.cs new file mode 100644 index 0000000..9444569 --- /dev/null +++ b/src/Moryx.Factory/IMachineGroup.cs @@ -0,0 +1,15 @@ +using Moryx.AbstractionLayer.Resources; + +namespace Moryx.Factory +{ + /// + /// Group of resources inside the factory + /// + public interface IMachineGroup : IPublicResource + { + /// + /// Default icon for this resource group + /// + string DefaultIcon { get; set; } + } +} diff --git a/src/Moryx.Factory/IMachineLocation.cs b/src/Moryx.Factory/IMachineLocation.cs new file mode 100644 index 0000000..b846828 --- /dev/null +++ b/src/Moryx.Factory/IMachineLocation.cs @@ -0,0 +1,20 @@ +using Moryx.AbstractionLayer.Resources; + +namespace Moryx.Factory +{ + /// + /// A resource/machine location inside the factory + /// + public interface IMachineLocation : ILocation, IPublicResource + { + /// + /// Resource/Machine at this location + /// + IPublicResource Machine { get; } + + /// + /// Icon for the machine at this location + /// + string SpecificIcon { get; set; } + } +} \ No newline at end of file diff --git a/src/Moryx.Factory/IManufacturingFactory.cs b/src/Moryx.Factory/IManufacturingFactory.cs new file mode 100644 index 0000000..3726f21 --- /dev/null +++ b/src/Moryx.Factory/IManufacturingFactory.cs @@ -0,0 +1,15 @@ +using Moryx.AbstractionLayer.Resources; + +namespace Moryx.Factory +{ + /// + /// A manufacturing factory interface + /// + public interface IManufacturingFactory : IPublicResource + { + /// + /// Background URL of the factory monitor + /// + string BackgroundUrl { get; set; } + } +} diff --git a/src/Moryx.Factory/ITransportPath.cs b/src/Moryx.Factory/ITransportPath.cs new file mode 100644 index 0000000..3a76374 --- /dev/null +++ b/src/Moryx.Factory/ITransportPath.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Moryx.AbstractionLayer.Resources; + +namespace Moryx.Factory +{ + /// + /// A transport path inside a factory + /// + public interface ITransportPath : IResource + { + /// + /// Origin of the transport path + /// + ILocation Origin { get; } + + /// + /// Destination of the transport path + /// + ILocation Destination { get; } + + /// + /// Trajectory to follow from origin to reach the destination + /// + List WayPoints { get; set; } + } +} \ No newline at end of file diff --git a/src/Moryx.Factory/MachineGroup.cs b/src/Moryx.Factory/MachineGroup.cs new file mode 100644 index 0000000..6e9b913 --- /dev/null +++ b/src/Moryx.Factory/MachineGroup.cs @@ -0,0 +1,16 @@ +using Moryx.AbstractionLayer.Resources; +using Moryx.Serialization; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace Moryx.Factory +{ + /// + /// Class for all machine groups in manufacturing factory + /// + public class MachineGroup : PublicResource, IMachineGroup + { + [DataMember, EntrySerialize, DefaultValue("settings")] + public string DefaultIcon { get; set; } + } +} diff --git a/src/Moryx.Factory/MachineLocation.cs b/src/Moryx.Factory/MachineLocation.cs new file mode 100644 index 0000000..56e6f5d --- /dev/null +++ b/src/Moryx.Factory/MachineLocation.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.Serialization; +using Moryx.AbstractionLayer.Resources; +using Moryx.ControlSystem.Cells; +using Moryx.Serialization; + +namespace Moryx.Factory +{ + /// + /// Class for MachineLocation in the factory + /// + public class MachineLocation : PublicResource, IMachineLocation + { + public IPublicResource Machine => Children.OfType().FirstOrDefault(); + + [DataMember, EntrySerialize] + public string SpecificIcon { get; set; } + + [DataMember, EntrySerialize] + public string Image { get; set; } + + /// + /// X position of the location + /// + [DataMember, EntrySerialize, DefaultValue(10)] + public int PositionX { get; set; } + + /// + /// Y position of the location + /// + [DataMember, EntrySerialize, DefaultValue(10)] + public int PositionY { get; set; } + + public Position Position + { + get => new() { PositionX = PositionX, PositionY = PositionY }; + set + { + PositionX = value.PositionX; + PositionY = value.PositionY; + } + } + + [ResourceReference(ResourceRelationType.TransportRoute, ResourceReferenceRole.Source)] + public IReferences Origins { get; set; } + + [ResourceReference(ResourceRelationType.TransportRoute, ResourceReferenceRole.Target)] + public IReferences Destinations { get; set; } + + IEnumerable ILocation.Origins => Origins; + IEnumerable ILocation.Destinations => Destinations; + } +} diff --git a/src/Moryx.Factory/ManufacturingFactory.cs b/src/Moryx.Factory/ManufacturingFactory.cs new file mode 100644 index 0000000..898aa98 --- /dev/null +++ b/src/Moryx.Factory/ManufacturingFactory.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using System.Runtime.Serialization; +using Moryx.AbstractionLayer.Resources; + +using Moryx.Serialization; + +namespace Moryx.Factory +{ + public class ManufacturingFactory : PublicResource, IManufacturingFactory + { + [DataMember, EntrySerialize, DefaultValue("assets/Fabrik_Hintergrund.png"), Description("URL of the background picture of the Factory Monitor")] + public string BackgroundUrl { get; set; } + } +} diff --git a/src/Moryx.Factory/Moryx.Factory.csproj b/src/Moryx.Factory/Moryx.Factory.csproj new file mode 100644 index 0000000..fc95922 --- /dev/null +++ b/src/Moryx.Factory/Moryx.Factory.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0;net6.0 + enable + + + + + + + + + + + diff --git a/src/Moryx.Factory/Position.cs b/src/Moryx.Factory/Position.cs new file mode 100644 index 0000000..2fbb5c5 --- /dev/null +++ b/src/Moryx.Factory/Position.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace Moryx.Factory +{ + /// + /// Position of a resource/machine + /// + [DataContract] + public class Position + { + [DataMember] + public int PositionX { get; set; } + + [DataMember] + public int PositionY { get; set; } + } +} \ No newline at end of file diff --git a/src/Moryx.Factory/SwitchPoint.cs b/src/Moryx.Factory/SwitchPoint.cs new file mode 100644 index 0000000..bec52d7 --- /dev/null +++ b/src/Moryx.Factory/SwitchPoint.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Runtime.Serialization; +using Moryx.AbstractionLayer.Resources; +using Moryx.Serialization; + +namespace Moryx.Factory +{ + /// + /// Point where the direction changes in a transport path. + /// + public class SwitchPoint : Resource, ILocation + { + + [DataMember, EntrySerialize] + public int PositionX { get; set; } + + [DataMember, EntrySerialize] + public int PositionY { get; set; } + + public Position Position + { + get => new() { PositionX = PositionX, PositionY = PositionY }; + set + { + PositionX = value.PositionX; + PositionY = value.PositionY; + } + } + + public IEnumerable Origins { get; set; } + + public IEnumerable Destinations { get; set; } + + public string Image { get; set; } + } +} diff --git a/src/Moryx.Factory/TransportPath.cs b/src/Moryx.Factory/TransportPath.cs new file mode 100644 index 0000000..29eab67 --- /dev/null +++ b/src/Moryx.Factory/TransportPath.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Moryx.AbstractionLayer.Resources; +using Moryx.Serialization; + +namespace Moryx.Factory +{ + /// + /// Transport path in a factory + /// + public class TransportPath : Resource, ITransportPath + { + [ResourceReference(ResourceRelationType.TransportRoute, ResourceReferenceRole.Source)] + public ILocation Origin { get; set; } + + [ResourceReference(ResourceRelationType.TransportRoute, ResourceReferenceRole.Target)] + public ILocation Destination { get; set; } + + [DataMember, EntrySerialize] + public List WayPoints { get; set; } = new List(); + } +} From 84c282395bb2f615f27c6b2599890631a3dbe18c Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Tue, 22 Aug 2023 13:39:16 +0200 Subject: [PATCH 2/2] Final sync and copyright header --- src/Moryx.Factory/EntryVisualizationAttribute.cs | 5 ++++- src/Moryx.Factory/ILocation.cs | 5 ++++- src/Moryx.Factory/IMachineGroup.cs | 5 ++++- src/Moryx.Factory/IMachineLocation.cs | 5 ++++- src/Moryx.Factory/IManufacturingFactory.cs | 5 ++++- src/Moryx.Factory/ITransportPath.cs | 5 ++++- src/Moryx.Factory/MachineGroup.cs | 5 ++++- src/Moryx.Factory/MachineLocation.cs | 9 ++++++--- src/Moryx.Factory/ManufacturingFactory.cs | 5 ++++- src/Moryx.Factory/Position.cs | 9 ++++++--- src/Moryx.Factory/SwitchPoint.cs | 9 ++++++--- src/Moryx.Factory/TransportPath.cs | 5 ++++- 12 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/Moryx.Factory/EntryVisualizationAttribute.cs b/src/Moryx.Factory/EntryVisualizationAttribute.cs index f4ffba5..ca1da1a 100644 --- a/src/Moryx.Factory/EntryVisualizationAttribute.cs +++ b/src/Moryx.Factory/EntryVisualizationAttribute.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System; using System.Collections.Generic; using System.Text; diff --git a/src/Moryx.Factory/ILocation.cs b/src/Moryx.Factory/ILocation.cs index 40c0ac2..b0de97c 100644 --- a/src/Moryx.Factory/ILocation.cs +++ b/src/Moryx.Factory/ILocation.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System.Collections.Generic; using System.Collections.Specialized; using Moryx.AbstractionLayer.Resources; diff --git a/src/Moryx.Factory/IMachineGroup.cs b/src/Moryx.Factory/IMachineGroup.cs index 9444569..ce28323 100644 --- a/src/Moryx.Factory/IMachineGroup.cs +++ b/src/Moryx.Factory/IMachineGroup.cs @@ -1,4 +1,7 @@ -using Moryx.AbstractionLayer.Resources; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using Moryx.AbstractionLayer.Resources; namespace Moryx.Factory { diff --git a/src/Moryx.Factory/IMachineLocation.cs b/src/Moryx.Factory/IMachineLocation.cs index b846828..d9fb48c 100644 --- a/src/Moryx.Factory/IMachineLocation.cs +++ b/src/Moryx.Factory/IMachineLocation.cs @@ -1,4 +1,7 @@ -using Moryx.AbstractionLayer.Resources; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using Moryx.AbstractionLayer.Resources; namespace Moryx.Factory { diff --git a/src/Moryx.Factory/IManufacturingFactory.cs b/src/Moryx.Factory/IManufacturingFactory.cs index 3726f21..7e4f275 100644 --- a/src/Moryx.Factory/IManufacturingFactory.cs +++ b/src/Moryx.Factory/IManufacturingFactory.cs @@ -1,4 +1,7 @@ -using Moryx.AbstractionLayer.Resources; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using Moryx.AbstractionLayer.Resources; namespace Moryx.Factory { diff --git a/src/Moryx.Factory/ITransportPath.cs b/src/Moryx.Factory/ITransportPath.cs index 3a76374..0ef06f4 100644 --- a/src/Moryx.Factory/ITransportPath.cs +++ b/src/Moryx.Factory/ITransportPath.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System.Collections.Generic; using Moryx.AbstractionLayer.Resources; namespace Moryx.Factory diff --git a/src/Moryx.Factory/MachineGroup.cs b/src/Moryx.Factory/MachineGroup.cs index 6e9b913..28bf77a 100644 --- a/src/Moryx.Factory/MachineGroup.cs +++ b/src/Moryx.Factory/MachineGroup.cs @@ -1,4 +1,7 @@ -using Moryx.AbstractionLayer.Resources; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using Moryx.AbstractionLayer.Resources; using Moryx.Serialization; using System.ComponentModel; using System.Runtime.Serialization; diff --git a/src/Moryx.Factory/MachineLocation.cs b/src/Moryx.Factory/MachineLocation.cs index 56e6f5d..a5aff79 100644 --- a/src/Moryx.Factory/MachineLocation.cs +++ b/src/Moryx.Factory/MachineLocation.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.Serialization; @@ -25,13 +28,13 @@ public class MachineLocation : PublicResource, IMachineLocation /// X position of the location /// [DataMember, EntrySerialize, DefaultValue(10)] - public int PositionX { get; set; } + public double PositionX { get; set; } /// /// Y position of the location /// [DataMember, EntrySerialize, DefaultValue(10)] - public int PositionY { get; set; } + public double PositionY { get; set; } public Position Position { diff --git a/src/Moryx.Factory/ManufacturingFactory.cs b/src/Moryx.Factory/ManufacturingFactory.cs index 898aa98..a0f94db 100644 --- a/src/Moryx.Factory/ManufacturingFactory.cs +++ b/src/Moryx.Factory/ManufacturingFactory.cs @@ -1,4 +1,7 @@ -using System.ComponentModel; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System.ComponentModel; using System.Runtime.Serialization; using Moryx.AbstractionLayer.Resources; diff --git a/src/Moryx.Factory/Position.cs b/src/Moryx.Factory/Position.cs index 2fbb5c5..5a0b85a 100644 --- a/src/Moryx.Factory/Position.cs +++ b/src/Moryx.Factory/Position.cs @@ -1,4 +1,7 @@ -using System.Runtime.Serialization; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System.Runtime.Serialization; namespace Moryx.Factory { @@ -9,9 +12,9 @@ namespace Moryx.Factory public class Position { [DataMember] - public int PositionX { get; set; } + public double PositionX { get; set; } [DataMember] - public int PositionY { get; set; } + public double PositionY { get; set; } } } \ No newline at end of file diff --git a/src/Moryx.Factory/SwitchPoint.cs b/src/Moryx.Factory/SwitchPoint.cs index bec52d7..2a0dd30 100644 --- a/src/Moryx.Factory/SwitchPoint.cs +++ b/src/Moryx.Factory/SwitchPoint.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System.Collections.Generic; using System.Runtime.Serialization; using Moryx.AbstractionLayer.Resources; using Moryx.Serialization; @@ -12,10 +15,10 @@ public class SwitchPoint : Resource, ILocation { [DataMember, EntrySerialize] - public int PositionX { get; set; } + public double PositionX { get; set; } [DataMember, EntrySerialize] - public int PositionY { get; set; } + public double PositionY { get; set; } public Position Position { diff --git a/src/Moryx.Factory/TransportPath.cs b/src/Moryx.Factory/TransportPath.cs index 29eab67..d668856 100644 --- a/src/Moryx.Factory/TransportPath.cs +++ b/src/Moryx.Factory/TransportPath.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System; using System.Collections.Generic; using System.Runtime.Serialization; using Moryx.AbstractionLayer.Resources;