mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
Added register collection base methods
This commit is contained in:
@@ -356,6 +356,14 @@ namespace MewtocolNet {
|
||||
|
||||
};
|
||||
|
||||
if (collection != null)
|
||||
collection.OnInterfaceLinked(this);
|
||||
|
||||
Connected += (i) => {
|
||||
if(collection != null)
|
||||
collection.OnInterfaceLinkedAndOnline(this);
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,17 +10,34 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MewtocolNet.RegisterAttributes {
|
||||
|
||||
/// <summary>
|
||||
/// A register collection base with full auto read and notification support built in
|
||||
/// </summary>
|
||||
public class RegisterCollectionBase : INotifyPropertyChanged {
|
||||
|
||||
/// <summary>
|
||||
/// Reference to its bound interface
|
||||
/// </summary>
|
||||
public MewtocolInterface PLCInterface { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whenever one of its props changes
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
internal void TriggerPropertyChanged (string propertyName = null) {
|
||||
/// <summary>
|
||||
/// Triggers a property changed event
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Name of the property to trigger for</param>
|
||||
public void TriggerPropertyChanged (string propertyName = null) {
|
||||
var handler = PropertyChanged;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public virtual void OnInterfaceLinked (MewtocolInterface plc) { }
|
||||
|
||||
public virtual void OnInterfaceLinkedAndOnline (MewtocolInterface plc) { }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user