JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
GUIserial.H
Go to the documentation of this file.
1// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2//
3// JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2024 by Laurent Itti, the University of Southern
4// California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5//
6// This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7// redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8// Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10// License for more details. You should have received a copy of the GNU General Public License along with this program;
11// if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12//
13// Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14// Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16/*! \file */
17
18#pragma once
19
20#ifdef JEVOIS_PRO
21
22#include <jevois/Core/Serial.H>
23#include <string>
24#include <deque>
25#include <memory>
26
27namespace jevois
28{
29 //! Simple class to monitor a serial port in the JeVois-Pro GUI
30 /*! This class opens a window and displays traffic on a given serial port. Its interface is the same as a regular
31 Serial (or its parent, UserInterface), with the addition of a draw() function to render into a window managed by
32 the caller. */
33 class GUIserial : public Serial
34 {
35 public:
36 //! Inherited constructor ok
37 using Serial::Serial;
38
39 //! Virtual destructor for safe inheritance
40 virtual ~GUIserial();
41
42 //! Read some bytes if available, and return true and a string when one is complete
43 /*! If the monitor window is open, anything read will also be displayed in the window. */
44 bool readSome(std::string & str) override;
45
46 //! Write a string, using the line termination convention of serial::linestyle
47 /*! No line terminator should be included in the string, writeString() will add one. If the monitor window is
48 open, anything written will also be displayed in the window. */
49 void writeString(std::string const & str) override;
50
51 //! Render into ImGui
52 /*! Render into a window that was already opened and will be closed by the caller. */
53 void draw();
54
55 protected:
56 //! Clear the contents of the window
57 void clear();
58
59 private:
60 mutable std::mutex itsDataMtx;
61 std::deque<std::pair<bool /* user/jevois */, std::string> > itsData;
62 };
63} // namespace jevois
64
65#endif // JEVOIS_PRO
Simple class to monitor a serial port in the JeVois-Pro GUI.
Definition GUIserial.H:34
void clear()
Clear the contents of the window.
Definition GUIserial.C:126
void draw()
Render into ImGui.
Definition GUIserial.C:56
bool readSome(std::string &str) override
Read some bytes if available, and return true and a string when one is complete.
Definition GUIserial.C:27
virtual ~GUIserial()
Virtual destructor for safe inheritance.
Definition GUIserial.C:23
void writeString(std::string const &str) override
Write a string, using the line termination convention of serial::linestyle.
Definition GUIserial.C:42
Interface to a serial port.
Definition Serial.H:88
Serial(std::string const &instance, UserInterface::Type type)
Constructor.
Definition Serial.C:61
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2