00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdio.h>
00024 #include <signal.h>
00025
00026 #include <ptc/ptc.h>
00027
00028 #include <Alloc.hh>
00029
00030 #include "Config.h"
00031 #include "Messages.hh"
00032 #include "SockClie.hh"
00033 #include "SockOp.hh"
00034
00035
00036 bool bRun = true;
00037 Console Con;
00038 Format Fmt(32, 0x00ff0000, 0x0000ff00, 0x000000ff);
00039
00040
00041 void SigHandler (int iSigNum)
00042 {
00043 bRun = false;
00044 }
00045
00046
00047 void PlotData (Surface &Sfc, GDT *fpData, int iWidth, int iHeight)
00048 {
00049 int iDataCntr;
00050
00051
00052
00053 unsigned int *ipSfc;
00054
00055 ipSfc = (unsigned int *) Sfc.lock();
00056 for (iDataCntr = 0; iDataCntr < (iWidth * iHeight); iDataCntr++)
00057 {
00058 if (fpData[iDataCntr] > 1) fpData[iDataCntr] = 1;
00059 ipSfc[iDataCntr] =
00060 ((unsigned int) (fpData[iDataCntr] * 0xff) << 16) |
00061 ((unsigned int) (fpData[iDataCntr] * 0xff) << 8) |
00062 ((unsigned int) (fpData[iDataCntr] * 0xff));
00063
00064
00065
00066
00067
00068
00069 }
00070 Sfc.unlock();
00071 }
00072
00073
00074 int main (int argc, char *argv[])
00075 {
00076 int iDataSize;
00077 char cpMsgHdr[GLOBAL_HEADER_LEN];
00078 stLocateHdr sHdr;
00079 stLocateRes sRes;
00080 clAlloc InData;
00081 clAlloc ResData;
00082 clSockClie SClient;
00083 clSockOp SOp;
00084 clLocateMsg Msg;
00085
00086 signal(SIGINT, SigHandler);
00087 SOp.SetHandle(SClient.Connect("localhost", NULL, 30002));
00088 if (SOp.ReadN(cpMsgHdr, GLOBAL_HEADER_LEN) == GLOBAL_HEADER_LEN)
00089 {
00090 Msg.GetHeader(cpMsgHdr, &sHdr);
00091 iDataSize = GLOBAL_HEADER_LEN +
00092 sHdr.iWidth * sHdr.iHeight * sizeof(GDT);
00093 InData.Size(iDataSize);
00094 ResData.Size(sHdr.iWidth * sHdr.iHeight * sizeof(GDT));
00095 Con.open("Locate test", sHdr.iWidth, sHdr.iHeight, Fmt);
00096 Surface Sfc(sHdr.iWidth, sHdr.iHeight, Fmt);
00097 while (bRun && !Con.key() && SOp.ReadN(InData, iDataSize) == iDataSize)
00098 {
00099 Msg.GetResult(InData, &sRes, (GDT *) ResData);
00100 PlotData(Sfc, ResData, sHdr.iWidth, sHdr.iHeight);
00101 Sfc.copy(Con);
00102 Con.update();
00103 }
00104 Con.close();
00105 }
00106 return 0;
00107 }
00108