Initial commit

This commit is contained in:
2025-03-09 15:25:03 -05:00
commit 97a63ac287
124 changed files with 54197 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file ASCIILogFile.hpp
///
/// @brief Defines a CAN logger that saves messages in a Vector .asc file.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef ASCII_LOG_FILE_HPP
#define ASCII_LOG_FILE_HPP
#include "isobus/hardware_integration/can_hardware_interface.hpp"
#include "JuceHeader.h"
/// @brief Logs to Vector .asc file
class ASCIILogFile
{
public:
ASCIILogFile();
~ASCIILogFile() = default;
private:
File logFile;
isobus::EventCallbackHandle canFrameReceivedListener;
isobus::EventCallbackHandle canFrameSentListener;
Time initialTimestamp;
};
#endif // ASCII_LOG_FILE_HPP

View File

@@ -0,0 +1,16 @@
/* (Auto-generated binary data file). */
#pragma once
namespace AlarmMaskAudio
{
extern const char *alarmMaskHigh_mp3;
const int alarmMaskHigh_mp3Size = 37281;
extern const char *alarmMaskLow_mp3;
const int alarmMaskLow_mp3Size = 15393;
extern const char *alarmMaskMedium_mp3;
const int alarmMaskMedium_mp3Size = 16488;
}

View File

@@ -0,0 +1,34 @@
//================================================================================================
/// @file AlarmMaskComponent.hpp
///
/// @brief Defines a GUI component to draw a data mask.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef ALARM_MASK_COMPONENT_HPP
#define ALARM_MASK_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class AlarmMaskComponent : public isobus::AlarmMask
, public Component
{
public:
AlarmMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::AlarmMask sourceObject, int dataMaskSize);
void on_content_changed(bool initial = false);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AlarmMaskComponent)
};
#endif // ALARM_MASK_COMPONENT_HPP

View File

@@ -0,0 +1,12 @@
/* (Auto-generated binary data file). */
#pragma once
namespace AppImages
{
extern const char *logo2_png;
const int logo2_pngSize = 49015;
extern const char *logosmall_png;
const int logosmall_pngSize = 21145;
}

View File

@@ -0,0 +1,36 @@
//================================================================================================
/// @file ButtonComponent.hpp
///
/// @brief Defines a GUI component to draw a button.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef BUTTON_COMPONENT_HPP
#define BUTTON_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class ButtonComponent : public isobus::Button
, public Button
{
public:
ButtonComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::Button sourceObject);
void paint(Graphics &g) override;
void paintButton(Graphics &g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
void set_options(std::uint8_t value) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ButtonComponent)
};
#endif // BUTTON_COMPONENT_HPP

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file ColourMapComponent.hpp
///
/// @brief Defines a GUI component to draw a button.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef COLOR_MAP_COMPONENT_HPP
#define COLOR_MAP_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class ColourMapComponent : public isobus::ColourMap
, public Component
{
public:
ColourMapComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::ColourMap sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ColourMapComponent)
};
#endif // COLOR_MAP_COMPONENT_HPP

View File

@@ -0,0 +1,37 @@
//================================================================================================
/// @file ConfigureHardwareComponent.hpp
///
/// @brief Defines a GUI component which allows selecting and configuring a hardware interface.
/// @author Adrian Del Grosso
///
/// @copyright 2023 The Open-Agriculture Contributors
//================================================================================================
#ifndef CONFIGURE_HARDWARE_COMPONENT_HPP
#define CONFIGURE_HARDWARE_COMPONENT_HPP
#include "isobus/hardware_integration/can_hardware_interface.hpp"
#include <JuceHeader.h>
class ConfigureHardwareWindow;
class ConfigureHardwareComponent : public Component
{
public:
ConfigureHardwareComponent(ConfigureHardwareWindow &parent, std::vector<std::shared_ptr<isobus::CANHardwarePlugin>> &canDrivers);
void paint(Graphics &graphics) override;
void resized() override;
private:
ComboBox hardwareInterfaceSelector;
TextEditor socketCANNameEditor;
TextEditor touCANSerialEditor;
TextButton okButton;
std::vector<std::shared_ptr<isobus::CANHardwarePlugin>> &parentCANDrivers;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ConfigureHardwareComponent)
};
#endif // CONFIGURE_HARDWARE_COMPONENT_HPP

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file ConfigureHardwareWindow.hpp
///
/// @brief Defines a GUI window which allows selecting and configuring a hardware interface.
/// @author Adrian Del Grosso
///
/// @copyright 2023 The Open-Agriculture Contributors
//================================================================================================
#ifndef CONFIGURE_HARDWARE_WINDOW_HPP
#define CONFIGURE_HARDWARE_WINDOW_HPP
#include "ConfigureHardwareComponent.hpp"
class ServerMainComponent;
class ConfigureHardwareWindow : public DocumentWindow
{
public:
ConfigureHardwareWindow(ServerMainComponent &parentComponent, std::vector<std::shared_ptr<isobus::CANHardwarePlugin>> &canDrivers);
void closeButtonPressed() override;
ServerMainComponent &parentServer;
private:
ConfigureHardwareComponent content;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ConfigureHardwareWindow)
};
#endif // CONFIGURE_HARDWARE_WINDOW_HPP

View File

@@ -0,0 +1,32 @@
//================================================================================================
/// @file ContainerComponent.hpp
///
/// @brief Defines a GUI component to draw a container.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef CONTAINER_COMPONENT_HPP
#define CONTAINER_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class ContainerComponent : public isobus::Container
, public Component
{
public:
ContainerComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::Container sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ContainerComponent)
};
#endif // CONTAINER_COMPONENT_HPP

View File

@@ -0,0 +1,34 @@
//================================================================================================
/// @file DataMaskComponent.hpp
///
/// @brief Defines a GUI component to draw a data mask.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef DATA_MASK_COMPONENT_HPP
#define DATA_MASK_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class DataMaskComponent : public isobus::DataMask
, public Component
{
public:
DataMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::DataMask sourceObject, int dataMaskSize);
void on_content_changed(bool initial = false);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DataMaskComponent)
};
#endif // DATA_MASK_COMPONENT_HPP

View File

@@ -0,0 +1,77 @@
//================================================================================================
/// @file DataMaskRenderArea.hpp
///
/// @brief A component to hold all the data mask render components.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef DATA_MASK_RENDER_AREA_COMPONENT_HPP
#define DATA_MASK_RENDER_AREA_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class ServerMainComponent;
class DataMaskRenderAreaComponent : public Component
{
public:
DataMaskRenderAreaComponent(ServerMainComponent &parentServer);
void on_change_active_mask(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet);
void on_working_set_disconnect(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet);
void paint(Graphics &g) override;
// Used to calculate button press events
void mouseDown(const MouseEvent &event) override;
// Used to calculate button release events
void mouseUp(const MouseEvent &event) override;
bool needsRepaint() const;
void set_has_started(bool started);
private:
class InputNumberListener : public Slider::Listener
{
public:
InputNumberListener() = default;
void sliderValueChanged(Slider *slider) override;
std::uint32_t get_last_value() const;
void set_last_value(std::uint32_t value);
std::shared_ptr<isobus::InputNumber> get_target();
void set_target(std::shared_ptr<isobus::InputNumber> objectBeingModified);
private:
std::shared_ptr<isobus::InputNumber> targetObject;
std::uint32_t lastValue = 0;
};
std::shared_ptr<isobus::VTObject> getClickedChildRecursive(std::shared_ptr<isobus::VTObject> object, int x, int y);
static bool objectCanBeClicked(std::shared_ptr<isobus::VTObject> object);
static bool isClickWithinBounds(int clickXRelative, int clickYRelative, int objectX, int objectY, int objectWidth, int objectHeight);
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::unique_ptr<AlertWindow> inputListModal;
std::unique_ptr<AlertWindow> inputNumberModal;
std::unique_ptr<AlertWindow> inputStringModal;
std::unique_ptr<Slider> inputNumberSlider;
std::vector<std::shared_ptr<Component>> childComponents;
std::vector<std::shared_ptr<Component>> currentModalComponentCache;
ServerMainComponent &ownerServer;
InputNumberListener inputNumberListener;
bool needToRepaintActiveArea = false;
bool hasStarted = false;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DataMaskRenderAreaComponent)
};
#endif // DATA_MASK_RENDER_AREA_COMPONENT_HPP

View File

@@ -0,0 +1,29 @@
//================================================================================================
/// @file InputBooleanComponent.hpp
///
/// @brief Defines a GUI component to draw an input boolean.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef INPUT_BOOLEAN_COMPONENT_HPP
#define INPUT_BOOLEAN_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class InputBooleanComponent : public isobus::InputBoolean
, public Component
{
public:
InputBooleanComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::InputBoolean sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
};
#endif // INPUT_BOOLEAN_COMPONENT_HPP

View File

@@ -0,0 +1,35 @@
//================================================================================================
/// @file InputListComponent.hpp
///
/// @brief Defines a GUI component to draw an input list.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef INPUT_LIST_COMPONENT_HPP
#define INPUT_LIST_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class InputListComponent : public isobus::InputList
, public Component
{
public:
InputListComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::InputList sourceObject);
void paint(Graphics &g) override;
void paintOverChildren(Graphics &g) override;
void onChanged(bool initial);
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::shared_ptr<Component> childComponent;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InputListComponent)
};
#endif // INPUT_LIST_COMPONENT_HPP

View File

@@ -0,0 +1,33 @@
//================================================================================================
/// @file InputNumberComponent.hpp
///
/// @brief Defines a GUI component to draw an input number.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef INPUT_NUMBER_COMPONENT_HPP
#define INPUT_NUMBER_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class InputNumberComponent : public isobus::InputNumber
, public Component
{
public:
InputNumberComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::InputNumber sourceObject);
void paint(Graphics &g) override;
static Justification convert_justification(HorizontalJustification horizontalJustification, VerticalJustification verticalJustification);
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InputNumberComponent)
};
#endif // INPUT_NUMBER_COMPONENT_HPP

View File

@@ -0,0 +1,33 @@
//================================================================================================
/// @file InputStringComponent.hpp
///
/// @brief Defines a GUI component to draw an input string.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef INPUT_STRING_COMPONENT_HPP
#define INPUT_STRING_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class InputStringComponent : public isobus::InputString
, public Component
{
public:
InputStringComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::InputString sourceObject);
void paint(Graphics &g) override;
static Justification convert_justification(HorizontalJustification horizontalJustification, VerticalJustification verticalJustification);
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InputStringComponent)
};
#endif // INPUT_STRING_COMPONENT_HPP

View File

@@ -0,0 +1,39 @@
//================================================================================================
/// @file JuceManagedWorkingSetCache.hpp
///
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef JUCE_MANAGED_WORKING_SET_HPP
#define JUCE_MANAGED_WORKING_SET_HPP
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
#include "SoftKeyMaskComponent.hpp"
class JuceManagedWorkingSetCache
{
public:
static std::shared_ptr<Component> create_component(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, std::shared_ptr<isobus::VTObject> sourceObject);
static void set_softkey_mask_dimension_info(const SoftKeyMaskDimensions &info);
private:
class ComponentCacheClass
{
public:
ComponentCacheClass(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> associatedWorkingSet) :
workingSet(associatedWorkingSet){};
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet;
//std::map<std::uint16_t, std::shared_ptr<Component>> componentLookup;
};
static std::vector<ComponentCacheClass> workingSetComponentCache;
static SoftKeyMaskDimensions softKeyDimensionInfo;
static int dataAndAlarmMaskSize;
};
#endif // JUCE_MANAGED_WORKING_SET_HPP

View File

@@ -0,0 +1,32 @@
//================================================================================================
/// @file KeyComponent.hpp
///
/// @brief Defines a GUI component to draw a soft key.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef KEY_COMPONENT_HPP
#define KEY_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class KeyComponent : public isobus::Key
, public Component
{
public:
KeyComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::Key sourceObject, int keyWidth, int keyHeight);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(KeyComponent)
};
#endif // KEY_COMPONENT_HPP

View File

@@ -0,0 +1,42 @@
//================================================================================================
/// @file LoggerComponent.hpp
///
/// @brief Defines a GUI component to draw log output.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef LOGGER_COMPONENT_HPP
#define LOGGER_COMPONENT_HPP
#include "isobus/isobus/can_stack_logger.hpp"
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
/// @brief Defines a GUI component that will draw log info sunk from the stack
class LoggerComponent : public Component
, public FileLogger
, public isobus::CANStackLogger
{
public:
LoggerComponent();
void paint(Graphics &g) override;
void sink_CAN_stack_log(LoggingLevel level, const std::string &logText) override;
private:
struct LogData
{
String logText;
isobus::CANStackLogger::LoggingLevel logLevel;
};
static constexpr std::size_t MAX_NUMBER_MESSAGES = 3000;
std::deque<LogData> loggedMessages;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LoggerComponent)
};
#endif // LOGGER_COMPONENT_HPP

View File

@@ -0,0 +1,34 @@
//================================================================================================
/// @file ObjectPointerComponent.hpp
///
/// @brief Defines a GUI component to draw an object pointer.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OBJECT_POINTER_COMPONENT_HPP
#define OBJECT_POINTER_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class ObjectPointerComponent : public isobus::ObjectPointer
, public Component
{
public:
ObjectPointerComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::ObjectPointer sourceObject);
void on_content_changed(bool initial = false);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::shared_ptr<Component> childComponent;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ObjectPointerComponent)
};
#endif // OBJECT_POINTER_COMPONENT_HPP

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file OutputEllipseComponent.hpp
///
/// @brief Defines a GUI component to draw an input number.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OUTPUT_ELLIPSE_COMPONENT_HPP
#define OUTPUT_ELLIPSE_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class OutputEllipseComponent : public isobus::OutputEllipse
, public Component
{
public:
OutputEllipseComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::OutputEllipse sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OutputEllipseComponent)
};
#endif // OUTPUT_ELLIPSE_COMPONENT_HPP

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file OutputLineComponent.hpp
///
/// @brief Defines a GUI component to draw an output line.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OUTPUT_LINE_COMPONENT_HPP
#define OUTPUT_LINE_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class OutputLineComponent : public isobus::OutputLine
, public Component
{
public:
OutputLineComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::OutputLine sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OutputLineComponent)
};
#endif // OUTPUT_LINE_COMPONENT_HPP

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file OutputLinearBarGraphComponent.hpp
///
/// @brief Defines a GUI component to draw a linear bar graph.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OUTPUT_LINEAR_BAR_GRAPH_COMPONENT_HPP
#define OUTPUT_LINEAR_BAR_GRAPH_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class OutputLinearBarGraphComponent : public isobus::OutputLinearBarGraph
, public Component
{
public:
OutputLinearBarGraphComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::OutputLinearBarGraph sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OutputLinearBarGraphComponent)
};
#endif // OUTPUT_LINEAR_BAR_GRAPH_COMPONENT_HPP

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file OutputMeterComponent.hpp
///
/// @brief Defines a GUI component to draw an output meter.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OUTPUT_METER_COMPONENT_HPP
#define OUTPUT_METER_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class OutputMeterComponent : public isobus::OutputMeter
, public Component
{
public:
OutputMeterComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::OutputMeter sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OutputMeterComponent)
};
#endif // OUTPUT_METER_COMPONENT_HPP

View File

@@ -0,0 +1,33 @@
//================================================================================================
/// @file OutputNumberComponent.hpp
///
/// @brief Defines a GUI component to draw an output number.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OUTPUT_NUMBER_COMPONENT_HPP
#define OUTPUT_NUMBER_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class OutputNumberComponent : public isobus::OutputNumber
, public Component
{
public:
OutputNumberComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::OutputNumber sourceObject);
void paint(Graphics &g) override;
static Justification convert_justification(HorizontalJustification horizontalJustification, VerticalJustification verticalJustification);
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OutputNumberComponent)
};
#endif // OUTPUT_NUMBER_COMPONENT_HPP

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file OutputPolygonComponent.hpp
///
/// @brief Defines a GUI component to draw an output polygon.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OUTPUT_POLYGON_COMPONENT_HPP
#define OUTPUT_POLYGON_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class OutputPolygonComponent : public isobus::OutputPolygon
, public Component
{
public:
OutputPolygonComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::OutputPolygon sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OutputPolygonComponent)
};
#endif // OUTPUT_POLYGON_COMPONENT_HPP

View File

@@ -0,0 +1,31 @@
//================================================================================================
/// @file OutputRectangleComponent.hpp
///
/// @brief Defines a GUI component to draw an output rectangle.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OUTPUT_RECTANGLE_COMPONENT_HPP
#define OUTPUT_RECTANGLE_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class OutputRectangleComponent : public isobus::OutputRectangle
, public Component
{
public:
OutputRectangleComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::OutputRectangle sourceObject);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OutputRectangleComponent)
};
#endif // OUTPUT_RECTANGLE_COMPONENT_HPP

View File

@@ -0,0 +1,33 @@
//================================================================================================
/// @file OutputStringComponent.hpp
///
/// @brief Defines a GUI component to draw an output string.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef OUTPUT_STRING_COMPONENT_HPP
#define OUTPUT_STRING_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class OutputStringComponent : public isobus::OutputString
, public Component
{
public:
OutputStringComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::OutputString sourceObject);
void paint(Graphics &g) override;
static Justification convert_justification(HorizontalJustification horizontalJustification, VerticalJustification verticalJustification);
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OutputStringComponent)
};
#endif // OUTPUT_STRING_COMPONENT_HPP

View File

@@ -0,0 +1,34 @@
//================================================================================================
/// @file PictureGraphicComponent.hpp
///
/// @brief Defines a GUI component to draw a picture graphic.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef PICTURE_GRAPHIC_COMPONENT_HPP
#define PICTURE_GRAPHIC_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class PictureGraphicComponent : public isobus::PictureGraphic
, public Component
{
public:
PictureGraphicComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::PictureGraphic sourceObject);
void generate_and_store_image();
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
Image reconstructedImage;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PictureGraphicComponent)
};
#endif // PICTURE_GRAPHIC_COMPONENT_HPP

View File

@@ -0,0 +1,193 @@
#pragma once
#include "ConfigureHardwareWindow.hpp"
#include "DataMaskRenderAreaComponent.hpp"
#include "LoggerComponent.hpp"
#include "SoftKeyMaskComponent.hpp"
#include "SoftKeyMaskRenderAreaComponent.hpp"
#include "WorkingSetSelectorComponent.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server.hpp"
#include <filesystem>
class ServerMainComponent : public juce::Component
, public juce::KeyListener
, public isobus::VirtualTerminalServer
, public Timer
, public ApplicationCommandTarget
, public MenuBarModel
{
public:
ServerMainComponent(std::shared_ptr<isobus::InternalControlFunction> serverControlFunction, std::vector<std::shared_ptr<isobus::CANHardwarePlugin>> &canDrivers);
~ServerMainComponent() override;
bool get_is_enough_memory(std::uint32_t requestedMemory) const override;
VTVersion get_version() const override;
std::uint8_t get_number_of_navigation_soft_keys() const override;
std::uint8_t get_soft_key_descriptor_x_pixel_width() const override;
std::uint8_t get_soft_key_descriptor_y_pixel_height() const override;
std::uint8_t get_number_of_possible_virtual_soft_keys_in_soft_key_mask() const override;
std::uint8_t get_number_of_physical_soft_keys() const override;
std::uint8_t get_physical_soft_key_rows() const;
std::uint8_t get_physical_soft_key_columns() const;
std::uint16_t get_data_mask_area_size_x_pixels() const override;
std::uint16_t get_data_mask_area_size_y_pixels() const override;
void suspend_working_set(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSetWithError) override;
SupportedWideCharsErrorCode get_supported_wide_chars(std::uint8_t codePlane,
std::uint16_t firstWideCharInInquiryRange,
std::uint16_t lastWideCharInInquiryRange,
std::uint8_t &numberOfRanges,
std::vector<std::uint8_t> &wideCharRangeArray) override;
bool keyPressed(const juce::KeyPress &key, juce::Component *originatingComponent) override;
bool keyStateChanged(bool isKeyDown, juce::Component *originatingComponent) override;
std::vector<std::array<std::uint8_t, 7>> get_versions(isobus::NAME clientNAME) override;
std::vector<std::uint8_t> get_supported_objects() const override;
/// @brief This function is called when the client wants the server to load a previously stored object pool.
/// If there exists in the VT's non-volatile memory an object pool matching the provided version label,
/// return it. If one does not exist, return an empty vector.
/// @param[in] versionLabel The object pool version to load for the given client NAME
/// @param[in] clientNAME The client requesting the object pool
/// @returns The requested object pool associated with the version label.
std::vector<std::uint8_t> load_version(const std::vector<std::uint8_t> &versionLabel, isobus::NAME clientNAME) override;
/// @brief This function is called when the client wants the server to save an object pool
/// to the VT's non-volatile memory.
/// If the object pool is saved successfully, return true, otherwise return false.
/// @note This may be called multiple times with the same version, but different data. When this
/// happens, the expectation is that you will append each objectPool together into one large file.
/// @param[in] objectPool The object pool data to save
/// @param[in] versionLabel The object pool version to save for the given client NAME
/// @param[in] clientNAME The client requesting the object pool
/// @returns The requested object pool associated with the version label.
bool save_version(const std::vector<std::uint8_t> &objectPool, const std::vector<std::uint8_t> &versionLabel, isobus::NAME clientNAME) override;
/// @brief This function is called when the client wants the server to delete a stored object pool.
/// All object pool files matching the specified version label should then be deleted from the VT's
/// non-volatile storage.
/// @param[in] versionLabel The version label for the object pool(s) to delete
/// @param[in] clientNAME The NAME of the client that is requesting deletion
/// @returns True if the version was deleted from VT non-volatile storage, otherwise false.
bool delete_version(const std::vector<std::uint8_t> &versionLabel, isobus::NAME clientNAME) override;
/// @brief This function is called when the client wants the server to delete ALL stored object pools associated to it's NAME.
/// All object pool files matching the specified client NAME should then be deleted from the VT's
/// non-volatile storage.
/// @param[in] clientNAME The NAME of the client that is requesting deletion
/// @returns True if all relevant object pools were deleted from VT non-volatile storage, otherwise false.
bool delete_all_versions(isobus::NAME clientNAME) override;
/// @brief This function is called when the client wants the server to deactivate its object pool.
/// You should treat this as a disconnection by the client, as it may be moving to another VT.
/// @attention This does not mean to delete the pool from non-volatile memory!!! This only deactivates the active pool.
/// @details This command is used to delete the entire object pool of this Working Set from volatile storage.
/// This command can be used by an implement when it wants to move its object pool to another VT,
/// or when it is shutting down or during the development of object pools.
/// @param[in] clientNAME The NAME of the client that is requesting deletion
/// @returns True if the client's active object pool was deactivated and removed from volatile storage, otherwise false.
bool delete_object_pool(isobus::NAME clientNAME) override;
void timerCallback() override;
void paint(juce::Graphics &g) override;
void resized() override;
ApplicationCommandTarget *getNextCommandTarget() override;
void getAllCommands(juce::Array<juce::CommandID> &allCommands) override;
void getCommandInfo(juce::CommandID commandID, ApplicationCommandInfo &result) override;
bool perform(const InvocationInfo &info) override;
StringArray getMenuBarNames() override;
PopupMenu getMenuForIndex(int, const juce::String &) override;
void menuItemSelected(int, int) override;
std::shared_ptr<isobus::ControlFunction> get_client_control_function_for_working_set(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet) const;
void change_selected_working_set(std::uint8_t index);
void set_button_held(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, std::uint16_t objectID, std::uint16_t maskObjectID, std::uint8_t keyCode, bool isSoftKey);
void set_button_released(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, std::uint16_t objectID, std::uint16_t maskObjectID, std::uint8_t keyCode, bool isSoftKey);
void repaint_on_next_update();
void save_settings();
private:
enum class CommandIDs : int
{
NoCommand = 0, /// 0 Is an invalid command ID
About,
ConfigureLanguageCommand,
ConfigureReportedVersion,
ConfigureReportedHardware,
ConfigureLogging,
ConfigureShortcuts,
GenerateLogPackage,
ClearISOData,
ConfigureCANHardware,
StartStop,
AutoStart
};
SoftKeyMaskDimensions softKeyMaskDimensions;
class LanguageCommandConfigClosed
{
public:
void operator()(int result) const noexcept;
ServerMainComponent &mParent;
private:
};
friend class LanguageCommandConfigClosed;
struct HeldButtonData
{
HeldButtonData(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, std::uint16_t objectID, std::uint16_t maskObjectID, std::uint8_t keyCode, bool isSoftKey);
bool operator==(const HeldButtonData &other);
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> associatedWorkingSet;
std::uint32_t timestamp_ms;
std::uint16_t buttonObjectID;
std::uint16_t activeMaskObjectID;
std::uint8_t buttonKeyCode;
bool isSoftKey;
};
static VTVersion get_version_from_setting(std::uint8_t aVersion);
std::size_t number_of_iop_files_in_directory(std::filesystem::path path);
void on_change_active_mask_callback(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> affectedWorkingSet, std::uint16_t workingSet, std::uint16_t newMask);
void repaint_data_and_soft_key_mask();
void check_load_settings();
void remove_working_set(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSetToRemove);
void clear_iso_data();
const std::string ISO_DATA_PATH = "iso_data";
juce::ApplicationCommandManager mCommandManager;
WorkingSetSelectorComponent workingSetSelector;
DataMaskRenderAreaComponent dataMaskRenderer;
SoftKeyMaskRenderAreaComponent softKeyMaskRenderer;
MenuBarComponent menuBar;
LoggerComponent logger;
Viewport loggerViewport;
SoundPlayer mSoundPlayer;
AudioDeviceManager mAudioDeviceManager;
std::unique_ptr<AlertWindow> popupMenu;
std::unique_ptr<ConfigureHardwareWindow> configureHardwareWindow;
std::shared_ptr<isobus::ControlFunction> alarmAckKeyWs;
std::vector<std::shared_ptr<isobus::CANHardwarePlugin>> &parentCANDrivers;
std::vector<HeldButtonData> heldButtons;
std::uint32_t alarmAckKeyMaskId = isobus::NULL_OBJECT_ID;
int alarmAckKeyCode = juce::KeyPress::escapeKey;
std::uint8_t numberOfPoolsToRender = 0;
VTVersion versionToReport = VTVersion::Version5;
bool needToRepaint = false;
bool autostart = false;
bool hasStartBeenCalled = false;
bool alarmAckKeyPressed = false;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ServerMainComponent)
};

View File

@@ -0,0 +1,34 @@
//================================================================================================
/// @file ShortcutsWindow.hpp
///
/// @brief Defines a dialog where keyboard shortcuts could be selected
/// @author Miklos Marton
///
/// @copyright The Open-Agriculture Developers
//================================================================================================
#pragma once
#include "JuceHeader.h"
class ShortcutsWindow : public juce::AlertWindow
, public juce::KeyListener
{
public:
ShortcutsWindow(int alarmAckKeyCode, Component *associatedComponent = nullptr);
void resized() override;
bool keyPressed(const juce::KeyPress &key, juce::Component *originatingComponent) override;
int alarmAckKeyCode() const;
private:
juce::TextButton selectAlarmAckKeyButton;
int alarmAckKey = juce::KeyPress::escapeKey;
bool keySelectionMode = false;
void updateAlarmAckButtonLabel(const juce::KeyPress &key);
void setAlarmAckKeySelection(bool isEnabled);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ShortcutsWindow)
};

View File

@@ -0,0 +1,60 @@
//================================================================================================
/// @file SoftKeyMaskComponent.hpp
///
/// @brief Defines a GUI component to draw a soft key mask.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef SOFT_KEY_MASK_COMPONENT_HPP
#define SOFT_KEY_MASK_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class SoftKeyMaskDimensions
{
public:
SoftKeyMaskDimensions() = default;
/**
* @brief total_width
* @return The total width of the softkeymask (including inner and outer column paddings)
*/
int total_width() const;
/**
* @brief key_count
* @return the number of the possible key positions in the softkey mask
*/
int key_count() const;
int keyHeight = 60;
int keyWidth = 60;
int rowCount = 6;
int columnCount = 1;
int height = 480;
static constexpr std::uint8_t PADDING = 10;
};
class SoftKeyMaskComponent : public isobus::SoftKeyMask
, public Component
{
public:
SoftKeyMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::SoftKeyMask sourceObject, SoftKeyMaskDimensions dimensions);
void on_content_changed(bool initial = false);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
SoftKeyMaskDimensions dimensionInfo;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SoftKeyMaskComponent)
};
#endif // SOFT_KEY_MASK_COMPONENT_HPP

View File

@@ -0,0 +1,48 @@
//================================================================================================
/// @file SoftKeyMaskRenderAreaComponent.hpp
///
/// @brief A component to hold all the data mask render components.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef SOFT_KEY_MASK_RENDER_AREA_COMPONENT_HPP
#define SOFT_KEY_MASK_RENDER_AREA_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class ServerMainComponent;
class SoftKeyMaskRenderAreaComponent : public Component
{
public:
SoftKeyMaskRenderAreaComponent(ServerMainComponent &parentServer);
void on_change_active_mask(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet);
void on_working_set_disconnect(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet);
void paint(Graphics &g) override;
// Used to calculate button press events
void mouseDown(const MouseEvent &event) override;
// Used to calculate button release events
void mouseUp(const MouseEvent &event) override;
private:
std::shared_ptr<isobus::VTObject> getClickedChildRecursive(std::shared_ptr<isobus::VTObject> object, int x, int y);
static bool objectCanBeClicked(std::shared_ptr<isobus::VTObject> object);
static bool isClickWithinBounds(int clickXRelative, int clickYRelative, int objectX, int objectY, int objectWidth, int objectHeight);
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
ServerMainComponent &ownerServer;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SoftKeyMaskRenderAreaComponent)
};
#endif // SOFT_KEY_MASK_RENDER_AREA_COMPONENT_HPP

View File

@@ -0,0 +1,26 @@
//================================================================================================
/// @file StringEncodingConversions.hpp
///
/// @brief Helper functions for converting ISO 11783's string encodings to UTF-8
/// @author Adrian Del Grosso
///
/// @copyright 2024 Adrian Del Grosso
//================================================================================================
#ifndef STRING_ENCODING_CONVERSIONS_HPP
#define STRING_ENCODING_CONVERSIONS_HPP
#include <string>
enum class SourceEncoding
{
ISO8859_1,
ISO8859_2,
ISO8859_4,
ISO8859_5,
ISO8859_7,
ISO8859_15
};
void convert_string_to_utf_8(SourceEncoding encoding, const std::string &input, std::string &output, bool autoWrappingEnabled);
#endif // STRING_ENCODING_CONVERSIONS_HPP

View File

@@ -0,0 +1,32 @@
//================================================================================================
/// @file WorkingSetComponent.hpp
///
/// @brief Defines a GUI component to draw a working set designator.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef WORKING_SET_COMPONENT_HPP
#define WORKING_SET_COMPONENT_HPP
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
class WorkingSetComponent : public isobus::WorkingSet
, public Component
{
public:
WorkingSetComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::WorkingSet sourceObject, int keyHeight, int keyWidth);
void paint(Graphics &g) override;
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WorkingSetComponent)
};
#endif // WORKING_SET_COMPONENT_HPP

View File

@@ -0,0 +1,46 @@
//================================================================================================
/// @file WorkingSetSelectorComponent.hpp
///
/// @brief Defines a GUI component allow selecting the active working set.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#ifndef WORKING_SET_SELECTOR_COMPONENT_HPP
#define WORKING_SET_SELECTOR_COMPONENT_HPP
#include "WorkingSetComponent.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "JuceHeader.h"
#include <vector>
class ServerMainComponent;
class WorkingSetSelectorComponent : public Component
{
public:
explicit WorkingSetSelectorComponent(ServerMainComponent &server);
void update_drawn_working_sets(std::vector<std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet>> &managedWorkingSetList);
void paint(Graphics &g) override;
void resized() override;
void mouseUp(const MouseEvent &event) override;
void redraw();
private:
struct SELECTOR_CHILD_OBJECTS_STRUCT
{
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet;
std::vector<std::shared_ptr<Component>> childComponents;
};
std::vector<SELECTOR_CHILD_OBJECTS_STRUCT> children;
ServerMainComponent &parentServer;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WorkingSetSelectorComponent)
};
#endif // WORKING_SET_SELECTOR_COMPONENT_HPP