예제 #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            if (!inited)
            {
                MessageBox.Show("Avesta not inited");
                return;
            }

            int    pixels = ExtendParams.nNumPixelsH * ExtendParams.nNumPixelsV * ExtendParams.nNumReadOuts;
            int    cb     = pixels * sizeof(uint);
            IntPtr pData  = Marshal.AllocHGlobal(cb);

            UsbCCD.CCD_InitMeasuringData(0, pData);
            UsbCCD.CCD_StartWaitMeasuring(0);
            int[] data = new int[pixels];

            Marshal.Copy(pData, data, 0, data.Length);

            for (int i = 0; i < data.Length; i++)
            {
                int val = (int)data[i];
                //double y = val;
                chart1.Series[0].Points.AddXY(i, val);
            }

            Marshal.FreeHGlobal(pData);
        }
예제 #2
0
        private void Button3_Click(object sender, EventArgs e)
        {
            if (!inited)
            {
                MessageBox.Show("Avesta not inited");
                return;
            }

            UsbCCD.CCD_SetParameter(0, UsbCCD.PRM_EXPTIME, 4000f);

            int    pixels = ExtendParams.nNumPixelsH * 1;//ExtendParams.nNumPixelsH * ExtendParams.nNumPixelsV * ExtendParams.nNumReadOuts;
            int    cb     = pixels * sizeof(uint);
            IntPtr pData  = Marshal.AllocHGlobal(cb);

            bool res = UsbCCD.CCD_InitMeasuring(0);

            UsbCCD.CCD_StartWaitMeasuring(0);


            int[]  data  = new int[pixels];
            byte[] bData = new byte[cb];
            UsbCCD.CCD_GetData(0, pData);

            Marshal.Copy(pData, data, 0, data.Length);
            //Marshal.Copy(pData, bData, 0, bData.Length);

            Marshal.FreeHGlobal(pData);


            using (var sw = new StreamWriter("data.txt", false))
            {
                for (int i = 0; i < data.Length; i++)
                {
                    sw.WriteLine(data[i]);
                }
                sw.Close();
            }

            chart1.Series[0].Points.Clear();
            for (int i = 0; i < data.Length; i++)
            {
                uint val = (uint)data[i];
                //double y = val;
                chart1.Series[0].Points.AddXY(i, val);
            }
        }