// Huffman coding version by 3Com Palm Computing, Inc. // dfm: 7/13/99 // Modified by MLF 11/19/99 for generic Public Domain // Some more standard types - MLF #define UInt8 unsigned char #define Int16 short #define UInt16 unsigned short #define TRUE 1 #define FALSE 0 #define oneFlag 0x01 // The number of Loops and Stations from WirelessXXX.STA int iNumberOfDataStations; // An array that holds the expanded data from WirelessXXX.DAT int iRoadwayData[1000]; // One byte value for expresslane direction unsigned char ucExpressLanes; // Value of the most current data stream unsigned char ucVersion; // Time stamp of current data short sYear, sMonth, sDay, sHour, sMinute; // Constant values for colors of roaday segments // Developers will want to change these to RGB or color indexes of the target system. #define GREEN 1 #define YELLOW 2 #define RED 3 #define BLACK 4 #define NO_DATA 5 // GENERAL INSTRUCTIONS: // Open the file WirelessXXX.DAT and read into a buffer. // Call this function with a pointer to that buffer. // iRoadwayData[] stores the data to paint a roadway segment. int ExpandHuffmanData(UInt8 * rawP) { UInt8 currentData; Int16 bit = 7; UInt16 loop = 0; UInt8 * dP = rawP; Int16 byteCount = 0; // Get ExpressLane Direction ucExpressLanes = *dP++; byteCount++; sYear = *dP++ << 8; byteCount++; sYear += *dP++; byteCount++; sMonth = *dP++; byteCount++; sDay = *dP++; byteCount++; sHour = *dP++; byteCount++; sMinute = *dP++; byteCount++; while(loop < iNumberOfDataStations) { if (bit < 0) { dP++; bit=7; byteCount++; } currentData = *dP & (oneFlag << bit); bit--; // 0 if (currentData == 0x00) //0 is signed to WIDE_OPEN on the proxy side iRoadwayData[loop++] = GREEN; // 1 else { if(bit < 0) { dP++; bit = 7; byteCount++; } currentData = *dP & (oneFlag << bit); bit--; //1 0 if (currentData == 0x00) // 10 is signed to NO_DATA on the proxy iRoadwayData[loop++] = NO_DATA; //1 1 else { if(bit<0) { dP++; bit = 7; byteCount++; } currentData = *dP & (oneFlag << bit); bit--; // 1 1 0 if (currentData == 0x00) //110 is signed to MODERATE on proxy iRoadwayData[loop++] = YELLOW; // 1 1 1 else { if(bit<0) { dP++; bit = 7; byteCount++; } currentData = *dP & (oneFlag << bit); bit--; // 1 1 1 0 if (currentData == 0x00) //1110 is signed to HEAVY on proxy iRoadwayData[loop++] = RED; // 1 1 1 1 else //1111 is signed to STOP_GO on proxy iRoadwayData[loop++] = BLACK; } } } } if (loop == iNumberOfDataStations) return TRUE; else return FALSE; }