From b8a55682d45215d82f5a9fe30f6e66f18c9e33fe Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 12 Mar 2012 11:44:22 -0400 Subject: [PATCH] I removed IOIOManager, IOIOThread, and IOIOListener Thier functionality have been replaced by IOIOAndroidApplicationHelper Change-Id: I8a4d7a647e7e78a078c08929be93a1dd18cbf70f Signed-off-by: Ricky Barrette --- .../android/ioio/IOIOListener.class | Bin 350 -> 0 bytes .../android/ioio/IOIOManager.class | Bin 3469 -> 0 bytes .../TwentyCodes/android/ioio/IOIOThread.class | Bin 1899 -> 0 bytes .../android/ioio/IOIOListener.java | 53 ----- .../TwentyCodes/android/ioio/IOIOManager.java | 143 -------------- .../TwentyCodes/android/ioio/IOIOThread.java | 181 ------------------ 6 files changed, 377 deletions(-) delete mode 100644 IOIOLib/bin/classes/com/TwentyCodes/android/ioio/IOIOListener.class delete mode 100644 IOIOLib/bin/classes/com/TwentyCodes/android/ioio/IOIOManager.class delete mode 100644 IOIOLib/bin/classes/com/TwentyCodes/android/ioio/IOIOThread.class delete mode 100644 IOIOLib/src/com/TwentyCodes/android/ioio/IOIOListener.java delete mode 100644 IOIOLib/src/com/TwentyCodes/android/ioio/IOIOManager.java delete mode 100644 IOIOLib/src/com/TwentyCodes/android/ioio/IOIOThread.java diff --git a/IOIOLib/bin/classes/com/TwentyCodes/android/ioio/IOIOListener.class b/IOIOLib/bin/classes/com/TwentyCodes/android/ioio/IOIOListener.class deleted file mode 100644 index 76cb19af020246f55f6551b19c9413156325a435..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 350 zcmY+Ay-veG5QJwPV+RL9(oj;zO-`bv3?Nyutmb}=Ksd{_tEUV zbS{_P|A`1;BhnHEvve8boN#rBk~z;^w`n!Okzg$D*7nsQTk;^AuHt*!FkyPU+kER4 n5!7D)1{mn7Cy2C4|Y96-{f7@R#;0Ot!&5} zulyorV21L{f8j4Me6n3%YUR>49rCbiY4z#od>0+bfB*aYp8!6_W(FySe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ctnT@#yKU^gkgbHN11je20!}n#>5&RlGH+qF@;?ZxO$!Arx{W+099+dU z>RG8a%dqf<0|$dec1r)*dg+FPS1_bUw;Wu;pdP*HU>GA*r=bG5e&FxQXiMv$TN1W} z*A$V`^K7w@>?_`>dU2I$e|gh>udC)}<&+dzo6k|_V(_l!>0M_XTt-P>=dOb*7-bJz zy+#y-=|fRyH|V5y9oQHc!25X6hx-RYNCAyJ5X??LKI++v{dPk$p zI~c~*C1G^rs@M&}#1);6r&_vO?&o1-QhD_Q zpKmjEE2-WyZfe2jpH^)fPq3tIvut7XoYrW64aYJ$`#=hnos+GTCv})TsX}E{Z{>WN z#NG@KqLy4%+D${fhdZnF!6c>2)0t(Aqlgk`eVpac&wqBujA>vK=~@%%Srh446WMeV z*>V%v2gZJ4UB#>XeT}mgS#pdMwU-#L<&W`t?Fz0RV^WWA)~1g!^@BNlo4?}*@IDHt zv#`5-BySP=0oUhH;r>_(g(_;C5fsxbg8a7PzYySXp3~^Wh diff --git a/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOListener.java b/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOListener.java deleted file mode 100644 index 0400956..0000000 --- a/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOListener.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * IOIOListener.java - * @date Jan 24, 2012 - * @author ricky barrette - * @author Twenty Codes, LLC - * - * Copyright 2012 Richard Barrette - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.TwentyCodes.android.ioio; - -import ioio.lib.api.IOIO; -import ioio.lib.api.exception.ConnectionLostException; - -/** - * This is a simple interface used to pass information from the IOIO thread to the manager - * @author ricky barrette - */ -public interface IOIOListener { - - /** - * Called when a IOIO is connected. - * here is a good time to init ports - * @param ioio - * @author ricky barrette - */ - public void onConnected(IOIO ioio) throws ConnectionLostException; - - /** - * Called when the IOIO thread loops. - * Here you want to update the ports - * @author ricky barrette - */ - public void loop() throws ConnectionLostException, InterruptedException; - - /** - * Called when the IOIO is disconnected. - * @author ricky barrette - */ - public void onDisconnected(); - -} diff --git a/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOManager.java b/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOManager.java deleted file mode 100644 index fc027fb..0000000 --- a/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOManager.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * IOIOManager.java - * @date Jan 21, 2012 - * @author ricky barrette - * @author Twenty Codes, LLC - * - * Copyright 2012 Richard Barrette - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.TwentyCodes.android.ioio; - -import ioio.lib.bluetooth.BluetoothIOIOConnectionDiscovery; -import ioio.lib.util.IOIOConnectionDiscovery; -import ioio.lib.util.SocketIOIOConnectionDiscovery; -import ioio.lib.util.IOIOConnectionDiscovery.IOIOConnectionSpec; - -import java.util.Collection; -import java.util.LinkedList; - -import android.util.Log; - -/** - * This class manages the IOIO connectivity threads. It is based on the AbstractIOIOActivity - * Remember that onConnected(), loop(), and onDisconnected() are called from the one of the IOIO threads - * @author ricky barrette - */ -public abstract class IOIOManager implements IOIOListener{ - - private static final String TAG = "IOIOManager"; - private Collection mThreads = new LinkedList(); - - /** - * Aborts the IOIO connectivity threads and joins them - * @throws InterruptedException - * @author ricky barrette - */ - public void abort() throws InterruptedException { - for (IOIOThread thread : mThreads) - thread.abort(); - joinAllThreads(); - } - - /** - * @param discoveryClassName - * @param result - * @author Ytai Ben-Tsvi - */ - private void addConnectionSpecs(String discoveryClassName, Collection result) { - try { - Class cls = Class.forName(discoveryClassName); - IOIOConnectionDiscovery discovery = (IOIOConnectionDiscovery) cls.newInstance(); - discovery.getSpecs(result); - } catch (ClassNotFoundException e) { - Log.d(TAG, "Discovery class not found: " + discoveryClassName+ ". Not adding."); - } catch (Exception e) { - Log.w(TAG,"Exception caught while discovering connections - not adding connections of class "+ discoveryClassName, e); - } - } - - /** - * Creates all the required IOIO connectivity threads - * @author ricky barrette - */ - private void createAllThreads() { - mThreads.clear(); - Collection specs = getConnectionSpecs(); - for (IOIOConnectionSpec spec : specs) - mThreads.add(new IOIOThread(spec.className, spec.args, this)); - } - - /** - * @return - * @author Ytai Ben-Tsvi - */ - private Collection getConnectionSpecs() { - Collection result = new LinkedList(); - addConnectionSpecs(SocketIOIOConnectionDiscovery.class.getName(),result); - addConnectionSpecs(BluetoothIOIOConnectionDiscovery.class.getName(), result); - return result; - } - - /** - * @return true is the stat led is enabled - * @author ricky barrette - */ - public boolean isStatLedEnabled() { - for(IOIOThread thread : mThreads) - if(thread.isConnected()) - return thread.isStatLedEnabled(); - return false; - } - - /** - * Joins all the threads - * @throws InterruptedException - * @author ricky barrette - */ - private void joinAllThreads() throws InterruptedException { - for (IOIOThread thread : mThreads) - thread.join(); - } - - /** - * @param isStatLedEnabled the isStatLedEnabled to set - * @author ricky barrette - */ - public void setStatLedEnabled(boolean isStatLedEnabled) { - for(IOIOThread thread : mThreads) - thread.setStatLedEnabled(isStatLedEnabled); - } - - /** - * Sets the update interval of the IOIO thread - * @param ms - * @author ricky barrette - */ - public void setUpdateInverval(long ms){ - for(IOIOThread thread : mThreads) - thread.setUpdateInverval(ms); - } - - /** - * Starts IOIO connectivity threads - * @author ricky barrette - */ - public void start() { - createAllThreads(); - for (IOIOThread thread : mThreads) - thread.start(); - } - -} \ No newline at end of file diff --git a/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOThread.java b/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOThread.java deleted file mode 100644 index 15b7e6f..0000000 --- a/IOIOLib/src/com/TwentyCodes/android/ioio/IOIOThread.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * IOIOThread.java - * @date Jan 11, 2012 - * @author ricky barrette - * @author Ytai Ben-Tsvi - * @author Twenty Codes, LLC - * - * Copyright 2012 Richard Barrette - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.TwentyCodes.android.ioio; - -import android.util.Log; -import ioio.lib.api.DigitalOutput; -import ioio.lib.api.IOIO; -import ioio.lib.api.IOIOFactory; -import ioio.lib.api.exception.ConnectionLostException; -import ioio.lib.api.exception.IncompatibilityException; - -/** - * This is the thread that maintains the IOIO interaction. - * - * It first creates a IOIO instance and wait for a connection to be - * established. - * - * Whenever a connection drops, it tries to reconnect, unless this is a - * result of abort(). - * - * @author Ytai Ben-Tsvi - * @author ricky barrette - */ -public class IOIOThread extends Thread{ - - private static final String TAG = "IOIOThread"; - private IOIO mIOIO; - private boolean isAborted = false; - private long mUpdateInterval = 10; - private boolean isStatLedEnabled = false; - private IOIOListener mListener; - private String mClassName; - private Object[] mArgs; - private boolean isConnected; - - public IOIOThread(IOIOListener listener){ - super(); - mListener = listener; - } - - public IOIOThread(String className, Object[] args, IOIOListener listener) { - super(); - mListener = listener; - mClassName = className; - mArgs = args; - } - - /** - * Abort the connection. - * - * This is a little tricky synchronization-wise: we need to be handle - * the case of abortion happening before the IOIO instance is created or - * during its creation. - */ - public synchronized void abort() { - isAborted = true; - if (mIOIO != null) { - mIOIO.disconnect(); - } - } - - /** - * @return true if this tread is connected to a IOIO - * @author ricky barrette - */ - public synchronized boolean isConnected() { - return isConnected; - } - - - /** - * @return the isStatLedEnabled - */ - public synchronized boolean isStatLedEnabled() { - return isStatLedEnabled; - } - - /** - * Thread Body - * (non-Javadoc) - * @see java.lang.Thread#run() - */ - @Override - public void run() { - while (true) { - synchronized (this) { - if (isAborted) { - break; - } - if(mClassName == null || mArgs == null) - mIOIO = IOIOFactory.create(); - else - try { - mIOIO = IOIOFactory.create(mClassName, mArgs); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - isConnected = true; - try { - /* - * Here we will try to connect to the IOIO board. - * - * the waitForConnect() is blocking until it can connect - */ - mIOIO.waitForConnect(); - - /* - * Here we register and initialize each port - */ - DigitalOutput statLed = mIOIO.openDigitalOutput(IOIOValues.STAT_LED_PORT, true); - mListener.onConnected(mIOIO); - - /* - * Here we will update the ports every 10 ms (default) - */ - while (true) { - mListener.loop(); - statLed.write(!isStatLedEnabled); - sleep(mUpdateInterval ); - } - } catch (ConnectionLostException e) { - mListener.onDisconnected(); - isConnected = false; - } catch (InterruptedException e) { - Log.e(TAG, e.getMessage()); - e.printStackTrace(); - mIOIO.disconnect(); - mListener.onDisconnected(); - isConnected = false; - break; - } catch (IncompatibilityException e) { - Log.e(TAG, e.getMessage()); - e.printStackTrace(); - } finally { - try { - mIOIO.waitForDisconnect(); - mListener.onDisconnected(); - isConnected = false; - } catch (InterruptedException e) { - } - } - } - } - - /** - * Sets the stat led on / off - * @param isStatLedEnabled the isStatLedEnabled to set - */ - public synchronized void setStatLedEnabled(boolean isStatLedEnabled) { - this.isStatLedEnabled = isStatLedEnabled; - } - - /** - * Sets the update interval of the IOIO thread - * @param ms - */ - public synchronized void setUpdateInverval(long ms){ - mUpdateInterval = ms; - } - -} \ No newline at end of file