
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.
2. Make your own class ex. GuruxCustomObject and derive it from GXDLMSObject and IGXDLMSBase. Then add constructor where you tell class ID.
/*
* 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.
//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.