/// <summary> /// Read association view. /// </summary> public void GetAssociationView() { GXReplyData reply = new GXReplyData(); ReadDataBlock(Client.GetObjectsRequest(), reply); Client.ParseObjects(reply.Data, true); }
/// <summary> /// Read association view. /// </summary> 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); SaveObjects(); }