It should be ok i think, by small test app i tried. Same way that you can convert single to double, and byte to single, etc.
You can just write this too:
ChannelValue[j,CurrentSample]:=EngUnits;
I tried with
ChannelValue[j,CurrentSample]:= EngUnits; and since it crashed, I tried
ChannelValue[j,CurrentSample]:= Extended(EngUnits);Other than that, i don't see why you should use extended type if original data comes as single. You're just using much more memory.
The idea of DAQData is to be as a general format, for using with different data acquisition devices (DAQ) or files.
While I do not expect to have a DAQ with more than 24 or let's say 32 bits resolution, some files some files use 8 bytes per sample, used in a strange way, so that I am not sure that even extended vars will be sufficient in some cases.
Hmm, I see now.
Now I think it crashes on bad indexing of "CurrentSample"
ChannelValue[j,CurrentSample]:= Extended(EngUnits);
end;
index:= index+ ChannelCount ;
CurrentSample:=CurrentSample+1;
end;
When I replaced the last line:
CurrentSample:=0; //CurrentSample+1;
it did not crash.
But I run modified code, I had to comment many lines because code is incomplete.
Shall I understand that the app crashed for you, too, before changing that line?
The idea of that piece of code is that I have for example four measurement channels, but all data comes from the DAQ in a single array. Data for each channel comes serially- one sample from channel 1, one form channel 2, one form channel 3, one from channel 4 and again - channel 1;2;3;4.
EDIT: It is really an indexing problem, the bug is here:
for i:= 0 to Length(ADData)-1 doIt should be something like:
for i:= 0 to trunc(Length(ADData)/ChannelCount-1) do //TODO: to make sure that Length(ADData) is dividable by ChannelCount.
I still have some bug around, but I'll handle it later.
Still I do not (and probably I won't) understand why the compiler does not crash during the cycle, but at a later stage and why it does it with single precision values only.
Thanks for the help!