Skip to content

Commit f5785ea

Browse files
author
MrsSima
committed
Implement functionality for constraints plugin
1 parent 6b650fd commit f5785ea

32 files changed

+299
-182
lines changed

REAL.NET.sln

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.28721.148
2+
# Visual Studio 15
3+
VisualStudioVersion = 15.0.28307.168
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{63297B98-5CED-492C-A5B7-A5B4F73CF142}"
66
ProjectSection(SolutionItems) = preProject
@@ -40,6 +40,9 @@ EndProject
4040
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Repo", "src\Repo\Repo.fsproj", "{9E7065A4-BA5E-4752-84BF-54D5C00DB60C}"
4141
EndProject
4242
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{F12CD406-E1CD-43B7-B4BC-E2991723C56E}"
43+
ProjectSection(SolutionItems) = preProject
44+
src\plugins\ConstraintsPlugin\ConstraintsPlugin.csproj = src\plugins\ConstraintsPlugin\ConstraintsPlugin.csproj
45+
EndProjectSection
4346
EndProject
4447
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginManager", "src\PluginManager\PluginManager.csproj", "{8B9C8D76-65B3-4A01-9D6F-B6192A823642}"
4548
EndProject
@@ -52,17 +55,15 @@ EndProject
5255
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfEditor", "src\WpfEditor\WpfEditor.csproj", "{734861E8-17D4-43C4-BCFE-2B0C9434AD83}"
5356
ProjectSection(ProjectDependencies) = postProject
5457
{C57410A1-A86F-418B-9AC7-38249450C497} = {C57410A1-A86F-418B-9AC7-38249450C497}
55-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD} = {F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}
5658
EndProjectSection
5759
EndProject
5860
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirSim", "src\AirSim\AirSim.csproj", "{757A3BAF-F8E1-4B54-96E7-B4D57B23251B}"
5961
EndProject
6062
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfControlsLib.Tests", "tests\WpfControlsLib.Tests\WpfControlsLib.Tests.csproj", "{8EDF4429-251A-416D-BB68-93F227191BCF}"
6163
EndProject
6264
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repo.CSharp.Tests", "tests\Repo.CSharp.Tests\Repo.CSharp.Tests.csproj", "{604E3254-B3F7-4A16-872A-B0EACC7846DC}"
63-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstraintsPlugin", "src\plugins\ConstraintsPlugin\ConstraintsPlugin.csproj", "{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}"
6465
EndProject
65-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstraintsMatcher", "ConstraintsMatcher\ConstraintsMatcher.csproj", "{10456FBA-B53A-486A-811A-96A5E962B026}"
66+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstraintsMatcher", "src\plugins\ConstraintsMatcher\ConstraintsMatcher.csproj", "{10456FBA-B53A-486A-811A-96A5E962B026}"
6667
EndProject
6768
Global
6869
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -214,18 +215,6 @@ Global
214215
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|Any CPU.Build.0 = Release|Any CPU
215216
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|x64.ActiveCfg = Release|Any CPU
216217
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|x64.Build.0 = Release|Any CPU
217-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
218-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
219-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|x64.ActiveCfg = Debug|Any CPU
220-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|x64.Build.0 = Debug|Any CPU
221-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|Any CPU.ActiveCfg = MonoRelease|Any CPU
222-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|Any CPU.Build.0 = MonoRelease|Any CPU
223-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|x64.ActiveCfg = MonoRelease|Any CPU
224-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|x64.Build.0 = MonoRelease|Any CPU
225-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
226-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|Any CPU.Build.0 = Release|Any CPU
227-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|x64.ActiveCfg = Release|Any CPU
228-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|x64.Build.0 = Release|Any CPU
229218
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
230219
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|Any CPU.Build.0 = Debug|Any CPU
231220
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -250,7 +239,6 @@ Global
250239
{C57410A1-A86F-418B-9AC7-38249450C497} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
251240
{8EDF4429-251A-416D-BB68-93F227191BCF} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
252241
{604E3254-B3F7-4A16-872A-B0EACC7846DC} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
253-
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
254242
{10456FBA-B53A-486A-811A-96A5E962B026} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
255243
EndGlobalSection
256244
GlobalSection(ExtensibilityGlobals) = postSolution

src/AirSim/View/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private void InitAndLaunchPlugins()
7777
var libs = new PluginLauncher<PluginConfig>();
7878
const string folder = "../../../plugins/SamplePlugin/bin";
7979
var dirs = new List<string>(System.IO.Directory.GetDirectories(folder));
80-
var config = new PluginConfig(this.model, null, null, this.Console, null, null);
80+
var config = new PluginConfig(this.model, null, null, this.Console, null);
8181
foreach (var dir in dirs)
8282
{
8383
libs.LaunchPlugins(dir, config);

src/EditorPluginInterfaces/PluginConfig.cs

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public class PluginConfig
3838
/// </summary>
3939
public IToolbar Toolbar { get; }
4040

41+
/// <summary>
42+
/// Left panel grid
43+
/// </summary>
44+
public Grid LeftPanelGrid { get; }
4145
/// <summary>
4246
/// Console's reference that should be given to plugin
4347
/// </summary>
@@ -48,35 +52,14 @@ public class PluginConfig
4852
/// </summary>
4953
public IElementProvider ElementProvider { get; }
5054

51-
/// <summary>
52-
///
53-
/// </summary>
54-
public Grid ConstraintsGrid { get; set; }
55-
56-
/// <summary>
57-
/// RightPanel
58-
/// </summary>
59-
public Grid RightPanel { get; set; }
60-
61-
/// <summary>
62-
/// SceneGrid
63-
/// </summary>
64-
public Grid SceneGrid { get; set; }
65-
66-
/// <summary>
67-
/// SceneGrid
68-
/// </summary>
69-
public Grid PaletteGrid { get; set; }
70-
7155
public delegate void Func(string modelName);
7256
public Func FuncCreateConstraintsModel;
73-
public Func OnMainModelChangedFunction;
7457

75-
public delegate void Func1(bool modelName);
76-
public Func1 FuncChangeSelectorVisibility;
58+
public delegate void VisibilityFunc(bool isVisible);
59+
public VisibilityFunc FuncChangeSelectorVisibility;
7760

61+
public Action<String> OnMainModelChangedFunction;
7862

79-
public Action<String> OnMainModelChanged;
8063
/// <summary>
8164
/// Initializes a new instance of <see cref="PluginConfig"/>
8265
/// </summary>
@@ -86,22 +69,14 @@ public class PluginConfig
8669
/// <param name="toolbar">Toolbar</param>
8770
/// <param name="console">Console</param>
8871
/// <param name="elementProvider">Element provider</param>
89-
public PluginConfig(IModel model, IScene scene, IToolbar toolbar, IConsole console, IElementProvider elementProvider, Grid constraintsGrid)
72+
public PluginConfig(IModel model, IScene scene, IToolbar toolbar, IConsole console, IElementProvider elementProvider, Grid leftPanelGrid)
9073
{
9174
this.Model = model;
9275
this.Scene = scene;
9376
this.Toolbar = toolbar;
9477
this.Console = console;
9578
this.ElementProvider = elementProvider;
96-
this.ConstraintsGrid = constraintsGrid;
79+
this.LeftPanelGrid = leftPanelGrid;
9780
}
98-
99-
//public void AddGrids(Grid rightPanel, Grid sceneGrid, Grid paletteGrid)
100-
//{
101-
//
102-
// this.RightPanel = rightPanel;
103-
// this.SceneGrid = sceneGrid;
104-
// this.PaletteGrid = paletteGrid;
105-
//}
10681
}
10782
}

src/Repo/FacadeLayer/Model.fs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ and Model
5151
member this.UnderlyingModel = model
5252

5353
interface IModel with
54-
member this.Visible
55-
with get (): bool =
56-
isVisible
57-
and set (v: bool): unit =
58-
isVisible <- v
5954

6055
member this.CreateElement (``type``: IElement) =
6156
let unwrappedType = (``type`` :?> Element).UnderlyingElement

src/Repo/ModelBuilders/ConstraintsMetamodelBuilder.fs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type ConstraintsMetamodelBuilder() =
5151
let edgeTargetNameAssociation = findAssociation metamodelAssociation "targetName"
5252

5353
let model = repo.CreateModel("ConstraintsMetamodel", metamodel)
54+
model.Properties <- model.Properties.Add ("IsVisible", false.ToString())
5455

5556
let (~+) (name, shape, isAbstract) =
5657
let node = infrastructure.Instantiate model metamodelNode :?> INode
@@ -78,6 +79,7 @@ type ConstraintsMetamodelBuilder() =
7879
edge
7980

8081
let abstractNode = +("AbstractNode", "", true)
82+
let initialNode = +("InitialNode", "View/Pictures/initialBlock.png", false)
8183
let finalNode = +("FinalNode", "View/Pictures/finalBlock.png", false)
8284

8385
let abstractMotorsBlock = +("AbstractMotorsBlock", "", true)
@@ -92,11 +94,10 @@ type ConstraintsMetamodelBuilder() =
9294
let timer = +("Timer", "View/Pictures/timerBlock.png", false)
9395

9496
let allNodes = +("AllNodes", "View/Pictures/allNodes.png", false)
95-
let anyNodes = +("AnyNodes", "View/Pictures/timerBlock.png", false)
96-
let noNodes = +("NoNodes", "View/Pictures/timerBlock.png", false)
97-
let andNode = +("AndNode", "View/Pictures/timerBlock.png", false)
98-
let orNode = +("OrNode", "View/Pictures/timerBlock.png", false)
99-
let notNode = +("NotNode", "View/Pictures/timerBlock.png", false)
97+
//let anyNodes = +("AnyNodes", "View/Pictures/timerBlock.png", false)
98+
let noNodes = +("NoNodes", "View/Pictures/noNodes.png", false)
99+
let orNode = +("OrNode", "View/Pictures/orNode.png", false)
100+
let notNode = +("NotNode", "View/Pictures/notNode.png", false)
100101

101102
let link = abstractNode ---> (abstractNode, "target", "Link")
102103
infrastructure.Element.AddAttribute link "guard" "AttributeKind.String" ""
@@ -111,9 +112,9 @@ type ConstraintsMetamodelBuilder() =
111112
abstractMotorsBlock --|> abstractNode
112113
timer --|> abstractNode
113114
allNodes --|> abstractNode
114-
anyNodes --|> abstractNode
115+
//anyNodes --|> abstractNode
115116
noNodes --|> abstractNode
116-
andNode --|> abstractNode
117+
//andNode --|> abstractNode
117118
orNode --|> abstractNode
118119
notNode --|> abstractNode
119120

src/Repo/ModelBuilders/ConstraintsTestModelBuilder.fs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Repo.Metametamodels
1717
open Repo.DataLayer
1818
open Repo.CoreSemanticLayer
1919
open Repo.InfrastructureSemanticLayer
20+
open System.Runtime.InteropServices
2021

2122
/// Initializes repository with test model conforming to Robots Metamodel, actual program that can be written by end-user.
2223
type ConstraintsTestModelBuilder() =
@@ -27,14 +28,14 @@ type ConstraintsTestModelBuilder() =
2728
let infrastructureMetamodel = infrastructure.Metamodel.Model
2829

2930
let metamodelAbstractNode = Model.findNode metamodel "AbstractNode"
30-
//let metamodelInitialNode = Model.findNode metamodel "InitialNode"
31+
let metamodelInitialNode = Model.findNode metamodel "InitialNode"
3132
let metamodelFinalNode = Model.findNode metamodel "FinalNode"
3233
let metamodelMotorsForward = Model.findNode metamodel "MotorsForward"
3334
let metamodelTimer = Model.findNode metamodel "Timer"
3435

3536
let metamodelAll = Model.findNode metamodel "AllNodes"
36-
let metamodelAny = Model.findNode metamodel "AnyNodes"
37-
let metamodelAnd = Model.findNode metamodel "AndNode"
37+
//let metamodelAny = Model.findNode metamodel "AnyNodes"
38+
3839
let metamodelOr = Model.findNode metamodel "OrNode"
3940
let metamodelNot = Model.findNode metamodel "NotNode"
4041
let metamodelNone = Model.findNode metamodel "NoNodes"
@@ -43,39 +44,20 @@ type ConstraintsTestModelBuilder() =
4344
let link = Model.findAssociationWithSource metamodelAbstractNode "target"
4445

4546
let model = repo.CreateModel("ConstraintsTestModel", metamodel)
47+
model.Properties <- model.Properties.Add ("IsVisible", false.ToString())
48+
let initialNode = infrastructure.Instantiate model metamodelInitialNode
4649

47-
//let initialNode = infrastructure.Instantiate model metamodelInitialNode
48-
let finalNode = infrastructure.Instantiate model metamodelFinalNode
49-
50-
let motorsForward = infrastructure.Instantiate model metamodelMotorsForward
51-
infrastructure.Element.SetAttributeValue motorsForward "ports" "M3, M4"
52-
infrastructure.Element.SetAttributeValue motorsForward "power" "100"
53-
54-
let motorsForward2 = infrastructure.Instantiate model metamodelMotorsForward
55-
infrastructure.Element.SetAttributeValue motorsForward2 "ports" "M3, M4"
56-
infrastructure.Element.SetAttributeValue motorsForward2 "power" "100"
57-
58-
let timer = infrastructure.Instantiate model metamodelTimer
59-
infrastructure.Element.SetAttributeValue timer "delay" "3000"
60-
61-
let notNode = infrastructure.Instantiate model metamodelNot
50+
let motorsForw = infrastructure.Instantiate model metamodelMotorsForward
51+
infrastructure.Element.SetAttributeValue motorsForw "ports" "M3, M4"
52+
infrastructure.Element.SetAttributeValue motorsForw "power" "10*"
6253

63-
let orNodes = infrastructure.Instantiate model metamodelOr
64-
65-
let timer2 = infrastructure.Instantiate model metamodelTimer
66-
infrastructure.Element.SetAttributeValue timer2 "delay" "3000"
67-
68-
let timer3 = infrastructure.Instantiate model metamodelTimer
69-
infrastructure.Element.SetAttributeValue timer3 "delay" "3000"
70-
7154

7255
let (-->) (src: IElement) dst =
7356
let aLink = infrastructure.Instantiate model link :?> IAssociation
7457
aLink.Source <- Some src
7558
aLink.Target <- Some dst
7659
dst
7760

78-
//initialNode -->
79-
finalNode --> timer --> motorsForward --> notNode --> timer2 |> ignore
80-
timer --> timer3 --> orNodes --> motorsForward2 |> ignore
61+
62+
motorsForw |> ignore
8163
()

src/Repo/ModelBuilders/RobotsMetamodelBuilder.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type RobotsMetamodelBuilder() =
5959
edge
6060

6161
let abstractNode = +("AbstractNode", "", true)
62-
// let initialNode = +("InitialNode", "View/Pictures/initialBlock.png", false)
62+
let initialNode = +("InitialNode", "View/Pictures/initialBlock.png", false)
6363
let finalNode = +("FinalNode", "View/Pictures/finalBlock.png", false)
6464

6565
let abstractMotorsBlock = +("AbstractMotorsBlock", "", true)

src/Repo/ModelBuilders/RobotsTestModelBuilder.fs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type RobotsTestModelBuilder() =
2727
let infrastructureMetamodel = infrastructure.Metamodel.Model
2828

2929
let metamodelAbstractNode = Model.findNode metamodel "AbstractNode"
30-
//let metamodelInitialNode = Model.findNode metamodel "InitialNode"
30+
let metamodelInitialNode = Model.findNode metamodel "InitialNode"
3131
let metamodelFinalNode = Model.findNode metamodel "FinalNode"
3232
let metamodelMotorsForward = Model.findNode metamodel "MotorsForward"
3333
let metamodelTimer = Model.findNode metamodel "Timer"
@@ -36,39 +36,25 @@ type RobotsTestModelBuilder() =
3636

3737
let model = repo.CreateModel("RobotsTestModel", metamodel)
3838

39-
//let initialNode = infrastructure.Instantiate model metamodelInitialNode
39+
let initialNode = infrastructure.Instantiate model metamodelInitialNode
4040
let finalNode = infrastructure.Instantiate model metamodelFinalNode
4141

4242
let motorsForward = infrastructure.Instantiate model metamodelMotorsForward
4343
infrastructure.Element.SetAttributeValue motorsForward "ports" "M3, M4"
4444
infrastructure.Element.SetAttributeValue motorsForward "power" "100"
4545

46-
let motorsForward2 = infrastructure.Instantiate model metamodelMotorsForward
47-
infrastructure.Element.SetAttributeValue motorsForward2 "ports" "M3, M4"
48-
infrastructure.Element.SetAttributeValue motorsForward2 "power" "100"
49-
5046
let timer = infrastructure.Instantiate model metamodelTimer
5147
infrastructure.Element.SetAttributeValue timer "delay" "3000"
5248

53-
let timer2 = infrastructure.Instantiate model metamodelTimer
54-
infrastructure.Element.SetAttributeValue timer2 "delay" "3000"
55-
56-
let timer3 = infrastructure.Instantiate model metamodelTimer
57-
infrastructure.Element.SetAttributeValue timer3 "delay" "3000"
58-
59-
let timer4 = infrastructure.Instantiate model metamodelTimer
60-
infrastructure.Element.SetAttributeValue timer4 "delay" "3000"
61-
6249
let (-->) (src: IElement) dst =
6350
let aLink = infrastructure.Instantiate model link :?> IAssociation
6451
aLink.Source <- Some src
6552
aLink.Target <- Some dst
6653
dst
6754

68-
//initialNode -->
69-
finalNode --> timer --> motorsForward |> ignore
70-
71-
//timer --> timer2 --> motorsForward --> finalNode |> ignore
72-
//motorsForward --> timer3 --> motorsForward2 |> ignore
73-
55+
56+
initialNode --> motorsForward --> timer --> finalNode |> ignore
7457
()
58+
59+
//initialNode -->
60+
//

src/WpfControlsLib/Model/Graph.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ private void CreateNodeWithPos(INode node)
162162
{
163163
DataVertex = vertex
164164
};
165+
165166
this.AddNewVertexControl?.Invoke(this, args);
166167
this.ElementAdded?.Invoke(this, new ElementAddedEventArgs { Element = node });
167168
}
@@ -198,6 +199,9 @@ private void RemoveElement(IElement element)
198199
this.DataGraph.RemoveVertex(nodeViewModel);
199200
}
200201

202+
var model = this.model.Repo.Model(this.model.ModelName);
203+
model.DeleteElement(element);
204+
201205
this.ElementRemoved?.Invoke(this, new ElementRemovedEventArgs { Element = element });
202206
}
203207

0 commit comments

Comments
 (0)