gccDppConsole Test C++ SDK
20170920
DPP C++ Console Demonstration
|
00001 00006 #pragma once 00007 00008 #include <string> 00009 #include <vector> 00010 #include "DppLibUsb.h" // LibUsb Support 00011 #include "DP5Protocol.h" // DPP Protocol Support 00012 #include "ParsePacket.h" // Packet Parser 00013 #include "SendCommand.h" // Command Generator 00014 #include "DP5Status.h" // Status Decoder 00015 #include <time.h> // time library for rand seed 00016 00017 typedef struct _SpectrumFileType { 00018 string strTag; 00019 string strDescription; 00020 short m_iNumChan; 00021 unsigned long SerialNumber; 00022 string strSpectrumConfig; 00023 string strSpectrumStatus; 00024 } SpectrumFileType; 00025 00026 class CConsoleHelper 00027 { 00028 public: 00029 CConsoleHelper(void); 00030 ~CConsoleHelper(void); 00031 00033 CDppLibUsb DppLibUsb; 00035 bool LibUsb_isConnected; 00037 int LibUsb_NumDevices; 00039 bool LibUsb_Connect_Default_DPP(); 00041 void LibUsb_Close_Connection(); 00043 bool LibUsb_SendCommand(TRANSMIT_PACKET_TYPE XmtCmd); 00045 bool LibUsb_SendCommand_Config(TRANSMIT_PACKET_TYPE XmtCmd, CONFIG_OPTIONS CfgOptions); 00047 bool LibUsb_ReceiveData(); 00048 00049 // communications helper functions 00050 00052 CDP5Protocol DP5Proto; 00054 CSendCommand SndCmd; 00056 CParsePacket ParsePkt; 00058 CDP5Status DP5Stat; 00059 00060 // DPP packet processing functions. 00061 00063 bool ReceiveData(); 00065 void ProcessSpectrumEx(Packet_In PIN, DppStateType DppState); 00067 void ClearConfigReadFormatFlags(); 00069 void ProcessCfgReadEx(Packet_In PIN, DppStateType DppState); 00071 void CreateConfigOptions(CONFIG_OPTIONS *CfgOptions, string strCfg, CDP5Status DP5Stat, bool bUseCoarseFineGain); 00072 00073 //display support 00074 00076 void ConsoleGraph(long lData[], long chan, bool bLog, std::string strStatus); 00078 string DppStatusString; 00079 00080 // DPP configuration information variables 00081 00083 bool b80MHzMode; 00085 string strMcaMode; 00087 vector<string> Dp5CmdList; 00088 00089 // configuration readback format control flags 00090 // these flags control how the configuration readback is formatted and processed 00091 00093 bool DisplayCfg; 00095 bool DisplaySca; 00097 bool CfgReadBack; 00099 bool SaveCfg; 00101 bool PrintCfg; 00103 bool HwCfgReady; 00105 bool ScaReadBack; 00106 00107 // Tuning and display variables. 00108 00110 string HwCfgDP5; 00112 int mcaCH; 00114 double SlowThresholdPct; 00116 int FastChThreshold; 00118 double RiseUS; 00120 string strGainDisplayValue; 00122 int AcqMode; 00123 00124 // configuration presets for display (status updates preset progress) 00125 00127 int PresetCount; 00129 double PresetAcq; 00131 double PresetRt; 00133 string strPresetCmd; 00135 string strPresetVal; 00136 00137 // configuration support functions 00138 00140 string GetCmdData(string strCmd, string strCfgData); 00142 string ReplaceCmdDesc(string strCmd, string strCfgData); 00144 string AppendCmdDesc(string strCmd, string strCfgData); 00146 string GetCmdDesc(string strCmd); 00147 00148 // oscilloscope support 00149 00150 00151 bool UpdateScopeCfg; 00152 string strInputOffset; 00153 string strAnalogOut; 00154 string strOutputOffset; 00155 string strTriggerSource; 00156 string strTriggerSlope; 00157 string strTriggerPosition; 00158 string strScopeGain; 00159 00160 string CreateMCAData(long m_larDataBuffer[], SpectrumFileType sfInfo, DP4_FORMAT_STATUS cfgStatusLst); 00162 void SaveSpectrumStringToFile(string strData); 00163 string CreateSpectrumConfig(string strRawCfgIn) ; 00164 vector<string> MakeDp5CmdList(); 00165 SpectrumFileType sfInfo; 00166 00167 }; 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189