Skip to content
Open
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
34 changes: 32 additions & 2 deletions REAL.NET.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28721.148
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{63297B98-5CED-492C-A5B7-A5B4F73CF142}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -60,6 +60,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfControlsLib.Tests", "tes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repo.CSharp.Tests", "tests\Repo.CSharp.Tests\Repo.CSharp.Tests.csproj", "{604E3254-B3F7-4A16-872A-B0EACC7846DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstraintsMatcher", "src\plugins\ConstraintsMatcher\ConstraintsMatcher.csproj", "{10456FBA-B53A-486A-811A-96A5E962B026}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstraintsPlugin", "src\plugins\ConstraintsPlugin\ConstraintsPlugin.csproj", "{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -210,6 +214,30 @@ Global
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|Any CPU.Build.0 = Release|Any CPU
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|x64.ActiveCfg = Release|Any CPU
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|x64.Build.0 = Release|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|x64.ActiveCfg = Debug|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|x64.Build.0 = Debug|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.MonoRelease|Any CPU.ActiveCfg = Release|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.MonoRelease|Any CPU.Build.0 = Release|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.MonoRelease|x64.ActiveCfg = Release|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.MonoRelease|x64.Build.0 = Release|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.Release|Any CPU.Build.0 = Release|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.Release|x64.ActiveCfg = Release|Any CPU
{10456FBA-B53A-486A-811A-96A5E962B026}.Release|x64.Build.0 = Release|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|x64.ActiveCfg = Debug|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|x64.Build.0 = Debug|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|Any CPU.ActiveCfg = MonoRelease|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|Any CPU.Build.0 = MonoRelease|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|x64.ActiveCfg = MonoRelease|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|x64.Build.0 = MonoRelease|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|Any CPU.Build.0 = Release|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|x64.ActiveCfg = Release|Any CPU
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -222,6 +250,8 @@ Global
{C57410A1-A86F-418B-9AC7-38249450C497} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
{8EDF4429-251A-416D-BB68-93F227191BCF} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
{604E3254-B3F7-4A16-872A-B0EACC7846DC} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
{10456FBA-B53A-486A-811A-96A5E962B026} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D0B60BC3-B119-4CD6-8FC4-CD8FA1429BE4}
Expand Down
Binary file added src/AirSim/View/Pictures/not.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/EditorPluginInterfaces/EditorPluginInterfaces.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -59,6 +60,7 @@
<Compile Include="EdgeEventArgs.cs" />
<Compile Include="ElementEventArgs.cs" />
<Compile Include="IConsole.cs" />
<Compile Include="IElementProvider.cs" />
<Compile Include="IModel.cs" />
<Compile Include="IPlugin.cs" />
<Compile Include="IPalette.cs" />
Expand Down
2 changes: 2 additions & 0 deletions src/EditorPluginInterfaces/ElementEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ public class ElementEventArgs : EventArgs
/// Element.
/// </summary>
public Repo.IElement Element { get; set; }

public bool IsAllowed { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License. */

namespace WpfControlsLib.Controls.Scene
namespace EditorPluginInterfaces
{
/// <summary>
/// Something that can say what element scene shall create when someone clicks on it. For example, selected
Expand Down
6 changes: 6 additions & 0 deletions src/EditorPluginInterfaces/IModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ namespace EditorPluginInterfaces
/// </summary>
public interface IModel
{

/// <summary>
/// Model name.
/// </summary>
string ModelName { get; set; }

/// <summary>
/// New vertex was added into a model.
/// </summary>
Expand Down
25 changes: 20 additions & 5 deletions src/EditorPluginInterfaces/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace EditorPluginInterfaces
{
using System;
using System.Windows.Controls;
using Toolbar;

/// <summary>
Expand All @@ -36,6 +38,10 @@ public class PluginConfig
/// </summary>
public IToolbar Toolbar { get; }

/// <summary>
/// Left panel grid
/// </summary>
public Grid LeftPanelGrid { get; }
/// <summary>
/// Console's reference that should be given to plugin
/// </summary>
Expand All @@ -44,7 +50,15 @@ public class PluginConfig
/// <summary>
/// Palette's reference that should be given to plugin
/// </summary>
public IPalette Palette { get; }
public IElementProvider ElementProvider { get; }

public delegate void Func(string modelName);
public Func FuncCreateConstraintsModel;

public delegate void VisibilityFunc(bool isVisible);
public VisibilityFunc FuncChangeSelectorVisibility;

public Action<String> OnMainModelChangedFunction;

/// <summary>
/// Initializes a new instance of <see cref="PluginConfig"/>
Expand All @@ -54,14 +68,15 @@ public class PluginConfig
/// <param name="scene">Scene</param>
/// <param name="toolbar">Toolbar</param>
/// <param name="console">Console</param>
/// <param name="palette">Palette</param>
public PluginConfig(IModel model, IScene scene, IToolbar toolbar, IConsole console, IPalette palette)
/// <param name="elementProvider">Element provider</param>
public PluginConfig(IModel model, IScene scene, IToolbar toolbar, IConsole console, IElementProvider elementProvider, Grid leftPanelGrid)
{
this.Model = model;
this.Scene = scene;
this.Toolbar = toolbar;
this.Console = console;
this.Palette = palette;
this.ElementProvider = elementProvider;
this.LeftPanelGrid = leftPanelGrid;
}
}
}
}
1 change: 1 addition & 0 deletions src/Repo/FacadeLayer/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ and Model
member this.UnderlyingModel = model

interface IModel with

member this.CreateElement (``type``: IElement) =
let unwrappedType = (``type`` :?> Element).UnderlyingElement
let element = infrastructure.Instantiate model unwrappedType
Expand Down
121 changes: 121 additions & 0 deletions src/Repo/ModelBuilders/ConstraintsMetamodelBuilder.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
(* Copyright 2017 Yurii Litvinov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. *)

namespace Repo.Metametamodels

open Repo
open Repo.DataLayer
open Repo.InfrastructureSemanticLayer

/// Initializes repository with Robots Metamodel, first testing metamodel of a real language.
type ConstraintsMetamodelBuilder() =
interface IModelBuilder with
member this.Build(repo: IRepo): unit =
let infrastructure = InfrastructureSemanticLayer.InfrastructureSemantic(repo)
let metamodel = infrastructure.Metamodel.Model

let find name = CoreSemanticLayer.Model.findNode metamodel name
let findAssociation node name = CoreSemanticLayer.Model.findAssociationWithSource node name

let metamodelElement = find "Element"
let metamodelNode = find "Node"
let metamodelGeneralization = find "Generalization"
let metamodelAssociation = find "Association"
let metamodelAttribute = find "Attribute"

let metamodelStringNode = find "String"
let metamodelBooleanNode = find "Boolean"
let metamodelMetatypeNode = find "Metatype"
let metamodelAttributeKindNode = find "AttributeKind"

let attributesAssociation = findAssociation metamodelElement "attributes"

let shapeAssociation = findAssociation metamodelElement "shape"
let isAbstractAssociation = findAssociation metamodelElement "isAbstract"
let instanceMetatypeAssociation = findAssociation metamodelElement "instanceMetatype"

let attributeKindAssociation = findAssociation metamodelAttribute "kind"
let attributeStringValueAssociation = findAssociation metamodelAttribute "stringValue"

let edgeTargetNameAssociation = findAssociation metamodelAssociation "targetName"

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

let (~+) (name, shape, isAbstract) =
let node = infrastructure.Instantiate model metamodelNode :?> INode
node.Name <- name
infrastructure.Element.SetAttributeValue node "shape" shape
infrastructure.Element.SetAttributeValue node "isAbstract" (if isAbstract then "true" else "false")
infrastructure.Element.SetAttributeValue node "instanceMetatype" "Metatype.Node"

node

let (--|>) (source: IElement) target =
model.CreateGeneralization(metamodelGeneralization, source, target) |> ignore

let (--->) (source: IElement) (target, targetName, linkName) =
let edge = infrastructure.Instantiate model metamodelAssociation :?> IAssociation
edge.Source <- Some source
edge.Target <- Some target
edge.TargetName <- targetName

infrastructure.Element.SetAttributeValue edge "shape" "View/Pictures/edge.png"
infrastructure.Element.SetAttributeValue edge "isAbstract" "false"
infrastructure.Element.SetAttributeValue edge "instanceMetatype" "Metatype.Edge"
infrastructure.Element.SetAttributeValue edge "name" linkName

edge

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

let abstractMotorsBlock = +("AbstractMotorsBlock", "", true)
infrastructure.Element.AddAttribute abstractMotorsBlock "ports" "AttributeKind.String" "M3, M4"

let abstractMotorsPowerBlock = +("AbstractMotorsPowerBlock", "", true)
infrastructure.Element.AddAttribute abstractMotorsPowerBlock "power" "AttributeKind.Int" "100"

let motorsForward = +("MotorsForward", "View/Pictures/enginesForwardBlock.png", false)
let motorsBackward = +("MotorsBackward", "View/Pictures/enginesBackwardBlock.png", false)
let motorsStop = +("MotorsStop", "View/Pictures/enginesStopBlock.png", false)
let timer = +("Timer", "View/Pictures/timerBlock.png", false)

let allNodes = +("AllNodes", "View/Pictures/allNodes.png", false)
//let anyNodes = +("AnyNodes", "View/Pictures/timerBlock.png", false)
let noNodes = +("NoNodes", "View/Pictures/noNodes.png", false)
let orNode = +("OrNode", "View/Pictures/orNode.png", false)
let notNode = +("NotNode", "View/Pictures/notNode.png", false)

let link = abstractNode ---> (abstractNode, "target", "Link")
infrastructure.Element.AddAttribute link "guard" "AttributeKind.String" ""

infrastructure.Element.AddAttribute timer "delay" "AttributeKind.Int" "1000"

finalNode --|> abstractNode
motorsForward --|> abstractMotorsPowerBlock
motorsBackward --|> abstractMotorsPowerBlock
abstractMotorsPowerBlock --|> abstractMotorsBlock
motorsStop --|> abstractMotorsBlock
abstractMotorsBlock --|> abstractNode
timer --|> abstractNode
allNodes --|> abstractNode
//anyNodes --|> abstractNode
noNodes --|> abstractNode
//andNode --|> abstractNode
orNode --|> abstractNode
notNode --|> abstractNode

()
63 changes: 63 additions & 0 deletions src/Repo/ModelBuilders/ConstraintsTestModelBuilder.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
(* Copyright 2017 Yurii Litvinov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. *)

namespace Repo.Metametamodels

open Repo.DataLayer
open Repo.CoreSemanticLayer
open Repo.InfrastructureSemanticLayer
open System.Runtime.InteropServices

/// Initializes repository with test model conforming to Robots Metamodel, actual program that can be written by end-user.
type ConstraintsTestModelBuilder() =
interface IModelBuilder with
member this.Build(repo: IRepo): unit =
let infrastructure = InfrastructureSemantic(repo)
let metamodel = Repo.findModel repo "ConstraintsMetamodel"
let infrastructureMetamodel = infrastructure.Metamodel.Model

let metamodelAbstractNode = Model.findNode metamodel "AbstractNode"
let metamodelInitialNode = Model.findNode metamodel "InitialNode"
let metamodelFinalNode = Model.findNode metamodel "FinalNode"
let metamodelMotorsForward = Model.findNode metamodel "MotorsForward"
let metamodelTimer = Model.findNode metamodel "Timer"

let metamodelAll = Model.findNode metamodel "AllNodes"
//let metamodelAny = Model.findNode metamodel "AnyNodes"

let metamodelOr = Model.findNode metamodel "OrNode"
let metamodelNot = Model.findNode metamodel "NotNode"
let metamodelNone = Model.findNode metamodel "NoNodes"


let link = Model.findAssociationWithSource metamodelAbstractNode "target"

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

let motorsForw = infrastructure.Instantiate model metamodelMotorsForward
infrastructure.Element.SetAttributeValue motorsForw "ports" "M3, M4"
infrastructure.Element.SetAttributeValue motorsForw "power" "10*"


let (-->) (src: IElement) dst =
let aLink = infrastructure.Instantiate model link :?> IAssociation
aLink.Source <- Some src
aLink.Target <- Some dst
dst


motorsForw |> ignore
()
2 changes: 1 addition & 1 deletion src/Repo/ModelBuilders/RobotsMetamodelBuilder.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type RobotsMetamodelBuilder() =
edge

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

let abstractMotorsBlock = +("AbstractMotorsBlock", "", true)
Expand Down
12 changes: 7 additions & 5 deletions src/Repo/ModelBuilders/RobotsTestModelBuilder.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type RobotsTestModelBuilder() =
let infrastructureMetamodel = infrastructure.Metamodel.Model

let metamodelAbstractNode = Model.findNode metamodel "AbstractNode"
//let metamodelInitialNode = Model.findNode metamodel "InitialNode"
let metamodelInitialNode = Model.findNode metamodel "InitialNode"
let metamodelFinalNode = Model.findNode metamodel "FinalNode"
let metamodelMotorsForward = Model.findNode metamodel "MotorsForward"
let metamodelTimer = Model.findNode metamodel "Timer"
Expand All @@ -36,7 +36,7 @@ type RobotsTestModelBuilder() =

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

//let initialNode = infrastructure.Instantiate model metamodelInitialNode
let initialNode = infrastructure.Instantiate model metamodelInitialNode
let finalNode = infrastructure.Instantiate model metamodelFinalNode

let motorsForward = infrastructure.Instantiate model metamodelMotorsForward
Expand All @@ -52,7 +52,9 @@ type RobotsTestModelBuilder() =
aLink.Target <- Some dst
dst

//initialNode -->
motorsForward --> timer --> finalNode |> ignore


initialNode --> motorsForward --> timer --> finalNode |> ignore
()

//initialNode -->
//
Loading