+package iotcode.IHome;
+
+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 Speaker_Skeleton implements Speaker {
+
+ private Speaker mainObj;
+ private IoTRMIObject rmiObj;
+
+ private String callbackAddress;
+ private int objIdCnt = 0;
+ private IoTRMICall rmiCall;
+ private int[] ports;
+
+ private final static int object0Id = 0; //SpeakerSmart
+ private static Integer[] object0Permission = { 6, 2, 9, 1, 3, 4, 5, 7, 8, 0, 10 };
+ private static List<Integer> set0Allowed;
+
+
+ public Speaker_Skeleton(Speaker _mainObj, String _callbackAddress, int _port) throws Exception {
+ mainObj = _mainObj;
+ callbackAddress = _callbackAddress;
+ rmiObj = new IoTRMIObject(_port);
+ set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
+ set0Allowed.add(-9998);
+ ___waitRequestInvokeMethod();
+ }
+
+ public void init() {
+ mainObj.init();
+ }
+
+ public boolean startPlayback() {
+ return mainObj.startPlayback();
+ }
+
+ public boolean stopPlayback() {
+ return mainObj.stopPlayback();
+ }
+
+ public boolean getPlaybackState() {
+ return mainObj.getPlaybackState();
+ }
+
+ public boolean setVolume(float _percent) {
+ return mainObj.setVolume(_percent);
+ }
+
+ public float getVolume() {
+ return mainObj.getVolume();
+ }
+
+ public int getPosition() {
+ return mainObj.getPosition();
+ }
+
+ public void setPosition(int _mSec) {
+ mainObj.setPosition(_mSec);
+ }
+
+ public void loadData(short _samples[], int _offs, int _len) {
+ mainObj.loadData(_samples, _offs, _len);
+ }
+
+ public void clearData() {
+ mainObj.clearData();
+ }
+
+ public void registerCallback(SpeakerSmartCallback _cb) {
+ mainObj.registerCallback(_cb);
+ }
+
+ public void ___regCB() throws IOException {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
+ ports = (int[]) paramObj[0];
+ rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
+ }
+
+ public void ___init() {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
+ new Class<?>[] { });
+ init();
+ }
+
+ public void ___startPlayback() throws IOException {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
+ new Class<?>[] { });
+ Object retObj = startPlayback();
+ rmiObj.sendReturnObj(retObj);
+ }
+
+ public void ___stopPlayback() throws IOException {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
+ new Class<?>[] { });
+ Object retObj = stopPlayback();
+ rmiObj.sendReturnObj(retObj);
+ }
+
+ public void ___getPlaybackState() throws IOException {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
+ new Class<?>[] { });
+ Object retObj = getPlaybackState();
+ rmiObj.sendReturnObj(retObj);
+ }
+
+ public void ___setVolume() throws IOException {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { float.class },
+ new Class<?>[] { null });
+ Object retObj = setVolume((float) paramObj[0]);
+ rmiObj.sendReturnObj(retObj);
+ }
+
+ public void ___getVolume() throws IOException {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
+ new Class<?>[] { });
+ Object retObj = getVolume();
+ rmiObj.sendReturnObj(retObj);
+ }
+
+ public void ___getPosition() throws IOException {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
+ new Class<?>[] { });
+ Object retObj = getPosition();
+ rmiObj.sendReturnObj(retObj);
+ }
+
+ public void ___setPosition() {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
+ new Class<?>[] { null });
+ setPosition((int) paramObj[0]);
+ }
+
+ public void ___loadData() {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { short[].class, int.class, int.class },
+ new Class<?>[] { null, null, null });
+ loadData((short[]) paramObj[0], (int) paramObj[1], (int) paramObj[2]);
+ }
+
+ public void ___clearData() {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
+ new Class<?>[] { });
+ clearData();
+ }
+
+ public void ___registerCallback() {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
+ new Class<?>[] { null });
+ try {
+ SpeakerSmartCallback stub0 = new SpeakerSmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
+ objIdCnt++;
+ registerCallback(stub0);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ throw new Error("Exception from callback object instantiation!");
+ }
+ }
+
+ private void ___waitRequestInvokeMethod() throws IOException {
+ while (true) {
+ rmiObj.getMethodBytes();
+ int _objectId = rmiObj.getObjectId();
+ int methodId = rmiObj.getMethodId();
+ if (_objectId == object0Id) {
+ if (!set0Allowed.contains(methodId)) {
+ throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId);
+ }
+ }
+ else {
+ throw new Error("Object Id: " + _objectId + " not recognized!");
+ }
+ switch (methodId) {
+ case 0: ___init(); break;
+ case 1: ___startPlayback(); break;
+ case 2: ___stopPlayback(); break;
+ case 3: ___getPlaybackState(); break;
+ case 4: ___setVolume(); break;
+ case 5: ___getVolume(); break;
+ case 6: ___getPosition(); break;
+ case 7: ___setPosition(); break;
+ case 8: ___loadData(); break;
+ case 9: ___clearData(); break;
+ case 10: ___registerCallback(); break;
+ case -9998: ___regCB(); break;
+ default:
+ throw new Error("Method Id " + methodId + " not recognized!");
+ }
+ }
+ }
+
+}