/* * This file is part of the Remote Sensor Actuator Interface (ReSAI). * * Copyright(c) Andreas Kipp, Frederic Siepmann * http://opensource.cit-ec.de/projects/resai * * This file may be licensed under the terms of of the * GNU Lesser General Public License Version 3 (the ``LGPL''), * or (at your option) any later version. * * Software distributed under the License is distributed * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the LGPL for the specific language * governing rights and limitations. * * You should have received a copy of the LGPL along with this * program. If not, go to http://www.gnu.org/licenses/lgpl.html * or write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The development of this software was supported by the * Excellence Cluster EXC 277 Cognitive Interaction Technology. * The Excellence Cluster EXC 277 is a grant of the Deutsche * Forschungsgemeinschaft (DFG) in the context of the German * Excellence Initiative. * */ /** * Tab showing information from navigation acturator. * * @author akipp */ package de.unibi.airobots.resaidroid.tabactivities; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import de.unibi.airobots.resaidroid.R; import de.unibi.airobots.resaidroid.constants.ServerConfig; import de.unibi.airobots.resaidroid.tabactivities.template.TabTemplate; public class TabNavigationActuator extends TabTemplate { private static TextView lblGoalX; private static TextView lblGoalY; private static TextView lblStatus; private static Button btnForward; private static Button btnBackward; private static Button btnLeft; private static Button btnRight; private static Button btnStop; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.navigationactuator); lblGoalX = (TextView) findViewById(R.id.lblGoalX); lblGoalY = (TextView) findViewById(R.id.lblGoalY); lblStatus = (TextView) findViewById(R.id.Status); btnForward = (Button) findViewById(R.id.btnForward); btnForward.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendNavCommand("FORWARD"); } }); btnBackward = (Button) findViewById(R.id.btnBackward); btnBackward.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendNavCommand("BACKWARD"); } }); btnLeft = (Button) findViewById(R.id.btnLeft); btnLeft.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendNavCommand("LEFT"); } }); btnRight = (Button) findViewById(R.id.btnRight); btnRight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendNavCommand("RIGHT"); } }); btnStop = (Button) findViewById(R.id.btnStop); btnStop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendNavCommand("MANUALSTOP"); } }); } @Override public void processProperties() { messageHandler.post(new Runnable() { public void run() { try { synchronized (receivedProperties) { lblStatus.setText(mIn.getProperty( cm.getComponent(TAG) + "_STATUS").toString()); lblGoalX.setText(mIn.getProperty( cm.getComponent(TAG) + "_GOAL_X").toString()); lblGoalY.setText(mIn.getProperty( cm.getComponent(TAG) + "_GOAL_Y").toString()); } } catch (Exception e) { // TODO Log.i(TAG, "ERROR: " + e.getMessage()); } } }); } private void sendNavCommand(String command) { addProperty("TAG", "NavigationActuatorThread"); addProperty("NavigationActuatorThread", "True"); addProperty(command, "true"); sendMessage(ServerConfig.RECIPIENT_FULL); } }