Skip to content

Commit

Permalink
[NEW-FEATURE] Change symbols composition for SLD > 0.14.2 (#155)
Browse files Browse the repository at this point in the history
* Create draft PR for #154

* updates to match symbol composition with sld ver0.14.2

---------

Co-authored-by: PTKu <PTKu@users.noreply.github.com>
  • Loading branch information
PTKu and PTKu authored Apr 12, 2023
1 parent 63b6578 commit 9d0382d
Show file tree
Hide file tree
Showing 24 changed files with 313 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ targets:
- axunit-llvm
devDependencies:
"@ax/sdk": 3.0.2
"@ax/sld": ^0.14.2
scripts:
ixc:
- dotnet run --project ..\\..\\..\\..\\AXSharp.compiler\\src\\ixc\\AXSharp.ixc.csproj --framework net7.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static CsOnlinerConstructorBuilder Create(IxNodeVisitor visitor, IClassDe

builder.AddToSource(
$"public {semantics.Name}({typeof(ITwinObject).n()} parent, string readableTail, string symbolTail)");
if (isExtended) builder.AddToSource(": base(parent, readableTail, symbolTail + \".$base\") ");
if (isExtended) builder.AddToSource(": base(parent, readableTail, symbolTail)");

builder.AddToSource("{");

Expand Down
4 changes: 4 additions & 0 deletions src/AXSharp.compiler/src/ixc/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ private static void DisplayInfo()
Console.WriteLine("THIS PROJECT IS POSSIBLE BECAUSE OF SOME AWESOME OPEN SOURCE PROJECTS\n" +
"THIRD PARTY LICENSES CAN BE FOUND AT \n" +
"https://github.com/ix-ax/axsharp/blob/master/notices.md");

Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("ATTENTION: This version requires the usage of `apax sld` v0.14.2 or later!");

Console.ForegroundColor = originalColor;

if (int.Parse(GitVersionInformation.Major) < 1 || string.IsNullOrEmpty(GitVersionInformation.PreReleaseLabel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class State1Transition : Simatic.Ax.StateFramework.AbstractState
{
partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public State1Transition(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail + ".$base")
public State1Transition(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail)
{
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class Extended : Extendee
{
partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Extended(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail + ".$base")
public Extended(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail)
{
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class ExtendsAndImplements : ExtendeeExtendsAndImplements, IImple
{
partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public ExtendsAndImplements(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail + ".$base")
public ExtendsAndImplements(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail)
{
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using AXSharp.Connector.S71500.WebApi;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -22,21 +23,53 @@ public class GH_PTKu_ix_56
protected static WebApiConnector Connector { get; } = TestConnector.TestApiConnector as WebApiConnector;
[Fact()]
public async Task reproduction()
{
try
{
TestConnector.TestApiConnector.ReadWriteCycleDelay = 2;
var baseTypeMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.$base.$base.baseMember");
await baseTypeMember.GetAsync();

var firstInheritanceTypeMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.$base.FirstInheritanceMember");
await firstInheritanceTypeMember.GetAsync();

var secondInheritanceTypeMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.SecondInheritanceMember");
await secondInheritanceTypeMember.GetAsync();

var baseComplexMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.$base.$base.baseComplexMember.Counter");
await baseComplexMember.GetAsync();

var firstInheritanceComplexMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.$base.FirstInheritanceComplexMember.Counter");
await firstInheritanceComplexMember.GetAsync();

var secondInheritanceComplexMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.SecondInheritanceComplexMember.Counter");
await secondInheritanceComplexMember.GetAsync();
}
catch (Exception e)
{
return;
}

throw new Exception("We should not be here");
}

[Fact()]
public async Task reproduction_no_base()
{
TestConnector.TestApiConnector.ReadWriteCycleDelay = 2;
var baseTypeMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.$base.$base.baseMember");
var baseTypeMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.baseMember");
await baseTypeMember.GetAsync();

var firstInheritanceTypeMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.$base.FirstInheritanceMember");
var firstInheritanceTypeMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.FirstInheritanceMember");
await firstInheritanceTypeMember.GetAsync();

var secondInheritanceTypeMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.SecondInheritanceMember");
await secondInheritanceTypeMember.GetAsync();

var baseComplexMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.$base.$base.baseComplexMember.Counter");
var baseComplexMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.baseComplexMember.Counter");
await baseComplexMember.GetAsync();

var firstInheritanceComplexMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.$base.FirstInheritanceComplexMember.Counter");
var firstInheritanceComplexMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.FirstInheritanceComplexMember.Counter");
await firstInheritanceComplexMember.GetAsync();

var secondInheritanceComplexMember = new WebApiString(Connector, "", $"GH_PKTu_ix_56_SecondInheritance.SecondInheritanceComplexMember.Counter");
Expand Down
Loading

0 comments on commit 9d0382d

Please sign in to comment.