Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion xtreeshr/XTreeDefaultResample.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,23 @@ inline static double *convertTimebaseToDouble(mds_signal_t *inSignalD,
}
double *outPtr = NULL;
EMPTYXD(currXd);
EMPTYXD(startXd);
EMPTYXD(endXd);
EMPTYXD(deltaXd);

int numSamples, i;
mdsdsc_a_t *currDim = (mdsdsc_a_t *)inSignalD->dimensions[0];
if (currDim->class != CLASS_A)
{
if (IS_NOT_OK(TdiData(currDim, &currXd MDS_END_ARG)))
//Reset time context when evaluating timebase to avoid errors in case the timebase expression refers to segmented data
TreeGetTimeContext(&startXd, &endXd, &deltaXd);
TreeSetTimeContext(NULL, NULL, NULL);
int status = TdiData(currDim, &currXd MDS_END_ARG);
TreeSetTimeContext(startXd.pointer, endXd.pointer, deltaXd.pointer);
MdsFree1Dx(&startXd, NULL);
MdsFree1Dx(&endXd, NULL);
MdsFree1Dx(&deltaXd, NULL);
if (IS_NOT_OK(status))
goto return_out;
currDim = (mdsdsc_a_t *)currXd.pointer;
}
Expand Down
38 changes: 36 additions & 2 deletions xtreeshr/XTreeGetTimedRecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ static int checkResampledVersion(int nid, mdsdsc_t *deltaD)
return outNid;
}

EXPORT int XTreeGetTimedRecord(int inNid, mdsdsc_t *startD, mdsdsc_t *endD,
mdsdsc_t *minDeltaD, mdsdsc_xd_t *outSignal)
EXPORT int XTreeGetTimedRecord(int inNid, mdsdsc_t *inStartD, mdsdsc_t *inEndD,
mdsdsc_t *inMinDeltaD, mdsdsc_xd_t *outSignal)
{
int status, nid;
int actNumSegments, currSegIdx, nonEmptySegIdx, numSegments, currIdx,
Expand All @@ -132,6 +132,36 @@ EXPORT int XTreeGetTimedRecord(int inNid, mdsdsc_t *startD, mdsdsc_t *endD,
EMPTYXD(endTimesXd);
double *startTimes, *endTimes, start, end;


//Start, End, Delta MUST be copied becuse they may become invalid in case TreeSetTimeContext is internally called (e.g. in DefaultResample)
EMPTYXD(startXd);
EMPTYXD(endXd);
EMPTYXD(minDeltaXd);
mdsdsc_t *startD, *endD, *minDeltaD;
if (inStartD)
{
MdsCopyDxXd(inStartD, &startXd);
startD = startXd.pointer;
}
else
startD = NULL;
if (inEndD)
{
MdsCopyDxXd(inEndD, &endXd);
endD = endXd.pointer;
}
else
endD = NULL;
if (inMinDeltaD)
{
MdsCopyDxXd(inMinDeltaD, &minDeltaXd);
minDeltaD = minDeltaXd.pointer;
}
else
minDeltaD = NULL;



mdsdsc_t resampleFunNameD = {0, DTYPE_T, CLASS_S, resampleFunName};
mdsdsc_t squishFunNameD = {0, DTYPE_T, CLASS_S, squishFunName};
DESCRIPTOR_R(resampleFunD, DTYPE_FUNCTION, 6);
Expand Down Expand Up @@ -456,6 +486,10 @@ EXPORT int XTreeGetTimedRecord(int inNid, mdsdsc_t *startD, mdsdsc_t *endD,
MdsFree1Dx(&emptyXd, NULL);
}
}
MdsFree1Dx(&startXd, NULL);
MdsFree1Dx(&endXd, NULL);
MdsFree1Dx(&minDeltaXd, NULL);

return status;
}

Expand Down