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. Manufacture Specific Object Types For Gurux DLMS/COSEM Class
Profile picture for user Administrator
By Administrator, 10 June, 2014
Getting started

 

Sometimes device manufacturers are using custom objects to add new functionality to the meters although this is not recommended.
You can create Manufacture specific object types (IC) for Gurux DLMS/COSEM in the following way.

1. Add a custom ID to the object type enum. C# uses an event notifier that can create a wanted object.

 

  • Java
  • C#
  • Delphi
  • ANSI C++
GURUX_CUSTOM_OBJECT(1234),
        
};

        
 

OBJECT_TYPE_GURUX_CUSTOM_OBJECT = 1234

 

2. Make your own class ex. GuruxCustomObject and derive it from GXDLMSObject and IGXDLMSBase. Then add constructor where you tell class ID.

 

  • Java
  • C#
  • Delphi
  • ANSI C++
/*
         * Gurux manufacture the specific object.
         */        
        class GuruxCustomObject extends GXDLMSObject implements IGXDLMSBase
        {    
            /*
             * Constructor.
             */
            public GuruxCustomObject()
            {
                super(ObjectType.GURUX_CUSTOM_OBJECT);
            }
            
            /*
             * Returns collection of attributes to read.
             * 
             * If attribute is static and already read or device is returned HW error it is not returned.
             */
            int[] getAttributeIndexToRead()            
            {
            
            }
                
            /*
            * Returns amount of attributes.
            */
            int getAttributeCount()
            {
                
            }
                
            
            /*
             * Returns amount of methods.
             */    
            int getMethodCount()
            {
                
            }
                    
            /*
             * Returns collection of class values.
             */
            @Override
            public Object[] getValues()
            {
                return new Object[] {getLogicalName(), };
            }
            
            /*
            * Returns value of given attribute.
            */
            Object getValue(int index, int selector, Object parameters)
            {
                
            }
           /*
            * Set value of given attribute.
            */
           void setValue(int index, Object value)
           {
               
           }
           
           /*
            * Invokes method.
            * 
             @param index Method index.
            */
           byte[][] invoke(Object sender, int index, Object parameters)
           {
               
           }
        }
        
/// 
        /// Gurux manufacture spesific object.
        /// 
        public class GuruxCustomObject : GXDLMSObject, IGXDLMSBase
        {
            ///  
            /// Constructor.
            ///  
            public GuruxCustomObject()
                : base(ObjectType.GuruxCustomObject)
            {
            }
            
            #region IGXDLMSBase Members
            /// 
            /// Returns collection of attributes to read.
            /// 
            /// 
            /// If attribute is static and already read or device is returned HW error it is not returned.
            /// 
            /// Collection of attributes to read.
            public int[] GetAttributeIndexToRead()
            {            
            }
            /// 
            /// Returns amount of attributes.
            /// 
            /// Count of attributes.
            public int GetAttributeCount()
            {
                throw new NotImplementedException();
            }
            // 
            /// Returns amount of methods.
            /// 
            /// 
            public int GetMethodCount()
            {
                throw new NotImplementedException();
            }
            /// 
            /// Returns names of attribute indexes.
            /// 
            /// 
            public string[] GetNames()
            {
                throw new NotImplementedException();
            }
            
            /// 
            /// Returns attributes as an array.
            /// 
            /// Collection of COSEM object values.
            public override object[] GetValues()
            {
                
            }
            /// 
            /// Returns value of given attribute.
            /// 
            /// 
            /// When raw parameter us not used example register multiplies value by scalar.
            /// 
            /// Attribute index
            /// Value of the attribute index.
            public object GetValue(int index, int selector, object parameters)
            {
                throw new NotImplementedException();
            }
            /// 
            /// Set value of given attribute.
            /// 
            /// 
            /// When raw parameter us not used example register multiplies value by scalar.
            /// 
            /// Attribute index
            /// Value of the attribute index.
            public void SetValue(int index, Object value)
            {
            }
            /// 
            /// Invokes method.
            /// 
            /// Method index.
            public byte[][] Invoke(object sender, int index, object parameters)
            {
                throw new NotImplementedException();
            }
            #endregion
        }
        
 
//Gurux manufacture spesific object.
        class CGuruxCustomObject : public CGXDLMSObject
        {
            //Constructor.
            GuruxCustomObject() : CGXDLMSObject(OBJECT_TYPE_GURUX_CUSTOM_OBJECT)
            {
            }
            // Returns amount of attributes.
        	int GetAttributeCount()
        	{
        	}
            // Returns amount of methods.
            int GetMethodCount()
        	{
        	}
        	//Get attribute values of object.
        	void GetValues(vector<string>;& values)
        	{
        	}
            // Returns value of given attribute.
            virtual int GetValue(int index, int selector, CGXDLMSVariant;& parameters, CGXDLMSVariant;& value)
        	{
        	}
            
            // Set value of given attribute.
            virtual int SetValue(int index, CGXDLMSVariant;& value)
        	{
        	}
            // Invokes method.
            virtual int Invoke(int index, CGXDLMSVariant;& parameters)
        	{
        	}
        	
            // Returns collection of attributes to read.
            // If attribute is static and already read or device is returned HW error it is not returned.
        	void GetAttributeIndexToRead(vector<int>& attributes)
        	{
        	}
        };
        

After you have created your class you must add it to the class factory. In C# this is done by listening OnCustomObject event.

 

  • Java
  • C#
  • Delphi
  • ANSI C++
        //createObject is located to GXDLMS.java
        static GXDLMSObject createObject(ObjectType type)
        {
            ...
            if (type == ObjectType.GURUX_CUSTOM_OBJECT)
            {
                return new GuruxCustomObject();
            }  
            ...
        }
        
//Create manufacturer-specific custom COSEM object.
client.OnCustomObject += (type, version) =>
{
   if (type == 6001)
   {
      return new GuruxCustomObject();
   }
   return null;
        
 
        CGXDLMSObject* CGXDLMSObjectFactory::CreateObject(OBJECT_TYPE type)
        {
            ...
            if (type == OBJECT_TYPE_GURUX_CUSTOM_OBJECT)
            {
                return new CGuruxCustomObject();
            } 
            ...
        }    
        

Now your custom IC is ready. Next time when you are reading your Association View your new IC is shown as well.

 

  • 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