mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
Register str data auto updates
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel>
|
||||
@@ -71,6 +70,17 @@
|
||||
</ItemsControl>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<DataGrid Grid.Row="1"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding Plc.Registers, Mode=OneWay}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Address" Binding="{Binding PLCAddressName}"/>
|
||||
<DataGridTextColumn Header="Name" Binding="{Binding UnderlyingSystemType.Name}"/>
|
||||
<DataGridTextColumn Header="Value" Binding="{Binding ValueStr}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -68,6 +68,8 @@ namespace MewtocolNet {
|
||||
/// </summary>
|
||||
int ConnectTimeout { get; set; }
|
||||
|
||||
IEnumerable<IRegister> Registers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Tries to establish a connection with the device asynchronously
|
||||
/// </summary>
|
||||
|
||||
@@ -34,6 +34,16 @@ namespace MewtocolNet.Registers {
|
||||
/// </summary>
|
||||
object ValueObj { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The current value of the register as a string
|
||||
/// </summary>
|
||||
string ValueStr { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The system (.NET) type of the underlying value thats held inside the register
|
||||
/// </summary>
|
||||
Type UnderlyingSystemType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The plc memory address of the register
|
||||
/// </summary>
|
||||
|
||||
@@ -39,14 +39,20 @@ namespace MewtocolNet.Registers {
|
||||
internal bool wasOverlapFitted = false;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RegisterCollection ContainedCollection => containedCollection;
|
||||
internal RegisterCollection ContainedCollection => containedCollection;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MewtocolInterface AttachedInterface => attachedInterface;
|
||||
internal MewtocolInterface AttachedInterface => attachedInterface;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Type UnderlyingSystemType => underlyingSystemType;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object ValueObj => lastValue;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string ValueStr => GetValueString();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RegisterPrefix RegisterType { get; internal set; }
|
||||
|
||||
@@ -63,7 +69,12 @@ namespace MewtocolNet.Registers {
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void TriggerNotifyChange() => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ValueObj)));
|
||||
public void TriggerNotifyChange() {
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ValueObj)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ValueStr)));
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -64,19 +64,17 @@ namespace MewtocolNet.UnderlyingRegisters {
|
||||
|
||||
internal async Task<bool> RequestByteReadAsync(ulong addStart, ulong addEnd) {
|
||||
|
||||
var station = mewInterface.GetStationNumber();
|
||||
var byteCount = (addEnd - addStart + 1) * 2;
|
||||
var result = await mewInterface.ReadByteRangeNonBlocking((int)addStart, (int)byteCount);
|
||||
|
||||
string requeststring = $"%{station}#RD{GetMewtocolIdent(addStart, addEnd)}";
|
||||
var result = await mewInterface.SendCommandAsync(requeststring);
|
||||
if (result != null) {
|
||||
|
||||
if (result.Success) {
|
||||
|
||||
var resBytes = result.Response.ParseDTRawStringAsBytes();
|
||||
SetUnderlyingBytes(resBytes, addStart);
|
||||
SetUnderlyingBytes(result, addStart);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return result.Success;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user