Skip to content

Commit

Permalink
Merge pull request #208 from mstevetodd/master
Browse files Browse the repository at this point in the history
fixed mis-handling of WiThrottle-created consists
  • Loading branch information
mstevetodd authored Apr 1, 2018
2 parents d0e913f + 4e346f9 commit 3d2ffae
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="jmri.enginedriver"
android:versionCode="43"
android:versionName="2.18-test7" android:installLocation="auto">
android:versionName="2.18-test8" android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Expand Down
4 changes: 3 additions & 1 deletion assets/about_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<h1>Engine Driver Throttle for Android</h1>
<div><img src="file:///android_asset/engine_driver_icon.png" height="144" width="166"
style="float:left;padding:0 8px 8px 0" alt=""/></div>
<p>Engine Driver version 2.18-test7 includes:<br/>
<p>Engine Driver version 2.18-test8 includes:<br/>
<ul>
<li>new 'Dark' Theme added</li>
<li>option for the volume keys to follow the last touched throttle</li>
Expand All @@ -25,6 +25,8 @@ <h1>Engine Driver Throttle for Android</h1>
<li>import includes throttle name if on the same device that exported them</li>
<li>prevent some crashes reported to Google Play</li>
<li>option to hide the demo server</li>
<li>fixed mis-handling of WiThrottle-created consists</li>

</ul>
</p>
<br/><em><a
Expand Down
1 change: 1 addition & 0 deletions changelog-and-todo-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* only send release for throttles actually in use
* option for ESU Mobile Control II to disable direction change at zero end-stop position
* option for ESU Mobile Control II to disable on-device stop button short-press
* fixed mis-handling of WiThrottle-created consists
**Version 2.17
* Add support for ESU Mobile Control II throttle
* Add toast messages when ESU Mobile Control II in stop mode
Expand Down
6 changes: 3 additions & 3 deletions src/jmri/enginedriver/select_loco.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ public void refresh_roster_list() {
//add consist entries to screen list
if (mainapp.consist_entries != null) {
Set<String> ces = mainapp.consist_entries.keySet();
for (String consistname : ces) {
for (String consist_addr : ces) {
// put key and values into temp hashmap
HashMap<String, String> hm = new HashMap<>();
hm.put("roster_name", mainapp.consist_entries.get(consistname));
hm.put("roster_address", consistname);
hm.put("roster_name", mainapp.consist_entries.get(consist_addr));
hm.put("roster_address", consist_addr);
hm.put("roster_entry_type", "consist");

// add temp hashmap to list which view is hooked to
Expand Down
15 changes: 9 additions & 6 deletions src/jmri/enginedriver/threaded_application.java
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ else if (whichThrottle == 'G')
if (consistname != null) { //if found, request function keys for lead, format MTAS13<;>CL1234
String[] cna = splitByString(consistname, "+");
String cmd = "M" + whichThrottle + "A" + addr + "<;>C" + cvtToLAddr(cna[0]);
Log.d("Engine_Driver", "rqsting fkeys for lead loco " + cvtToLAddr(cna[0]));
withrottle_send(cmd);
}

Expand Down Expand Up @@ -880,7 +881,7 @@ else if ('G' == whichThrottle)
case 'C':
if (response_str.charAt(2) == 'C' || response_str.charAt(2) == 'L') { //RCC1 or RCL1 (treated the same in ED)
clear_consist_list();
} else if (response_str.charAt(2) == 'D') { //RCD}|{88(S)}|{88(S)]\[2591(L)}|{true]\[3(S)}|{true]\[4805(L)}|{true
} else if (response_str.charAt(2) == 'D') { //RCD}|{88(S)}|{Consist Name]\[2591(L)}|{true]\[3(S)}|{true]\[4805(L)}|{true
process_consist_list(response_str);
}
break;
Expand Down Expand Up @@ -1023,7 +1024,7 @@ private void process_roster_list(String response_str) {
}

//parse consist list into appropriate mainapp hashmap
//RCD}|{88(S)}|{88(S)]\[2591(L)}|{true]\[3(S)}|{true]\[4805(L)}|{true
//RCD}|{88(S)}|{Consist Name]\[2591(L)}|{true]\[3(S)}|{true]\[4805(L)}|{true
private void process_consist_list(String response_str) {
String consist_addr = null;
String consist_desc = "";
Expand All @@ -1045,11 +1046,13 @@ private void process_consist_list(String response_str) {
} //end if i==0
i++;
} //end for
if (!consist_name.equals(consist_addr) && (consist_name.length() > 4)) {
consist_desc = consist_name; // use entered name if significant
}
// if (!consist_name.equals(consist_addr) && (consist_name.length() > 4)) {
// consist_desc = consist_name; // use entered name if significant
// }
Log.d("Engine_Driver","consist header, addr=" + consist_addr
+ ", name=" + consist_name + ", desc=" + consist_desc);
//don't add empty consists to list
if (consist_desc != null && consist_desc.length() > 0) {
if (consist_desc.length() > 0) {
consist_entries.put(consist_addr, consist_desc);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/jmri/enginedriver/throttle.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ private class throttle_handler extends Handler {
public void handleMessage(Message msg) {
String response_str = msg.obj.toString();

Log.d("Engine_Driver", "throttle handleMessage " + response_str );
// Log.d("Engine_Driver", "throttle handleMessage " + response_str );

switch (msg.what) {
case message_type.RESPONSE: { // handle messages from WiThrottle server
Expand Down

0 comments on commit 3d2ffae

Please sign in to comment.