[Gcblue-commits] gcb_wx/src/sim tcPlatformObject.cpp,1.15,1.16 tcRadar.cpp,1.2,1.3 tcSimState.cpp,1.
Status: Alpha
Brought to you by:
ddcforge
From: <ddc...@us...> - 2004-02-12 21:47:07
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15386/src/sim Modified Files: tcPlatformObject.cpp tcRadar.cpp tcSimState.cpp Log Message: Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tcPlatformObject.cpp 7 Feb 2004 02:19:54 -0000 1.15 --- tcPlatformObject.cpp 12 Feb 2004 21:41:53 -0000 1.16 *************** *** 206,209 **** --- 206,222 ---- } + /** + * update platform sensors + */ + void tcPlatformObject::UpdateSensors(double t) + { + unsigned nSensors = mapSensorState.size(); + for(unsigned n=0;n<nSensors;n++) + { + tcSensorState *sensor = mapSensorState[n]; + wxASSERT(sensor); + sensor->Update(t); + } + } void tcPlatformObject::UpdateKin(double afStatusTime) { *************** *** 227,230 **** --- 240,245 ---- UpdateLauncherState(dt_s); + UpdateSensors(afStatusTime); + mfStatusTime = afStatusTime; } Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcRadar.cpp 12 Feb 2004 01:54:49 -0000 1.2 --- tcRadar.cpp 12 Feb 2004 21:41:53 -0000 1.3 *************** *** 28,31 **** --- 28,32 ---- #include "tcMissileDBObject.h" #include "tcSimState.h" + #include "tcGameObjIterator.h" // break up this file later *************** *** 252,290 **** } ! void tcRadar::Update(double t) { ! if (!UpdateScan(t)) return; // only update once per scan period ! wxASSERT(parent); ! tcRect region; GetTestArea(region); ! /* ! tnPoolIndex aTargetKeys[100]; ! tnPoolIndex nTargetID; ! int nCount; ! ! tsGeoPoint currentpos; ! tcGameObject *pTarget; - currentpos.Set((float)applat->mcKin.mfLon_rad,(float)applat->mcKin.mfLat_rad,applat->mcKin.mfAlt_m); - apSensorState->UpdateCoverage(currentpos,applat->mcKin.mfHeading_rad); - apSensorState->GetTestArea(region); - nCount = GetPlatformsWithinRegion(aTargetKeys, 100, ®ion); - bool bOwnAllianceUpdate = mpUserInfo->IsOwnAlliance(applat->mnAlliance); - for(int k=0;k<nCount;k++) { - nTargetID = aTargetKeys[k]; - if (nTargetID != applat->mnID) { // no self detection - pTarget = GetObject(nTargetID); - tcRadar *pRadarSS = dynamic_cast<tcRadar*>(apSensorState); - if (pRadarSS) { - ProcessRadarDetection(applat,pTarget,pRadarSS); - } - else if (tcESMSensor *pESMSS = dynamic_cast<tcESMSensor*>(apSensorState)) { - ProcessESMDetection(applat,pTarget,pESMSS); - } } } ! */ } --- 253,346 ---- } ! /** ! * Called after a surveillance detection to update sensor map for ! * appropriate alliance. ! */ ! void tcRadar::UpdateSensorMap(double t, const tcGameObject* target, float range_km) { ! tcSensorReport *pReport; ! tcSensorMapTrack *pSMTrack; ! bool bAccept = simState->mcSensorMap.UpdateActiveReport(pReport,parent->mnID,target->mnID, ! pSMTrack, parent->mnAlliance); ! if (!bAccept) return; ! ! ! pReport->mfLat_rad = (float)target->mcKin.mfLat_rad; ! pReport->mfLon_rad = (float)target->mcKin.mfLon_rad; ! pReport->mfSpeed_kts = target->mcKin.mfSpeed_kts * cosf(target->mcKin.mfClimbAngle_rad); ! pReport->mfHeading_rad = target->mcKin.mfHeading_rad; ! pReport->mfTimestamp = t; ! pReport->mnSensorPlatformID = parent->mnID; ! pReport->mnTrackID = target->mnID; ! bool bNewReport = pReport->IsNew(); ! bool bNewDetection = pSMTrack->IsNew(); ! if (bNewReport) {pReport->mfStartTime = t;} // new detection ! double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; ! if (fTrackLife >= 16.0) ! { ! pReport->mnFlags = TRACK_SPEED_VALID | TRACK_HEADING_VALID; ! } ! else ! { ! pReport->mnFlags = 0; ! } ! if ((!pReport->mbClassified)&&(fTrackLife > 10.0)) ! { ! UINT16 nClassification = target->mpDBObject->mnType; ! teAffiliation eAffil = UNKNOWN; ! if (nClassification & PTYPE_MISSILE) {eAffil = HOSTILE;} ! pSMTrack->UpdateClassification(nClassification, eAffil, NULL_INDEX); ! pReport->mbClassified = 1; ! } ! ! ! if (bNewDetection) ! { ! pSMTrack->UpdateTrack(); ! if (simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) ! { ! simState->mpSound->PlayEffect(SEFFECT_PING); ! } ! char zBuff[128]; ! sprintf(zBuff,"target %d detected at %3.1f km at time %.1f [a:%d]", ! target->mnID,range_km,t,parent->mnAlliance); ! WTLC(zBuff); ! } ! ! } ! ! void tcRadar::UpdateSurveillance(double t) ! { ! tcGeoRect region; GetTestArea(region); ! tcGameObjIterator iter(region); ! ! for (iter.First();iter.NotDone();iter.Next()) ! { ! tcGameObject *target = iter.Get(); ! if (target != parent) // no self detection ! { ! float range_km; ! bool bDetected = (parent->mnAlliance != target->mnAlliance) && ! CanDetectTarget(target,range_km); ! if (bDetected) UpdateSensorMap(t, target, range_km); } } ! } ! ! void tcRadar::Update(double t) ! { ! if ((mnMode != SSMODE_SURVEILLANCE) && (mnMode != SSMODE_FCSURVEILLANCE)) ! { ! return; ! } ! ! if (!UpdateScan(t)) return; // only update once per scan period ! wxASSERT(parent); ! ! UpdateSurveillance(t); } Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** tcSimState.cpp 12 Feb 2004 01:54:49 -0000 1.31 --- tcSimState.cpp 12 Feb 2004 21:41:53 -0000 1.32 *************** *** 624,628 **** /********************************************************************/ #define MAX_UPDATESENSORS 16 ! void tcSimState::UpdateSensors() { tcGameObject *pplat; tcSensorState *pSensorState; --- 624,630 ---- /********************************************************************/ #define MAX_UPDATESENSORS 16 ! void tcSimState::UpdateSensors() ! { ! /* tcGameObject *pplat; tcSensorState *pSensorState; *************** *** 641,645 **** pSensorState = pSS->at(k); if((pSensorState!=NULL)&&(pSensorState->UpdateScan(mfSimTime))) { ! switch (pSensorState->mnMode) { case SSMODE_FC: case SSMODE_FCSURVEILLANCE: --- 643,648 ---- pSensorState = pSS->at(k); if((pSensorState!=NULL)&&(pSensorState->UpdateScan(mfSimTime))) { ! switch (pSensorState->mnMode) ! { case SSMODE_FC: case SSMODE_FCSURVEILLANCE: *************** *** 680,683 **** --- 683,687 ---- } // for(int i + */ } *************** *** 699,703 **** pSMTrack,apRadarPlat->mnAlliance); ! if (bAccept) { pReport->mfLat_rad = (float)apTarget->mcKin.mfLat_rad; pReport->mfLon_rad = (float)apTarget->mcKin.mfLon_rad; --- 703,708 ---- pSMTrack,apRadarPlat->mnAlliance); ! if (bAccept) ! { pReport->mfLat_rad = (float)apTarget->mcKin.mfLat_rad; pReport->mfLon_rad = (float)apTarget->mcKin.mfLon_rad; *************** *** 711,721 **** if (bNewReport) {pReport->mfStartTime = mfSimTime;} // new detection double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; ! if (fTrackLife >= 16.0) { pReport->mnFlags = TRACK_SPEED_VALID | TRACK_HEADING_VALID; } ! else { pReport->mnFlags = 0; } ! if ((!pReport->mbClassified)&&(fTrackLife > 10.0)) { tcDatabaseObject *pTargetData; mpDatabase->GetObject(apTarget->mnDBKey,pTargetData); // watch out for bad call here --- 716,729 ---- if (bNewReport) {pReport->mfStartTime = mfSimTime;} // new detection double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; ! if (fTrackLife >= 16.0) ! { pReport->mnFlags = TRACK_SPEED_VALID | TRACK_HEADING_VALID; } ! else ! { pReport->mnFlags = 0; } ! if ((!pReport->mbClassified)&&(fTrackLife > 10.0)) ! { tcDatabaseObject *pTargetData; mpDatabase->GetObject(apTarget->mnDBKey,pTargetData); // watch out for bad call here *************** *** 728,734 **** ! if (bNewDetection) { pSMTrack->UpdateTrack(); ! if (mpUserInfo->IsOwnAlliance(apRadarPlat->mnAlliance)) {mpSound->PlayEffect(SEFFECT_PING);} char zBuff[128]; sprintf(zBuff,"target %d detected at %3.1f km at time %.1f [a:%d]", --- 736,746 ---- ! if (bNewDetection) ! { pSMTrack->UpdateTrack(); ! if (mpUserInfo->IsOwnAlliance(apRadarPlat->mnAlliance)) ! { ! mpSound->PlayEffect(SEFFECT_PING); ! } char zBuff[128]; sprintf(zBuff,"target %d detected at %3.1f km at time %.1f [a:%d]", *************** *** 856,869 **** } /********************************************************************/ ! void tcSimState::UpdateSurveillance(tcGameObject *applat, tcSensorState *apSensorState) { tnPoolIndex aTargetKeys[100]; tnPoolIndex nTargetID; int nCount; tcRect region; - tsGeoPoint currentpos; tcGameObject *pTarget; - currentpos.Set((float)applat->mcKin.mfLon_rad,(float)applat->mcKin.mfLat_rad,applat->mcKin.mfAlt_m); - //apSensorState->UpdateCoverage(currentpos,applat->mcKin.mfHeading_rad); apSensorState->GetTestArea(region); nCount = GetPlatformsWithinRegion(aTargetKeys, 100, ®ion); --- 868,879 ---- } /********************************************************************/ ! void tcSimState::UpdateSurveillance(tcGameObject *applat, tcSensorState *apSensorState) ! { tnPoolIndex aTargetKeys[100]; tnPoolIndex nTargetID; int nCount; tcRect region; tcGameObject *pTarget; apSensorState->GetTestArea(region); nCount = GetPlatformsWithinRegion(aTargetKeys, 100, ®ion); *************** *** 871,881 **** for(int k=0;k<nCount;k++) { nTargetID = aTargetKeys[k]; ! if (nTargetID != applat->mnID) { // no self detection pTarget = GetObject(nTargetID); tcRadar *pRadarSS = dynamic_cast<tcRadar*>(apSensorState); ! if (pRadarSS) { ProcessRadarDetection(applat,pTarget,pRadarSS); } ! else if (tcESMSensor *pESMSS = dynamic_cast<tcESMSensor*>(apSensorState)) { ProcessESMDetection(applat,pTarget,pESMSS); } --- 881,894 ---- for(int k=0;k<nCount;k++) { nTargetID = aTargetKeys[k]; ! if (nTargetID != applat->mnID) // no self detection ! { pTarget = GetObject(nTargetID); tcRadar *pRadarSS = dynamic_cast<tcRadar*>(apSensorState); ! if (pRadarSS) ! { ProcessRadarDetection(applat,pTarget,pRadarSS); } ! else if (tcESMSensor *pESMSS = dynamic_cast<tcESMSensor*>(apSensorState)) ! { ProcessESMDetection(applat,pTarget,pESMSS); } *************** *** 1387,1390 **** --- 1400,1405 ---- file.Open(sFileName.GetBuffer(),tcFile::modeCreate|tcFile::modeWrite|tcFile::modeText); + sprintf(buff,"Total platform count: %d\n", maPlatformState.GetCount()); + file.WriteString(buff); tcGameObjIterator iter; *************** *** 1400,1403 **** --- 1415,1419 ---- } + file.Close(); } |