Skip to main content
Home
for DLMS smart meters

Main navigation

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

Breadcrumb

  1. Home
  2. Forums
  3. Saving and using association View

Saving and using association View

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By qamran.shahzad, 20 September, 2022
Forums
Gurux.Net

Hello together
I am using the below function, i can save the association view to an xml file via the Client.Objects.Save method but not able to read and use it again. Has anyone had any luck with this or can help me out ?

public void GetAssociationView(bool useCache)
{
if (useCache)
{
string path = GetCacheName();
List<Type> extraTypes = new List<Type>(Gurux.DLMS.GXDLMSClient.GetObjectTypes());
extraTypes.Add(typeof(GXDLMSAttributeSettings));
extraTypes.Add(typeof(GXDLMSAttribute));
XmlSerializer x = new XmlSerializer(typeof(GXDLMSObjectCollection), extraTypes.ToArray());
//You can save association view, but make sure that it is not change.
//Save Association view to the cache so it is not needed to retrieve every time.
if (File.Exists(path))
{
try
{
using (Stream stream = File.Open(path, FileMode.Open))
{
Console.WriteLine("Get available objects from the cache.");
Client.Objects.AddRange(x.Deserialize(stream) as GXDLMSObjectCollection);
stream.Close();
}
return;
}
catch (Exception ex)
{
if (File.Exists(path))
{
File.Delete(path);
}
throw ex;
}
}
}
GXReplyData reply = new GXReplyData();
ReadDataBlock(Client.GetObjectsRequest(), reply);
Client.ParseObjects(reply.Data, true);
}

Profile picture for user Kurumi

Kurumi

1 year ago

Hi,

Hi,

There might be data that XmlSerializer can't serialize. For that reason, GXDLMSObjectCollection.Load and GXDLMSObjectCollection.Save methods are implemented.

BR,
Mikko

qamran.shahzad

1 year ago

In reply to Hi, by Kurumi

HI

Update:
Never mind figured it out should be like this
GXDLMSObjectCollection a = GXDLMSObjectCollection.Load(path);
Thanks for the help
-----------------------------------------------------------------------------
HI

I am using Guru.net 8.4.2208.2301 and Gurux.DLMS 9.0.2208.3001. GXDLMSObjectCollection.Save works and writes an xml to a file problem is reading it back
as far as i can see both of below cases do not resolve in a method . What am i missing here ? also i did not find an example on the internet

GXDLMSObjectCollection a = new GXDLMSObjectCollection();
a.Load
Client.Objects.Load

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

Fri, 09/22/2023 - 19:50
gurux.dlms.c 20230922.1
Mon, 09/18/2023 - 13:51
Gurux.DLMS.AMI4 4.0.2309.1801
Fri, 09/15/2023 - 12:00
gurux.dlms.c 20230915.1
Tue, 09/12/2023 - 11:10
Gurux.DLMS.AMI4 4.0.2309.1201
Fri, 09/08/2023 - 10:59
gurux.dlms.c 20230908.1

Open bugs

gurux.dlms.c
3
gurux.dlms.cpp
3
gurux.dlms.delphi
1

New forum topics

  • problem with date and time in ION
  • Permament rejected
  • DLMS- GMAC: SNRM, AARQ, AARE is responding but not able to decrypt the Authentication key received from the meter
  • List complete policy security configuration basic (configuration security))
  • Save Association view in database
More

Who's new

  • azcah
  • Robertciz
  • Ilushikqtg
  • Margaretyhs
  • Mariohag
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin