Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Old Data Doesn't Disappear On Second Request In DLMSDirector With .NET Gurux DLMServer

Old data doesn't disappear on Second Request in DLMSDirector with .NET Gurux DLMServer

By liemoon, 1 November, 2024
Forums
Gurux.DLMS

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);
}
}
}

Profile picture for user Kurumi

Kurumi

1 year 2 months ago

Hi, I get the latest version…

Hi, I got the latest version from GitHub and it worked without problems. Check your code.

 

protected override void PreRead(ValueEventArgs[] args)
{
    foreach (ValueEventArgs e in args)
    {
        //Framework will handle profile generic automatically.
        if (e.Target is GXDLMSProfileGeneric)
        {
            if (e.Index == 2)
            {
        	    //Client reads buffer.
        	    GXDLMSProfileGeneric p = (GXDLMSProfileGeneric)e.Target;
        	    var obj = (GXDLMSProfileGeneric)e.Target;
        	    obj.Buffer.Clear();
        	    DateTime now = DateTime.Now;
        	    obj.Buffer.Add(new object[] { now.AddDays(-2), 123 });
        	    obj.Buffer.Add(new object[] { now, 1234 });
            }
        }
    }
}

BR,

Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 12/29/2025 - 10:38
    Gurux.Serial.Android 3.0.5
  • Mon, 12/15/2025 - 08:11
    Gurux.DLMS.Net 4.0.87
  • Fri, 12/12/2025 - 08:38
    Gurux.DLMS.Python 1.0.195
  • Thu, 12/11/2025 - 13:22
    Gurux.DLMS.Python 1.0.194
  • Thu, 12/11/2025 - 11:01
    gurux.dlms.java 4.0.88

New forum topics

  • 6-digit field values from meter not fully received (only 5 digits shown)
  • Gurux DLMS Android App
  • AMR support for bidirectional meters.
  • addition of new object in object list, meter not working
  • old meter take to much time(l&t)
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin