Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

354 update to stc v8 #356

Merged
merged 7 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
commit expected output from integration
  • Loading branch information
PTKu committed Dec 11, 2024
commit d56baeb38ac7bd3ec4807c16f328db69f85fe2f9
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using AXSharp.Connector;
using AXSharp.Connector.ValueTypes;
using System.Collections.Generic;
using AXSharp.Connector.Localizations;
using AXSharp.Abstractions.Presentation;

public partial class appTwinController : ITwinController
{
public AXSharp.Connector.Connector Connector { get; }
public lib1.MyClass lib1_MyClass { get; }
public lib2.MyClass lib2_MyClass { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public appTwinController(AXSharp.Connector.ConnectorAdapter adapter, object[] parameters)
{
this.Connector = adapter.GetConnector(parameters);
lib1_MyClass = new lib1.MyClass(this.Connector, "", "lib1_MyClass");
lib2_MyClass = new lib2.MyClass(this.Connector, "", "lib2_MyClass");
}

public appTwinController(AXSharp.Connector.ConnectorAdapter adapter)
{
this.Connector = adapter.GetConnector(adapter.Parameters);
lib1_MyClass = new lib1.MyClass(this.Connector, "", "lib1_MyClass");
lib2_MyClass = new lib2.MyClass(this.Connector, "", "lib2_MyClass");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["NAMESPACE lib1\n\n{S7.extern=ReadWrite}\nCLASS MyClass \nEND_CLASS\nEND_NAMESPACE","NAMESPACE lib2\n\n{S7.extern=ReadWrite}\nCLASS MyClass \nEND_CLASS\nEND_NAMESPACE"]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ax-source":"../app"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
using System;
using AXSharp.Connector;
using AXSharp.Connector.ValueTypes;
using System.Collections.Generic;
using AXSharp.Connector.Localizations;
using AXSharp.Abstractions.Presentation;

namespace lib1
{
public partial class MyClass : AXSharp.Connector.ITwinObject
{
public OnlinerString MyString { get; }
public OnlinerInt MyInt { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public MyClass(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
PreConstruct(parent, readableTail, symbolTail);
MyString = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "MyString", "MyString");
MyInt = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "MyInt", "MyInt");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
{
return await (dynamic)this.OnlineToPlainAsync();
}

public async Task<global::Pocos.lib1.MyClass> OnlineToPlainAsync()
{
global::Pocos.lib1.MyClass plain = new global::Pocos.lib1.MyClass();
await this.ReadAsync<IgnoreOnPocoOperation>();
plain.MyString = MyString.LastValue;
plain.MyInt = MyInt.LastValue;
return plain;
}

[Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public async Task<global::Pocos.lib1.MyClass> _OnlineToPlainNoacAsync()
{
global::Pocos.lib1.MyClass plain = new global::Pocos.lib1.MyClass();
plain.MyString = MyString.LastValue;
plain.MyInt = MyInt.LastValue;
return plain;
}

[Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
protected async Task<global::Pocos.lib1.MyClass> _OnlineToPlainNoacAsync(global::Pocos.lib1.MyClass plain)
{
plain.MyString = MyString.LastValue;
plain.MyInt = MyInt.LastValue;
return plain;
}

public async virtual Task PlainToOnline<T>(T plain)
{
await this.PlainToOnlineAsync((dynamic)plain);
}

public async Task<IEnumerable<ITwinPrimitive>> PlainToOnlineAsync(global::Pocos.lib1.MyClass plain)
{
#pragma warning disable CS0612
MyString.LethargicWrite(plain.MyString);
#pragma warning restore CS0612
#pragma warning disable CS0612
MyInt.LethargicWrite(plain.MyInt);
#pragma warning restore CS0612
return await this.WriteAsync<IgnoreOnPocoOperation>();
}

[Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public async Task _PlainToOnlineNoacAsync(global::Pocos.lib1.MyClass plain)
{
#pragma warning disable CS0612
MyString.LethargicWrite(plain.MyString);
#pragma warning restore CS0612
#pragma warning disable CS0612
MyInt.LethargicWrite(plain.MyInt);
#pragma warning restore CS0612
}

public async virtual Task<T> ShadowToPlain<T>()
{
return await (dynamic)this.ShadowToPlainAsync();
}

public async Task<global::Pocos.lib1.MyClass> ShadowToPlainAsync()
{
global::Pocos.lib1.MyClass plain = new global::Pocos.lib1.MyClass();
plain.MyString = MyString.Shadow;
plain.MyInt = MyInt.Shadow;
return plain;
}

protected async Task<global::Pocos.lib1.MyClass> ShadowToPlainAsync(global::Pocos.lib1.MyClass plain)
{
plain.MyString = MyString.Shadow;
plain.MyInt = MyInt.Shadow;
return plain;
}

public async virtual Task PlainToShadow<T>(T plain)
{
await this.PlainToShadowAsync((dynamic)plain);
}

public async Task<IEnumerable<ITwinPrimitive>> PlainToShadowAsync(global::Pocos.lib1.MyClass plain)
{
MyString.Shadow = plain.MyString;
MyInt.Shadow = plain.MyInt;
return this.RetrievePrimitives();
}

///<inheritdoc/>
public async virtual Task<bool> AnyChangeAsync<T>(T plain)
{
return await this.DetectsAnyChangeAsync((dynamic)plain);
}

///<summary>
///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated.
///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed.
///</summary>
public async Task<bool> DetectsAnyChangeAsync(global::Pocos.lib1.MyClass plain, global::Pocos.lib1.MyClass latest = null)
{
if (latest == null)
latest = await this._OnlineToPlainNoacAsync();
var somethingChanged = false;
return await Task.Run(async () =>
{
if (plain.MyString != MyString.LastValue)
somethingChanged = true;
if (plain.MyInt != MyInt.LastValue)
somethingChanged = true;
plain = latest;
return somethingChanged;
});
}

public void Poll()
{
this.RetrievePrimitives().ToList().ForEach(x => x.Poll());
}

public global::Pocos.lib1.MyClass CreateEmptyPoco()
{
return new global::Pocos.lib1.MyClass();
}

private IList<AXSharp.Connector.ITwinObject> Children { get; } = new List<AXSharp.Connector.ITwinObject>();

public IEnumerable<AXSharp.Connector.ITwinObject> GetChildren()
{
return Children;
}

private IList<AXSharp.Connector.ITwinElement> Kids { get; } = new List<AXSharp.Connector.ITwinElement>();

public IEnumerable<AXSharp.Connector.ITwinElement> GetKids()
{
return Kids;
}

private IList<AXSharp.Connector.ITwinPrimitive> ValueTags { get; } = new List<AXSharp.Connector.ITwinPrimitive>();

public IEnumerable<AXSharp.Connector.ITwinPrimitive> GetValueTags()
{
return ValueTags;
}

public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag)
{
ValueTags.Add(valueTag);
}

public void AddKid(AXSharp.Connector.ITwinElement kid)
{
Kids.Add(kid);
}

public void AddChild(AXSharp.Connector.ITwinObject twinObject)
{
Children.Add(twinObject);
}

protected AXSharp.Connector.Connector @Connector { get; }

public AXSharp.Connector.Connector GetConnector()
{
return this.@Connector;
}

public string GetSymbolTail()
{
return this.SymbolTail;
}

public AXSharp.Connector.ITwinObject GetParent()
{
return this.@Parent;
}

public string Symbol { get; protected set; }

private string _attributeName;
public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; }

public System.String GetAttributeName(System.Globalization.CultureInfo culture)
{
return this.Translate(_attributeName, culture).Interpolate(this);
}

private string _humanReadable;
public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; }

public System.String GetHumanReadable(System.Globalization.CultureInfo culture)
{
return this.Translate(_humanReadable, culture);
}

protected System.String @SymbolTail { get; set; }
protected AXSharp.Connector.ITwinObject @Parent { get; set; }
public AXSharp.Connector.Localizations.Translator Interpreter => global::lib1.PlcTranslator.Instance;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using AXSharp.Abstractions.Presentation;
using AXSharp.Connector;

namespace Pocos
{
namespace lib1
{
public partial class MyClass : AXSharp.Connector.IPlain
{
public MyClass()
{
}

public string MyString { get; set; } = string.Empty;
public Int16 MyInt { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

using System.Reflection;
using AXSharp.Connector.Localizations;

namespace lib1
{
public sealed class PlcTranslator : Translator
{
private static readonly PlcTranslator instance = new PlcTranslator();

public static PlcTranslator Instance
{
get
{
return instance;
}
}

private PlcTranslator()
{
var defaultResourceType = Assembly.GetAssembly(typeof(lib1.PlcTranslator))
.GetType("lib1.Resources.PlcStringResources");
this.SetLocalizationResource(defaultResourceType);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["NAMESPACE lib1\n\n{S7.extern=ReadWrite}\nCLASS MyClass \nEND_CLASS\nEND_NAMESPACE",""]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ax-source":"../lib1"}
Loading
Loading