Commit 53882e88 authored by markus's avatar markus

Fix inheritance

parent 57358696
......@@ -3,15 +3,3 @@
Communicator::Communicator()
{
}
//String Communicator::getCommandString(MessageError* msg_error)
//{
// *msg_error = MSG_NONE_AVAILABLE;
// return "";
//}
//Communicator::messageError Communicator::sendMessage(String message)
//{
// Serial.println("whaaaat");
// return Communicator::MSG_NONE_AVAILABLE;
//}
......@@ -10,8 +10,8 @@ public:
MSG_NONE_AVAILABLE };
Communicator();
String getCommandString(messageError*);
messageError sendMessage(String);
virtual String getCommandString(messageError*);
virtual messageError sendMessage(String);
private:
};
......
......@@ -5,6 +5,8 @@
Control::Control(Rotor *rotor)
{
rotor_ = rotor;
serial_communicator_ = new SerialCommunicator();
udp_communicator_ = new UDPCommunicator();
debugTime_ = 0;
}
......@@ -13,14 +15,11 @@ void Control::doCommunicate()
String command_string;
Communicator::messageError msg_r;
//if((command_string = udp_communicator_.getCommandString(&msg_r)) && (msg_r == Communicator::MSG_OK)) {
// executeCommandString(command_string, &udp_communicator_);
//}
if((command_string = udp_communicator_->getCommandString(&msg_r)) && (msg_r == Communicator::MSG_OK)) {
executeCommandString(&command_string, udp_communicator_);
}
if((command_string = serial_communicator_->getCommandString(&msg_r)) && (msg_r == Communicator::MSG_OK)) {
if(command_string != "") {
Serial.println(command_string);
}
executeCommandString(&command_string, serial_communicator_);
}
}
......@@ -63,11 +62,11 @@ Control::hamlibError Control::executeCommandString(String *command_string, Commu
if ( substring == "state" )
{
// GNAAAARRR
//communicator->sendMessage(String(String(AZIM_MIN) + "/" + String(AZIM_MAX) + " " + String(ELEV_MIN) + "/" + String(ELEV_MAX)));
communicator->sendMessage(String(String(AZIM_MIN) + "/" + String(AZIM_MAX) + " " + String(ELEV_MIN) + "/" + String(ELEV_MAX)));
}
else if ( substring == "get position" ) {
// GNAAAARRR
//communicator->sendMessage(String(rotor_->getActualAzimuth()) + " " + String(rotor_->getActualElevation()));
communicator->sendMessage(String(rotor_->getActualAzimuth()) + " " + String(rotor_->getActualElevation()));
}
else if ( substring.startsWith("set az") ) {
if( substring.length() < 8 )
......
......@@ -21,7 +21,6 @@ String SerialCommunicator::getCommandString(messageError *err)
SerialCommunicator::messageError SerialCommunicator::sendMessage(String message)
{
Serial.println("tst");
Serial.println(message);
return Communicator::MSG_OK;
}
#include "udp_communicator.h"
String UDPCommunicator::getCommandString(Communicator::messageError* msg_error)
{
*msg_error = Communicator::MSG_NONE_AVAILABLE;
return "";
}
Communicator::messageError UDPCommunicator::sendMessage(String message)
{
return Communicator::MSG_NONE_AVAILABLE;
}
......@@ -8,6 +8,8 @@
class UDPCommunicator: public Communicator
{
public:
String getCommandString(messageError*);
messageError sendMessage(String);
private:
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment