diff --git a/include/botui/Create3Widget.h b/include/botui/Create3Widget.h
index d7c0e8af..3705148a 100644
--- a/include/botui/Create3Widget.h
+++ b/include/botui/Create3Widget.h
@@ -27,6 +27,7 @@ private slots:
void sensorList();
void exampleList();
QString getIP();
+ void toggleChanged();
private:
diff --git a/left.png b/left.png
new file mode 100644
index 00000000..9cfc7780
Binary files /dev/null and b/left.png differ
diff --git a/rc/left.png b/rc/left.png
new file mode 100644
index 00000000..9cfc7780
Binary files /dev/null and b/rc/left.png differ
diff --git a/rc/qml.qrc b/rc/qml.qrc
index c7836019..23217176 100644
--- a/rc/qml.qrc
+++ b/rc/qml.qrc
@@ -1,7 +1,9 @@
-
- qml/loading.qml
- qml/lock.qml
- qml/50-screenlock.png
-
+
+ qml/loading.qml
+ qml/lock.qml
+ qml/50-screenlock.png
+ qml/left.png
+ qml/right.png
+
diff --git a/rc/qml/Switch.qml b/rc/qml/Switch.qml
new file mode 100644
index 00000000..6ae2d5c5
--- /dev/null
+++ b/rc/qml/Switch.qml
@@ -0,0 +1,61 @@
+import QtQuick 2.0
+
+Item {
+ id: toggleswitch
+ width: background.width; height: background.height
+
+ property bool on: false
+
+ function toggle() {
+ if (toggleswitch.state == "on")
+ toggleswitch.state = "off";
+ else
+ toggleswitch.state = "on";
+ }
+
+ function releaseSwitch() {
+ if (knob.x == 1) {
+ if (toggleswitch.state == "off") return;
+ }
+ if (knob.x == 78) {
+ if (toggleswitch.state == "on") return;
+ }
+ toggle();
+ }
+
+ Image {
+ id: background
+ source: "background.png"
+ MouseArea { anchors.fill: parent; onClicked: toggle() }
+ }
+
+ Image {
+ id: knob
+ x: 1; y: 2
+ source: "knob.png"
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78
+ onClicked: toggle()
+ onReleased: releaseSwitch()
+ }
+ }
+
+ states: [
+ State {
+ name: "on"
+ PropertyChanges { target: knob; x: 78 }
+ PropertyChanges { target: toggleswitch; on: true }
+ },
+ State {
+ name: "off"
+ PropertyChanges { target: knob; x: 1 }
+ PropertyChanges { target: toggleswitch; on: false }
+ }
+ ]
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 }
+ }
+}
diff --git a/rc/qml/left.png b/rc/qml/left.png
new file mode 100644
index 00000000..9cfc7780
Binary files /dev/null and b/rc/qml/left.png differ
diff --git a/rc/qml/right.png b/rc/qml/right.png
new file mode 100644
index 00000000..1b34342e
Binary files /dev/null and b/rc/qml/right.png differ
diff --git a/right.png b/right.png
new file mode 100644
index 00000000..1b34342e
Binary files /dev/null and b/right.png differ
diff --git a/src/Create3Widget.cpp b/src/Create3Widget.cpp
index b61fb8df..42c1663a 100644
--- a/src/Create3Widget.cpp
+++ b/src/Create3Widget.cpp
@@ -30,6 +30,8 @@ class Create3SensorItemDelegate : public QItemDelegate
const QPixmap _down;
};
+QByteArray output;
+
Create3Widget::Create3Widget(Device *device, QWidget *parent)
: StandardWidget(device, parent),
ui(new Ui::Create3Widget), _model(new Create3SensorModel(this))
@@ -41,8 +43,33 @@ Create3Widget::Create3Widget(Device *device, QWidget *parent)
// connect(ui->ResetServerButton, SIGNAL(clicked()), SLOT(resetServer()));
connect(ui->Create3SensorListButton, SIGNAL(clicked()), SLOT(sensorList()));
connect(ui->Create3ExampleProgramButton, SIGNAL(clicked()), SLOT(exampleList()));
-
+
ui->create3IP->setText(getIP());
+
+ QStringList arguments;
+ arguments << "/home/kipr/wombat-os/configFiles/create3_server_ip.txt";
+
+ QProcess *myProcess = new QProcess(parent);
+ myProcess->start("cat", arguments);
+ myProcess->waitForFinished();
+ output = myProcess->readAllStandardOutput();
+
+ qDebug() << output;
+
+ QString ipOutput = QString(output);
+
+ if (ipOutput == "192.168.125.1")
+ {
+ ui->toggleSwitch->setChecked(false);
+ }
+ else if (ipOutput == "192.168.186.3")
+ {
+ ui->toggleSwitch->setChecked(true);
+ }
+
+
+
+ connect(ui->toggleSwitch, SIGNAL(stateChanged(int)), this, SLOT(toggleChanged()));
}
Create3Widget::~Create3Widget()
@@ -50,10 +77,62 @@ Create3Widget::~Create3Widget()
delete ui;
}
+void Create3Widget::toggleChanged()
+{
+ QProcess checkCreate3IPState;
+ QString startCommand = "cat";
+ QStringList startArgs = {"/home/kipr/wombat-os/configFiles/create3_server_ip.txt"};
+
+ checkCreate3IPState.start(startCommand, startArgs);
+ checkCreate3IPState.waitForFinished();
+ QByteArray output = checkCreate3IPState.readAllStandardOutput();
+
+ QString ipOutput = QString(output);
+
+ qDebug() << "IP OUTPUT: " << ipOutput; // Get current IP output
+
+
+ if (ipOutput.contains("192.168.125.1"))
+ {
+
+ if (QMessageBox::question(this, "Change Interface?",
+ QString("You are about to change your Create 3 connection from Wifi to Ethernet. \nThe Wombat will reboot once you make this change. \n Do you want to continue? \n (Be sure to change the Fast DDS discovery server IP address to 192.168.186.3)"),
+ QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
+ {
+ return;
+ }
+ else
+ {
+ QProcess process;
+ process.startDetached("/bin/sh", QStringList() << "/home/kipr/wombat-os/configFiles/create3_interface_swap.sh"
+ << "eth");
+ }
+
+
+ }
+ else if (ipOutput.contains("192.168.186.3"))
+ {
+ if (QMessageBox::question(this, "Change Interface?",
+ QString("You are about to change your Create 3 connection from Ethernet to Wifi. \n The Wombat will reboot once you make this change. \nDo you want to continue? \n (Be sure to change the Fast DDS discovery server IP address to 192.168.125.1)"),
+ QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
+ {
+ return;
+ }
+ else
+ {
+ QProcess process;
+ process.startDetached("/bin/sh", QStringList() << "/home/kipr/wombat-os/configFiles/create3_interface_swap.sh"
+ << "wifi");
+ }
+
+
+ }
+}
+
QString Create3Widget::getIP()
{
- // The command to execute
+ // The command to execute
const char *command = "arp -a | grep 'iRobot' | awk -F '[()]' '{print $2}'";
// Open a pipe to the command
@@ -81,78 +160,11 @@ QString Create3Widget::getIP()
std::cout << "Output:\n"
<< result << std::endl;
-
QString output = QString::fromStdString(result);
return output;
}
-// void Create3Widget::resetServer()
-// {
-// QProcess stopCreate3Service;
-// QString stopCommand = "systemctl";
-// QStringList stopArgs = {
-// "stop",
-// "create3_server.service"
-// };
-
-// stopCreate3Service.start(stopCommand, stopArgs);
-// if(stopCreate3Service.waitForFinished())
-// {
-// QByteArray data = stopCreate3Service.readAllStandardOutput();
-// qDebug() << "Create3 Server successfully stopped\n" << data;
-// }
-// else
-// {
-// QByteArray data = stopCreate3Service.readAllStandardError();
-// qDebug() << "Create3 Server failed to stop or crashed\n" << data;
-// }
-
-// // Need a command to run between start and stop for some reason for things to work
-// QProcess statusCreate3Service;
-// QString statusCommand = "systemctl";
-// QStringList statusArgs = {
-// "status",
-// "create3_server.service",
-// "--no-pager"
-// };
-
-// statusCreate3Service.start(statusCommand, statusArgs);
-// if(statusCreate3Service.waitForFinished())
-// {
-// QByteArray data = statusCreate3Service.readAllStandardOutput();
-// qDebug() << "Create3 Server status\n" << data;
-// }
-// else
-// {
-// QByteArray data = statusCreate3Service.readAllStandardError();
-// qDebug() << "Create3 Server failed to get status\n" << data;
-// }
-
-
-
-// QProcess startCreate3Service;
-// QString startCommand = "systemctl";
-// QStringList startArgs = {
-// "start",
-// "create3_server.service"
-// };
-
-// startCreate3Service.start(startCommand, startArgs);
-// if(startCreate3Service.waitForFinished())
-// {
-// QByteArray data = startCreate3Service.readAllStandardOutput();
-// qDebug() << "Create3 Server successfully started\n" << data;
-// }
-// else
-// {
-// QByteArray data = startCreate3Service.readAllStandardError();
-// qDebug() << "Create3 Server failed to start or crashed\n" << data;
-// }
-
-// RootController::ref().dismissWidget();
-// }
-
void Create3Widget::sensorList()
{
RootController::ref().presentWidget(new Create3SensorListWidget(device()));
diff --git a/ui/Create3Widget.ui b/ui/Create3Widget.ui
index 2f07440c..8a00ac8f 100644
--- a/ui/Create3Widget.ui
+++ b/ui/Create3Widget.ui
@@ -23,160 +23,258 @@
-
-
-
-
- 22
-
+
+
+ 0
-
- Create 3 Info
+
+ 0
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
-
-
-
-
-
- 0
- 80
-
-
-
-
- 33
-
-
-
- Create Connect
-
-
-
-
- -
-
-
-
-
-
-
- 22
-
-
-
- Create3 Connected State:
-
-
-
- -
-
-
-
- 22
-
-
-
-
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
-
-
-
- -
-
-
-
-
-
-
- 160
- 16777215
-
-
-
-
- 22
-
-
-
- Create3 IP:
-
-
-
- -
-
-
-
- 25
- 0
-
-
-
-
- 22
-
-
-
-
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
-
-
-
- -
-
-
-
-
-
-
- 0
- 80
-
-
-
-
- 21
-
-
-
- Create 3 Sensor List
-
-
-
- -
-
-
-
- 0
- 80
-
-
-
-
- 21
-
-
-
- Create 3 Example Programs
-
-
-
-
-
-
-
+ -
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+
+ 1
+ 80
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+
+ 33
+
+
+
+ Create Connect
+
+
+
+ -
+
+
+ 7
+
+
+ 0
+
+
+ 35
+
+
-
+
+
+
+ 25
+ 0
+
+
+
+
+ 60
+ 16777215
+
+
+
+
+ 22
+
+
+
+ Wifi
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 100
+ 16777215
+
+
+
+ QCheckBox::indicator{
+ margin-left:13%;
+ margin-right:10%
+}
+
+QCheckBox::indicator:checked{
+ image:url("://qml/right.png");
+}
+
+QCheckBox::indicator:unchecked{
+ image:url("://qml/left.png");
+}
+
+
+
+
+
+ false
+
+
+
+ -
+
+
+
+ 35
+ 0
+
+
+
+
+ 134
+ 16777215
+
+
+
+
+ 22
+
+
+
+ Ethernet
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 22
+
+
+
+ Create3 Connected State:
+
+
+
+ -
+
+
+
+ 22
+
+
+
+
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 160
+ 16777215
+
+
+
+
+ 22
+
+
+
+ Create3 IP:
+
+
+
+ -
+
+
+
+ 25
+ 0
+
+
+
+
+ 22
+
+
+
+
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 80
+
+
+
+
+ 21
+
+
+
+ Create 3 Sensor List
+
+
+
+ -
+
+
+
+ 0
+ 80
+
+
+
+
+ 21
+
+
+
+ Create 3 Example Programs
+
+
+
+