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 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

  • Wed, 10/29/2025 - 08:51
    gurux.dlms.c 9.0.2510.2901
  • Thu, 10/16/2025 - 09:59
    gurux.dlms.java 4.0.83
  • Wed, 10/08/2025 - 10:21
    gurux.dlms.c 9.0.2510.0801
  • Fri, 09/26/2025 - 10:02
    gurux.dlms.cpp 9.0.2509.2601
  • Fri, 09/26/2025 - 09:45
    gurux.dlms.c 9.0.2509.2601

New forum topics

  • Guidance on using the source codes
  • How to get/convert user readable format data from readRowsByRange
  • Insufficient memory to continue the execution of the program.
  • The client instance code failed to connect to the electricity meter for authentication
  • Unable to Release Request when closing connection with meter.
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin