Index: branches/mavlink/tools/Controller/Mavlink/src/Mavlink_test.cpp
===================================================================
--- branches/mavlink/tools/Controller/Mavlink/src/Mavlink_test.cpp	(revision 71)
+++ 	(revision )
@@ -1,366 +1,0 @@
-// %flair:license{
-// This file is part of the Flair framework distributed under the
-// CECILL-C License, Version 1.0.
-// %flair:license}
-//  created:    2016/07/05
-//  filename:   Mavlink_test.cpp
-//
-//  author:     Thomas Fuhrmann
-//              Copyright Heudiasyc UMR UTC/CNRS 7253
-//
-//  version:    $Id: $
-//
-//  purpose:    Base class for host side remote controls that talks to target
-//  side through ethernet connection
-//
-//
-/*********************************************************************/
-#include "Mavlink_test.h"
-
-#include <Controller.h>
-#include <cvmatrix.h>
-#include <Tab.h>
-#include <TabWidget.h>
-#include <CheckBox.h>
-#include <Label.h>
-#include <DataPlot1D.h>
-#include <SpinBox.h>
-#include <FrameworkManager.h>
-#include <Socket.h>
-#include <sstream>
-
-#include <DoubleSpinBox.h>
-#include <PushButton.h>
-#include <ComboBox.h>
-#include <GroupBox.h>
-#include <ListWidget.h>
-
-#include "mavlink.h"
-
-#include <iostream>
-
-using namespace flair::core;
-using namespace flair::gui;
-using namespace std;
-
-namespace flair {
-namespace sensor {
-
-Mavlink::Mavlink(const FrameworkManager *parent, string name,
-                  string receiverAddress, int receiverPort)
-                  : Thread(parent, name, 6),
-                  tab(new Tab(parent->GetTabWidget(), name)) {
-
-  tabWidget = new TabWidget(tab->NewRow(), name);
-
-  // Main tab
-  Tab* settingsTab = new Tab(tabWidget, "Settings");
-  
-  // Controls group
-  controlsGroupBox = new GroupBox(settingsTab->NewRow(), "Controls");
-  btn_initialize = new PushButton(controlsGroupBox->LastRowLastCol(), "Initialize");
-  btn_start_mission = new PushButton(controlsGroupBox->LastRowLastCol(), "Start mission");
-  btn_stop_mission = new PushButton(controlsGroupBox->LastRowLastCol(), "Stop mission");
-  btn_kill = new PushButton(controlsGroupBox->LastRowLastCol(), "Kill");
-
-  // Add wpt group
-  add_wptGroupBox = new GroupBox(settingsTab->NewRow(), "Add waypoint");
-  latField = new DoubleSpinBox(add_wptGroupBox->NewRow(), "Latitude",
-                                -90, 90, 0.001, 3, 3);
-  lonField = new DoubleSpinBox(add_wptGroupBox->LastRowLastCol(), "Longitude",
-                                -180, 180, 0.001, 3, 3);
-  btn_add_mission_wpt = new PushButton(add_wptGroupBox->NewRow(), "Add mission wpt");
-  btn_add_entrance_wpt = new PushButton(add_wptGroupBox->LastRowLastCol(), "Add entrance wpt");
-  btn_add_exit_wpt = new PushButton(add_wptGroupBox->LastRowLastCol(), "Add exit wpt");
-
-  // Show wpt group
-  show_wptGroupBox = new GroupBox(settingsTab->NewRow(), "Show waypoints");
-  list_mission_wpt = new ListWidget(show_wptGroupBox->NewRow(), "Mission wpt");
-  list_entrance_wpt = new ListWidget(show_wptGroupBox->LastRowLastCol(), "Entrance wpt");
-  list_exit_wpt = new ListWidget(show_wptGroupBox->LastRowLastCol(), "Exit wpt");
-  btn_remove_mission_wpt = new PushButton(show_wptGroupBox->NewRow(), "Remove mission wpt");
-  btn_remove_entrance_wpt = new PushButton(show_wptGroupBox->LastRowLastCol(), "Remove entrance wpt");
-  btn_remove_exit_wpt = new PushButton(show_wptGroupBox->LastRowLastCol(), "Remove exit wpt");
-
-  // Action wpt group
-  action_wptGroupBox = new GroupBox(settingsTab->NewRow(), "Action");
-  btn_send_wpt = new PushButton(action_wptGroupBox->NewRow(), "Send wpt");
-  btn_clear_wpt = new PushButton(action_wptGroupBox->LastRowLastCol(), "Clear wpt");
-  btn_loop = new PushButton(action_wptGroupBox->LastRowLastCol(), "Loop");
-
-  mavlinkSocket = new Socket((Thread *)this, "mavlink socket", "127.0.0.1:5000");
-  
-  recvSocket = new Socket((Thread *)this, "recv socket", "127.0.0.1:5001");
-
-}
-
-Mavlink::~Mavlink() {
-}
-
-void Mavlink::Run() {
-  Thread::Info("Debug: enter mavlink acquisition loop\n");
-
-  // double latValue;
-  // double lonValue;
-
-  Message *msgControllerAction = new Message(1024);
-
-  if (getFrameworkManager()->ErrorOccured()) {
-    SafeStop();
-    Thread::Err("An error occurred, we don't launch the Run loop.\n");
-  }
-
-  while (!ToBeStopped()) {
-    // Thread::Info("Debug: Mavlink acquisition loop\n");
-    Thread::SleepMS(500);
-    // latValue = latField->Value();
-    // lonValue = lonField->Value();
-	
-  	if (btn_initialize->Clicked()) {
-  		MissionInitialize();
-    }
-  	if (btn_start_mission->Clicked()) {
-  		MissionStart();
-    }
-  	if (btn_stop_mission->Clicked()) {
-  		MissionStop();
-    }
-  	if (btn_kill->Clicked()) {
-  		MissionKill();
-    }
-  	if (btn_add_mission_wpt->Clicked()) {
-  		list_mission_wpt->AddItem(GetWptLatLon());
-    }
-  	if (btn_add_entrance_wpt->Clicked()) {
-  		list_entrance_wpt->AddItem(GetWptLatLon());
-    }
-  	if (btn_add_exit_wpt->Clicked()) {
-  		list_exit_wpt->AddItem(GetWptLatLon());
-    }
-    if (btn_remove_mission_wpt->Clicked()) {
-      list_mission_wpt->RemoveItem();
-    }
-    if (btn_remove_entrance_wpt->Clicked()) {
-      list_entrance_wpt->RemoveItem();
-    }
-    if (btn_remove_exit_wpt->Clicked()) {
-      list_exit_wpt->RemoveItem();
-    }
-    if (btn_send_wpt->Clicked()) {
-  		WptSend();
-    }
-  	if (btn_clear_wpt->Clicked()) {
-  		WptClear();
-    }
-  	if (btn_loop->Clicked()) {
-  		WptLoopSend();
-    }
-
-    // Thread::Info("Debug: Lat=%f, Lon=%f\n", latValue, lonValue);
-  }
-}
-
-void Mavlink::SendAllWptMessage() {
-  Thread::Info("Debug: SendAllWptMessage\n");
-  // SendWptMessage(latField_wpt0, lonField_wpt0);
-  // SendWptMessage(latField_wpt1, lonField_wpt1);
-  // SendWptMessage(latField_wpt2, lonField_wpt2);
-  // SendWptMessage(latField_wpt3, lonField_wpt3);
-}
-
-void Mavlink::SendWptMessage(gui::DoubleSpinBox* latField, gui::DoubleSpinBox* lonField) {
-
-// (uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
-// uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, 
-// float param1, float param2, float param3, float param4, float x, float y, float z)
-
-
-  Thread::Info("Debug: SendWptMessage\n");
-  mavlink_message_t msg;
-
-  mavlink_msg_mission_item_pack(100, 200, &msg, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, latField->Value(), lonField->Value(), 5);
-
-
-  uint8_t buf[MAVLINK_MAX_PACKET_LEN];
-  uint16_t buf_size = mavlink_msg_to_send_buffer(buf, &msg);
-
-  // //print the buffer
-  // Thread::Info("Debug: DecodeWptMessage : u8 message (buf : %d) :\n", buf_size);
-  // for(uint8_t index = 0; index < buf_size; index++) {
-  //   Thread::Info("%d\n", buf[index]);
-  // }
-
-  std::string message_to_send = U8toString(buf, buf_size);
-
-  //send the message
-  mavlinkSocket->SendMessage(message_to_send); 
-
-  DecodeWptMessage(message_to_send);
-
-}
-
-void Mavlink::DecodeWptMessage(std::string wpt_to_decode) {
-
-  Thread::Info("Debug: start of decode loop\n");
-
-  mavlink_message_t rcv_msg;
-  mavlink_status_t rcv_status;
-
-  float received_x;
-  float received_y;
-
-  const char * message_to_decode = wpt_to_decode.c_str();
-  uint8_t message_size = wpt_to_decode.size();
-
-  // Thread::Info("Debug: DecodeWptMessage : u8 message (buf : %d) :\n", message_size);
-
-  for (uint8_t index = 0; index < message_size; index++) {
-
-    //Thread::Info("Hexa data before cast : %02x\n", data_buffer.c_str()[index]);
-
-    uint8_t single_data = (uint8_t)message_to_decode[index];
-    // Thread::Info("%d\n", single_data);
-
-    // Thread::Info("Hexa data after cast : %02x\n", single_data);
-
-    if(mavlink_parse_char(MAVLINK_COMM_0, single_data, &rcv_msg, &rcv_status)) {
-        // Thread::Info("Debug: in the if, before the switch\n");
-        switch(rcv_msg.msgid)
-        {
-            case MAVLINK_MSG_ID_HEARTBEAT :
-                 Thread::Info("Debug: heartbeat received !!!\n");
-                 break;
-            case MAVLINK_MSG_ID_MISSION_ITEM :
-                 // Thread::Info("Debug: mission item received !!!\n");
-                 
-                 received_x = mavlink_msg_mission_item_get_x(&rcv_msg);
-                 received_y = mavlink_msg_mission_item_get_y(&rcv_msg);
-
-                 Thread::Info("Debug: received x : %f, y : %f\n", received_x, received_y);
-                 break;
-            default :
-                  Thread::Info("Debug: default, no item decoded...\n");
-                  break;
-        }
-    }
-  }
-  Thread::Info("Debug: end of decode loop\n");
-}
-
-std::string Mavlink::GetWptLatLon() {
-  std::ostringstream stringStream;
-  stringStream.precision(3);
-  stringStream << fixed;
-  stringStream << latField->Value() << " - " << lonField->Value();
-  return stringStream.str();
-}
-
-// First tab callbacks
-void Mavlink::MissionInitialize() {
-	
-}
-void Mavlink::MissionStart() {
-	
-}
-void Mavlink::MissionStop() {
-	
-}
-void Mavlink::MissionKill() {
-	
-}
-// Second tab callbacks  
-void Mavlink::MissionWptAdd() {
-	
-}
-void Mavlink::EntranceWptAdd() {
-	
-}
-void Mavlink::ExitWptAdd() {
-	
-}
-void Mavlink::WptSend() {
-	
-}
-void Mavlink::WptClear() {
-	
-}
-void Mavlink::WptLoopSend() {
-	
-}
-
-void Mavlink::SendHeartbeat() {
-  Thread::Info("Debug: heartbeat pressed !\n");
-  mavlink_message_t msg;
-
-  msg.payload64[0] = (uint64_t)36;
-
-  mavlink_msg_heartbeat_pack(100, 200, &msg, MAV_TYPE_GENERIC, MAV_AUTOPILOT_GENERIC, MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, 0, MAV_STATE_UNINIT);
-
-  uint8_t buf[MAVLINK_MAX_PACKET_LEN];
-  uint16_t buf_size = mavlink_msg_to_send_buffer(buf, &msg);
-
-  // std::string data_buffer = U8toString(buf, buf_size);
-  // std::string data_buffer(my_chars);
-
-  // Thread::Info("Debug:  buf_size=%d, data_buffer_size=%d\n", buf_size, data_buffer.size());
-  // Thread::Info("Debug: send data_buffer=%s\n", data_buffer.c_str());
-
-  //to send the message thanks to udp
-  // mavlinkSocket->SendMessage(data_buffer); 
-
-  //decode the content of the heartbeat message
-  Thread::Info("Debug: start of decode loop\n");
-
-  mavlink_message_t rcv_msg;
-  mavlink_status_t rcv_status;
-
-  // for (uint8_t index = 0; index < data_buffer.size(); index++) {
-  for (uint8_t index = 0; index < buf_size; index++) {
-
-    //Thread::Info("Hexa data before cast : %02x\n", data_buffer.c_str()[index]);
-
-    // uint8_t single_data = static_cast<uint8_t>(data_buffer.c_str()[index]);
-    uint8_t single_data = buf[index];
-
-    Thread::Info("Hexa data after cast : %02x\n", single_data);
-
-    if(mavlink_parse_char(MAVLINK_COMM_0, single_data, &rcv_msg, &rcv_status)) {
-        Thread::Info("Debug: in the if, before the switch\n");
-        switch(msg.msgid)
-        {
-            case MAVLINK_MSG_ID_HEARTBEAT:
-            {
-                 Thread::Info("Debug: heartbeat received !!!\n");
-            }
-            break;
-            default:
-              //Do nothing
-              break;
-        }
-    }
-  }
-  Thread::Info("Debug: end of decode loop\n");
-}
-
-std::string Mavlink::U8toString(const uint8_t* chars, const uint16_t chars_size) {
-  // string converted_chars;
-  char message[chars_size];
-
-  // Thread::Info("Debug: U8toString size : %d\n", chars_size);
-
-  for (uint16_t index = 0; index < chars_size; index++) {
-    message[index] = (char)chars[index];
-    // Thread::Info("Debug: U8toString index : %d, get_data : %02X, saved_data : %02x\n", index, (char)chars[index], message[index]);
-    // converted_chars.append((const char*)(&chars[index]));
-
-  }
-
-  std::string converted_chars(message, chars_size);
-
-  // Thread::Info("Debug: U8toString string size : %d\n", converted_chars.size());
-
-  return converted_chars; 
-}
-
-} // end namespace sensor
-} // end namespace flair
Index: branches/mavlink/tools/Controller/Mavlink/src/Mavlink_test.h
===================================================================
--- branches/mavlink/tools/Controller/Mavlink/src/Mavlink_test.h	(revision 71)
+++ 	(revision )
@@ -1,128 +1,0 @@
-// %flair:license{
-// This file is part of the Flair framework distributed under the
-// CECILL-C License, Version 1.0.
-// %flair:license}
-//  created:    2016/07/05
-//  filename:   Mavlink.h
-//
-//  authors:    Thomas Fuhrmann
-//              Copyright Heudiasyc UMR UTC/CNRS 7253
-//
-//  version:    $Id: $
-//
-//  purpose:    Mavlink controller in client side.
-//
-//
-/*********************************************************************/
-
-#ifndef MAVLINK_TEST_H
-#define MAVLINK_TEST_H
-
-#include <stdint.h>
-#include <Thread.h>
-
-namespace flair {
-namespace core {
-  class FrameworkManager;
-  class Socket;
-}
-namespace gui {
-  class SpinBox;
-  class Label;
-  class CheckBox;
-  class Tab;
-  class TabWidget;
-  class DoubleSpinBox;
-  class PushButton;
-  class Label;
-  class ComboBox;
-  class GroupBox;
-  class ListWidget;
-}
-}
-
-namespace flair {
-namespace sensor {
-
-class Mavlink : public core::Thread {
-public:
-
-  Mavlink(const core::FrameworkManager *parent, std::string name,
-             std::string receiverAddress, int receiverPort);
-  ~Mavlink();
-
-private:
-  gui::SpinBox *deadZone;
-  gui::CheckBox *enabled;
-  gui::Label *batteryChargeLevel;
-  core::Time now;
-  gui::TabWidget *tabWidget;
-  gui::Tab *tab;
-  gui::Tab *settingsTab;
-  
-  // Controls groupbox
-  gui::GroupBox* controlsGroupBox;
-  gui::PushButton* btn_initialize;
-  gui::PushButton* btn_start_mission;
-  gui::PushButton* btn_stop_mission;
-  gui::PushButton* btn_kill;
-  
-  // Add wpt groupbox
-  gui::GroupBox* add_wptGroupBox;
-  gui::DoubleSpinBox* latField;
-  gui::DoubleSpinBox* lonField;
-  gui::PushButton* btn_add_mission_wpt;
-  gui::PushButton* btn_add_entrance_wpt;
-  gui::PushButton* btn_add_exit_wpt;
-
-  // Show wpt groupbox
-  gui::GroupBox* show_wptGroupBox;
-  gui::ListWidget* list_mission_wpt;
-  gui::ListWidget* list_entrance_wpt;
-  gui::ListWidget* list_exit_wpt;
-  gui::PushButton* btn_remove_mission_wpt;
-  gui::PushButton* btn_remove_entrance_wpt;
-  gui::PushButton* btn_remove_exit_wpt;  
-
-  // Action wpt groupbox
-  gui::GroupBox* action_wptGroupBox;
-  gui::PushButton* btn_send_wpt;
-  gui::PushButton* btn_clear_wpt;
-  gui::PushButton* btn_loop;
-
-  core::Socket* mavlinkSocket;
-  core::Socket* recvSocket;
-
-  // reimplement the run of the Thread class
-  void Run();
-
-  std::string GetWptLatLon();
-  
-  // First tab callbacks
-  void MissionInitialize();
-  void MissionStart();
-  void MissionStop();
-  void MissionKill();
-  
-  // Second tab callbacks
-  void MissionWptAdd();
-  void EntranceWptAdd();
-  void ExitWptAdd();
-  void WptSend();
-  void WptClear();
-  void WptLoopSend();
-
-  void SendWptMessage(gui::DoubleSpinBox* latField, gui::DoubleSpinBox* lonField);
-  void SendHeartbeat();
-
-  void SendAllWptMessage();
-
-  void DecodeWptMessage(std::string wpt_to_decode);
-
-  std::string U8toString(const uint8_t* chars, const uint16_t chars_size);
-};
-
-}
-}
-
-#endif // MAVLINK_H
