mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 11:11:23 +00:00
Fixed bug a bug where the writeregister method always returned false
- fixed a bug where the adress ToString of a register with a special adress was always ending with 0 - counted up version
This commit is contained in:
@@ -278,18 +278,13 @@ namespace MewtocolNet {
|
||||
//read number as bit array by invdividual properties
|
||||
if (prop.PropertyType == typeof(bool) && cAttribute.AssignedBitIndex != -1) {
|
||||
|
||||
if (cAttribute.BitCount == BitCount.B16) {
|
||||
AddRegister<short>(collection.GetType(), cAttribute.MemoryArea, _name: propName, _isBitwise: true);
|
||||
} else {
|
||||
AddRegister<int>(collection.GetType(), cAttribute.MemoryArea, _name: propName, _isBitwise: true);
|
||||
}
|
||||
//var bitwiseCount = Registers.Count(x => x.Value.isUsedBitwise);
|
||||
|
||||
//attach for bools to be read when bitregister
|
||||
//RegisterChanged += (reg) => {
|
||||
// if (reg.Name == propName) {
|
||||
// prop.SetValue()
|
||||
// }
|
||||
//};
|
||||
if (cAttribute.BitCount == BitCount.B16) {
|
||||
AddRegister<short>(collection.GetType(), cAttribute.MemoryArea, _name: $"Auto_Bitwise_DT{cAttribute.MemoryArea}", _isBitwise: true);
|
||||
} else {
|
||||
AddRegister<int>(collection.GetType(), cAttribute.MemoryArea, _name: $"Auto_Bitwise_DDT{cAttribute.MemoryArea}", _isBitwise: true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace MewtocolNet {
|
||||
|
||||
var result = await SendCommandAsync(requeststring);
|
||||
|
||||
return result.Success && result.Response.StartsWith($"%{ GetStationNumber()}#WC");
|
||||
return result.Success && result.Response.StartsWith($"%{ GetStationNumber()}$WC");
|
||||
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace MewtocolNet {
|
||||
|
||||
var result = await SendCommandAsync(requeststring);
|
||||
|
||||
return result.Success && result.Response.StartsWith($"%{ GetStationNumber()}#WD");
|
||||
return result.Success && result.Response.StartsWith($"%{ GetStationNumber()}$WD");
|
||||
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ namespace MewtocolNet {
|
||||
var result = await SendCommandAsync(requeststring);
|
||||
|
||||
|
||||
return result.Success && result.Response.StartsWith($"%{ GetStationNumber()}#WD");
|
||||
return result.Success && result.Response.StartsWith($"%{ GetStationNumber()}$WD");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace MewtocolNet.Registers {
|
||||
using System;
|
||||
|
||||
namespace MewtocolNet.Registers {
|
||||
/// <summary>
|
||||
/// Result for a read/write operation
|
||||
/// </summary>
|
||||
@@ -11,6 +13,19 @@
|
||||
string errmsg = Result.Success ? "" : $", Error [{Result.ErrorDescription}]";
|
||||
return $"Result [{Result.Success}], Register [{Register.ToString()}]{errmsg}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trys to get the value of there is one
|
||||
/// </summary>
|
||||
public bool TryGetValue (out T value) {
|
||||
if(Result.Success) {
|
||||
value = Register.Value;
|
||||
return true;
|
||||
}
|
||||
value = default(T);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -212,6 +212,10 @@ namespace MewtocolNet.Registers {
|
||||
|
||||
internal string GetRegisterPLCName () {
|
||||
|
||||
if (this is BRegister bReg && bReg.SpecialAddress != SpecialAddress.None) {
|
||||
return $"{GetRegisterString()}{bReg.SpecialAddress}";
|
||||
}
|
||||
|
||||
return $"{GetRegisterString()}{MemoryAdress}";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user