但未在发行版中运行

但未在发行版中运行

本文介绍了我的程序在调试模式下运行,但未在发行版中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一些代码可以对对话框进行编程,以从外部仪器中获取信息并在屏幕上显示值.当我在Debug模式下编译并运行代码时,它运行得很好,但是当我切换到Release时,程序崩溃并告诉我我访问的内容不正确.在Web上进行一些搜索后,我将编译器配置为无需优化即可运行,并且还尝试在项目配置中启用调试信息(对于Release).但是,它不会在发行版中的断点处停止,因此很难进行故障排除.我的印象是有些东西没有正确初始化,但是我找不到问题.有人可以帮忙吗?

这是对话框的实现文件.

I have some code that programs a dialog box to take in information from an outside instrument and display the values on the screen. When I compile and run my code in Debug mode it runs just fine, but when I switch to Release the program crashes and tells me I am accessing something incorrectly. After some searching on the web I configured my compiler to run without optimizations and also tried to enable debugging info in the project configurations (for Release). However, it does not stop at breakpoints in the Release version and so troubleshooting has been difficult. I get the impression that there is something not being initialized correctly, but I cannot find the problem. Can anyone help?

Here is the implementation file for the dialog box.

#include "stdafx.h"
#include "winstm.h"
#include "Dlg_Channel_Meter.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#ifdef HARDWARE_NI
/////////////////////////////////////////////////////////////////////////////
// CDlg_Channel_Meter dialog


CDlg_Channel_Meter::CDlg_Channel_Meter(CWnd* pParent /*=NULL*/)
	: CDialog(CDlg_Channel_Meter::IDD, pParent)
	, m_DAC_Dev(0)
{

	theInst = ((CWinSTMApp*)AfxGetApp())->GetInstrument();

	m_Scan_Chan[0] = 0;
	m_Scan_Chan[1] = 1;
	m_Scan_Chan[2] = 2;
	m_Scan_Chan[3] = 3;
	m_Scan_Chan[4] = 4;
	m_Scan_Chan[5] = 5;
	m_Scan_Chan[6] = 6;
	m_Scan_Chan[7] = 7;

	m_pThread = NULL;
	//{{AFX_DATA_INIT(CDlg_Channel_Meter)
	m_ADC0 = _T("");
	m_ADC1 = _T("");
	m_ADC2 = _T("");
	m_ADC3 = _T("");
	m_ADC4 = _T("");
	m_ADC5 = _T("");
	m_ADC6 = _T("");
	m_ADC7 = _T("");

	ticks = 0;
	counts = 0;
	upperlimit = 10;  //any number up to 100, 10 = 10 cyles, each cycle = 100 ms, so 10 = 1 seconds

	for (int i = 0; i < 8; i++)
	{
		m_ADC_data[i]=0;
		m_ADC_ddata[i]=0;
		for (int c = 0; c < upperlimit; c++)
		{
			m_ADC_a_array[i][c] = 0;
		}
	}

	m_ADC_a.SetSize (8);
	m_ADC_std.SetSize (8);

	m_ADC_a[0] = _T("");
	m_ADC_a[1] = _T("");
	m_ADC_a[2] = _T("");
	m_ADC_a[3] = _T("");
	m_ADC_a[4] = _T("");
	m_ADC_a[5] = _T("");
	m_ADC_a[6] = _T("");
	m_ADC_a[7] = _T("");

	m_ADC_std[0] = _T("");
	m_ADC_std[1] = _T("");
	m_ADC_std[2] = _T("");
	m_ADC_std[3] = _T("");
	m_ADC_std[4] = _T("");
	m_ADC_std[5] = _T("");
	m_ADC_std[6] = _T("");
	m_ADC_std[7] = _T("");

	//}}AFX_DATA_INIT

	if(AfxGetApp()->GetProfileInt("UEI DAC","Enable",0))
		m_DAC_Dev = -1;
	else
		m_DAC_Dev = theInst->m_DAQ.m_6508_Device;

}


void CDlg_Channel_Meter::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlg_Channel_Meter)
	DDX_Text(pDX, IDC_6052E_ADC0, m_ADC0);
	DDX_Text(pDX, IDC_6052E_ADC1, m_ADC1);
	DDX_Text(pDX, IDC_6052E_ADC2, m_ADC2);
	DDX_Text(pDX, IDC_6052E_ADC3, m_ADC3);
	DDX_Text(pDX, IDC_6052E_ADC4, m_ADC4);
	DDX_Text(pDX, IDC_6052E_ADC5, m_ADC5);
	DDX_Text(pDX, IDC_6052E_ADC6, m_ADC6);
	DDX_Text(pDX, IDC_6052E_ADC7, m_ADC7);

	DDX_Text(pDX, IDC_6052E_ADC0_a, m_ADC_a[0]);
	DDX_Text(pDX, IDC_6052E_ADC1_a, m_ADC_a[1]);
	DDX_Text(pDX, IDC_6052E_ADC2_a, m_ADC_a[2]);
	DDX_Text(pDX, IDC_6052E_ADC3_a, m_ADC_a[3]);
	DDX_Text(pDX, IDC_6052E_ADC4_a, m_ADC_a[4]);
	DDX_Text(pDX, IDC_6052E_ADC5_a, m_ADC_a[5]);
	DDX_Text(pDX, IDC_6052E_ADC6_a, m_ADC_a[6]);
	DDX_Text(pDX, IDC_6052E_ADC7_a, m_ADC_a[7]);

	DDX_Text(pDX, IDC_6052E_ADC0_std, m_ADC_std[0]);
	DDX_Text(pDX, IDC_6052E_ADC1_std, m_ADC_std[1]);
	DDX_Text(pDX, IDC_6052E_ADC2_std, m_ADC_std[2]);
	DDX_Text(pDX, IDC_6052E_ADC3_std, m_ADC_std[3]);
	DDX_Text(pDX, IDC_6052E_ADC4_std, m_ADC_std[4]);
	DDX_Text(pDX, IDC_6052E_ADC5_std, m_ADC_std[5]);
	DDX_Text(pDX, IDC_6052E_ADC6_std, m_ADC_std[6]);
	DDX_Text(pDX, IDC_6052E_ADC7_std, m_ADC_std[7]);

	DDX_Text(pDX, IDC_STATIC_CH0, theInst->m_ADC_Description[0]);
	DDX_Text(pDX, IDC_STATIC_CH1, theInst->m_ADC_Description[1]);
	DDX_Text(pDX, IDC_STATIC_CH2, theInst->m_ADC_Description[2]);
	DDX_Text(pDX, IDC_STATIC_CH3, theInst->m_ADC_Description[3]);
	DDX_Text(pDX, IDC_STATIC_CH4, theInst->m_ADC_Description[4]);
	DDX_Text(pDX, IDC_STATIC_CH5, theInst->m_ADC_Description[5]);
	DDX_Text(pDX, IDC_STATIC_CH6, theInst->m_ADC_Description[6]);
	DDX_Text(pDX, IDC_STATIC_CH7, theInst->m_ADC_Description[7]);

	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlg_Channel_Meter, CDialog)
	//{{AFX_MSG_MAP(CDlg_Channel_Meter)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlg_Channel_Meter message handlers

BOOL CDlg_Channel_Meter::OnInitDialog()
{
	CDialog::OnInitDialog();

	theInst->ADC_ScanSetup(8,&m_Scan_Chan[0]);

	for(int i = 0; i <8 ; i++)
	{
		m_6052_IO_State[i] = false;
		/////////////////////////m_6704_IO_State[i] = false;
	}

	// set update timer
	SetTimer(1,100,NULL); // JJS, second parameter is 100 ms

	UpdateData(false);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlg_Channel_Meter::OnTimer(UINT nIDEvent)
{
	theInst->ADCread(8,m_Scan_Chan,m_ADC_data);
	theInst->DAQ_VScale(m_6052_Device,8,m_ADC_data,m_ADC_ddata);

	for (int i = 0; i < 8; i++)
	{
		m_ADC_a_array[i][counts] = m_ADC_ddata[i];
	}

	counts++;
	ticks++;

	CStatic *stat=NULL;

	if (ticks >= 1)
	{
		m_ADC0.Format("%.4f V",m_ADC_ddata[0]);
		m_ADC1.Format("%.4f V",m_ADC_ddata[1]);
		m_ADC2.Format("%.4f V",m_ADC_ddata[2]);
		m_ADC3.Format("%.4f V",m_ADC_ddata[3]);
		m_ADC4.Format("%.4f V",m_ADC_ddata[4]);
		m_ADC5.Format("%.4f V",m_ADC_ddata[5]);
		m_ADC6.Format("%.4f V",m_ADC_ddata[6]);
		m_ADC7.Format("%.4f V",m_ADC_ddata[7]);

		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC0);
		stat->SetWindowText(m_ADC0);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC1);
		stat->SetWindowText(m_ADC1);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC2);
		stat->SetWindowText(m_ADC2);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC3);
		stat->SetWindowText(m_ADC3);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC4);
		stat->SetWindowText(m_ADC4);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC5);
		stat->SetWindowText(m_ADC5);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC6);
		stat->SetWindowText(m_ADC6);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC7);
		stat->SetWindowText(m_ADC7);
		ticks = 0;
	}

	if (counts >= upperlimit)
	{
		double average[8];
		double std[8];
		for (int i = 0; i < 8; i++)
		{
			average[i] = 0;
			std[i] = 0;
		}

		for (int i = 0; i < 8; i++)
		{
			for (int c = 0; c < upperlimit; c++)
			{
				average[i] += m_ADC_a_array[i][c];
			}
			average[i] = average[i] / upperlimit;
			for (int c = 0; c < upperlimit; c++)
			{
				double diff = (average[i] - m_ADC_a_array[i][c]);
				std[i] += (diff * diff);
			}
			std[i] = sqrt(std[i] / upperlimit);

			m_ADC_a[i].Format("%.4f V",average[i]);
			m_ADC_std[i].Format("%.4f V",std[i]);
		}

		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC0_a);
		stat->SetWindowText(m_ADC_a[0]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC1_a);
		stat->SetWindowText(m_ADC_a[1]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC2_a);
		stat->SetWindowText(m_ADC_a[2]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC3_a);
		stat->SetWindowText(m_ADC_a[3]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC4_a);
		stat->SetWindowText(m_ADC_a[4]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC5_a);
		stat->SetWindowText(m_ADC_a[5]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC6_a);
		stat->SetWindowText(m_ADC_a[6]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC7_a);
		stat->SetWindowText(m_ADC_a[7]);

		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC0_std);
		stat->SetWindowText(m_ADC_std[0]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC1_std);
		stat->SetWindowText(m_ADC_std[1]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC2_std);
		stat->SetWindowText(m_ADC_std[2]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC3_std);
		stat->SetWindowText(m_ADC_std[3]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC4_std);
		stat->SetWindowText(m_ADC_std[4]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC5_std);
		stat->SetWindowText(m_ADC_std[5]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC6_std);
		stat->SetWindowText(m_ADC_std[6]);
		stat = (CStatic*)GetDlgItem(IDC_6052E_ADC7_std);
		stat->SetWindowText(m_ADC_std[7]);

		for (int i = 0; i < 8; i++)
		{
			for (int c = 0; c < upperlimit; c++)
			{
				m_ADC_a_array[i][c] = 0;
			}
		}
		counts = 0;
	}
}


	/////////////////////////////////////////
// THIS MUST GO AT END OF FILE
#endif // #ifdef HARDWARE_NI
/////////////////////////////////////////

推荐答案


这篇关于我的程序在调试模式下运行,但未在发行版中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:15