Hello,
I’m building a DLMServer in .NET and testing it with DLMSDirector. On the first read of a profile generic, two data entries appear as expected. However, on the second request, the old data doesn’t clear, resulting in four entries showing up in DLMSDirector. In the preread section of DLMServer, I’ve tried clearing the buffer before adding new data, but the issue persists. How can I ensure the old data is cleared properly before each new read request?
Here's my code to handle the profile generic:
[LogicalName("1.97.99.98.1.255")]
public class TestController(ILogger<TestController> logger) : DLMSControllerBase
{
private static GXDLMSProfileGeneric pf = new();
public override GXDLMSObject gxObject => new GXDLMSProfileGeneric
{
LogicalName = logicalName,
CaptureObjects = [
new(new GXDLMSClock(),new GXDLMSCaptureObject(2,0)),
new(new GXDLMSRegister("0.0.96.6.3.255"),new GXDLMSCaptureObject(2,0)),
]
};
private static DateTime now = DateTime.Now;
public override void ReadHandler(ValueEventArgs e)
{
try
{
if (e.Index == 2)
{
var obj = (GXDLMSProfileGeneric)e.Target;
obj.Buffer.Clear();
obj.Buffer.AddRange([[now.AddDays(-2), 123], [now, 1234]]);
}
}
catch (Exception ex)
{
logger.LogError(ex.Message);
}
}
}
Hi, I get the latest version…
Hi, I got the latest version from GitHub and it worked without problems. Check your code.
BR,
Mikko