[88] | 1 | // %flair:license{
|
---|
| 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %flair:license}
|
---|
| 5 | // created: 2016/09/02
|
---|
| 6 | // filename: GuiFlair.cpp
|
---|
| 7 | //
|
---|
| 8 | // authors: Thomas Fuhrmann
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: Implementation of GuiInterface using Flair
|
---|
| 14 | // communication mechanism
|
---|
| 15 | //
|
---|
| 16 | //
|
---|
| 17 | /*********************************************************************/
|
---|
| 18 |
|
---|
| 19 | #include "GuiFlair.h"
|
---|
| 20 | #include "GuiInterface.h"
|
---|
| 21 |
|
---|
| 22 | #include <Socket.h>
|
---|
| 23 |
|
---|
| 24 | //todo remove for tests
|
---|
| 25 | #include <iostream>
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | using namespace std;
|
---|
| 29 | using namespace flair::core;
|
---|
| 30 | using namespace flair::gui;
|
---|
| 31 |
|
---|
[137] | 32 | GuiFlair::GuiFlair(string name):
|
---|
| 33 | GuiInterface(name) {
|
---|
[88] | 34 | cout << "MavPlanner GuiFlair constructor" << endl;
|
---|
| 35 |
|
---|
| 36 | outputSocket = new Socket((Thread *)this, "output socket", "127.0.0.1:5036");
|
---|
| 37 |
|
---|
| 38 | // outputSocket = new Socket(parent, "output socket", "127.255.255.255:9001", true);
|
---|
| 39 | inputSocket = new Socket((Thread *)this, "input socket", 9001);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | GuiFlair::~GuiFlair() {
|
---|
| 43 |
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | void GuiFlair::MissionStart() {
|
---|
| 47 | cout << "MavPlanner GuiFlair MissionStart" << endl;
|
---|
| 48 |
|
---|
| 49 | int received = 0;
|
---|
| 50 | char receiveFrameBuffer[200];
|
---|
| 51 |
|
---|
| 52 | std::string message_to_send("Test of sending a message");
|
---|
| 53 |
|
---|
| 54 | //fonctionne en récéption si on prend un broadcast pour la création du socket
|
---|
| 55 | // outputSocket->SendMessage(message_to_send);
|
---|
| 56 |
|
---|
| 57 | do {
|
---|
| 58 | // cout << "." << endl;
|
---|
| 59 | received=inputSocket->RecvMessage(receiveFrameBuffer,200, TIME_NONBLOCK);
|
---|
| 60 | // cout << "." << endl;
|
---|
| 61 | if (received > 0) {
|
---|
| 62 | cout << "MavPlanner GuiFlair MissionStart data received : " << receiveFrameBuffer << endl;
|
---|
| 63 | outputSocket->SendMessage(receiveFrameBuffer, received);
|
---|
| 64 | }
|
---|
| 65 | } while (received != 0);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | void GuiFlair::MissionStop() {
|
---|
| 69 | cout << "MavPlanner GuiFlair MissionStop" << endl;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | void GuiFlair::MissionPause() {
|
---|
| 73 | cout << "MavPlanner GuiFlair MissionResume" << endl;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | void GuiFlair::MissionSend() {
|
---|
| 77 | cout << "MavPlanner GuiFlair MissionSend" << endl;
|
---|
| 78 | }
|
---|