--------------------------------------------------------------------------------
/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 | [](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 |