Exemplo n.º 1
0
        private void buttonDWGfromArray_Click(object sender, EventArgs e)
        {
            int error = 0;

            // Config the Output Bus selected in pins 0 to 15 of Port selected
            moduleDIO.busConfig(SD_DIO_Bus.DIO_OUTPUT_BUS0 + nChannel, nChannel, 0, 15);

            //Config all pins of both ports as output
            moduleDIO.IOdirectionConfig(-1 /*0XFFFFFFFFFFFFFFFF*/, SD_PinDirections.DIR_OUT);

            // Erase all waveforms from module memory
            moduleDIO.waveformFlush();

            printToConsole("Module configuration successfull. Press any key to start the DWG.");
            runPause();

            //Load waveforms from Array with prestaler 1 (100MSPS) and infinite cycles
            int[] points = { 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 };
            error = moduleDIO.DWG(nChannel, SD_TriggerModes.AUTOTRIG, 0, 0, 1, SD_WaveformTypes.WAVE_DIGITAL, points);
            if (error < 0)
            {
                printToConsole(SD_Error.getErrorMessage(error));
                return;
            }

            printToConsole("Press any key to stop the DWG.");
            runPause();

            moduleDIO.DWGstop(nChannel);

            printToConsole("Press any key to finish.");
            runPause();
        }
Exemplo n.º 2
0
        private void stopButton_Click(object sender, EventArgs e)
        {
            int error;

            if ((error = this.HVI.stop()) < 0)
            {
                MessageBox.Show("Error", SD_Error.getErrorMessage(error), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void triggerWrite_Click(object sender, EventArgs e)
        {
            int error;

            if (this.module == null)
            {
                MessageBox.Show("Error", "No module owned.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if ((error = this.module.PXItriggerWrite((int)(this.registerNumber.Value), (int)(this.value2write.Value))) < 0)
                {
                    MessageBox.Show("Error", SD_Error.getErrorMessage(error), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 4
0
        private void openButton_Click(object sender, EventArgs e)
        {
            int error;

            if ((error = this.HVI.open(this.HVIpath.Text)) < 0)
            {
                MessageBox.Show("Error", SD_Error.getErrorMessage(error), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                this.openButton.Enabled   = false;
                this.closeButton.Enabled  = true;
                this.moduleButton.Enabled = true;
                this.startButton.Enabled  = true;
                this.stopButton.Enabled   = true;
                this.pauseButton.Enabled  = true;
                this.resumeButton.Enabled = true;
            }
        }
Exemplo n.º 5
0
        private void triggerRead_Click(object sender, EventArgs e)
        {
            int value;

            if (this.module == null)
            {
                MessageBox.Show("Error", "No module owned.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                value = this.module.PXItriggerRead((int)(this.registerNumber.Value));
                if (value < 0)
                {
                    MessageBox.Show("Error", SD_Error.getErrorMessage(value), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    this.readTrigger.Text = value.ToString();
                }
            }
        }
Exemplo n.º 6
0
        private void readButton_Click(object sender, EventArgs e)
        {
            int error, value;

            if (this.module == null)
            {
                MessageBox.Show("Error", "No module owned.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                value = this.module.readVariable((int)(this.registerNumber.Value), out error);
                if (error < 0)
                {
                    MessageBox.Show("Error", SD_Error.getErrorMessage(error), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    this.readValue.Text = value.ToString();
                }
            }
        }
Exemplo n.º 7
0
        private void buttonBuses_Click(object sender, EventArgs e)
        {
            int error, dataAux;

            // Config the Output Bus selected in pins 0 to 15 of Port selected
            moduleDIO.busConfig(SD_DIO_Bus.DIO_OUTPUT_BUS0 + nChannel, nChannel, 0, 15);

            // Config the Input Bus selected in pins 0 to 15 of Port selected
            moduleDIO.busConfig(SD_DIO_Bus.DIO_INPUT_BUS0 + nChannel, nChannel, 1, 15);

            //Config all pins as output
            moduleDIO.IOdirectionConfig(-1 /*0xFFFFFFFFFFFFFFFF*/, SD_PinDirections.DIR_OUT);

            printToConsole("Module configuration successfull. Press any key to set the trigger.");
            runPause();

            dataAux = 32768;

            while (dataAux > 0)
            {
                error = moduleDIO.busWrite(SD_DIO_Bus.DIO_OUTPUT_BUS0 + nChannel, dataAux);
                if (error < 0)
                {
                    return;
                }

                printToConsole("Write data in OutputBus 0\n");

                dataAux = moduleDIO.busRead(SD_DIO_Bus.DIO_INPUT_BUS0 + nChannel, out error);
                if (error < 0)
                {
                    printToConsole(SD_Error.getErrorMessage(error));
                    return;
                }

                printToConsole("Read data in InputBus : " + dataAux.ToString());
                runPause();
            }
        }
Exemplo n.º 8
0
        private void closeButton_Click(object sender, EventArgs e)
        {
            int error;

            if ((error = this.HVI.close()) < 0)
            {
                MessageBox.Show("Error", SD_Error.getErrorMessage(error), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                this.openButton.Enabled   = true;
                this.closeButton.Enabled  = false;
                this.startButton.Enabled  = false;
                this.stopButton.Enabled   = false;
                this.pauseButton.Enabled  = false;
                this.resumeButton.Enabled = false;
                this.moduleButton.Enabled = false;
                this.module               = null;
                this.readButton.Enabled   = false;
                this.writeButton.Enabled  = false;
                this.triggerRead.Enabled  = false;
                this.triggerWrite.Enabled = false;
            }
        }
Exemplo n.º 9
0
        private void buttonDAQwithBuffers_Click(object sender, EventArgs e)
        {
            ulong dataPrev = 0;

            ulong[] dataBuffer      = new ulong[16];
            int     totalPointsRead = 0;
            int     nPointsRead     = 0;
            int     error           = 0;
            int     i = 0;

            // Config DAQ Buffers Pool with Callback
            moduleTDC.DAQbufferPoolConfig(nChannel, dataBuffer, 1000);

            // Add other buffer
            dataBuffer = new ulong[16];
            moduleTDC.DAQbufferAdd(nChannel, dataBuffer);

            // Stop DAQ
            moduleTDC.DAQstop(nChannel);

            // Flush DAQ
            moduleTDC.DAQflush(nChannel);

            // Config DAQ with two cycles of 16 points
            moduleTDC.DAQconfig(nChannel, 16, 2, 1, SD_TriggerModes.VIHVITRIG);

            printToConsole("Module configuration successfull. Press any key to start the DAQ.");
            runPause();

            // Start DAQ
            moduleTDC.DAQstart(nChannel);

            printToConsole("DAQ started. Waiting for trigger for first cycles. Press any key to send a VI/HVI trigger.");
            runPause();

            // Send VI/HVI trigger
            moduleTDC.DAQtrigger(nChannel);

            // Waiting for 16 points (first cycle)
            while (moduleTDC.DAQcounterRead(nChannel) < 16)
            {
                ;
            }

            printToConsole("DAQ has acquired " + (moduleTDC.DAQcounterRead(nChannel)).ToString() + " points.");
            runPause();

            printToConsole("Waiting for another trigger for second cycles. Press any key to send a VI/HVI trigger.");
            runPause();

            // Send VI/HVI trigger
            moduleTDC.DAQtrigger(nChannel);

            // Waiting for 16 points (second cycle)
            while (moduleTDC.DAQcounterRead(nChannel) < 32)
            {
                ;
            }

            printToConsole("DAQ has acquired " + (moduleTDC.DAQcounterRead(nChannel)).ToString() + " points.");
            runPause();

            // Read data
            while (totalPointsRead < 32)
            {
                dataBuffer = moduleTDC.DAQbufferGet(nChannel, out nPointsRead, out error);
                printToConsole("Points Read : " + nPointsRead.ToString());
                printToConsole("error : " + SD_Error.getErrorMessage(error));
                printToConsole("Data Buffer: ");
                for (i = 0; i < nPointsRead; i++)
                {
                    printToConsole("\tData[" + (i + totalPointsRead).ToString() + "] : " + dataBuffer[i].ToString() + " ps : difference = " + (dataBuffer[i] - dataPrev).ToString() + " ps\n");
                    dataPrev = dataBuffer[i];
                }

                totalPointsRead = totalPointsRead + nPointsRead;
                printToConsole("Total Points read : " + totalPointsRead.ToString());
            }

            printToConsole("Press any key to finish.");
            runPause();

            // Free all  buffers
            moduleTDC.DAQbufferPoolRelease(nChannel);
            while (moduleTDC.DAQbufferRemove(nChannel) != null)
            {
                ;
            }
        }