@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, obis = "0.2.0.0.0.255", version = 2) public class DemoClass { ... @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)); } @CosemMethod
(id = 3, consumes = Type.OCTET_STRING) public DataObject fooBar(DataObject param, ConnectionId 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 optional parameter.
|
public abstract byte id
public abstract DataObject.Type consumes
public abstract MethodAccessMode accessMode