VR-Vantage 3.0.3 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sonar.h
Go to the documentation of this file.
1 /* © 2006 JRM Technologies, Inc.*/
2 
3 #ifndef _SIGSIM_SONAR
4 #define _SIGSIM_SONAR
5 
6 /***********************************
7 Copyright JRM Enterprises, Inc. 1998
8 All rights reserved.
9 
10 This code is the intellectual property of JRM Enterprises, Inc.
11 It may not be used or released as source or compiled binary form
12 without the prior written consent of JRM Enterprises, Inc.
13 ***********************************/
14 
15 
16 #include "SigSimStructs.h"
17 #include "sigsimDLLstub.h"
18 //#include "GetScenario.h"
19 
20 
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif
25 
26  //----------Grabbed #define MINDB, stuck in .c file-----------------
27 
28  /* --------------- GENERAL TARGET and REQUEST INFORMATION --------------------------- */
29 
30  typedef struct
31  {
32  char name_acoustic_contact[SIGSIM_STRING_SIZE]; // The Name for the Acoustic Contact in the data set. This name includes all sound sources of waterborne radiated energy for a single contact. Included are aircraft, ships, submarines, biologics and all other manmade or natural sources.
33  char ctry_code_user[SIGSIM_STRING_SIZE]; // The country known or estimated to be operating or maintaining a system, weapon, or platform within its inventory.
34  char ac_trng_ver[SIGSIM_STRING_SIZE]; // The Acoustic training version number for the Equipment code and Country code user. This field identifies the different training versions of the radiated signature.
35  } CONTACT_ID; // ATAS Basic Unique Contact ID
36 
37  typedef struct
38  {
39  char vessel_class[SIGSIM_STRING_SIZE]; // Vessel class identifier (e.g. xxx_SS_CH_DD)
40  char vessel_type[SIGSIM_STRING_SIZE]; // Vessel type identifier (e.g. Ship)
41  char platform_type[SIGSIM_STRING_SIZE]; // Platform type (e.g. Submarine)
42  char threat_type[SIGSIM_STRING_SIZE]; // Threat type (e.g. Hostile)
43  } TARGET_VSSL; // Passive-mode vessel type information
44 
45  typedef struct
46  {
47  double length_ovrl_ft; // [ft] Long-axis length of target.
48  double beam_max_ft; // [ft] Width of target hull at maximum point.
49  double draft_min_ft; // [ft] Distance from hull bottom to waterline, measured at location of minimum value.
50  double draft_nom_ft; // [ft] Distance from hull bottom to waterline, measured at location of average value.
51  double draft_max_ft; // [ft] Distance from hull bottom to waterline, measured at location of maximum value.
52  double keel_depth_min_ft; // [ft] Minimum keel depth when surfaced
53  double keel_depth_nom_ft; // [ft] Nominal keel depth when surfaced
54  double keel_depth_max_ft; // [ft] Maximum keel depth when surfaced
55  double depth_periscope_ft; // [ft] Maximum target depth at which top of fully-extended periscope just breaches the waterline.
56  } TARGET_PHYC; // Passive-mode vessel physical characteristics
57 
58  typedef struct
59  {
60  CONTACT_ID ID; // Target unique identifier
61  int mode; // <0 is ACTIVE, >=0 is PASSIVE mode #
62  double freq_khz; // [kHz] Frequency
63  double bandwidth_khz; // [kHz] Full Bandwidth
64  double pulse_width_sec; // [s] Pulse width
65  double delay_sec; // [s] 1-way time delay
66  double asp_angle_deg; // [deg] Azimuth from the centerline.
67  double target_velocity_mps; // [m/s] target linear velocity along front direction (for passive level calcs)
68  } TS_REQUEST; // Target Strength Request
69 
71 
72  /* ----------------- SOURCE STRENGTH --------------------- */
75  SIGSIM49_API void SetDICASS62SourceParms(char* channel, ACOUSTIC_TRANSDUCER *dicass62);
85  SIGSIM49_API int FindMALOSonarCodeBySource_ID(char *sourceID);
86 
87 
88  // CalculateSourceLevelAndDirectivities : Calculates Source Level (*SL), transmitter Directivity Index (*DIT), and receiver Directivity Index (*DI) in [dB]
89  // at particular direction totargetFRD in transducer source's FRD frame.
90  SIGSIM49_API int CalculateSourceLevelAndDirectivities(ACOUSTIC_TRANSDUCER source, VECTOR totargetFRD, double *SL, double *DIT, double *DI);
91 
92 
93 
94  /* ----------------- SCENARIO --------------------- */
95 
96  typedef enum
97  {
98  UNKNOWN = 0,
99  SQS510HM = 1, // Halifax hull mount active (#1)
100  TAKRHM = 2, // T-AR Bob Hope hull mount active (#2)
101  TMS118ADS = 3, // CH148 dipper active (#3)
102  CP140SB = 4, // CP-140 Sonobuoy active (#4)
103  CP140LF = 5, // CP-140 LF active (#5)
104  SINTRA2040HM = 6, // Victoria Hull Mount passive (#6)
105  CANTASSSQR501TA = 7, // Halifax Towed Array passive (#7)
106  CANTASS2046TA = 8, // Victoria Towed Array passive (#8)
107  DICASS62A = 9, // DICASS62 Channel A active
108  DICASS62B = 10, // DICASS62 Channel B active
109  DICASS62C = 11, // DICASS62 Channel C active
110  DICASS62D = 12 // DICASS62 Channel D active
111  } MALO_CODE;
112 
113 
114 
115  /* ----------------- PASSIVE MODE TARGET STRENGTH --------------------- */
116 
117  typedef struct
118  {
119  int blades; // [unitless] Number of blades on this shaft
120  double area; // [ft2?] Blade disk area
121  double diameter; // [ft] Blade diameter
122  double delh; // [ft] Screw to keel distance
123  } PASSIVE_SHAFT;
124 
125  typedef struct
126  {
127  int nshafts; // [unitless] Number of shafts on this vessel
128  PASSIVE_SHAFT *shaft; // Blade info for each shaft
129  } PASSIVE_PROP; // Passive-mode vessel propulsion data
130 
131  typedef struct
132  {
133  int mode; // [cardinal] Mode identifier
134  int *family; // Array of Harmonic Family identifiers
135  int nfamily; // Number of harmonic families in array
136  } PASSIVE_FTRE; // Passive-mode harmonic family numbers for this mode.
137 
138  typedef struct
139  {
140  double speed; // [knots] Speed of forward motion of a contact for turn rate.
141  double radius; // [yards] The turning radius of the contact at the maximum speed for the contact.
142  double rate; // [deg/s] Minimum contact turn rate.
143  double ang; // [deg] Angle of the rudder associated with a particular turn rate.
144  double decr_pct; // [%] Rate at which the forward motion decreases as the contact enters a turn.
145  } TURN_RATE_DATAPOINT; // Turn Rate data table entry
146 
147  typedef struct
148  {
149  double speed; // [knots] Linear speed
150  double srpm; // [rpm] shaft rotation frequency
151  double tpk; // [rev/kts] Contact's turns per knot at a particular speed.
152  double shft_of_pct[3]; // [%] Offset srpm of extra shafts as percentage of first shaft
153  int nextra_shafts; // Number of extra shafts
154  } ROTATION_DATAPOINT; // Rotation data table entry
155 
156  typedef struct
157  {
158  int mode; // [cardinal] Mode identifier
159  double depth_min; // [ft?] Minimum depth
160  double depth_max; // [ft?] Maximum depth
161  double speed_min; // [knots] Minimum speed
162  double speed_max; // [knots] Maximum speed
163  double srpm_min; // [rpm] Minimum shaft rotation frequency
164  double srpm_max; // [rpm] Maximum shaft rotation frequency
165  double *accel; // [knots/s]? Array of acceleration options?
166  int naccel; // Number of entries in accel array
167  double *decel; // [knots/s]? Array of deceleration options?
168  int ndecel; // Number of entries in decel array
169  double *dive; // [ft/s]? Array of dive options?
170  int ndive; // Number of entries in dive array
171  double *climb; // [ft/s]? Array of climb options?
172  int nclimb; // Number of entries in climb array
173  TURN_RATE_DATAPOINT *turn; // Turn Rate data table
174  int nturn; // Number of entries in turn array
175  ROTATION_DATAPOINT *rotation; // Rotation data table
176  int nrotation; // Number of entries in rotation array
177  } PASSIVE_MANC; // Passive-mode kinematic capabilities data table
178 
179  typedef struct
180  {
181  double aspect; // [deg] aspect angle (Definition? Assumed azimuth relative to body FRD)
182  double atten; // [dB] attenuation
183  } ATTENUATION_DATAPOINT; // Attenuation data table entry
184 
185  typedef struct
186  {
187  int pattern; // [cardinal] Attenuation pattern identifier
188  ATTENUATION_DATAPOINT *aspdp; // Array of attenuation values per aspect angle
189  int naspdp; // Number of entries in aspdp array
190  } ATTENUATION_PATTERN; // Attenuation Pattern
191 
192  typedef struct
193  {
194  int mode; // [cardinal] Mode identifier
195  ATTENUATION_PATTERN *atp; // Array of attenuation patterns
196  int natp; // Number of elements in atp array
197  } PASSIVE_NBAS; // Passive-mode narrow-band aspect pattern data for this mode
198 
199  typedef struct
200  {
201  double speed; // [knots] Speed of forward motion of a contact.
202  double power; // [dB] The noise level in a frequency band 1/3 octave wide.
203  } BROADBAND_POWER_DATAPOINT; // One-Third-Octave Center Power data table entry
204 
205  typedef struct
206  {
207  double freq; // [Hz] The frequency of a band 1/3 octave wide used in sound pressure level measurement.
208  BROADBAND_POWER_DATAPOINT *spl; // Array of center power vs speed for this frequency
209  int nspl; // Number of elements in spl array
210  } BROADBAND_POWER_TABLE; // Broadband Power vs speed for given frequency and mode
211 
212  typedef struct
213  {
214  int mode; // [cardinal] Mode identifier
215  BROADBAND_POWER_TABLE *bbp; // Array of Broadband power tables, one for each frequency
216  int nbbp; // Number of elements in bbp array
217  } PASSIVE_BBMA; // Passive-mode Broadband power vs speed and OTO frequency
218 
219  typedef struct
220  {
221  int mode; // [cardinal] Mode identifier
222  ATTENUATION_PATTERN *atp; // Array of attenuation patterns
223  int natp; // Number of elements in atp array
224  } PASSIVE_BBAS; // Passive-mode broadband aspect pattern data for this mode
225 
226  typedef struct
227  {
228  double srpm_min; // [rpm] Minimum of shaft rotation frequency range
229  double srpm_max; // [rpm] Maximum of shaft rotation frequency range
230  double freq_min; // [kHz?] Minimum of independent fundamental frequency range
231  double freq_max; // [kHz?] Maximum of independent fundamental frequency range
232  } FUNDFREQ_RANGE; // Fundamental frequency range for given shaft rotation frequency range
233 
234  typedef struct
235  {
236  int model; // 0=NON-SPEED, 1=SRPM, 2=HULL : Type of Independent Harmonic Family Model
237  FUNDFREQ_RANGE *ffr; // Array of fundamental frequency range vs shaft rotation frequency range correlations
238  int nffr; // Number of elements in ffr array
239  } PASSIVE_HIND; // Passive-mode Independent Harmonic Family data
240 
241  typedef struct
242  {
243  double freq_min; // [kHz?] Minimum of dependent driver fundamental frequency range
244  double freq_max; // [kHz?] Maximum of dependent driver fundamental frequency range
245  double factor; // [unitless] mutiplier or divisor
246  } FUNDFREQ_SCALE_DATAPOINT; // Scale factor for this dependent-model driver fundamental frequency range
247 
248  typedef struct
249  {
250  int hind_family; // [cardinal] Source independent harmonic family identifier
251  jrmbool factor_type; // FALSE=multiplier, TRUE=divisor
252  FUNDFREQ_SCALE_DATAPOINT *ffs; // Array of scale factors vs driver fundamental frequency ranges
253  int nffs; // Number of elements in ffs array
254  } PASSIVE_HDEP; // Passive-mode Dependent Harmonic Family scaling data
255 
256  typedef struct
257  {
258  int harmonic; // [cardinal] Harmonic number identifier
259  int pattern; // [cardinal] Attenuation pattern identifier
260  int P_pattern; // [cardinal] P pattern identifier?
261  double *spl; // [dB] Array of Source Power Level values, one for each fundamental frequency range in the speed model (HIND or HDEP) table
262  int nspl; // Number of entries in the spl array. Should equal nffr in corresponding PASSIVE_HIND table OR nffs in corresponding PASSIVE_HDEP table
263  } HARMONIC_LINE; // Harmonic line data in harmonic family
264 
265  typedef struct
266  {
267  int model; // 0=NON-SPEED, 1=SRPM, 2=HULL : Type of Harmonic Family Model
268  HARMONIC_LINE *hl; // Array of harmonic lines and their SPL patterns in this harmonic family
269  int nhl; // Number of entries in the hl array = number of harmonic lines in the family
270  } PASSIVE_HLIN; // Passive-mode Harmonic Line data for a given harmonic family
271 
272  typedef struct
273  {
274  int family; // [cardinal] Harmonic Family identifier
275  char name[SIGSIM_STRING_SIZE]; // Name of harmonic family
276  } PASSIVE_HFAM; // Passive-mode Harmonic Family identification data
277 
278  typedef struct
279  {
280  PASSIVE_HFAM HFAM; // Harmonic family identification data
281  PASSIVE_HIND HIND; // Independent harmonic family data
282  PASSIVE_HLIN HLIN; // Harmonic line data
283  } INDEPENDENT_HARMONIC_FAMILY; // Harmonic family for a given mode
284 
285  typedef struct
286  {
287  PASSIVE_HFAM HFAM; // Harmonic family identification data
288  PASSIVE_HDEP HDEP; // Dependent harmonic family data (If dependency==FALSE, this is empty)
289  PASSIVE_HLIN HLIN; // Harmonic line data
290  } DEPENDENT_HARMONIC_FAMILY; // Harmonic family for a given mode
291 
292  typedef struct
293  {
294  int mode; // [cardinal] Mode identifier
295  PASSIVE_FTRE FTRE; // List of harmonic families for this mode
296  PASSIVE_MANC MANC; // Kinematic capabilities for this mode
297  PASSIVE_BBMA BBMA; // Broadband power data for this mode
298  PASSIVE_BBAS BBAS; // Broadband aspect pattern data for this mode
299  PASSIVE_NBAS NBAS; // Narrow-band aspect pattern data for this mode
300  INDEPENDENT_HARMONIC_FAMILY *IND; // Array of harmonic families for this mode
301  int NIND; // Number of harmonic families in this mode
302  DEPENDENT_HARMONIC_FAMILY *DEP; // Array of harmonic families for this mode
303  int NDEP; // Number of harmonic families in this mode
304  } OPERATING_MODE; // Vehicle operating mode
305 
306  typedef struct
307  {
308  PASSIVE_PROP PROP; // Vessel Propulsion data
309  OPERATING_MODE *MODE; // Array of Operating Modes
310  int NMODE; // Number of Operating Modes
311  } PASSIVE_TARGET; // Passive-mode target data main structure
312 
359 
360  int GetShaftSRPMs(double hull_speed, ROTATION_DATAPOINT *rotation, int nrotation, DOUBLE_TABLE *srpm_out);
363  double GetAspectAttenuationFactor(double asp_angle_deg, int pattern, ATTENUATION_PATTERN *atp, int natp);
364  int GetIndependentHarmonicSPLs(double asp_angle_deg, DOUBLE_TABLE FREQ, INDEPENDENT_HARMONIC_FAMILY IND, PASSIVE_NBAS NBAS, DOUBLE_TABLE **SPL);
365  int GetDependentHarmonicSPLs(double asp_angle_deg, DOUBLE_TABLE FREQ, DEPENDENT_HARMONIC_FAMILY DEP, PASSIVE_NBAS NBAS, DOUBLE_TABLE **SPL);
366 
367  typedef struct
368  {
369  double freq; // [kHz?]
370  double spl; // [dB]
371  } SPL_TABLE;
372 
373  SIGSIM49_API int AddSPL_TABLE(SPL_TABLE **c, int *nc, SPL_TABLE toadd);
375  void RemoveSPL_TABLEFromArray(SPL_TABLE **c, int *nc, int index);
376  int CompareSPLs(void *AV, void *BV);
377  void SortSPL_TABLEArray(SPL_TABLE *SPL, int NSPL);
378  void AddSPLsAtSameFrequency(SPL_TABLE **SPL, int *NSPL);
379  jrmbool IsUsedInThisMode(PASSIVE_FTRE FTRE, int familyID);
380  int AddNarrowBandSPLTableArrayEntriesForDependentFamily(double asp_angle_deg, DOUBLE_TABLE fund, OPERATING_MODE MODE, int family, SPL_TABLE **SPL, int *NSPL);
381  int AddNarrowBandSPLTableArrayEntriesForIndependentFamily(double hull_speed, double asp_angle_deg, OPERATING_MODE MODE, int family, SPL_TABLE **SPL, int *NSPL);
382  int GetBroadBandSPLTableForMode(double hull_speed, double asp_angle_deg, OPERATING_MODE MODE, SPL_TABLE **SPL, int *NSPL);
383  int CullMaskedNarrowbandSPLs(SPL_TABLE **SPL, int *NSPL, int NBB);
384  int GetFullSPLTableForMode(double hull_speed, double asp_angle_deg, OPERATING_MODE MODE, SPL_TABLE **SPL, int *NSPL);
385  int PrintSPLSpectrum(char *file, SPL_TABLE *SPL, int NSPL);
387 
388 
389 
390  /* ----------------- ACTIVE MODE TARGET STRENGTH --------------------- */
391 
392  typedef struct
393  {
394  double start; // [s]
395  double stop; // [s]
396  double strength; // [dB]
397  } RETURN_PING;
398 
399  typedef struct
400  {
401  double freq_target_strength_khz; // [kHz] Frequency.
402  double target_strength_db; // [dB] Azimuth dependent Target Strength (TS).
403  } BULK_TS_DATAPOINT; // Active-mode bulk target strength data table entry
404 
405  typedef struct
406  {
407  double target_strength_asp_angle_deg; // [deg] Azimuth from the centerline.
408  BULK_TS_DATAPOINT *bts; // Array of target strength as function of frequency for this angle.
409  int nbts; // Number of elements in BULK_TS_DATAPOINT array for this angle.
410  } BULK_TS_TABLE; // Active-mode bulk target strength data table, from ATAS CONTACT_TARGET_STRENGTH.
411 
412  typedef struct
413  {
414  double hilght_freq_khz; // [kHz] Highlight frequency.
415  double brg_vssl_center_deg; // [deg] Angle measured between lines drawn through the contact's centerline and the highlight or event.
416  double dst_vssl_center_ft; // [ft] Distance measured from the center of the contact to a highlight or special event location.
417  double max_target_str_db; // [dB] Maximum signal reflection return amplitude of a highlight.
418  int asp_ptrn_nbr; // [unitless] Index identifying an individual aspect pattern.
419  } ACTIVE_HIGHLIGHT; // Active-mode contact highlight, from ATAS CONTACT_HIGHLIGHT_DATA.
420 
421  typedef struct
422  {
423  BULK_TS_TABLE *bulk; // Array of bulk target strength tables, one per angle.
424  int nbulk; // Number of elements in bulk array.
425  ACTIVE_HIGHLIGHT *high; // Array of active highlights
426  int nhigh; // Number of elements in active highlight array.
427  ATTENUATION_PATTERN *atp; // Array of attenuation patterns for highlights.
428  int natp; // Number of elements in atp array.
429  } ACTIVE_TARGET; // Active-mode target data main structure
430 
433  int AddBULK_TS_TABLE(BULK_TS_TABLE **c, int *nc, BULK_TS_TABLE toadd);
438  int AddACTIVE_TARGET(ACTIVE_TARGET **c, int *nc, ACTIVE_TARGET toadd);
441 
444  double FindRelevantAttenHighlight(ACTIVE_TARGET tgt, TS_REQUEST tsr, int asp_ptrn_nbr, double maxdB);
445  int AddRETURN_PING(RETURN_PING **c, int *nc, RETURN_PING toadd);
446  void FreeRETURN_PINGArray(RETURN_PING **c, int *nc, jrmbool init);
447  int CompareRETURN_PINGs(void *AV, void *BV);
448  void SortRETURN_PINGs(RETURN_PING *ping, int npings);
450 
451  /* ---------------- MORE GENERAL TARGET STRENGTH CALLS ------------------------------- */
452 
453  typedef struct
454  {
455  CONTACT_ID ID; // Target unique identifier
456  TARGET_VSSL VSSL; // Vessel Type data
457  TARGET_PHYC PHYC; // Vessel Physical Characteristics data
458  PASSIVE_TARGET PASSIVE; // Target passive-mode data
459  ACTIVE_TARGET ACTIVE; // Target active-mode data
460  } TARGET; // Target data main structure.
461 
462  typedef struct
463  {
464  TARGET *target; // Array of targets for which data is known
465  int ntargets; // Number of targets for which data is known
466  } TS_DATABASE; // Target Strength Database
467 
468  SIGSIM49_API int AddTARGET(TARGET **c, int *nc, TARGET toadd);
470  SIGSIM49_API void FreeTARGETArray(TARGET **c, int *nc, jrmbool init);
471  SIGSIM49_API void RemoveTARGETFromArray(TARGET **c, int *nc, int index);
472  SIGSIM49_API int LoadTARGETFile(char *file, TARGET *c);
474  SIGSIM49_API int LoadTS_DATABASE(TS_DATABASE *tsd, char *target_filelist, char *sigsim_data_dir);
475  int CompareTARGETs(void *AV, void *BV);
476  void SortTARGETs(TARGET *t, int nt);
477  SIGSIM49_API int FindTarget(TS_DATABASE tsd, char *contact_ID, TARGET *target);
478  SIGSIM49_API int FindTargetAndFreeTSD(TS_DATABASE *tsd, char *contact_ID, TARGET *target);
481 
482  /* ----------------- ACOUSTIC PROPAGATION --------------------- */
483 
484  typedef struct
485  {
486  double pathlength; // [m]
487  int layerindex; // index into SUBSURFACE_1DPROFILE
488  } PROPAGATION_PATHINTERVAL; // Path interval within SUBSURFACE_1DPROFILE
489 
490 
491  int GetSeaLayerIndex(SUBSURFACE_1DPROFILE seadata, double depth);
495  SIGSIM49_API int AcousticPropagator(ellipsoid E, SUBSURFACE_1DPROFILE seadata, ST_PLACEMENT plc, double freq_khz, double SL, double *TL, double *NL, double *RL, double *delay_sec);
499 
500  /* --------------- GENERAL SPL FUNCTIONS ---------------- */
501 
502  double AddSPLs(double SPL1, double SPL2);
503  double SubtractSPLs(double SPL1, double SPL2);
504  double IntegrateSPLArray(double *freq, double *spl, int n, double freq_lo, double freq_hi);
505  double IntegrateSPL_TABLEArray(SPL_TABLE *spl_table, int n, double freq_lo, double freq_hi);
506 
507  /* ---------------- FINAL RESULTS ---------------------- */
508 
509  typedef struct
510  {
511  double SL; // [dB] Source Level
512  double DIT; // [dB] Source Directivity Index
513  double DI; // [dB] Receiver Directivity Index
514  double TL1; // [dB] Source-to-target Transmission Loss
515  double TL2; // [dB] Target-to-sensor Transmission Loss
516  double RL; // [dB] Reverberation Level
517  double NL; // [dB] Noise Level
518  double TS; // [dB] Target Strength
519  double SNR; // [dB] Signal-to-Noise Ratio
520  double RTL; // [dB] Return Level
521  double RD; // [dB] Recognition Differential
522  double SE; // [dB] Signal Excess
523  int status; // Acquisition Status (0=nodetect, 1=detect, 2=classify, 3=recognize, 4=identify) based on SE and RD threshold
524  } MST_INTERACTION; // Monostatic Source-Target Interaction
525 
526 
527  SIGSIM49_API double ReturnLevel(double SL, double DIT, double TS, double DI, double TL1, double TL2, double NL);
528  SIGSIM49_API double SignalToNoiseRatio(double SL, double DIT, double TS, double DI, double TL1, double TL2, double NL);
529  SIGSIM49_API double SignalExcess(double SL, double DIT, double DI, double TL1, double TL2, double TS, double RL, double NL, double RD);
532  SIGSIM49_API int SonarAcquisitionStatus(double SE, double *DSEED);
533  SIGSIM49_API int SonarAcquisitionStatusKnownThresholds(double SE, double ThreshDetect, double ThreshClassify, double ThreshRecognize, double ThreshIdentify); // NOTE: Based on concept that ThreshIdentify<ThreshRecognize<ThreshClassify<ThreshDetect, not reverse!
534 
535 
536 
537 
538  /* ---------------------------------------------------------------------------------
539  SIGSIM SONAR RUNTIME API
540  CF070307
541  ------------------------
542 
543  1. Initialization (Do this once at the beginning of a scenario)
544 
545  a. Declare a TS_DATABASE (tsd) and fill its TS_FILELIST (tsf) :
546 
547  Example :
548 
549  TS_DATABASE tsd;
550  strcpy(tsd.tsf.contact_base_file,"../../../Data/object/Sonar/contact_base.txt\0");
551  strcpy(tsd.tsf.contact_target_strength_file,"../../../Data/object/Sonar/CONTACT_TARGET_STRENGTH.txt\0");
552  strcpy(tsd.tsf.contact_highlight_data_file,"../../../Data/object/Sonar/CONTACT_HIGHLIGHT_DATA.txt\0");
553  strcpy(tsd.tsf.aspect_pattern_horizontal_file,"../../../Data/object/Sonar/ASPECT_PATTERN_HORIZONTAL.txt\0");
554  strcpy(tsd.tsf.passive_file,"../../../Data/object/Sonar/passiveTS.txt\0");
555 
556  b. Run this code to fill the other data in the TS_DATABASE structure :
557 
558  // Set up TS database
559  err=LoadTS_DATABASE(&tsd, target_file_list, sigsim_data_dir);
560  if(err) return(err);
561 
562  c. Set the Earth ellipsoid
563 
564  ellipsoid E;
565  SetWGS84(&E); // JRMLibrary call
566 
567  d. Set the sea data profile, if Atlos not present. (Example below is for use of SigSim-read profile. For DRDC/Atlos/Modas, initialization will be different, and below is not needed) :
568 
569  SUBSURFACE_1DPROFILE seadata;
570  seadata.d=NULL;
571  seadata.nd=0;
572  err=LoadSubsurface1DProfile("../../../Data/terrain/Sonar/Subsurface1DProfile.txt\0", &seadata);
573  if(err) return(err);
574 
575 
576  2. Run-Time Request :
577 
578  a. (Optional) Declare an MST_INTERACTION to hold the results in one place :
579 
580  typedef struct
581  {
582  double range; // [m] source-target range
583  VECTOR totargetFRD; // [unitless cosines] direction to target in sensor's FRD frame
584  VECTOR tosourceFRD; // [unitless cosines] direction to source in target's FRD frame
585  double SL; // [dB] Source Level
586  double DIT; // [dB] Source Directivity Index
587  double DI; // [dB] Receiver Directivity Index
588  double TL1; // [dB] Source-to-target Transmission Loss
589  double TL2; // [dB] Target-to-sensor Transmission Loss
590  double RL; // [dB] Reverberation Level
591  double NL; // [dB] Noise Level
592  double TS; // [dB] Target Strength
593  double SNR; // [dB] Signal-to-Noise Ratio
594  double RTL; // [dB] Return Level
595  double RD; // [dB] Recognition Differential
596  double SE; // [dB] Signal Excess
597  int status; // Acquisition Status (0=nodetect, 1=detect, 2=classify, 3=recognize, 4=identify) based on SE and RD threshold
598  } MST_INTERACTION; // Monostatic Source-Target Interaction
599 
600  MST_INTERACTION msti;
601 
602  b. Set the geometry of the source-target interaction (use of ST_PLACEMENT structure is optional):
603 
604  typedef struct
605  {
606  GEODETIC_LOCATION sourceD; // source Geodetic location
607  EULERzyx sourceO; // source local orientation (FRD w.r.t. NED)
608  VECTOR sourceV; // source linear velocity ([m/s] in NED)
609  GEODETIC_LOCATION targetD; // target Geodetic location
610  EULERzyx targetO; // target local orientation (FRD w.r.t. NED)
611  VECTOR targetV; // target linear velocity ([m/s] in NED)
612  } ST_PLACEMENT; // Source-Target placement
613 
614  ST_PLACEMENT plc;
615  CalcSTGeometry(E, plc, &(msti.range), &(msti.totargetFRD), &(msti.tosourceFRD));
616 
617  c. Set the sensor and sensor channel in play :
618 
619  ACOUSTIC_TRANSDUCER transducer;
620  SetTransducerByMALOSonarCode(MALO_CODE=4,&transducer); // or whatever MALO_CODE comes in
621 
622  d. Get corresponding active emitter frequency and source level :
623 
624  err=CalculateSourceLevelAndDirectivities(transducer, msti.totargetFRD, &(msti.SL), &(msti.DIT), &(msti.DI));
625  if(err) return(err);
626 
627  e. Send the ST_PLACEMENT data, the sensor channel frequency, and possibly the source level (if Active Sonar request and reverberation is supported)
628  to ATLOS or other acoustic federate, to get LOS Transmission Loss, Reverberation, and Noise (TL1, TL2, RL, NL). Example :
629 
630  double delay_sec; // [s] time delay between source and target
631  if(transducer.active)
632  {
633  err=AcousticPropagator(E, seadata, plc, transducer.transmit_freq_hz, msti.SL, &(msti.TL1), &(msti.NL), &(msti.RL), &delay_sec);
634  msti.TL2=msti.TL1; // monostatic active : must set both legs of journey equal
635  }
636  else
637  {
638  err=AcousticPropagator(E, seadata, plc, transducer.receive_freq_hz, msti.SL, &(msti.TL2), &(msti.NL), &(msti.RL), &delay_sec);
639  msti.TL1=0.0; // passive mode : there is no forward path
640  }
641  if(err) return(err);
642 
643 
644  f. Set up a Target Strength Request :
645 
646  typedef struct
647  {
648  char name_acoustic_contact[SIGSIM_STRING_SIZE]; // Unique target type identifier
649  char ac_trng_ver[SIGSIM_STRING_SIZE]; // Version of target information
650  int mode; // <0 is ACTIVE, >=0 is PASSIVE mode #
651  double freq_khz; // [kHz] Frequency
652  double pulse_width_sec; // [s] Pulse width
653  double delay_sec; // [s] 1-way time delay
654  double asp_angle_deg; // [deg] Azimuth from the centerline.
655  double target_velocity_mps; // [m/s] target linear velocity along front direction (for passive level calcs)
656  } TS_REQUEST; // Target Strength Request
657 
658  TS_REQUEST tsr;
659  strcpy(tsr.name_acoustic_contact,"Merchant Test 01"); // or whatever target identifier is relevant for this interaction :
660  // Current choices are "Merchant Test 01", "Sub Test 01", "Sub Test 02", "Surface Test 01", and "Weapon Test 01".
661  // For passive requests, there is currently no choice so the above doesn't matter.
662  strcpy(tsr.ac_trng_ver,"1"); // All are ac_trng_ver "1" right now.
663  tsr.freq_khz=transducer.receive_operating_freq_khz; // Set request frequency to source frequency
664  tsr.pulse_width_sec=transducer.pulse_width_sec; // Set request pulse width to source pulse width
665  tsr.delay_sec=delay_sec; // Set request time delay to delay time from Propagator return
666  ExtractAngles(msti.tosourceFRD,&theta,&phi);
667  tsr.asp_angle_deg=phi/DEG2RAD; // Set request angle to LOS azimuth angle as seen in the target's frame
668  tsr.target_velocity_mps=vec_magnitude(plc.targetV);
669  if(transducer.active)
670  {
671  tsr.mode=-1;
672  }
673  else
674  {
675  tsr.mode=0;
676  }
677 
678 
679  g. Calculate the Target Strength (TS)
680 
681  err=CalculateTargetStrength(tsd, tsr, &(msti.TS)); // Calculate target strength TS
682  if(err) return(err);
683 
684 
685  h. Set Recognition Differential (RD) and calculate Signal Excess (SE), now that we have SL, DTI, DI, TL1, TL2, NL, RL, and TS :
686 
687  msti.RD = transducer.recognition_differential_db; // [dB] (only have data for passive at this point, but we'll use it anyway)
688  msti.SE = SignalExcess(msti.SL, msti.DIT, msti.DI, msti.TL1, msti.TL2, msti.TS, msti.RL, msti.NL, msti.RD);
689 
690  i. Calculate Acquisition Status based on SE and RD threshold
691 
692  msti.status = SonarAcquisitionStatus(msti.SE);
693 
694  3. Clean up when done :
695 
696  FreeTS_DATABASE(&tsd, FALSE); // Use FALSE when freeing, and TRUE when initializing
697  FreeSUBSURFACE_1DPROFILE(&seadata, FALSE); // Only needed if using the SigSim seadata profile (SUBSURFACE_1DPROFILE)
698 
699 
700  // --------------------------------------------------------------------------------- */
701 
702 #ifdef __cplusplus
703 }
704 #endif
705 
706 #endif


Copyright © 2005-2023 MAK Technologies. All Rights Reserved (www.mak.com)