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>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition/>
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
@@ -71,6 +70,17 @@
|
|||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
|
||||||
</StackPanel>
|
</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>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ namespace MewtocolNet {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
int ConnectTimeout { get; set; }
|
int ConnectTimeout { get; set; }
|
||||||
|
|
||||||
|
IEnumerable<IRegister> Registers { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to establish a connection with the device asynchronously
|
/// Tries to establish a connection with the device asynchronously
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -34,6 +34,16 @@ namespace MewtocolNet.Registers {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
object ValueObj { get; }
|
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>
|
/// <summary>
|
||||||
/// The plc memory address of the register
|
/// The plc memory address of the register
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -39,14 +39,20 @@ namespace MewtocolNet.Registers {
|
|||||||
internal bool wasOverlapFitted = false;
|
internal bool wasOverlapFitted = false;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public RegisterCollection ContainedCollection => containedCollection;
|
internal RegisterCollection ContainedCollection => containedCollection;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public MewtocolInterface AttachedInterface => attachedInterface;
|
internal MewtocolInterface AttachedInterface => attachedInterface;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Type UnderlyingSystemType => underlyingSystemType;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public object ValueObj => lastValue;
|
public object ValueObj => lastValue;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string ValueStr => GetValueString();
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public RegisterPrefix RegisterType { get; internal set; }
|
public RegisterPrefix RegisterType { get; internal set; }
|
||||||
|
|
||||||
@@ -63,7 +69,12 @@ namespace MewtocolNet.Registers {
|
|||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -64,19 +64,17 @@ namespace MewtocolNet.UnderlyingRegisters {
|
|||||||
|
|
||||||
internal async Task<bool> RequestByteReadAsync(ulong addStart, ulong addEnd) {
|
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)}";
|
if (result != null) {
|
||||||
var result = await mewInterface.SendCommandAsync(requeststring);
|
|
||||||
|
|
||||||
if (result.Success) {
|
SetUnderlyingBytes(result, addStart);
|
||||||
|
return true;
|
||||||
var resBytes = result.Response.ParseDTRawStringAsBytes();
|
|
||||||
SetUnderlyingBytes(resBytes, addStart);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.Success;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user