-
Notifications
You must be signed in to change notification settings - Fork 1
/
ConsoleHelper.h
190 lines (143 loc) · 5.19 KB
/
ConsoleHelper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/** CConsoleHelper simplifies DPP spectrum acquisition.
* Coordinates DPP communications and spectrum acquisition.
*
*/
#pragma once
#include <string>
#include <vector>
#include "DppLibUsb.h" // LibUsb Support
#include "DP5Protocol.h" // DPP Protocol Support
#include "ParsePacket.h" // Packet Parser
#include "SendCommand.h" // Command Generator
#include "DP5Status.h" // Status Decoder
#include <time.h> // time library for rand seed
typedef struct _SpectrumFileType {
string strTag;
string strDescription;
short m_iNumChan;
unsigned long SerialNumber;
string strSpectrumConfig;
string strSpectrumStatus;
} SpectrumFileType;
class CConsoleHelper
{
public:
CConsoleHelper(void);
~CConsoleHelper(void);
/// LibUsb communications class.
CDppLibUsb DppLibUsb;
/// LibUsb is connected if true.
bool LibUsb_isConnected;
/// LibUsb number of devices found.
int LibUsb_NumDevices;
/// LibUsb connect to the default DPP.
bool LibUsb_Connect_Default_DPP();
/// LibUsb close the current connection.
void LibUsb_Close_Connection();
/// LibUsb send a command that does not require additional processing.
bool LibUsb_SendCommand(TRANSMIT_PACKET_TYPE XmtCmd);
/// LibUsb send a command that requires configuration options processing.
bool LibUsb_SendCommand_Config(TRANSMIT_PACKET_TYPE XmtCmd, CONFIG_OPTIONS CfgOptions);
/// LibUsb receive data.
bool LibUsb_ReceiveData();
// communications helper functions
/// Defines and implements DPP protocol.
CDP5Protocol DP5Proto;
/// Generates command packet to be sent.
CSendCommand SndCmd;
/// DPP packet parsing.
CParsePacket ParsePkt;
/// DPP status processing.
CDP5Status DP5Stat;
// DPP packet processing functions.
/// Processes DPP data from all communication interfaces (USB,RS232,INET)
bool ReceiveData();
/// Processes spectrum packets.
void ProcessSpectrumEx(Packet_In PIN, DppStateType DppState);
/// Clears configuration readback format flags.
void ClearConfigReadFormatFlags();
/// Processes configuration packets.
void ProcessCfgReadEx(Packet_In PIN, DppStateType DppState);
/// Populates the configuration command options data structure.
void CreateConfigOptions(CONFIG_OPTIONS *CfgOptions, string strCfg, CDP5Status DP5Stat, bool bUseCoarseFineGain);
//display support
/// Provides a low resolution text console graph.
void ConsoleGraph(long lData[], long chan, bool bLog, std::string strStatus);
/// DPP status display string.
string DppStatusString;
// DPP configuration information variables
/// FPGA 80MHz clock when true, 20MHz clock otherwise.
bool b80MHzMode;
/// Holds MCA MODE display string. (NORM=MCA, MCS, FAST, etc.)
string strMcaMode;
/// DPP configuration command array.
vector<string> Dp5CmdList;
// configuration readback format control flags
// these flags control how the configuration readback is formatted and processed
/// format configuration for display
bool DisplayCfg;
/// format sca for display (sca config sent separately)
bool DisplaySca;
/// format configuration for general readback
bool CfgReadBack;
/// format configuration for file save
bool SaveCfg;
/// format configuration for print
bool PrintCfg;
/// configuration ready flag
bool HwCfgReady;
/// sca readback ready flag
bool ScaReadBack;
// Tuning and display variables.
/// Holds the hardware configuration readback.
string HwCfgDP5;
/// Number of data channels.
int mcaCH;
/// Slow threshold in percent.
double SlowThresholdPct;
/// Fast channel threshold.
int FastChThreshold;
/// Peaking time value.
double RiseUS;
/// Total gain display string.
string strGainDisplayValue;
/// Acquisition mode. (0=MCA, 1=MCS)
int AcqMode;
// configuration presets for display (status updates preset progress)
/// preset count setting
int PresetCount;
/// preset acquisition time setting
double PresetAcq;
/// preset real time setting
double PresetRt;
/// presets mode summary (counts,accum. time,real time)
string strPresetCmd;
/// presets settings summary (preset values, counts,times)
string strPresetVal;
// configuration support functions
/// Returns the configuration command data from a configuration command string.
string GetCmdData(string strCmd, string strCfgData);
/// Replaces (or inserts a command description (comment) in a configuration command string.
string ReplaceCmdDesc(string strCmd, string strCfgData);
/// Appends a command description (comment) in a configuration command string.
string AppendCmdDesc(string strCmd, string strCfgData);
/// Returns the command decription (comment) in a configuration command string.
string GetCmdDesc(string strCmd);
// oscilloscope support
bool UpdateScopeCfg;
string strInputOffset;
string strAnalogOut;
string strOutputOffset;
string strTriggerSource;
string strTriggerSlope;
string strTriggerPosition;
string strScopeGain;
string SpectrumFile ;
string CreateMCAData(long m_larDataBuffer[], SpectrumFileType sfInfo, DP4_FORMAT_STATUS cfgStatusLst);
/// Saves a spectrum data string to a default file (SpectrumData.mca).
void SaveSpectrumStringToFile(string strData);
string CreateSpectrumConfig(string strRawCfgIn) ;
vector<string> MakeDp5CmdList();
SpectrumFileType sfInfo;
void SetSpectrumFile (char *) ;
};