Annotation Type CosemMethod


  • @Target(METHOD)
    @Retention(RUNTIME)
    @Documented
    public @interface CosemMethod
    This annotation is used to define a COSEM method in a COSEM class.

    The annotate method must be public. It can have a single parameter of type DataObject, it can return a DataObject and it can throw an IllegalMethodAccessException.

     @CosemClass(id = 99, version = 2)
     public class DemoClass extends CosemInterfaceObject {
          ...
          @CosemMethod(id = 1)
          public void foo() {
              System.out.println("Hello World");
          }
     
          @CosemMethod(id = 2, consumes = Type.OCTET_STRING)
          public void bar(DataObject param) {
              byte[] octetStr = param.getValue();
              System.out.println("Hello " + new String(octetStr, StandardCharsets.US_ASCII));
          }
     
          @CosemMethod(id = 3, consumes = Type.OCTET_STRING)
          public DataObject fooBar(DataObject param, Long connectionId) {
              // evaluate connection ID
     
              byte[] octetStr = param.getValue();
              System.out.println("Hello " + new String(octetStr));
     
              return DataObject.newNullData();
          }
     }
     

    NOTE: Ambiguous method ID's in a class are not allowed.

    See Also:
    CosemClass, DataObject
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      byte id
      The method ID.
    • Element Detail

      • id

        byte id
        The method ID. The value must be greater than 0.
        Returns:
        the method ID > 0.
      • consumes

        DataObject.Type consumes
        The type of the parameter if it exists.
        Returns:
        the parameter type.
        Default:
        org.openmuc.jdlms.datatypes.DataObject.Type.DONT_CARE
      • accessMode

        MethodAccessMode accessMode
        Restrict the access mode of the method.
        Returns:
        the access mode of the method.
        Default:
        org.openmuc.jdlms.MethodAccessMode.ACCESS
      • snOffset

        int snOffset
        The offset from the base name. E.g. 0x18.

        Must be a multiple of 0x08 and unique in the class.

        Returns:
        the short name offset.
        Default:
        -1