/** Directions for use: ** After including other files, like "encodes.h" and "css_inc.h", ** insert the line ** #include "extenc.h" ** At the end of your source code, inlude the following line ** #include "extenc.c" ** ** To encode a floating point number in the data file, your function ** should look something like this ** ** void YourFunction(...) { ** float x; int y; ** ... ** encode(YourMarker1); ** EncodeFloat(&x); ** ... ** encode(YourMarker2); ** EncodeInt(&y); ** ... ** } ** ** Encoding an integer looks the same ** ** The encoding of "YourMarker" is optional. But, if you have several ** locations in which you are encoding numbers, then this can serve ** to differentiate them, (ie, by using different markers before the ** float or int is encoded.) To extract the float or int, you can use ** the Matlab functions ctx2mat and convint/convfloat. ** ** Shorts only exist in the 16-bit version of Cortex. (In which case, an ** int is 16-bits and a long is 32.) In the 32-bit version, all ints ** and longs are 32-bits. ** ** If you want to use the DatawaveEncode function (which tells the ** Datawave machine to encode something in its data file) you need to do ** #define DATAWAVE ** #include "extenc.h" **/ #ifndef _EXT_ENCODES_C_ #define _EXT_ENCODES_C_ void EncodeFloat(pchar WeirdFloat) { encode(FLOAT_MARKER); encode(ENCODE_FLOAT1 | WeirdFloat[0]); encode(ENCODE_FLOAT2 | WeirdFloat[1]); encode(ENCODE_FLOAT3 | WeirdFloat[2]); encode(ENCODE_FLOAT4 | WeirdFloat[3]); } void EncodeShort(pchar WeirdShort) { encode(SHORT_MARKER); encode(ENCODE_SHORT1 | WeirdShort[0]); encode(ENCODE_SHORT2 | WeirdShort[1]); } void EncodeInt(pchar WeirdInt) { encode(INT_MARKER); encode(ENCODE_INT1 | WeirdInt[0]); encode(ENCODE_INT2 | WeirdInt[1]); encode(ENCODE_INT3 | WeirdInt[2]); encode(ENCODE_INT4 | WeirdInt[3]); } // The following code works in our lab setup and may or may not // work for yours. We have a Compuboard connected to the Datawave // machine. No guarantees and no support, because I didn't write this, // and I don't use Datawave currently. (rickr@cmu.edu) void __DataWaveEncode(int code) { int time_over = 0; MS_TIMERset(8,100); while ((DEVinp(1,0)==90) && (time_over==0)) { if ((100-MS_TIMERcheck(8))>=10) { time_over = 1; //comm_fail = 1; } } time_over = 0; MS_TIMERset(8,100); // encode(code); DEVoutp(1,1,code); DEVoutp(1,2,192); while ((DEVinp(1,0)!=90) && (time_over==0)) { if ((100-MS_TIMERcheck(8))>=10) { time_over = 1; //comm_fail = 1; } } DEVoutp(1,1,0); DEVoutp(1,2,0); } #endif