1 #ifndef __pnlAnalog_view__
2 #define __pnlAnalog_view__
3 
4 /**	@brief GUI for writing and reading analog controls
5 	@author Lime Microsystems (www.limemicro.com)
6 */
7 
8 #include <wx/artprov.h>
9 #include <wx/xrc/xmlres.h>
10 #include <wx/string.h>
11 #include <wx/button.h>
12 #include <wx/gdicmn.h>
13 #include <wx/font.h>
14 #include <wx/colour.h>
15 #include <wx/settings.h>
16 #include <wx/stattext.h>
17 #include <wx/choice.h>
18 #include <wx/sizer.h>
19 #include <wx/statbox.h>
20 #include <wx/frame.h>
21 #include <wx/spinctrl.h>
22 #include "lime/LimeSuite.h"
23 #include <vector>
24 #include <string>
25 #include <stdint.h>
26 #include <LMSBoards.h>
27 
28 namespace lime{
29 }
30 
31 class wxTextCtrl;
32 
33 class pnlBoardControls : public wxFrame
34 {
35 	public:
36         struct ADC_DAC
37         {
38             std::string name;
39             bool writable;
40             double value;
41             uint8_t channel;
42             std::string units;
43             int8_t powerOf10;
44             int minValue;
45             int maxValue;
46         };
47 
48         class Param_GUI
49         {
50         public:
Param_GUI()51             Param_GUI() : title(nullptr), units(nullptr), rValue(nullptr),wValue(nullptr){};
~Param_GUI()52             ~Param_GUI()
53             {
54                 if (title)
55                     title->Destroy();
56                 if (units)
57                     units->Destroy();
58                 if (rValue)
59                     rValue->Destroy();
60                 if (wValue)
61                     wValue->Destroy();
62             }
63             wxStaticText* title;
64             wxStaticText* units;
65             wxStaticText* rValue;
66             wxSpinCtrl* wValue;
67         };
68 
69         pnlBoardControls(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString &title = _(""), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
70         ~pnlBoardControls();
71 
72         void UpdatePanel();
73         void Initialize(lms_device_t* controlPort);
74         lms_device_t* lmsControl;
75 
76         void SetupControls(const std::string &boardID);
77         void OnSetDACvalues(wxSpinEvent &event);
78         void OnSetDACvaluesENTER(wxCommandEvent &event);
79         void OnDACWrite(wxCommandEvent &event);
80         static std::vector<ADC_DAC> mParameters;
81 	protected:
82         wxPanel* pnlCustomControls;
83         wxPanel* pnlReadControls;
84         wxSpinCtrl *spinCustomChannelRd;
85         wxStaticText *txtCustomValueRd;
86         wxStaticText *txtCustomUnitsRd;
87         wxStaticText *txtCustomPowerOf10Rd;
88         wxSpinCtrl *spinCustomChannelWr;
89         wxSpinCtrl *spinCustomValueWr;
90         wxChoice *cmbCustomUnitsWr;
91         wxChoice *cmbCustomPowerOf10Wr;
92         wxButton *btnCustomRd;
93         wxButton *btnCustomWr;
94         void OnCustomRead(wxCommandEvent& event);
95         void OnCustomWrite(wxCommandEvent& event);
96 
97         wxFlexGridSizer* sizerAnalogRd;
98         wxPanel* additionalControls;
99         wxStaticText* txtDACTitle;
100         wxTextCtrl* txtDACValue;
101         wxButton* btnDAC;
102         wxFlexGridSizer* sizerDAC;
103 
104         wxFlexGridSizer* sizerAdditionalControls;
105 
106         std::vector<ADC_DAC> getBoardParams(const std::string &boardID);
107 
108         void OnUserChangedBoardType(wxCommandEvent& event);
109         void OnReadAll( wxCommandEvent& event );
110         void OnWriteAll( wxCommandEvent& event );
111 
112         wxButton* btnReadAll;
113         wxButton* btnWriteAll;
114         wxStaticText* m_staticText349;
115         wxChoice* cmbBoardSelection;
116 
117 
118 
119         std::vector<Param_GUI*> mGUI_widgets;
120         static const std::vector<lime::eLMS_DEV> board_list;
121 };
122 
123 #endif // __pnlAnalog_view__
124