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. Manufacturer Custom Objects
gxdn
Profile picture for user Administrator
By Administrator, 30 July, 2024
Getting started

Read basic information from Gurux.DLMS component before you start to create DLMS client.

Device manufacturer custom objects

DLMS standard defines COSEM objects that manufacturers should use. Sometimes manufacturers use their own custom objects to extend the meter functionality. This is not recommended, but support for custom objects has been added to some of Gurux DLMS libraries.

Impementing custom object

At first, implement a custom object and derive it from GXDLMSObject and IGXDLMSBase.
  • Java
  • C#
  • Delphi
  • ANSI C++
  • Python

public class ManufacturerSpecificObject 
        extends GXDLMSObject 
        implements IGXDLMSBase {
    /*
    *  Manufacturer specific attribute.
    */
    public int Manufacturer;

    /*
     * Returns amount of attributes.
     */
    @Override
    public final int getAttributeCount() {
        return 2;
    }

    /*
     * Returns amount of methods.
     */
    @Override
    public final int getMethodCount() {
        return 1;
    }

    /**
     * Returns read attributes.
     */
    @Override
    public int[] getAttributeIndexToRead(boolean all) {
        return new int[] { 1, 2 };
    }

    /**
     * Returns attribute names.
     */
    @Override
    public String[] getNames() {
        return new String[] { "Logical Name", "Manufacturer attribute" };
    }

    /**
     * Returns method names.
     */
    @Override
    public String[] getMethodNames() {
        return new String[] { "Reset", };
    }

/*
	 * Returns value of given attribute.
	 */
	@Override
	public final Object getValue(final GXDLMSSettings settings, final ValueEventArgs e) {
		if (e.getIndex() == 1) {
			return GXCommon.logicalNameToBytes(getLogicalName());
		}
		if (e.getIndex() == 2) {
			return Manufacturer;
		}
		e.setError(ErrorCode.READ_WRITE_DENIED);
		return null;
	}

	/*
	 * Set value of given attribute.
	 */
	@Override
	public final void setValue(final GXDLMSSettings settings, final ValueEventArgs e) {
		if (e.getIndex() == 1) {
			setLogicalName(GXCommon.toLogicalName(e.getValue()));
		} else if (e.getIndex() == 2) {
			Manufacturer = ((Number) e.getValue()).intValue();
		} else {
			e.setError(ErrorCode.READ_WRITE_DENIED);
		}
	}

    @Override
    public void load(GXXmlReader reader) throws XMLStreamException {
        // Load attribute values.

    }

    @Override
    public void save(GXXmlWriter writer) throws XMLStreamException {
        // Save attribute values.
    }

    @Override
    public void postLoad(GXXmlReader reader) {
        // Update attributes after load.
    }
}
 /// 
 /// This class implments manucaturer spesific COSEM object.
 /// 
 public class ManufacturerSpecificObject :
        GXDLMSObject, 
        IGXDLMSBase
 {
     /// 
     /// Manufacturer specific attribute.
     /// 
     public int Manufacturer
     {
         get;
         set;
     }
     /// 
     /// Returns amount of attributes.
     /// 
     public int GetAttributeCount()
     {
         return 2;
     }

     /// 
     /// Returns read attributes.
     /// 
     /// 
     /// 
     public int[] GetAttributeIndexToRead(bool all)
     {
         return new int[] { 1, 2 };
     }

     public int GetMaxSupportedVersion()
     {
         return 0;
     }

     /// 
     /// Returns amount of methods.
     /// 
     public int GetMethodCount()
     {
         return 1;
     }

     /// 
     /// Returns method names.
     /// 
     public string[] GetMethodNames()
     {
         return new string[] { "Reset" };
     }

     /// 
     /// Returns attribute names.
     /// 
     public string[] GetNames()
     {
         return new string[] { "Logical Name", "Manufacturer" };
     }

     /// 
     /// Value is write for the meter.
     /// 
     /// 
     /// 
     /// 
     public object GetValue(GXDLMSSettings settings, ValueEventArgs e)
     {
         object ret;
         if (e.Index == 1)
         {
             ret = GXCommon.LogicalNameToBytes(LogicalName);
         }
         else if (e.Index == 2)
         {
             ret = (byte)Manufacturer;
         }
         else
         {
             e.Error = ErrorCode.ReadWriteDenied;
             ret = null;
         }
         return ret;
     }

     /// 
     /// Value is read from the meter.
     /// 
     /// 
     /// 
     public void SetValue(GXDLMSSettings settings, ValueEventArgs e)
     {
         switch (e.Index)
         {
             case 1:
                 LogicalName = GXCommon.ToLogicalName(e.Value);
                 break;
             case 2:
                 Manufacturer = Convert.ToByte(e.Value);
                 break;
             default:
                 e.Error = ErrorCode.ReadWriteDenied;
                 break;
         }
     }

     public byte[] Invoke(GXDLMSSettings settings, ValueEventArgs e)
     {
         //This is not needed on the client side.
         throw new NotImplementedException();
     }

     public void Load(GXXmlReader reader)
     {
         // Load attribute values.
     }

     public void PostLoad(GXXmlReader reader)
     {
         // Update attributes after load.
     }

     public void Save(GXXmlWriter writer)
     {
         // Save attribute values.
     }
 }
Custom objects is not implemented at the moment.
Custom objects is not implemented at the moment.
Custom objects is not implemented at the moment.

The framework invokes onObjectCreate when unknown COSEM type is returned in association view. At first the client must register to listen onObjectCreate events.
  • Java
  • C#
  • Delphi
  • ANSI C++
  • Python
public class GXDLMSSecureClient2 extends GXDLMSSecureClient implements IGXCustomObjectNotifier {
    /**
     * Create manufacturer specific custom COSEM object.
    */
    @Override
    public GXDLMSObject onObjectCreateEventHandler(int type, int version) {
        if (type == 10006 && version == 1) {
           return new ManufacturerSpecificObject();
        }
        return null;
    }
}

GXDLMSClient client = new GXDLMSClient();
client.OnCustomObject += (type, version) =>
{
    if (type == 6001 && version == 0)
    {
    	return new ManufacturerSpecificObject();
        }
	return null;
    };
Custom objects is not implemented at the moment.
Custom objects is not implemented at the moment.
Custom objects is not implemented at the moment.

If you have any questions or ideas on how to improve Gurux DLMS component let us know or ask questions in a Forum

Book traversal links for Manufacturer custom objects

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

Book navigation

  • Activity calendar
  • Association Logical Name
  • Auto Connect
  • Auto answer
  • Clock
  • Compact data
  • Data
  • Demand register
  • Disconnect control
  • Extended register
  • GPRS modem setup
  • GSM diagnostic
  • IEC HDLC setup
  • IEC local port setup
  • IPv4 setup
  • IPv6 setup
  • Image transfer
  • Limiter
  • M-Bus Client
  • M-Bus master port setup
  • M-Bus slave port setup
  • MAC address setup
  • Modem configuration
  • PPP setup
  • Profile generic
  • Push Setup
  • Register
  • Register Monitor
  • Register activation
  • Register table
  • SAP assignment
  • Script table
  • Security setup
  • Single action schedule
  • Special days table
  • Status mapping
  • Tcp Udp Setup
  • Utility tables
  • Manufacturer custom objects

Hire Us!

Latest Releases

  • Tue, 06/17/2025 - 13:03
    Gurux.DLMS.Python 1.0.182
  • Wed, 06/04/2025 - 13:35
    gurux.dlms.c 9.0.2506.0401
  • Fri, 05/30/2025 - 08:30
    gurux.dlms.c 9.0.2505.3001
  • Tue, 05/27/2025 - 08:10
    Gurux.Serial.Android 2.0.12
  • Mon, 05/26/2025 - 08:39
    gurux.dlms.c 9.0.2505.2601

New forum topics

  • Day profile action item add error (String is not recognized as valid DateTime value)
  • Create gateway protocol in c
  • Error while reading event log object
  • GXDLMS Simulator – AssociationLogicalName Not Listed
  • Failed to read meter through raspberry pi 5 and probe
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin