Permalink
Browse files

Completed conversion to libkovanserial

  • Loading branch information...
bmcdorman committed Jan 2, 2013
1 parent 80f60aa commit 502f087ce96b56acfbe1f46209510e5128824f43
Showing with 1,680 additions and 1,222 deletions.
  1. +2 −0 CMakeLists.txt
  2. +1 −1 include/build_options.hpp
  3. +0 −20 include/c_highlighter.hpp
  4. +0 −76 include/code_editor.hpp
  5. +38 −0 include/dialogs/manual_target_dialog.hpp
  6. +2 −0 include/dialogs/target_dialog.hpp
  7. +23 −0 include/external_tools.hpp
  8. +9 −4 include/interface/communication_manager.hpp
  9. +6 −2 include/interface/communication_queue.hpp
  10. +36 −0 include/interface/communication_queue_model.hpp
  11. +1 −0 include/interface/dummy_interface.hpp
  12. +3 −1 include/interface/interface.hpp
  13. +3 −3 include/interface/interface_model.hpp
  14. +29 −0 include/interface/main_responder.hpp
  15. +0 −46 include/interface/qt_target_responder.hpp
  16. +29 −26 include/interface/target.hpp
  17. +6 −20 include/interface/target_responder.hpp
  18. +32 −0 include/interface/target_response.hpp
  19. +18 −3 include/main_window.hpp
  20. +2 −2 include/project/project.hpp
  21. +8 −19 include/source_file.hpp
  22. +0 −48 include/syntax_highlighter.hpp
  23. +0 −1 include/tab.hpp
  24. +2 −5 include/unit.hpp
  25. +39 −0 include/widgets/communication_progress_bar.hpp
  26. +27 −0 include/widgets/communication_widget.hpp
  27. +2 −2 plugins/interfaces/CMakeLists.txt
  28. +2 −5 plugins/interfaces/computer/computer_interface.hpp
  29. +1 −1 plugins/interfaces/kovan/CMakeLists.txt
  30. +52 −13 plugins/interfaces/kovan/kovan_interface.cpp
  31. +50 −18 plugins/interfaces/kovan/kovan_interface.hpp
  32. +4 −2 plugins/interfaces/{serial → kovan_serial}/CMakeLists.txt
  33. +83 −0 plugins/interfaces/kovan_serial/kovan_serial_interface.cpp
  34. +52 −0 plugins/interfaces/kovan_serial/kovan_serial_interface.hpp
  35. +161 −79 plugins/interfaces/shared/kovan_proto_target.cpp
  36. +41 −27 plugins/interfaces/shared/kovan_proto_target.hpp
  37. +0 −69 src/c_highlighter.cpp
  38. +0 −217 src/code_editor.cpp
  39. +30 −0 src/dialogs/manual_target_dialog.cpp
  40. +14 −0 src/dialogs/target_dialog.cpp
  41. +23 −0 src/external_tools.cpp
  42. +29 −7 src/interface/communication_manager.cpp
  43. +28 −9 src/interface/communication_queue.cpp
  44. +143 −0 src/interface/communication_queue_model.cpp
  45. +13 −8 src/interface/dummy_interface.cpp
  46. +3 −2 src/interface/interface_model.cpp
  47. +34 −0 src/interface/main_responder.cpp
  48. +0 −68 src/interface/qt_target_responder.cpp
  49. +10 −18 src/interface/target.cpp
  50. +6 −3 src/interface/target_model.cpp
  51. +5 −0 src/interface/target_responder.cpp
  52. +30 −0 src/interface/target_response.cpp
  53. +33 −14 src/main_window.cpp
  54. +2 −8 src/project/project.cpp
  55. +19 −132 src/source_file.cpp
  56. +0 −86 src/syntax_highlighter.cpp
  57. +18 −16 src/unit.cpp
  58. +49 −0 src/widgets/communication_progress_bar.cpp
  59. +24 −0 src/widgets/communication_widget.cpp
  60. +0 −3 tests/CMakeLists.txt
  61. +152 −123 ui/MainWindow.ui
  62. +12 −11 ui/TargetDialog.ui
  63. +100 −0 ui/communication_widget.ui
  64. +136 −0 ui/manual_target_dialog.ui
  65. +3 −4 ui/template_dialog.ui
View
@@ -68,6 +68,8 @@ QT4_ADD_RESOURCES(KISS_SRCS_CXX ${KISS_QRC_FILES})
SET(CMAKE_CXX_FLAGS "-Wall")
+ADD_DEFINITIONS(-DQT_SHAREDPOINTER_TRACK_POINTERS)
+
IF(APPLE)
SET(CMAKE_OSX_SYSROOT "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.6.sdk")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -g")
@@ -11,7 +11,7 @@
// This option will enable GUI logging. Disables console output as a side-effect
-#define ENABLE_LOG_WINDOW
+// #define ENABLE_LOG_WINDOW
#ifndef QT_PHONON_LIB
#undef BUILD_AUDIO_TUTORIAL
View
@@ -1,20 +0,0 @@
-#ifndef _C_HIGHLIGHTER_HPP_
-#define _C_HIGHLIGHTER_HPP_
-
-#include "syntax_highlighter.hpp"
-
-#include <QHash>
-
-class QTextDocument;
-
-namespace Kiss
-{
- class CHighlighter : public SyntaxHighlighter
- {
- Q_OBJECT
- public:
- CHighlighter(QTextDocument *parent = 0);
- };
-}
-
-#endif
View
@@ -1,76 +0,0 @@
-#ifndef _CODE_EDITOR_HPP_
-#define _CODE_EDITOR_HPP_
-
-#include <QMap>
-#include <QWidget>
-#include <QPlainTextEdit>
-
-namespace Kiss
-{
- namespace Widget
- {
- class CodeEditor;
-
- class CodeEditorMargin : public QWidget
- {
- public:
- CodeEditorMargin(CodeEditor *editor);
- QSize sizeHint() const;
-
- protected:
- void paintEvent(QPaintEvent *event);
-
- private:
- CodeEditor *m_editor;
- };
-
- class MarginIndicator
- {
- public:
- MarginIndicator(const QColor& color);
- const QColor& color() const;
-
- static const MarginIndicator& none();
- private:
- QColor m_color;
-
- static MarginIndicator s_none;
- };
-
- class CodeEditor : public QPlainTextEdit
- {
- Q_OBJECT
- public:
- CodeEditor(QWidget *parent = 0);
-
- void setEditorFont(const QFont& font);
- QFont editorFont() const;
- QFont marginFont() const;
-
- void setMarginIndicator(const int& line, const MarginIndicator& indicator);
- void clearIndicators();
-
- quint16 marginSize() const;
-
- friend class CodeEditorMargin;
- protected:
- void marginPaintEvent(QPaintEvent *event);
- void resizeEvent(QResizeEvent *e);
- void scrollContentsBy(int dx, int dy);
-
- void keyPressEvent(QKeyEvent *e);
-
- private slots:
- void highlightCurrentLine();
- void updateMarginArea(const QRect& rect, const int& dy);
- void updateMarginSize();
-
- private:
- QFont m_marginFont;
- CodeEditorMargin *m_margin;
- QMap<int, MarginIndicator> m_indicators;
- };
- }
-}
-
-#endif
@@ -0,0 +1,38 @@
+#ifndef _MANUAL_TARGET_SELECTOR_HPP_
+#define _MANUAL_TARGET_SELECTOR_HPP_
+
+#include <QDialog>
+
+#include "target.hpp"
+
+namespace Ui
+{
+ class ManualTargetDialog;
+}
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class InterfaceModel;
+ }
+
+ namespace Dialog
+ {
+ class ManualTarget : public QDialog
+ {
+ Q_OBJECT
+ public:
+ ManualTarget(QWidget *parent = 0);
+ ~ManualTarget();
+
+ Kiss::Target::TargetPtr target() const;
+
+ private:
+ Ui::ManualTargetDialog *ui;
+ Kiss::Target::InterfaceModel *m_model;
+ };
+ }
+}
+
+#endif
@@ -47,11 +47,13 @@ namespace Kiss
void targetChosen(const QModelIndex& index);
void on_ui_interfaces_currentIndexChanged(int index);
void on_ui_refresh_clicked();
+ void on_ui_manual_clicked();
private:
Kiss::Target::InterfaceManager *m_manager;
Kiss::Target::TargetModel m_model;
Kiss::Target::InterfaceModel m_interfaceModel;
+ Kiss::Target::TargetPtr m_manualTarget;
};
}
}
View
@@ -0,0 +1,23 @@
+#ifndef _EXTERNAL_TOOLS_HPP_
+#define _EXTERNAL_TOOLS_HPP_
+
+#include <QString>
+#include <QSettings>
+
+namespace Kiss
+{
+ class ExternalTools
+ {
+ public:
+ void setTool(const QString &name, const QString &path);
+ QString tool(const QString &name);
+ void removeTool(const QString &name);
+
+ bool launch(const QString &name);
+
+ private:
+ QSettings m_settings;
+ };
+}
+
+#endif
@@ -3,6 +3,7 @@
#include <QObject>
#include <QRunnable>
+#include <QMutex>
#include "singleton.hpp"
#include "communication_queue.hpp"
@@ -13,20 +14,22 @@ namespace Kiss
{
class CommunicationWorker : public QObject, public QRunnable
{
+ Q_OBJECT
public:
CommunicationWorker(const CommunicationEntryPtr &entry);
virtual void run();
signals:
void progress(const CommunicationEntryPtr &entry);
- void finished(const CommunicationEntryPtr &entry);
+ void finished(const CommunicationEntryPtr &entry, const bool &success);
private:
CommunicationEntryPtr m_entry;
};
class CommunicationManager : public QObject, public Singleton<CommunicationManager>
{
+ Q_OBJECT
public:
CommunicationManager();
~CommunicationManager();
@@ -36,17 +39,19 @@ namespace Kiss
signals:
void admitted(const CommunicationEntryPtr &entry);
void began(const CommunicationEntryPtr &entry);
- void progress(const CommunicationEntryPtr &entry, const double &fraction);
- void finished(const CommunicationEntryPtr &entry);
+ void progress(const CommunicationEntryPtr &entry, double fraction);
+ void finished(const CommunicationEntryPtr &entry, bool success);
+ void queueFinished();
private slots:
void saturate();
- void workerFinished(const CommunicationEntryPtr &entry);
+ void workerFinished(CommunicationEntryPtr entry, const bool &success);
private:
quint64 m_id;
QList<CommunicationEntryPtr> m_running;
CommunicationQueue m_queue;
+ QMutex m_queueMutex;
};
}
}
@@ -1,5 +1,5 @@
-#ifndef _COMMUNICATIONQUEUE_H_
-#define _COMMUNICATIONQUEUE_H_
+#ifndef _COMMUNICATION_QUEUE_HPP_
+#define _COMMUNICATION_QUEUE_HPP_
#include "target.hpp"
@@ -9,6 +9,7 @@
#include <QString>
#include <QByteArray>
#include <QSharedPointer>
+#include <QMetaType>
namespace Kiss
{
@@ -36,6 +37,7 @@ namespace Kiss
const TargetPtr &target() const;
const CommunicationEntry::Type& type() const;
+ QString typeString() const;
const QString& custom() const;
const QByteArray& payload() const;
const QString& name() const;
@@ -64,4 +66,6 @@ namespace Kiss
}
}
+Q_DECLARE_METATYPE(Kiss::Target::CommunicationEntryPtr);
+
#endif
@@ -0,0 +1,36 @@
+#ifndef _COMMUNICATION_QUEUE_MODEL_HPP_
+#define _COMMUNICATION_QUEUE_MODEL_HPP_
+
+#include "communication_queue.hpp"
+
+#include <QStandardItemModel>
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class CommunicationManager;
+
+ class CommunicationQueueModel : public QStandardItemModel
+ {
+ Q_OBJECT
+ public:
+ CommunicationQueueModel(CommunicationManager *manager, QObject *parent);
+ ~CommunicationQueueModel();
+
+ CommunicationManager *manager() const;
+
+ private slots:
+ void admitted(const CommunicationEntryPtr &entry);
+ void began(const CommunicationEntryPtr &entry);
+ void progress(const CommunicationEntryPtr &entry, double success);
+ void finished(const CommunicationEntryPtr &entry, bool success);
+ void queueFinished();
+
+ private:
+ CommunicationManager *m_manager;
+ };
+ }
+}
+
+#endif
@@ -16,6 +16,7 @@ namespace Kiss
public:
DummyInterface();
+ virtual Kiss::Target::TargetPtr createTarget(const QString &address);
virtual const bool scan(Kiss::Target::InterfaceResponder *responder);
virtual void invalidateResponder();
};
@@ -2,6 +2,7 @@
#define _INTERFACE_HPP_
#include "interface_responder.hpp"
+#include "target.hpp"
#include <QList>
#include <QString>
@@ -16,7 +17,8 @@ namespace Kiss
Interface(const QString& name);
const QString& name() const;
-
+
+ virtual Kiss::Target::TargetPtr createTarget(const QString &address) = 0;
virtual const bool scan(InterfaceResponder *responder) = 0;
virtual void invalidateResponder() = 0;
private:
@@ -14,10 +14,10 @@ namespace Kiss
{
Q_OBJECT
public:
- InterfaceModel(InterfaceManager *manager);
+ InterfaceModel(InterfaceManager *manager, QObject *parent = 0);
- Interface* rowToInterface(const int& row) const;
- Interface* indexToInterface(const QModelIndex& index) const;
+ Interface *rowToInterface(const int& row) const;
+ Interface *indexToInterface(const QModelIndex& index) const;
void setAllInterface(const bool& on);
@@ -0,0 +1,29 @@
+#ifndef _MAIN_RESPONDER_HPP_
+#define _MAIN_RESPONDER_HPP_
+
+#include "target_responder.hpp"
+
+namespace Kiss
+{
+ namespace Widget
+ {
+ class MainWindow;
+ }
+
+ namespace Target
+ {
+ class MainResponder : public Responder
+ {
+ public:
+ MainResponder(Widget::MainWindow *mainWindow);
+ virtual ~MainResponder();
+
+ virtual void response(Target *target, const Response &response);
+
+ private:
+ Widget::MainWindow *m_mainWindow;
+ };
+ }
+}
+
+#endif
Oops, something went wrong.

0 comments on commit 502f087

Please sign in to comment.