├── LICENSE.txt ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── MobileModbus ├── libs │ └── android-support-v4.jar ├── src │ └── main │ │ ├── res │ │ ├── drawable-hdpi │ │ │ ├── ic_drawer.png │ │ │ ├── indicator.png │ │ │ ├── ic_launcher.png │ │ │ └── drawer_shadow.9.png │ │ ├── drawable-ldpi │ │ │ ├── indicator.png │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ ├── ic_drawer.png │ │ │ ├── indicator.png │ │ │ ├── ic_launcher.png │ │ │ └── drawer_shadow.9.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_drawer.png │ │ │ ├── ic_launcher.png │ │ │ ├── indicator.png │ │ │ └── drawer_shadow.9.png │ │ ├── color │ │ │ └── colors.xml │ │ ├── _pre-production_src-files-drawables │ │ │ ├── edit.png │ │ │ ├── edit_svg.png │ │ │ ├── path5622.png │ │ │ ├── edit_svg_96x96.png │ │ │ ├── edit_svg_96x96.xcf │ │ │ ├── ic_dialog_edit.png │ │ │ ├── ic_menu_disconnect.zip │ │ │ ├── ic_menu_connect_144x144.png │ │ │ ├── ic_menu_connect_144x144_2.png │ │ │ ├── mobilemodbus_icon_480x480.png │ │ │ ├── mobilemodbus_icon_72x72.png │ │ │ ├── ic_menu_disconnect_144x144.png │ │ │ ├── ic_menu_disconnect_144x144_2.png │ │ │ ├── mobilemodbus_icon_36x36-ldpi.png │ │ │ ├── mobilemodbus_icon_48x48-mdpi.png │ │ │ ├── mobilemodbus_icon_96x96-xdpi.png │ │ │ ├── mobilemodbus_icon(playbook)-512x512.png │ │ │ ├── Android_Navigation_Drawer_Icon_20130516.zip │ │ │ ├── edit.svg │ │ │ ├── Connect.svg │ │ │ ├── disconnect.svg │ │ │ └── modbusdroid_icon_2.0.svg │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── styles.xml │ │ │ ├── arrays.xml │ │ │ └── strings.xml │ │ ├── layout │ │ │ ├── menu_frame.xml │ │ │ ├── company_info_layout.xml │ │ │ ├── modbus_data_fragment.xml │ │ │ ├── basic_menu.xml │ │ │ ├── value_row.xml │ │ │ └── activity_modbusdataview.xml │ │ ├── drawable │ │ │ ├── defaultshadow.xml │ │ │ ├── menu_boarder.xml │ │ │ └── menu_outline.xml │ │ ├── values-v11 │ │ │ └── styles.xml │ │ ├── values-v14 │ │ │ └── styles.xml │ │ ├── menu │ │ │ └── menu_modbusdataview │ │ ├── layout-sw600dp │ │ │ └── modbus_data_fragment.xml │ │ └── xml │ │ │ └── preferences_basic_menu.xml │ │ ├── java │ │ └── com │ │ │ └── bencatlin │ │ │ └── mobilemodbus │ │ │ ├── interfaces │ │ │ └── ModbusBatchProvider.java │ │ │ ├── system │ │ │ └── BatchManager.java │ │ │ ├── preferencetypes │ │ │ └── IntEditTextPreference.java │ │ │ ├── util │ │ │ ├── base │ │ │ │ ├── IStrictMode.java │ │ │ │ └── SharedPreferenceSaver.java │ │ │ ├── LegacySharedPreferenceSaver.java │ │ │ ├── LegacyStrictMode.java │ │ │ ├── HoneycombStrictMode.java │ │ │ ├── FroyoSharedPreferenceSaver.java │ │ │ ├── GingerbreadSharedPreferenceSaver.java │ │ │ └── PlatformSpecificImplementationFactory.java │ │ │ ├── MMBackupAgent.java │ │ │ ├── ui │ │ │ ├── fragments │ │ │ │ ├── ModbusDataViewFragment.java │ │ │ │ └── BasicSlidingMenuFragment.java │ │ │ └── ModbusDataViewActivity.java │ │ │ ├── MMConstants.java │ │ │ └── PollingService.java │ │ └── AndroidManifest.xml └── build.gradle ├── Libraries └── Modbus4J │ └── build.gradle ├── .gitignore ├── README.md ├── gradlew.bat └── gradlew /LICENSE.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':MobileModbus', ':Libraries:Modbus4J'//, ':Libraries:SlidingMenu:SlidingMenu' -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /MobileModbus/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/libs/android-support-v4.jar -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-hdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-hdpi/ic_drawer.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-hdpi/indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-hdpi/indicator.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-ldpi/indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-ldpi/indicator.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-mdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-mdpi/ic_drawer.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-mdpi/indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-mdpi/indicator.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-xhdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-xhdpi/ic_drawer.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-xhdpi/indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-xhdpi/indicator.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-hdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-hdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-mdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-mdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable-xhdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/drawable-xhdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/color/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/edit.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/edit_svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/edit_svg.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/path5622.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/path5622.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/edit_svg_96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/edit_svg_96x96.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/edit_svg_96x96.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/edit_svg_96x96.xcf -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_dialog_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_dialog_edit.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6dp 4 | 45dp 5 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_disconnect.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_disconnect.zip -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_connect_144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_connect_144x144.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_connect_144x144_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_connect_144x144_2.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_480x480.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_480x480.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_72x72.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_disconnect_144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_disconnect_144x144.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_disconnect_144x144_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/ic_menu_disconnect_144x144_2.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_36x36-ldpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_36x36-ldpi.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_48x48-mdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_48x48-mdpi.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_96x96-xdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon_96x96-xdpi.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon(playbook)-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/mobilemodbus_icon(playbook)-512x512.png -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/Android_Navigation_Drawer_Icon_20130516.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcat/Mobile-Modbus/HEAD/MobileModbus/src/main/res/_pre-production_src-files-drawables/Android_Navigation_Drawer_Icon_20130516.zip -------------------------------------------------------------------------------- /MobileModbus/src/main/res/layout/menu_frame.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jan 02 18:18:01 CST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-rc-3-bin.zip 7 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable/defaultshadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /Libraries/Modbus4J/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | dependencies { 4 | compile files ('lib/seroUtils.jar', 'lib/commons-lang3-3.0.jar', 'lib/commons-logging-1.0.4.jar', 'lib/RXTXcomm.jar', 'lib/serotonin-timer.jar') 5 | } 6 | 7 | //ant.importBuild('build.xml') 8 | 9 | 10 | sourceSets { 11 | main { 12 | java.srcDirs = ['src', 'src_cdc'] 13 | 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/interfaces/ModbusBatchProvider.java: -------------------------------------------------------------------------------- 1 | package com.bencatlin.mobilemodbus.interfaces; 2 | 3 | import com.serotonin.modbus4j.BatchRead; 4 | 5 | /**************************************************************** 6 | * 7 | * 8 | * 9 | * 10 | ****************************************************************/ 11 | public interface ModbusBatchProvider { 12 | 13 | public BatchRead getBatch(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/menu/menu_modbusdataview: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/system/BatchManager.java: -------------------------------------------------------------------------------- 1 | package com.bencatlin.mobilemodbus.system; 2 | 3 | /************************************************* 4 | * 5 | * 6 | * 7 | *************************************************/ 8 | public class BatchManager { 9 | 10 | private static BatchManager mInstance = new BatchManager(); 11 | 12 | private BatchManager () { 13 | 14 | } 15 | 16 | public static BatchManager getInstance() { 17 | 18 | 19 | return mInstance; 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable/menu_boarder.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/layout/company_info_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | -------------------------------------------------------------------------------- /MobileModbus/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:0.7.+' 7 | } 8 | } 9 | apply plugin: 'android' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | compile 'com.android.support:support-v4:19.+' 17 | compile 'com.android.support:appcompat-v7:19.+' 18 | compile project(':Libraries:Modbus4J') 19 | } 20 | 21 | android { 22 | compileSdkVersion 19 23 | buildToolsVersion "19.0" 24 | 25 | defaultConfig { 26 | minSdkVersion 14 27 | targetSdkVersion 19 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/layout/modbus_data_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/layout-sw600dp/modbus_data_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Menu Item 1 5 | Menu Item 2 6 | Menu Item 3 7 | 8 | 9 | Input Coils (Read-Only Bits) 10 | Holding Coils (Read-Write Bits) 11 | Input Registers (Read-Only Words) 12 | Holding Registers (Read-Write Words) 13 | 14 | 15 | 0 16 | 1 17 | 3 18 | 4 19 | 20 | 21 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/drawable/menu_outline.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 11 | 12 | 13 | 14 | 19 | 20 | 23 | 24 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Blatantly stolen from ActionbarSherlock 2 | # 3 | 4 | # Java class files 5 | *.class 6 | 7 | #Android generated 8 | bin 9 | gen 10 | lint.xml 11 | 12 | # built application files 13 | *.apk 14 | *.ap_ 15 | 16 | # files for the dex VM 17 | *.dex 18 | 19 | #Eclipse 20 | .project 21 | .classpath 22 | .settings 23 | .checkstyle 24 | 25 | #IntelliJ IDEA 26 | .idea 27 | *.iml 28 | *.ipr 29 | *.iws 30 | classes 31 | gen-external-apklibs 32 | 33 | # Android Studio 34 | .idea/ 35 | .gradle 36 | /*/local.properties 37 | /*/out 38 | /*/*/build 39 | /*/build 40 | /*/*/production 41 | *~ 42 | *.swp 43 | 44 | # Local configuration file (sdk path, etc) 45 | local.properties 46 | 47 | #Maven 48 | target 49 | release.properties 50 | pom.xml.* 51 | 52 | #Ant 53 | build.xml 54 | ant.properties 55 | local.properties 56 | proguard.cfg 57 | proguard-project.txt 58 | 59 | #Other 60 | .DS_Store 61 | tmp 62 | 63 | # generated files 64 | bin/ 65 | gen/ 66 | 67 | #Progject specific 68 | Libraries/* 69 | !Libraries/Modbus4J/build.gradle 70 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/preferencetypes/IntEditTextPreference.java: -------------------------------------------------------------------------------- 1 | package com.bencatlin.mobilemodbus.preferencetypes; 2 | 3 | import android.content.Context; 4 | import android.preference.EditTextPreference; 5 | import android.util.AttributeSet; 6 | 7 | public class IntEditTextPreference extends EditTextPreference { 8 | 9 | 10 | public IntEditTextPreference(Context context) { 11 | super(context); 12 | } 13 | 14 | public IntEditTextPreference(Context context, AttributeSet attrs) { 15 | super(context, attrs); 16 | } 17 | 18 | public IntEditTextPreference(Context context, AttributeSet attrs, int defStyle) { 19 | super(context, attrs, defStyle); 20 | } 21 | 22 | @Override 23 | protected String getPersistedString(String defaultReturnValue) { 24 | return String.valueOf(getPersistedInt(-1)); 25 | } 26 | 27 | @Override 28 | protected boolean persistString(String value) { 29 | return persistInt(Integer.valueOf(value)); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/util/base/IStrictMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus.util.base; 18 | 19 | /** 20 | * This Interface definition allows you to create OS version-specific 21 | * implementations that offer the full Strict Mode functionality 22 | * available in each platform release. 23 | */ 24 | public interface IStrictMode { 25 | /** 26 | * Enable {@link StrictMode} using whichever platform-specific flags you wish. 27 | */ 28 | public void enableStrictMode(); 29 | } 30 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/layout/basic_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 24 | 25 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/layout/value_row.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 26 | 27 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/MMBackupAgent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus; 18 | 19 | import android.app.backup.BackupAgentHelper; 20 | import android.app.backup.SharedPreferencesBackupHelper; 21 | 22 | /** 23 | * A class that specifies which of the shared preferences you want to backup 24 | * to the Google Backup Service. 25 | */ 26 | public class MMBackupAgent extends BackupAgentHelper { 27 | @Override 28 | public void onCreate() { 29 | SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, MMConstants.SHARED_PREFERENCE_FILE); 30 | //addHelper(MMConstants.SP_KEY_FOLLOW_LOCATION_CHANGES, helper); 31 | // TODO Add additional helpers for each of the preferences you want to backup. 32 | } 33 | } -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/util/LegacySharedPreferenceSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus.util; 18 | 19 | import android.content.Context; 20 | import android.content.SharedPreferences; 21 | import android.content.SharedPreferences.Editor; 22 | 23 | import com.bencatlin.mobilemodbus.util.base.SharedPreferenceSaver; 24 | 25 | /** 26 | * Save {@link SharedPreferences} in a way compatible with Android 1.6. 27 | */ 28 | public class LegacySharedPreferenceSaver extends SharedPreferenceSaver { 29 | 30 | public LegacySharedPreferenceSaver(Context context) { 31 | super(context); 32 | } 33 | 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | @Override 38 | public void savePreferences(Editor editor, boolean backup) { 39 | editor.commit(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MobileModbus/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/util/LegacyStrictMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus.util; 18 | 19 | import com.bencatlin.mobilemodbus.util.base.IStrictMode; 20 | 21 | import android.os.StrictMode; 22 | 23 | /** 24 | * Implementation that supports the Strict Mode functionality 25 | * available for the first platform release that supported Strict Mode. 26 | */ 27 | public class LegacyStrictMode implements IStrictMode { 28 | 29 | /** 30 | * Enable {@link StrictMode} 31 | * TODO Set your preferred Strict Mode features. 32 | */ 33 | public void enableStrictMode() { 34 | StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() 35 | .detectDiskReads() 36 | .detectDiskWrites() 37 | .detectNetwork() 38 | .penaltyLog() 39 | .build()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/util/HoneycombStrictMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus.util; 18 | 19 | import android.os.StrictMode; 20 | 21 | import com.bencatlin.mobilemodbus.util.base.IStrictMode; 22 | 23 | /** 24 | * Implementation that supports the Strict Mode functionality 25 | * available Honeycomb. 26 | */ 27 | public class HoneycombStrictMode implements IStrictMode { 28 | protected static String TAG = "HoneycombStrictMode"; 29 | 30 | /** 31 | * Enable {@link StrictMode} 32 | * TODO Set your preferred Strict Mode features. 33 | */ 34 | public void enableStrictMode() { 35 | StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() 36 | .detectDiskReads() 37 | .detectDiskWrites() 38 | .detectNetwork() 39 | .penaltyLog() 40 | .penaltyFlashScreen() 41 | .build()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/ui/fragments/ModbusDataViewFragment.java: -------------------------------------------------------------------------------- 1 | package com.bencatlin.mobilemodbus.ui.fragments; 2 | /****************************************************************************** 3 | * ModbusDataViewFragment 4 | * 5 | * Fragment used to display the data returned from the modbus batch. 6 | * 7 | * For a tablet this shows a gridview with a varying number of columns 8 | * depending on screen width, and for a phone a listview. 9 | * 10 | * 11 | * 12 | * @author ben@bencatlin.com 13 | *****************************************************************************/ 14 | 15 | import android.app.Fragment; 16 | import android.os.Bundle; 17 | import android.view.LayoutInflater; 18 | import android.view.View; 19 | import android.view.ViewGroup; 20 | import android.widget.AbsListView; 21 | import com.bencatlin.mobilemodbus.R; 22 | 23 | public class ModbusDataViewFragment extends Fragment { 24 | 25 | // This will hold our view - it is an AbsListView because that is a 26 | // common ancestor to both ListView and GridView - we will do 27 | // type-specific work in the buildViewDetails method 28 | private AbsListView mDataView; 29 | 30 | @Override 31 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 32 | Bundle savedInstanceState) { 33 | 34 | mDataView = (AbsListView) inflater.inflate(R.layout.modbus_data_fragment, container, false); 35 | 36 | return mDataView; 37 | } 38 | 39 | private void buildViewDetails () { 40 | 41 | } 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/util/FroyoSharedPreferenceSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus.util; 18 | 19 | import android.app.backup.BackupManager; 20 | import android.content.Context; 21 | import android.content.SharedPreferences; 22 | import android.content.SharedPreferences.Editor; 23 | 24 | /** 25 | * Save {@link SharedPreferences} and provide the option to notify 26 | * the BackupManager to initiate a backup. 27 | */ 28 | public class FroyoSharedPreferenceSaver extends LegacySharedPreferenceSaver { 29 | 30 | protected BackupManager backupManager; 31 | 32 | public FroyoSharedPreferenceSaver(Context context) { 33 | super(context); 34 | backupManager = new BackupManager(context); 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | @Override 41 | public void savePreferences(Editor editor, boolean backup) { 42 | editor.commit(); 43 | backupManager.dataChanged(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/util/GingerbreadSharedPreferenceSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus.util; 18 | 19 | import android.annotation.TargetApi; 20 | import android.content.Context; 21 | import android.content.SharedPreferences; 22 | import android.os.Build; 23 | 24 | /** 25 | * Save {@link SharedPreferences} using the asynchronous apply method available 26 | * in Gingerbread, and provide the option to notify the BackupManager to 27 | * initiate a backup. 28 | */ 29 | @TargetApi(Build.VERSION_CODES.GINGERBREAD) 30 | public class GingerbreadSharedPreferenceSaver extends FroyoSharedPreferenceSaver { 31 | 32 | public GingerbreadSharedPreferenceSaver(Context context) { 33 | super(context); 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public void savePreferences(SharedPreferences.Editor editor, boolean backup) { 41 | editor.apply(); 42 | backupManager.dataChanged(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/util/base/SharedPreferenceSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus.util.base; 18 | 19 | import android.content.Context; 20 | import android.content.SharedPreferences; 21 | 22 | /** 23 | * Abstract base class that can be extended to provide classes that save 24 | * {@link SharedPreferences} in the most efficient way possible. 25 | * Decendent classes can optionally choose to backup some {@link SharedPreferences} 26 | * to the Google {@link BackupService} on platforms where this is available. 27 | */ 28 | public abstract class SharedPreferenceSaver { 29 | 30 | protected Context context; 31 | 32 | protected SharedPreferenceSaver(Context context) { 33 | this.context = context; 34 | } 35 | 36 | /** 37 | * Save the Shared Preferences modified through the Editor object. 38 | * @param editor Shared Preferences Editor to commit. 39 | * @param backup Backup to the cloud if possible. 40 | */ 41 | public void savePreferences(SharedPreferences.Editor editor, boolean backup) {} 42 | } 43 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/MMConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus; 18 | 19 | public class MMConstants { 20 | 21 | /** 22 | * You'll need to modify these values to suit your own app. 23 | */ 24 | // TODO Turn off when deploying your app. 25 | public static boolean DEVELOPER_MODE = true; 26 | 27 | /** 28 | * These values are constants used for intents, extras, and shared preferences. 29 | * You shouldn't need to modify them. 30 | */ 31 | public static String SHARED_PREFERENCE_FILE = "SHARED_PREFERENCE_FILE"; 32 | public static String SP_KEY_RUN_ONCE = "SP_KEY_RUN_ONCE"; 33 | 34 | public static boolean SUPPORTS_JELLYBEAN = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN; 35 | public static boolean SUPPORTS_ICECRAMSANDWICH = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH; 36 | public static boolean SUPPORTS_GINGERBREAD = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD; 37 | public static boolean SUPPORTS_HONEYCOMB = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB; 38 | public static boolean SUPPORTS_FROYO = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO; 39 | public static boolean SUPPORTS_ECLAIR = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ECLAIR; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/util/PlatformSpecificImplementationFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.bencatlin.mobilemodbus.util; 18 | 19 | import android.content.Context; 20 | 21 | import com.bencatlin.mobilemodbus.MMConstants; 22 | import com.bencatlin.mobilemodbus.util.base.IStrictMode; 23 | import com.bencatlin.mobilemodbus.util.base.SharedPreferenceSaver; 24 | 25 | /** 26 | * Factory class to create the correct instances 27 | * of a variety of classes with platform specific 28 | * implementations. 29 | * 30 | */ 31 | public class PlatformSpecificImplementationFactory { 32 | 33 | 34 | /** 35 | * Create a new StrictMode instance. 36 | * @return StrictMode 37 | */ 38 | public static IStrictMode getStrictMode() { 39 | if (MMConstants.SUPPORTS_HONEYCOMB) 40 | return new HoneycombStrictMode(); 41 | else if (MMConstants.SUPPORTS_GINGERBREAD) 42 | return new LegacyStrictMode(); 43 | else 44 | return null; 45 | } 46 | 47 | 48 | /** 49 | * Create a new SharedPreferenceSaver 50 | * @param context Context 51 | * @return SharedPreferenceSaver 52 | */ 53 | public static SharedPreferenceSaver getSharedPreferenceSaver(Context context) { 54 | return MMConstants.SUPPORTS_GINGERBREAD ? 55 | new GingerbreadSharedPreferenceSaver(context) : 56 | MMConstants.SUPPORTS_FROYO ? 57 | new FroyoSharedPreferenceSaver(context) : 58 | new LegacySharedPreferenceSaver(context); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/layout/activity_modbusdataview.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 14 | 15 | 23 | 24 | 25 | 26 | 27 | 28 | 36 | 42 | 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mobile Modbus 2 | ============= 3 | 4 | ------------------- 5 | 6 | Mobile Modbus is an Android Modbus polling client using modern android UI design guidelines and design patterns such as the Action bar for navigation, a slide-in menu for settings, and appropriately scaled data-display for the device you are working on (i.e. list views on a phone, and a grid on a tablet). And as I love all the new hottness, it also is built in Android Studio using the new gradle-based build system, so you will need to download that to work on this project. 7 | 8 | More info to come as this project develops. Until then feel free to follow along with my [blog](http://www.bencatlin.com) for information, or follow me on [twitter](http://www.twitter.com/bigcat2k). 9 | 10 | 11 | ### Contributing / Reporting Issues 12 | ----------- 13 | 14 | Eventually I'll put some basic stuff here to know how to contribute more easily - but basically for now, fork the project on github, and submit a pull request and I'll evaluate it and add it if it is in line with the goals of the project. 15 | 16 | If you see anything wrong with it in any way or just want to add something to the project, file a ticket or submit a pull request. 17 | 18 | 19 | ### Building 20 | -------------- 21 | 22 | This project relies on two android support libraries, and one 3rd party library: 23 | 24 | * [Modbus4J](http://sourceforge.net/projects/modbus4j/) - a Java Modbus library that is pretty extensible and full-featured with some nice batching functions that we (are going to) make use of. Just download and copy (or CVS-checkout) it into the top-level "Libraries/Modbus4J" folder (whole project). There should already be an appropriate build.gradle in that folder, all ready to build the library. 25 | 26 | 27 | #### License 28 | 29 | ------------ 30 | This project is Apache 2.0, which should be GPL 3.0 compatible, which I/you have to care about because Modbus4J is GPL3. 31 | 32 | I'll add the preamble here sometime soon, and get the class header comments all in line as well. 33 | 34 | -------------- 35 | ###### Last edited by [Ben Catlin](mailto://ben@bencatlin.com) on July 29, 2013 36 | 37 | [![Analytics](https://ga-beacon.appspot.com/UA-75215-3/Mobile-Modbus/ReadMe)](https://github.com/igrigorik/ga-beacon) 38 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/xml/preferences_basic_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 10 | 11 | 17 | 18 | 21 | 28 | 34 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Connect 5 | Settings 6 | 7 | Mobile Modbus 8 | Host Name / IP Address 9 | Port 10 | Length 11 | Slave Address / Unit ID 12 | 13 | Input Discretes 14 | Holding/Output Discretes 15 | Input Registers 16 | Holding/Output Registers 17 | 18 | Brought to you by BigCat Inc.
20 |

For more information about the app and development updates check out the GitHub project homepage.

21 |

This software is based on the Modbus library Modbus4J, created by Seretonin software.

22 |

This app is also open source, licensed under the GPL version 3, and its source code is hosted and available on GitHub.

]]> 23 |
24 | Connection Settings 25 | IP Address / Host Name 26 | Port Number 27 | Modbus Parameters 28 | Data Type 29 | Select a Data Type 30 | 31 | Starting Address Offset 32 | Data Length to Read 33 | 34 | Connection/Modbus Parameters 35 | Mobile Modbus 36 | 37 |
-------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/ui/fragments/BasicSlidingMenuFragment.java: -------------------------------------------------------------------------------- 1 | package com.bencatlin.mobilemodbus.ui.fragments; 2 | /************************************************************************ 3 | * 4 | * 5 | * 6 | * 7 | *************************************************************************/ 8 | 9 | import android.content.Context; 10 | import android.os.Bundle; 11 | import android.preference.PreferenceFragment; 12 | import android.view.LayoutInflater; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | 16 | import com.bencatlin.mobilemodbus.R; 17 | import com.bencatlin.mobilemodbus.interfaces.ModbusBatchProvider; 18 | import com.serotonin.modbus4j.BatchRead; 19 | 20 | 21 | /** 22 | * Class: BasicSlidingMenuFragment 23 | * 24 | * TODO: Check for alternative way to implement a PreferenceFragment in API < v11 25 | * or replace with a ListFragment 26 | */ 27 | public class BasicSlidingMenuFragment extends PreferenceFragment 28 | implements ModbusBatchProvider { 29 | 30 | private Context mContext; 31 | 32 | /* onCreate 33 | * 34 | * (non-Javadoc) 35 | * @see android.preference.PreferenceFragment#onCreate(android.os.Bundle) 36 | */ 37 | @Override 38 | public void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | 41 | // Load the preferences from an XML resource 42 | this.addPreferencesFromResource(R.xml.preferences_basic_menu); 43 | 44 | } 45 | 46 | 47 | @Override 48 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 49 | Bundle savedInstanceState) { 50 | 51 | // Inflate the layout for this fragment 52 | View view = super.onCreateView(inflater, container, savedInstanceState); 53 | view.setBackgroundColor(getResources().getColor(android.R.color.white)); 54 | 55 | return view; 56 | } 57 | 58 | 59 | /* 60 | * onActivityCreated 61 | * 62 | * This is where we instantiate things that require an activity context 63 | * 64 | * (non-Javadoc) 65 | * @see android.preference.PreferenceFragment#onActivityCreated(android.os.Bundle) 66 | */ 67 | /*@Override 68 | public void onActivityCreated(Bundle savedInstanceState) { 69 | super.onActivityCreated(savedInstanceState); 70 | 71 | this.mContext = this.getActivity(); 72 | }*/ 73 | 74 | 75 | /* 76 | * (non-Javadoc) 77 | * @see com.bencatlin.mobilemodbus.interfaces.ModbusBatchProvider#getBatch() 78 | */ 79 | @Override 80 | public BatchRead getBatch() { 81 | // TODO Auto-generated method stub 82 | return null; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/edit.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 39 | 41 | 43 | 47 | 51 | 52 | 54 | 58 | 62 | 63 | 64 | 66 | 67 | 69 | image/svg+xml 70 | 72 | 73 | 74 | 75 | 76 | 80 | 87 | 88 | 93 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/PollingService.java: -------------------------------------------------------------------------------- 1 | package com.bencatlin.mobilemodbus; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.Handler; 6 | import android.os.IBinder; 7 | import android.os.Looper; 8 | import android.os.Message; 9 | import android.util.Log; 10 | 11 | import com.serotonin.modbus4j.BatchRead; 12 | import com.serotonin.modbus4j.BatchResults; 13 | import com.serotonin.modbus4j.ModbusFactory; 14 | import com.serotonin.modbus4j.ModbusMaster; 15 | import com.serotonin.modbus4j.code.DataType; 16 | import com.serotonin.modbus4j.ip.IpParameters; 17 | import com.serotonin.modbus4j.locator.BaseLocator; 18 | 19 | /** 20 | * Created by Ben Catlin on 7/19/13. 21 | */ 22 | public class PollingService extends Service { 23 | 24 | 25 | private boolean mAllowRebind; // indicates whether onRebind should be used 26 | private BatchRead mCurrentBatch; 27 | private PollingRunnable mPollingRunnable; 28 | //private ; //connection data or modbus factory/master 29 | private boolean mConnected = false; 30 | 31 | private class PollingServiceHandler extends Handler 32 | { 33 | 34 | public PollingServiceHandler() { 35 | super(); 36 | } 37 | @Override 38 | public void handleMessage(Message msg) { 39 | // Eventually we need to check what the message is, and respond according. 40 | 41 | // Case statement to check message type, basically we are looking for a "Batch Update" 42 | // to update our batch info. 43 | 44 | // Remove this later 45 | //stopSelf(msg.arg1); 46 | } 47 | } 48 | 49 | 50 | 51 | /*============================================================================================ 52 | * LifeCycle Methods 53 | *===========================================================================================*/ 54 | 55 | @Override 56 | public void onCreate() { 57 | super.onCreate(); 58 | } 59 | 60 | @Override 61 | public IBinder onBind(Intent intent) { 62 | // We need to do some logic here to return the interface if someone exists the client app, 63 | // but wants to continue polling in the background. 64 | return null; 65 | } 66 | 67 | @Override 68 | public int onStartCommand(Intent intent, int flags, int startId) { 69 | // We want this service to continue running until it is explicitly 70 | // stopped, so return sticky. 71 | return START_STICKY; 72 | } 73 | 74 | 75 | 76 | // Not sure if we need this stuff yet???? 77 | 78 | /* 79 | @Override 80 | public boolean onUnbind(Intent intent) { 81 | // All clients have unbound with unbindService() 82 | return mAllowRebind; 83 | } 84 | 85 | @Override 86 | public void onRebind(Intent intent) { 87 | // A client is binding to the service with bindService(), 88 | // after onUnbind() has already been called 89 | } 90 | */ 91 | 92 | @Override 93 | public void onDestroy() { 94 | super.onDestroy(); 95 | // The service is no longer used and is being destroyed 96 | } 97 | 98 | /*========================================================= 99 | * Service-y type stuffs methods 100 | *==========================================================*/ 101 | 102 | 103 | 104 | /*========================================================= 105 | * Setters and Getters 106 | *========================================================*/ 107 | 108 | /** 109 | * @Method setCurrentBatch 110 | * 111 | * Not sure we actually need this? 112 | * 113 | * @param batch 114 | */ 115 | public void setCurrentBatch(BatchRead batch) { 116 | this.mCurrentBatch = batch; 117 | } 118 | 119 | 120 | private class PollingRunnable implements Runnable { 121 | 122 | @Override 123 | public void run() { 124 | // I do stuff at regular intervals 125 | 126 | // This should probably all go somewhere else - and should be done based on 127 | // the user selection of modbus connection type. 128 | IpParameters tcpParameters = new IpParameters(); 129 | tcpParameters.setHost("10.0.0.2"); 130 | 131 | ModbusFactory modbusFactory = new ModbusFactory(); 132 | ModbusMaster master = modbusFactory.createTcpMaster(tcpParameters, true); 133 | // End of parameters that need to be abstracted somewhere better 134 | 135 | if (!mConnected) { 136 | try { 137 | 138 | master.init(); 139 | } 140 | catch (Exception e) { 141 | Log.e( getClass().getSimpleName(), e.getMessage() ); 142 | } 143 | 144 | mConnected = true; 145 | 146 | } 147 | 148 | while (mConnected) { 149 | try { 150 | 151 | // Dummy data 152 | if (mCurrentBatch == null) { 153 | mCurrentBatch = new BatchRead(); 154 | } 155 | 156 | mCurrentBatch.addLocator("40000 sb -1968", 157 | BaseLocator.holdingRegister(1, 40000, DataType.TWO_BYTE_INT_SIGNED)); 158 | 159 | BatchResults results = master.send(mCurrentBatch); 160 | 161 | } 162 | catch (Exception e) { 163 | Log.e( getClass().getSimpleName(), e.getMessage() ); 164 | 165 | mConnected = false; 166 | } 167 | } 168 | 169 | 170 | 171 | 172 | 173 | } 174 | } 175 | 176 | } 177 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /MobileModbus/src/main/java/com/bencatlin/mobilemodbus/ui/ModbusDataViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.bencatlin.mobilemodbus.ui; 2 | /****************************************************************************** 3 | * ModbusDataViewActivity 4 | * 5 | * This is the activity that starts the main application and views. 6 | * 7 | * 8 | * 9 | * @author Ben Catlin 10 | * 11 | * GPL 3.0 12 | * TODO: Add GPL Preamble 13 | * 14 | *****************************************************************************/ 15 | 16 | import android.app.Activity; 17 | //import android.support.v7.app.ActionBar; 18 | import android.app.ActionBar; 19 | import android.app.Fragment; 20 | import android.app.FragmentTransaction; 21 | import android.content.SharedPreferences; 22 | import android.content.SharedPreferences.Editor; 23 | import android.content.pm.PackageInfo; 24 | import android.content.pm.PackageManager.NameNotFoundException; 25 | import android.content.res.Configuration; 26 | import android.os.Bundle; 27 | import android.os.Handler; 28 | import android.preference.PreferenceManager; 29 | import android.util.Log; 30 | import android.view.Menu; 31 | import android.view.MenuInflater; 32 | import android.view.MenuItem; 33 | import android.view.View; 34 | import android.support.v4.app.ActionBarDrawerToggle; 35 | import android.support.v4.widget.DrawerLayout; 36 | import android.support.v4.view.GravityCompat; 37 | 38 | import com.bencatlin.mobilemodbus.MMConstants; 39 | import com.bencatlin.mobilemodbus.R; 40 | import com.bencatlin.mobilemodbus.ui.fragments.BasicSlidingMenuFragment; 41 | 42 | /**============================================================================ 43 | * 44 | * Class: ModbusDataActivity 45 | * 46 | * 47 | *=============================================================================*/ 48 | public class ModbusDataViewActivity extends Activity { 49 | 50 | private String TAG = "MM/MainActivity"; 51 | private static MMConstants mConstants = new MMConstants(); 52 | 53 | private static final String PREF_FIRST_RUN = "first_run"; 54 | 55 | //private Fragment mMenu; 56 | private Fragment mBatchProviderMenu; //This should also implement the menu and batch interface 57 | private ActionBar mActionBar; 58 | private DrawerLayout mMainDrawerLayout; 59 | private ActionBarDrawerToggle mDrawerToggle; 60 | private SharedPreferences mSettings; 61 | private Boolean mFirstRun = false; 62 | private int mVersionNumber = -1; 63 | private Handler mBatchResponseHandler; 64 | 65 | private CharSequence mDrawerTitle = "Connection Options"; 66 | private CharSequence mTitle = "Mobile Modbus"; 67 | 68 | /** 69 | * 70 | * 71 | * 72 | */ 73 | @Override 74 | public void onCreate(Bundle savedInstanceState) { 75 | 76 | /* Get the current version from package */ 77 | PackageInfo pinfo = null; 78 | try { 79 | pinfo = getPackageManager().getPackageInfo(getPackageName(), 0); 80 | } catch (NameNotFoundException e) { 81 | Log.e(TAG, "package info not found."); 82 | } 83 | if (pinfo != null) 84 | mVersionNumber = pinfo.versionCode; 85 | 86 | /* Get settings */ 87 | mSettings = PreferenceManager.getDefaultSharedPreferences(this); 88 | 89 | /* Check if it's the first run */ 90 | mFirstRun = mSettings.getInt(PREF_FIRST_RUN, -1) != mVersionNumber; 91 | if (mFirstRun) { 92 | Editor editor = mSettings.edit(); 93 | editor.putInt(PREF_FIRST_RUN, mVersionNumber); 94 | editor.commit(); 95 | } 96 | 97 | super.onCreate(savedInstanceState); 98 | 99 | /*** Set up some data tracking for user metrics ***/ 100 | 101 | 102 | /*** Start initializing the UI ***/ 103 | 104 | // Set up the content 105 | setContentView( R.layout.activity_modbusdataview ); 106 | mMainDrawerLayout = (DrawerLayout) findViewById(R.id.main_activity_drawer_layout); 107 | mMainDrawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START ); 108 | 109 | 110 | this.buildMenu(); 111 | 112 | 113 | /* Set up the handler for our batch responses */ 114 | 115 | mBatchResponseHandler = getWindow().getDecorView().getHandler(); 116 | 117 | 118 | /* Initialize UI variables */ 119 | 120 | /* Set up the action bar */ 121 | mActionBar = this.getActionBar(); 122 | mActionBar.setDisplayHomeAsUpEnabled( true ); 123 | mActionBar.setHomeButtonEnabled( true ); 124 | mDrawerToggle.syncState(); 125 | 126 | 127 | } 128 | 129 | /** 130 | * 131 | * @param savedInstanceState 132 | */ 133 | @Override 134 | protected void onPostCreate(Bundle savedInstanceState) { 135 | super.onPostCreate(savedInstanceState); 136 | // Sync the toggle state after onRestoreInstanceState has occurred. 137 | mDrawerToggle.syncState(); 138 | } 139 | 140 | 141 | /** 142 | * 143 | * @param newConfig 144 | */ 145 | @Override 146 | public void onConfigurationChanged(Configuration newConfig) { 147 | super.onConfigurationChanged(newConfig); 148 | mDrawerToggle.onConfigurationChanged(newConfig); 149 | } 150 | 151 | 152 | /** 153 | * 154 | */ 155 | /*@Override 156 | public boolean onOptionsItemSelected(MenuItem item) { 157 | switch (item.getItemId()) { 158 | case android.R.id.home: 159 | mMenu.toggle(); 160 | return true; 161 | } 162 | return super.onOptionsItemSelected(item); 163 | }*/ 164 | 165 | /** 166 | * 167 | */ 168 | @Override 169 | public boolean onCreateOptionsMenu(Menu menu) { 170 | MenuInflater inflater = getMenuInflater(); 171 | inflater.inflate(R.menu.menu_modbusdataview, menu); 172 | return true; 173 | } 174 | 175 | /* Called whenever we call invalidateOptionsMenu() */ 176 | 177 | /** 178 | * 179 | * @param menu 180 | * @return 181 | */ 182 | @Override 183 | public boolean onPrepareOptionsMenu(Menu menu) { 184 | // If the nav drawer is open, hide action items related to the content view 185 | //boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); 186 | //menu.findItem(R.id.action_websearch).setVisible(!drawerOpen); 187 | return super.onPrepareOptionsMenu(menu); 188 | } 189 | 190 | @Override 191 | public boolean onOptionsItemSelected(MenuItem item) { 192 | // Pass the event to ActionBarDrawerToggle, if it returns 193 | // true, then it has handled the app icon touch event 194 | if (mDrawerToggle.onOptionsItemSelected(item)) { 195 | return true; 196 | } 197 | // Handle your other action bar items... 198 | 199 | return super.onOptionsItemSelected(item); 200 | } 201 | 202 | 203 | /*----------------------------------------------------------------------- 204 | * Private Methods 205 | *-----------------------------------------------------------------------*/ 206 | 207 | /* 208 | * buildMenu 209 | * 210 | * Builds the local menu with the correct parameters 211 | * 212 | */ 213 | private void buildMenu() { 214 | 215 | mTitle = getResources().getString( R.string.drawer_closed_title ); 216 | mDrawerTitle = getResources().getString( R.string.drawer_open_title ); 217 | 218 | mDrawerToggle = new ActionBarDrawerToggle( 219 | this, 220 | mMainDrawerLayout, 221 | R.drawable.ic_drawer, 222 | R.string.drawer_open_title, 223 | R.string.drawer_closed_title) { 224 | 225 | /** Called when a drawer has settled in a completely closed state. */ 226 | public void onDrawerClosed(View view) { 227 | getActionBar().setTitle(mTitle); 228 | invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() 229 | } 230 | 231 | /** Called when a drawer has settled in a completely open state. */ 232 | public void onDrawerOpened(View drawerView) { 233 | getActionBar().setTitle(mDrawerTitle); 234 | invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() 235 | } 236 | }; 237 | 238 | // Set the drawer toggle as the DrawerListener 239 | mMainDrawerLayout.setDrawerListener(mDrawerToggle); 240 | 241 | 242 | } 243 | 244 | 245 | } 246 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/Connect.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 25 | 27 | 31 | 35 | 36 | 45 | 54 | 56 | 60 | 64 | 65 | 73 | 77 | 78 | 87 | 89 | 93 | 97 | 98 | 102 | 106 | 107 | 116 | 118 | 122 | 126 | 127 | 137 | 147 | 150 | 155 | 156 | 166 | 175 | 177 | 181 | 185 | 186 | 196 | 203 | 207 | 208 | 217 | 219 | 223 | 227 | 228 | 237 | 239 | 243 | 247 | 248 | 258 | 261 | 266 | 267 | 277 | 280 | 284 | 285 | 286 | 310 | 312 | 313 | 315 | image/svg+xml 316 | 318 | 319 | 320 | 321 | 322 | 334 | 340 | 346 | 347 | 352 | 358 | 359 | 360 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/disconnect.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 25 | 27 | 31 | 35 | 36 | 45 | 54 | 56 | 60 | 64 | 65 | 74 | 76 | 80 | 84 | 85 | 89 | 93 | 94 | 103 | 105 | 109 | 113 | 114 | 124 | 134 | 137 | 142 | 143 | 153 | 162 | 164 | 168 | 172 | 173 | 181 | 185 | 186 | 195 | 197 | 201 | 205 | 206 | 210 | 214 | 215 | 224 | 226 | 230 | 234 | 235 | 245 | 255 | 258 | 264 | 265 | 275 | 276 | 300 | 302 | 303 | 305 | image/svg+xml 306 | 308 | 309 | 310 | 311 | 312 | 317 | 323 | 324 | 330 | 337 | 338 | 343 | 350 | 351 | 352 | -------------------------------------------------------------------------------- /MobileModbus/src/main/res/_pre-production_src-files-drawables/modbusdroid_icon_2.0.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 41 | 43 | 45 | 49 | 53 | 54 | 57 | 61 | 65 | 66 | 68 | 72 | 76 | 77 | 79 | 83 | 87 | 91 | 95 | 99 | 103 | 107 | 108 | 110 | 114 | 118 | 122 | 126 | 130 | 134 | 138 | 139 | 146 | 153 | 155 | 159 | 163 | 164 | 166 | 170 | 174 | 175 | 177 | 181 | 185 | 186 | 188 | 192 | 196 | 197 | 199 | 203 | 207 | 208 | 210 | 214 | 218 | 219 | 221 | 225 | 229 | 230 | 232 | 236 | 240 | 241 | 243 | 247 | 251 | 252 | 254 | 258 | 262 | 263 | 265 | 269 | 273 | 274 | 276 | 280 | 284 | 285 | 294 | 296 | 300 | 304 | 305 | 315 | 317 | 321 | 325 | 326 | 336 | 338 | 342 | 346 | 347 | 349 | 353 | 357 | 358 | 362 | 366 | 367 | 376 | 385 | 394 | 396 | 400 | 404 | 405 | 414 | 416 | 420 | 424 | 425 | 435 | 437 | 441 | 445 | 446 | 456 | 458 | 462 | 466 | 467 | 469 | 473 | 477 | 478 | 488 | 497 | 506 | 515 | 517 | 521 | 525 | 526 | 536 | 546 | 556 | 566 | 568 | 572 | 576 | 577 | 587 | 589 | 593 | 597 | 598 | 608 | 617 | 626 | 635 | 637 | 641 | 645 | 646 | 656 | 666 | 668 | 672 | 676 | 677 | 687 | 697 | 707 | 709 | 713 | 717 | 718 | 728 | 729 | 731 | 732 | 734 | image/svg+xml 735 | 737 | 738 | 739 | 740 | 741 | 746 | 749 | 754 | 764 | 774 | 784 | 794 | 804 | 814 | 822 | 823 | 824 | 829 | 833 | 840 | 846 | 847 | 851 | 858 | 864 | 865 | 866 | 872 | 878 | 884 | 890 | 893 | 900 | 906 | 907 | 913 | 919 | 925 | 931 | 932 | 938 | 945 | 946 | 952 | 956 | 961 | 966 | 971 | 972 | 973 | 1003 | 1004 | --------------------------------------------------------------------------------