Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving eclipse project working directory
-moved entire Coordinator workspace to coordinator_eclipse_workspace -added .metadata Coordinator.java: -check for duplicate drivers during initialization Driver.java: ControllerModule.java: SensorModule.java: -now implemented as abstract classes instead of interfaces LedFlash.java: StatefullLed.java: -extend ControllerModule instead of implement Log.java -warning and error messages are now prefixed accordingly
- Loading branch information
1 parent
ba95d7f
commit d32835e
Showing
486 changed files
with
69,035 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
coordinator_eclipse_workspace/.metadata/.plugins/org.eclipse.cdt.core/.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
*** SESSION Jan 21, 2014 23:28:31.49 ------------------------------------------- | ||
*** SESSION Jan 21, 2014 23:37:31.75 ------------------------------------------- | ||
*** SESSION Jan 22, 2014 14:16:31.81 ------------------------------------------- | ||
*** SESSION Jan 23, 2014 12:00:16.96 ------------------------------------------- | ||
*** SESSION Jan 23, 2014 13:37:27.83 ------------------------------------------- | ||
*** SESSION Jan 25, 2014 10:21:30.56 ------------------------------------------- | ||
*** SESSION Jan 25, 2014 15:12:03.56 ------------------------------------------- | ||
*** SESSION Jan 25, 2014 17:59:13.78 ------------------------------------------- | ||
*** SESSION Jan 25, 2014 21:23:37.94 ------------------------------------------- | ||
*** SESSION Jan 26, 2014 14:03:33.27 ------------------------------------------- | ||
*** SESSION Jan 27, 2014 16:54:07.51 ------------------------------------------- | ||
*** SESSION Jan 27, 2014 21:56:54.95 ------------------------------------------- | ||
*** SESSION Jan 27, 2014 23:32:46.82 ------------------------------------------- | ||
*** SESSION Jan 28, 2014 00:21:27.01 ------------------------------------------- | ||
*** SESSION Jan 28, 2014 11:54:53.38 ------------------------------------------- | ||
*** SESSION Jan 28, 2014 12:11:10.42 ------------------------------------------- | ||
*** SESSION Jan 28, 2014 13:31:33.87 ------------------------------------------- | ||
*** SESSION Jan 28, 2014 17:17:30.51 ------------------------------------------- | ||
*** SESSION Jan 28, 2014 21:25:18.91 ------------------------------------------- | ||
*** SESSION Jan 28, 2014 21:30:38.59 ------------------------------------------- |
1 change: 1 addition & 0 deletions
1
coordinator_eclipse_workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
1 change: 1 addition & 0 deletions
1
coordinator_eclipse_workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
6 changes: 6 additions & 0 deletions
6
....metadata/.plugins/org.eclipse.core.resources/.history/1/80351813c08300131636968a6a637f39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.apparatus_templi; | ||
|
||
public interface RemoteModule { | ||
public String getModuleType(); | ||
public String getModuleName(); | ||
} |
134 changes: 134 additions & 0 deletions
134
...metadata/.plugins/org.eclipse.core.resources/.history/10/808418090f8600131d8dcd18dba31b17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
package org.apparatus_templi; | ||
|
||
/** | ||
* StatefullLed | ||
* @author Jonathan Nelson <ciasaboark@gmail.com> | ||
* A driver for a remote module with a number of LEDs. Each LED | ||
* can be turned on or off, and the driver keeps track of the state | ||
* of each 'pixel' | ||
* | ||
* Remote side expects one of the following commands: | ||
* "RESET" - reset all attached LEDs to their off state | ||
* "(int):(int)" - set the state of the LED attached to | ||
* the first (int) to the boolean value of the second int. | ||
* Valid values for the first int are 4,5,6. | ||
* The second int may be any valid signed int value, with 0 | ||
* equating to false, all other values to true. | ||
* | ||
* Driver listens for the following responses: | ||
* "RESETOK" - the reset command was received and all LEDs | ||
* were reset to off. | ||
* "OK(int)" - the state of the LED on pin number (int) was | ||
* toggled. | ||
*/ | ||
|
||
public class StatefullLed extends Coordinator implements ControllerModule, Runnable { | ||
private String moduleName = "StatefullLED"; | ||
private boolean running = true; | ||
|
||
//our remote module has three LEDs attached | ||
private int[] leds = {4, 5, 6}; | ||
private boolean[] ledsState = {false, false, false}; | ||
|
||
@Override | ||
public String getModuleType() { | ||
return "Controller"; | ||
} | ||
|
||
@Override | ||
public String getModuleName() { | ||
return moduleName; | ||
} | ||
|
||
@Override | ||
public void receiveMessage(String message) { | ||
//throw away the message for now | ||
Log.d(moduleName, "received message, ignoring"); | ||
|
||
} | ||
|
||
@Override | ||
public void terminate() { | ||
Log.d(moduleName, "told to terminate"); | ||
running = false; | ||
|
||
} | ||
|
||
@Override | ||
public String getWidgetXML() { | ||
Log.w(moduleName, "getWidgetXML() unimplimented"); | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getFullPageXML() { | ||
Log.w(moduleName, "getFullPageXML() unimplimented"); | ||
return null; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
//since we don't know the state of the remote module at the beginning we | ||
//+ tell it to reset to a default state (all LEDs off). If the remote | ||
//+ side does not respond within 3 seconds then the driver will terminate | ||
if (super.isModulePresent(moduleName)) { | ||
if (Coordinator.sendCommandAndWait(moduleName, "RESET", 3).equals("OKRESET")) { | ||
for (boolean ledState: ledsState) { | ||
ledState = false; | ||
} | ||
} else { | ||
Log.e(moduleName, "did not get a response from the remote side, exiting"); | ||
terminate(); | ||
} | ||
} else { | ||
Log.e(moduleName, "remote module is not present, shutting down"); | ||
terminate(); | ||
} | ||
|
||
|
||
while (running) { | ||
//run through a hardcoded loop for now. | ||
for (int i = 0; i < 2; i++) { | ||
toggleLED(i); | ||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} | ||
|
||
//thread is terminating, do whatever cleanup is needed | ||
Coordinator.sendCommand(moduleName, "RESET"); | ||
Log.d(moduleName, "terminating"); | ||
|
||
} | ||
|
||
private void toggleLED(int ledNum) { | ||
Log.d(moduleName, "toggling LED " + ledNum + " on pin " + leds[ledNum] + " to state: " + | ||
(ledsState[ledNum]? "OFF" : "ON")); | ||
Coordinator.sendCommand(moduleName, String.valueOf(leds[ledNum]) + ":" + (ledsState[ledNum]? "0" : "1")); | ||
ledsState[ledNum] = !ledsState[ledNum]; | ||
} | ||
|
||
@Override | ||
public String getControllerListXML() { | ||
Log.w(moduleName, "getControllerListXML() unimplimented for now"); | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getControllerStatusXML(String controllerName) { | ||
Log.w(moduleName, "getControllerStatusXML() unimplimented for now"); | ||
return null; | ||
} | ||
|
||
@Override | ||
public void tellController(String controllerName, String command) { | ||
Log.d(moduleName, "tellController() not validating command, passing without verification"); | ||
Coordinator.sendCommand(moduleName, command); | ||
|
||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...metadata/.plugins/org.eclipse.core.resources/.history/12/f02fab9185880013142d9777a99f0fe4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.apparatus_templi; | ||
|
||
public interface ControllerModule extends Driver { | ||
public String getControllerListXML(); | ||
public String getControllerStatusXML(String controllerName); | ||
public void tellController(String controllerName, String command); | ||
} |
57 changes: 57 additions & 0 deletions
57
...metadata/.plugins/org.eclipse.core.resources/.history/13/4068c93a86880013142d9777a99f0fe4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.apparatus_templi; | ||
|
||
public abstract class Driver implements Runnable { | ||
// protected String type; //Controller or Sensor type. | ||
protected final String name; //name of the device Empty String as default or could assign a random name if not assigned one | ||
public volatile int counter = 0; //used to assign the threads random names if not explicitly given one | ||
protected String protocol_version =" "; //this current operating protocol verison the device is running | ||
protected boolean running = false; | ||
|
||
public abstract String getModuleType(); | ||
public abstract String getModuleName(); | ||
public abstract void receiveCommand(String command); | ||
public abstract String getWidgetXML(); | ||
public abstract String getFullPageXML(); | ||
public abstract void will_run(); //let the thread know it is about to run | ||
|
||
|
||
/* | ||
* Let the subclass know it is about to terminate. | ||
* The subclass can do any extra serialization or whatever it needs | ||
* to do before terminating. | ||
*/ | ||
public abstract void will_terminate(); | ||
|
||
|
||
public void terminate() { | ||
this.will_terminate(); //call the subclass implementation | ||
} | ||
|
||
/* | ||
* If the device is not given a name during creation, it will have an empty string as default | ||
* The thread's begin_execution() function (make shift constructor) can handle this. It can assign it a random | ||
* name. | ||
*/ | ||
public void setName(String device_name) { | ||
this.name = device_name; | ||
} | ||
|
||
public String deviceName() { | ||
return this.name; | ||
} | ||
|
||
public void isRunning() { | ||
return this.running; | ||
} | ||
|
||
public void setRunning(boolean run) { | ||
this.running = run; | ||
} | ||
|
||
/* | ||
* The devices' current running protocol verison. I.e (0.0 or 0.1) and so fourth | ||
*/ | ||
public void protocol_version(String version) { | ||
this.protocol_version = version; | ||
} | ||
} |
Oops, something went wrong.