DppApi C++ Development

Examples provide cut/paste solutions for rapid application development. Below is a list of examples demonstrating Visual C++ DppApi development.

  • vcDppApi - DPPAPI Demonstration Project

    • Plots in linear and log scales.

    • Start/Stop acquisition loop.

  • vcMinEx - Minimum C++ Example

    • Minimum code required for spectrum acquisition.

    • Snapshot data acquisition.

  • vcDppApi and vcMinEx Both:

    • Find connected USB DPP devices.

    • Selects default USB DPP device from a list of connected devices.

    • Acquires spectrum data.

    • Reads/displays DPP status.

    • Reads DPP configuration.

    • Sends/Receives DPP configurations through USB.

  • Demonstrates DppApi control of Amptek USB DPP devices.

  • Visual C++ 7.1 source code.

vcDppApi - DPPAPI Demonstration Project

vcMinEx - Minimum C++ Example


Amptek DppAPI (C)2008 - Wednesday, December 31, 2008

The 1.0.1.6 DPPAPI is Pre-Release,
a release version with updated documentation will be available soon.

Changes from 1.0.1.4 to 1.0.1.6

- The DPPAPI has been updated to include the DP5.
- See the following DP5 documents for DP5 reference:
            DP5 Software Migration A3.pdf
            DP5 Product Changes B1.pdf
- The device type value has been changed
- A generic a generic DPP Vendor Request has been added
- FPGA clock functions have been added (DP5 only)

// Run GetStatusStruct or GetStatusString before running Get80MHzMode

///////////////////////////////////////////////////////////////////////////////
// New DPP/DP5 Functions
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// SendDPPVendorRequest -  Sends a generic DPP Vendor Request to the default usb device
void __stdcall SendDppVendorRequest(void * objptr, int Request, int Value);

///////////////////////////////////////////////////////////////////////////////
// Get80MHzMode -  get 80MHzMode for DP5 only, returns true if DP5 and in 80MHzMode
// Run GetStatusStruct or GetStatusString before running Get80MHzMode
long __stdcall Get80MHzMode(void * objptr);

///////////////////////////////////////////////////////////////////////////////
// SetFPGAClockDefault -  set 80MHzMode for DP5 only
void __stdcall SetFPGAClockDefault(void * objptr, BOOLEAN b80MHzMode, byte DPPDeviceType);

// determining the device type:
    indDPP5 = (byte)(StatusLst.Firmware >= 5.0);  //DPP5 20071023 indicates DPP5 type device
    DppDevice = ((indDPP5 * 2) + (StatusLst.StatDevInd * 1)) + 1;

// new device type values
enum DeviceType {
    devtypNONE = 0,		// no dpp device
    devtypDP4 = 1,		// dp4
    devtypPX4 = 2,		//px4
    devtypDP4EMUL = 3,	// dp5 (dp4 emulation)
    devtypPX4EMUL = 4	// dp5 (px4 emulation)
};

// !!!! new device values must be used for functions requiring a device type value !!!!!

/////////////////////////////////////////////////
// The FPGA Clock Default must be set to
// correctly read DP5 configuration files
// Run GetStatusStruct or GetStatusString before running Get80MHzMode
/////////////////////////////////////////////////
    Dpp80MHzMode = (BOOLEAN) Get80MHzMode(objDppApi);			// get clock value
    SetFPGAClockDefault (objDppApi, Dpp80MHzMode, DppDevice);	// set clock value

CString GetDeviceNameFromVal(int DeviceTypeVal) {
    CString cstrDeviceType;
    switch(DeviceTypeVal) {
        case 1:
            cstrDeviceType = "DP4";
            break;
        case 2:
            cstrDeviceType = "PX4";
            break;
        case 3:
            cstrDeviceType = "DP4EMUL";
            break;
        case 4:
            cstrDeviceType = "DP5";
            break;
        default:           // unknown
            cstrDeviceType = "";
            break;
    }
    return cstrDeviceType;
}

// an example of the OLD configuration read
void OnBnClickedConfigButton_OLD() {
    int numdev;											// number of usb devices
    void * objDppApi;									// pointer to dpp api
    CString cstrStatus;									// status display string
    long FilenameLen;									//
    byte DppDevice;
    DPP_STATUS StatusLst;

    GetDlgItem(IDC_CONFIG_BUTTON)->EnableWindow(false);	// disable button until done
    objDppApi = OpenDppApi();							// Create/Open DPPAPI
    numdev = OpenUSBDevice(objDppApi);					// Open USB communications
    if (numdev > 0) {
        GetStatusStruct(objDppApi, true, &StatusLst);	// get device status
        cstrStatus.Format("(s/n %7i)",(ULONG)StatusLst.SerialNumber);
        if (StatusLst.SerialNumber < 1) {
            GetDlgItem(IDC_STATUS_STATIC)->SetWindowText("Device status error.");
        } else {
            if(PromptFileName()) {						// get the configuration filename
                DppDevice = StatusLst.StatDevInd;
                FilenameLen = (long)m_csCurrentFile.GetLength();
                GetConfigFromFile(objDppApi, m_csCurrentFile, FilenameLen, DppDevice);
                SendConfigToDpp(objDppApi);
                GetDlgItem(IDC_STATUS_STATIC)->SetWindowText("Configuration loaded from file and sent to device. " + cstrStatus);
            } else {
                GetDlgItem(IDC_STATUS_STATIC)->SetWindowText("No configuration file selected.");
            }
        }
    } else {
        GetDlgItem(IDC_STATUS_STATIC)->SetWindowText("No devices detected.");
    }
    CloseUSBDevice (objDppApi);							// 7. close usb
    CloseDppApi (objDppApi);	                		// 8. close DPPAPI
    Sleep(750);
    GetDlgItem(IDC_CONFIG_BUTTON)->EnableWindow(true);
}

// Example of the new configuration read
void OnBnClickedConfigButton_NEW() {
    int numdev;											// number of usb devices
    void * objDppApi;									// pointer to dpp api
    CString cstrStatus;									// status display string
    long FilenameLen;									//
    byte DppDevice;
    byte indDPP5;
    DPP_STATUS StatusLst;
    BOOLEAN Dpp80MHzMode;

    GetDlgItem(IDC_CONFIG_BUTTON)->EnableWindow(false);	// disable button until done
    objDppApi = OpenDppApi();							// Create/Open DPPAPI
    numdev = OpenUSBDevice(objDppApi);					// Open USB communications
    if (numdev > 0) {
        GetStatusStruct(objDppApi, true, &StatusLst);	// get device status
        cstrStatus.Format("(s/n %7i)",StatusLst.SerialNumber);
        if (StatusLst.SerialNumber < 1) {				// check if device status can be read
            GetDlgItem(IDC_STATUS_STATIC)->SetWindowText("Device status error.");
        } else {										// device is communicating, get the config file
            if(PromptFileName()) {						// get the configuration filename, if any config dpp
                DppDevice = StatusLst.StatDevInd;		// determine device type (0=dp4,1=px4)

                //////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////////////////////////
                indDPP5 = (byte)(StatusLst.Firmware >= 5.0);  //DPP5 20071023 indicates DPP5 type device
                DppDevice = ((indDPP5 * 2) + (StatusLst.StatDevInd * 1)) + 1;
                // Run GetStatusStruct or GetStatusString before running Get80MHzMode
                Dpp80MHzMode = (BOOLEAN) Get80MHzMode(objDppApi);
                SetFPGAClockDefault (objDppApi, Dpp80MHzMode, DppDevice);
                //////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////////////////////////

                FilenameLen = (long)m_csCurrentFile.GetLength();	// get configuration filename buffer length
                GetConfigFromFile(objDppApi, m_csCurrentFile, FilenameLen, DppDevice);	// load cfg into dppapi
                SendConfigToDpp(objDppApi);												// send cfg to dpp
                GetDlgItem(IDC_STATUS_STATIC)->SetWindowText("Configuration loaded from file and sent to device. " + cstrStatus);
            } else {
                GetDlgItem(IDC_STATUS_STATIC)->SetWindowText("No configuration file selected.");
            }
        }
    } else {
        GetDlgItem(IDC_STATUS_STATIC)->SetWindowText("No devices detected.");
    }
    CloseUSBDevice (objDppApi);							// close usb
    CloseDppApi (objDppApi);	                		// close DPPAPI
    Sleep(750);
    GetDlgItem(IDC_CONFIG_BUTTON)->EnableWindow(true);
}