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:
@@ -45,8 +45,7 @@ namespace Examples {
|
|||||||
//corresponds to a DT7012 - DT7013 as a 32bit time value that gets parsed as a timespan (TIME)
|
//corresponds to a DT7012 - DT7013 as a 32bit time value that gets parsed as a timespan (TIME)
|
||||||
//the smallest value to communicate to the PLC is 10ms
|
//the smallest value to communicate to the PLC is 10ms
|
||||||
[Register(7012)]
|
[Register(7012)]
|
||||||
public TimeSpan TestTime { get; private set; }
|
public TimeSpan TestTime { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,6 +356,14 @@ namespace MewtocolNet {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (collection != null)
|
||||||
|
collection.OnInterfaceLinked(this);
|
||||||
|
|
||||||
|
Connected += (i) => {
|
||||||
|
if(collection != null)
|
||||||
|
collection.OnInterfaceLinkedAndOnline(this);
|
||||||
|
};
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,17 +10,34 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MewtocolNet.RegisterAttributes {
|
namespace MewtocolNet.RegisterAttributes {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A register collection base with full auto read and notification support built in
|
||||||
|
/// </summary>
|
||||||
public class RegisterCollectionBase : INotifyPropertyChanged {
|
public class RegisterCollectionBase : INotifyPropertyChanged {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reference to its bound interface
|
||||||
|
/// </summary>
|
||||||
public MewtocolInterface PLCInterface { get; set; }
|
public MewtocolInterface PLCInterface { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whenever one of its props changes
|
||||||
|
/// </summary>
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
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;
|
var handler = PropertyChanged;
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
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