Annotation Type CosemAttribute


  • @Target(FIELD)
    @Retention(RUNTIME)
    @Documented
    public @interface CosemAttribute
    This annotation is used to define a COSEM attribute in a COSEM class. Only fields of type DataObject can be annotated with this annotation.
     @CosemClass(id = 99, version = 2)
     public class DemoClass extends CosemInterfaceObject {
          @CosemAttribute(id = 2)
          private DataObject data;
          ...
     }
     
    To intercept read or write accesses of the attribute, a public get/set method must be provided. The get method must have get as a prefix and the set method respectively a set as a prefix.

    The set and get methods may only throw an IllegalAttributeAccessException.

     @CosemClass(id = 99, version = 2)
     public class DemoClass extends CosemInterfaceObject {
          @CosemAttribute(id = 2, type = Type.INTEGER)
          private DataObject data;
          ...
     
          public void setData(DataObject newData) throws IllegalAttributeAccessException {
              Number value = newData.getValue();
     
              if (value.intValue() < 10) {
                  throw new IllegalAttributeAccessException(AccessResultCode.TYPE_UNMATCHED);
              }
     
              this.data = newData;
          }
     }
     

    NOTE: Ambiguous attribute ID's in a class are not allowed. Attribute ID 1 is reserved for the system.

    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      byte id
      The attribute ID.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      AttributeAccessMode accessMode
      The access restriction for the attribute in a COSEM class.
      int[] selector
      Attribute sector ID's in a value range 0 to 255.
      int snOffset
      The offset from the base name.
      DataObject.Type type
      The data type of the attribute.
    • Element Detail

      • id

        byte id
        The attribute ID. The value must be greater than 1. Attribute ID 1 is reserved for the logical name (OBIS code / instance ID).
        Returns:
        the attribute ID > 1.
      • accessMode

        AttributeAccessMode accessMode
        The access restriction for the attribute in a COSEM class.

        NOTE: This attribute is optional.

        Returns:
        the access mode.
        Default:
        org.openmuc.jdlms.AttributeAccessMode.READ_AND_WRITE
      • type

        DataObject.Type type
        The data type of the attribute. If a client may want to send a different type, the server will deny the write access.
        Returns:
        the type of the attribute.
        Default:
        org.openmuc.jdlms.datatypes.DataObject.Type.DONT_CARE
      • snOffset

        int snOffset
        The offset from the base name. E.h. 0x18. Must be a multiple of 0x08 and unique in the class.
        Returns:
        the short name offset.
        Default:
        -1