Replacing default BUFFSIZE value with new buffer size value when a resize needs to...
[iot2.git] / benchmarks / drivers / GreenLawn / Lawn_Skeleton.java
1 package iotcode.GreenLawn;
2
3 import java.io.IOException;
4 import java.util.List;
5 import java.util.ArrayList;
6 import java.util.Arrays;
7 import iotrmi.Java.IoTRMICall;
8 import iotrmi.Java.IoTRMIObject;
9
10 import iotcode.interfaces.*;
11
12 public class Lawn_Skeleton implements Lawn {
13
14         private Lawn mainObj;
15         private IoTRMIObject rmiObj;
16
17         private String callbackAddress;
18         private final static int object0Id = 0; //LawnSmart
19         private static Integer[] object0Permission = {  };
20         private static List<Integer> set0Allowed;
21         
22
23         public Lawn_Skeleton(Lawn _mainObj, String _callbackAddress, int _port) throws Exception {
24                 mainObj = _mainObj;
25                 callbackAddress = _callbackAddress;
26                 rmiObj = new IoTRMIObject(_port);
27                 set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
28                 ___waitRequestInvokeMethod();
29         }
30
31         private void ___waitRequestInvokeMethod() throws IOException {
32                 while (true) {
33                         rmiObj.getMethodBytes();
34                         int _objectId = rmiObj.getObjectId();
35                         int methodId = rmiObj.getMethodId();
36                         if (_objectId == object0Id) {
37                                 if (!set0Allowed.contains(methodId)) {
38                                         throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
39                                 }
40                         }
41                         else {
42                                 throw new Error("Object Id: " + _objectId + " not recognized!");
43                         }
44                         switch (methodId) {
45                                 default: 
46                                 throw new Error("Method Id " + methodId + " not recognized!");
47                         }
48                 }
49         }
50
51 }