--- /dev/null
+package SpeakerController;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import iotrmi.Java.IoTRMICall;
+import iotrmi.Java.IoTRMIObject;
+
+import iotcode.interfaces.*;
+
+public class SpeakerSmart_Stub implements SpeakerSmart {
+
+ private IoTRMICall rmiCall;
+ private String callbackAddress;
+ private int[] ports;
+
+ private final static int objectId = 0;
+ // Callback properties
+ private IoTRMIObject rmiObj;
+ List<SpeakerCallback> listCallbackObj;
+ private int objIdCnt = 0;
+ private final static int object0Id = 0; //SpeakerSmartCallback
+ private static Integer[] object0Permission = { 0 };
+ private static List<Integer> set0Allowed;
+
+
+ public SpeakerSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
+ callbackAddress = _callbackAddress;
+ ports = _ports;
+ rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
+ set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
+ listCallbackObj = new ArrayList<SpeakerCallback>();
+ set0Allowed.add(-9999);
+ ___initCallBack();
+ }
+
+ public int getPosition() {
+ int methodId = 6;
+ Class<?> retType = int.class;
+ Class<?>[] paramCls = new Class<?>[] { };
+ Object[] paramObj = new Object[] { };
+ Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ return (int)retObj;
+ }
+
+ public boolean stopPlayback() {
+ int methodId = 2;
+ Class<?> retType = boolean.class;
+ Class<?>[] paramCls = new Class<?>[] { };
+ Object[] paramObj = new Object[] { };
+ Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ return (boolean)retObj;
+ }
+
+ public void clearData() {
+ int methodId = 9;
+ Class<?> retType = void.class;
+ Class<?>[] paramCls = new Class<?>[] { };
+ Object[] paramObj = new Object[] { };
+ rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ }
+
+ public boolean startPlayback() {
+ int methodId = 1;
+ Class<?> retType = boolean.class;
+ Class<?>[] paramCls = new Class<?>[] { };
+ Object[] paramObj = new Object[] { };
+ Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ return (boolean)retObj;
+ }
+
+ public boolean getPlaybackState() {
+ int methodId = 3;
+ Class<?> retType = boolean.class;
+ Class<?>[] paramCls = new Class<?>[] { };
+ Object[] paramObj = new Object[] { };
+ Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ return (boolean)retObj;
+ }
+
+ public boolean setVolume(float _percent) {
+ int methodId = 4;
+ Class<?> retType = boolean.class;
+ Class<?>[] paramCls = new Class<?>[] { float.class };
+ Object[] paramObj = new Object[] { _percent };
+ Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ return (boolean)retObj;
+ }
+
+ public float getVolume() {
+ int methodId = 5;
+ Class<?> retType = float.class;
+ Class<?>[] paramCls = new Class<?>[] { };
+ Object[] paramObj = new Object[] { };
+ Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ return (float)retObj;
+ }
+
+ public void setPosition(int _mSec) {
+ int methodId = 7;
+ Class<?> retType = void.class;
+ Class<?>[] paramCls = new Class<?>[] { int.class };
+ Object[] paramObj = new Object[] { _mSec };
+ rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ }
+
+ public void loadData(short _samples[], int _offs, int _len) {
+ int methodId = 8;
+ Class<?> retType = void.class;
+ Class<?>[] paramCls = new Class<?>[] { short[].class, int.class, int.class };
+ Object[] paramObj = new Object[] { _samples, _offs, _len };
+ rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ }
+
+ public void init() {
+ int methodId = 0;
+ Class<?> retType = void.class;
+ Class<?>[] paramCls = new Class<?>[] { };
+ Object[] paramObj = new Object[] { };
+ rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ }
+
+ public void registerCallback(SpeakerCallback _cb) {
+ try {
+ SpeakerCallback_CallbackSkeleton skel0 = new SpeakerCallback_CallbackSkeleton(_cb, callbackAddress, objIdCnt++);
+ listCallbackObj.add(skel0);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new Error("Exception when generating skeleton objects!");
+ }
+
+ int methodId = 10;
+ Class<?> retType = void.class;
+ Class<?>[] paramCls = new Class<?>[] { int.class };
+ Object[] paramObj = new Object[] { new Integer(1) };
+ rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ }
+
+ public void ___initCallBack() {
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ rmiObj = new IoTRMIObject(ports[0]);
+ while (true) {
+ byte[] method = rmiObj.getMethodBytes();
+ int objId = IoTRMIObject.getObjectId(method);
+ SpeakerCallback_CallbackSkeleton skel = (SpeakerCallback_CallbackSkeleton) listCallbackObj.get(objId);
+ if (skel != null) {
+ int methodId = IoTRMIObject.getMethodId(method);
+ if (!set0Allowed.contains(methodId)) {
+ throw new Error("Callback object for SpeakerCallback is not allowed to access method: " + methodId);
+ }
+ skel.invokeMethod(rmiObj);
+ } else {
+ throw new Error("SpeakerCallback: Object with Id " + objId + " not found!");
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new Error("Error instantiating class SpeakerCallback_CallbackSkeleton!");
+ }
+ }
+ };
+ thread.start();
+
+ int methodId = -9998;
+ Class<?> retType = void.class;
+ Class<?>[] paramCls = new Class<?>[] { int[].class, String.class, int.class };
+ Object[] paramObj = new Object[] { ports, callbackAddress, 0 };
+ rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ }
+
+}