ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  MFC Release Mode Error.
Posted by test on Dec-05-2014 14:37
Hello. , I have used the translation. I have been using the MFC now .
In DEBUG mode , I came out on a regular basis . However, in Release mode , and
disappear all but only one value .
Thank you.
code==========================
Layer *layer[TREND_MAX_TAG_CNT];
/*Layer **layer = (Layer**)malloc(sizeof(Layer*)*
(TREND_MAX_TAG_CNT));//[TREND_MAX_TAG_CNT];
for(int i=0; i<TREND_MAX_TAG_CNT; i++)
{
layer[i] = (Layer*)malloc(sizeof(Layer));
memset(layer[i], 0x0, sizeof(Layer));
}
*/
double **dData = (double**)malloc(sizeof(double *)*TREND_MAX_TAG_CNT);
double **dXData = (double**)malloc(sizeof(double *)*TREND_MAX_TAG_CNT);

int idx = 0;
while(pos != NULL)
{
int data_len = -1;

ST_EWS_CLIENT_TREND_DATA block_data = block_list.GetNext(pos);

//Call DB Data
CTime endTime;
if(m_iPlayMode == PDR_PLAY_MODE::REALTIME) endTime = eTime;
else if(m_iPlayMode == PDR_PLAY_MODE::REPLAY)
{
if(eTime > m_reETime) endTime = m_reETime;
else endTime = eTime;
}

/*ST_EWS_CLIENT_TAG_DATA *tag_data*/
/*m_tag_data*/ ST_EWS_CLIENT_TAG_DATA *tag_data =
::umdEWSCGetTagData( getTimeString(&sTime).GetBuffer(),
getTimeString(&endTime).GetBuffer(),
block_data.loop, block_data.pcu, block_data.module, block_data.block,
&data_len);

POSITION findPos = m_trendList.Find(block_data);

dData[idx] = (double*)malloc(sizeof(double)*(data_len));
dXData[idx] = (double*)malloc(sizeof(double)*(data_len));

memset(dData[idx], 0, sizeof(double)*(data_len));
memset(dXData[idx], 0, sizeof(double)*(data_len));

CTime fTime = sTime;

//statistics
ST_TREND_STAT_DATA statData;
statData.loop = block_data.loop;
statData.pcu = block_data.pcu;
statData.module = block_data.module;
statData.block = block_data.block;
statData.strLabel = block_data.strLabel;
statData.dMin = NONE_DATA;
statData.dMax = NONE_DATA;
statData.dAvg = NONE_DATA;
//

double dMin, dMax, dSum;
dMin = 99999999999;
dMax = -99999999999;
dSum = 0;

ST_CURR_TREND_DATA currData; //current data
memset(&currData, 0, sizeof(ST_CURR_TREND_DATA));
currData.data_len = data_len;
if(data_len>0) currData.data_list =
(ST_TREND_DATA*)malloc(sizeof(ST_TREND_DATA)*data_len);

for(int i=0; i<data_len; i++)
{
// block_data.value = getTestValue(block_data.lowScale,
block_data.highScale);//atof(tag_data[i].VALUE);
block_data.value = atof(tag_data[i].VALUE);
block_data.old_value = atof(tag_data[i].VALUE);

if(block_data.value > block_data.highScale) block_data.value =
block_data.highScale;
else if(block_data.value < block_data.lowScale) block_data.value =
block_data.lowScale;

dData[idx][i] = block_data.value;
dXData[idx][i] =
Chart::chartTime(getDateNumber(DATE_UNIT_ITEM_IDX::YEAR,
tag_data[i].EWS_DATA_TIME),

getDateNumber(DATE_UNIT_ITEM_IDX::MONTH, tag_data[i].EWS_DATA_TIME),

getDateNumber(DATE_UNIT_ITEM_IDX::DAY, tag_data[i].EWS_DATA_TIME),

getDateNumber(DATE_UNIT_ITEM_IDX::HOUR, tag_data[i].EWS_DATA_TIME),

getDateNumber(DATE_UNIT_ITEM_IDX::MIN, tag_data[i].EWS_DATA_TIME),

getDateNumber(DATE_UNIT_ITEM_IDX::SEC, tag_data[i].EWS_DATA_TIME));


if( (block_data.lowScale != m_xyChart->yAxis()->getMinValue()) ||
(block_data.highScale != m_xyChart->yAxis()->getMaxValue()))
{
/*
double dVal = (block_data.value/(block_data.highScale -
block_data.lowScale)) * 100;
dVal = (dVal * (m_xyChart->yAxis()->getMaxValue() -
m_xyChart->yAxis()->getMinValue()))/100;
dData[i] = dVal;
*/
double dVal = ((block_data.value-
block_data.lowScale)/(block_data.highScale - block_data.lowScale)) * 100;
dVal = (m_xyChart->yAxis()->getMaxValue() - m_xyChart-
>yAxis()->getMinValue())*(dVal/100)+m_xyChart->yAxis()->getMinValue();
dData[idx][i] = dVal;
}
//Log
//statistics
//Min
if(dMin >= block_data.value)
{
dMin = block_data.value;
statData.strMinDate.Format("%s",
tag_data[i].EWS_DATA_TIME);
}
//Max
if(dMax <= block_data.value)
{
dMax = block_data.value;
statData.strMaxDate.Format("%s",
tag_data[i].EWS_DATA_TIME);
}
dSum += block_data.value;

//Set Current Trend Data---------------------------------------------------
-----------
ST_TREND_DATA trendData;
trendData.loop = statData.loop;
trendData.pcu = statData.pcu;
trendData.module = statData.module;
trendData.block = statData.block;
trendData.value = block_data.old_value;//block_data.value;
//Date
trendData.year = getDateNumber(DATE_UNIT_ITEM_IDX::YEAR,
tag_data[i].EWS_DATA_TIME);
trendData.month = getDateNumber(DATE_UNIT_ITEM_IDX::MONTH,
tag_data[i].EWS_DATA_TIME);
trendData.day = getDateNumber(DATE_UNIT_ITEM_IDX::DAY,
tag_data[i].EWS_DATA_TIME);
trendData.hour = getDateNumber(DATE_UNIT_ITEM_IDX::HOUR,
tag_data[i].EWS_DATA_TIME);
trendData.min = getDateNumber(DATE_UNIT_ITEM_IDX::MIN,
tag_data[i].EWS_DATA_TIME);
trendData.sec = getDateNumber(DATE_UNIT_ITEM_IDX::SEC,
tag_data[i].EWS_DATA_TIME);

currData.loop = statData.loop;
currData.pcu = statData.pcu;
currData.module = statData.module;
currData.block = statData.block;

currData.data_list[i] = trendData;
//-----------------------------------------------------------------------------
---------
}

//Current Data
m_currDataList.AddTail(currData);

if(data_len == 0)
{
block_data.value = Chart::NoValue;
}
else
{
//statistics
statData.dMin = dMin;
statData.dMax = dMax;
statData.dAvg = dSum/data_len;
}
m_statList.AddTail(statData); //statistics

if(pInIFile->getTrendCurveType() == TREND_CURVE_TYPE::DEFAULT ||
pInIFile->getTrendCurveType() ==
TREND_CURVE_TYPE::INTERPOLATED)
{
layer[idx] = m_xyChart->addLineLayer();
}
else if( pInIFile->getTrendCurveType() == TREND_CURVE_TYPE::STEP)
{
layer[idx] = m_xyChart->addStepLineLayer();
}


layer[idx]->addDataSet(DoubleArray(dData[idx], data_len),
strtol(block_data.strColor, NULL, 16) , block_data.strLabel/*)-
>setDataSymbol(Chart::CircleSymbol*/);
layer[idx]->setXData(DoubleArray(dXData[idx], data_len));

if(iBlock_idx == 0 && m_iCurrGridIdx != -1) layer[idx]-
>setLineWidth(TREND_BOLD_LINE_WIDTH);
else layer[idx]->setLineWidth(TREND_NOMAL_LINE_WIDTH);

if(data_len>0) ::umsCommonDeleteDLLMemory(tag_data);
iBlock_idx++;

m_trendList.SetAt(findPos, block_data);

free(dData[idx]);
free(dXData[idx]);


idx++;
}

iTick = 0;
if(iCurrTimeSpan < XAXIS_STEP) iTick = 1;
else if(iCurrTimeSpan == XAXIS_STEP) iTick = 0;
else iTick = (int)(iCurrTimeSpan/XAXIS_STEP);

m_xyChart->xAxis()->setDateScale(Chart::chartTime(

sTime.GetYear(),

sTime.GetMonth(),

sTime.GetDay(),

sTime.GetHour(),

sTime.GetMinute(),

sTime.GetSecond()),
Chart::chartTime(

eTime.GetYear(),

eTime.GetMonth(),

eTime.GetDay(),

eTime.GetHour(),

eTime.GetMinute(),

eTime.GetSecond()), iTick);

m_xyChart->xAxis()->setLabelFormat("{value|hh:nn:ss\\ndd-mm-yyyy}");

free(dData);
free(dXData);

  Re: MFC Release Mode Error.
Posted by Peter Kwan on Dec-06-2014 03:10
Hi test,

As I do not have your complete code or data and also have not seen your charts, it is
hard for me to diagnose the problem. However, note that there is only one ChartDirector
DLL "chartdir51.dll", and it is already compiled by us in Release mode. In your case, the
Debug and Release mode only affects the compilation of your code. It cannot affect
ChartDirector which is already compiled. If the chart only shows one value, is it possible
your code only provide one value in Release mode?

One method to diagnose the problem is to simply dump the data you passed to
ChartDirector. For example, in your code, you have:

layer[idx]->addDataSet(DoubleArray(dData[idx], data_len),
strtol(block_data.strColor, NULL, 16) , block_data.strLabel/*)-
>setDataSymbol(Chart::CircleSymbol*/);

layer[idx]->setXData(DoubleArray(dXData[idx], data_len));

You can print the dump the data to a file using:

FILE *f = fopen("c:\\\\test.log", "a");
fprintf("Idx=%d, data_len=%d\\n", idx, data_len);
for (int i = 0; i < data_len; ++i)
    fprintf("(f, %f, %f)\\n", dData[idx][i], dXData[idx][i]);
fclose(f);

In this way, you can compare if the data used in Release mode and Debug mode are the
same. To avoid uncertainties, you can also remove all code that sets the x-axis or y-axis
scale, and let ChartDirector automatically determine the scale based on your data.

Regards
Peter Kwan