@Target(value=METHOD)
@Retention(value=RUNTIME)
@Documented
public @interface CosemMethod
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.
CosemClass
,
DataObject
Modifier and Type | Required Element and Description |
---|---|
byte |
id
The method ID.
|
Modifier and Type | Optional Element and Description |
---|---|
MethodAccessMode |
accessMode
Restrict the access mode of the method.
|
DataObject.Type |
consumes
The type of the parameter if it exsits.
|
public abstract byte id
public abstract DataObject.Type consumes
public abstract MethodAccessMode accessMode