PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/org.mwc.asset.legacy/src/ASSET/Models/TMA/TMAHandler.java

https://bitbucket.org/haris_peco/debrief
Java | 868 lines | 98 code | 33 blank | 737 comment | 0 complexity | 106930d72c68e0b61554445c53d3f029 MD5 | raw file
  1. package ASSET.Models.TMA;
  2. import ASSET.ParticipantType;
  3. import MWC.GenericData.WorldLocation;
  4. import MWC.GenericData.WorldSpeed;
  5. import MWC.GenericData.WorldVector;
  6. /*
  7. * Created by IntelliJ IDEA.
  8. * User: administrator
  9. * Date: 13-Mar-02
  10. * Time: 20:53:40
  11. * To change template for new class use
  12. * Code Style | Class Templates options (Tools | IDE Options).
  13. */
  14. public class TMAHandler
  15. {
  16. static {
  17. System.load("d:\\dev\\asset\\lib\\tma.dll");
  18. }
  19. static java.text.DecimalFormat df = new java.text.DecimalFormat("0000.0000");
  20. public native void displayHelloWorld();
  21. public native double newCalc(double val);
  22. public native double B180(double val);
  23. public native int sumArray(int[] arr);
  24. public static native double sumDArray(double[] arr);
  25. /*****************************************************************
  26. * routines from TMA_DLL
  27. ****************************************************************/
  28. public static native double SetControlParameters(double SpeedOfSound, double RangePrior,
  29. double SpeedPrior, double RangePriorSigma,
  30. double CoursePriorSigma,double SpeedPriorSigma, double OutOfContactTime,
  31. double ManoeuvreDetectionSensitivity, double CorrelationBetweenSolutions,
  32. double MinInfoMatrixDeterminant, double SolutionDegradationFactor);
  33. public static native double InitialiseNonFreq(double[] Target,double[] Sensor, double[] TrueTarget,double[] Sol, double[] Cov,
  34. double[] PolarCov, double B, double SigB, double R, double SigR, double RN[],
  35. double ThisUpdateTime, double[] LastUpdateTime, double[] InfMat, int TMASeed);
  36. public static native double Update(double[] LastUpdateTime, double[] InfMat, double[] Sensor,
  37. double[] TrueTarget, double[] Target, double ThisUpdateTime,
  38. double B, double SigB, double F, double SigF, double R, double SigR,
  39. double C, double SigC, double S, double SigS,
  40. double[] RN, double[] PolarCov, double[] CartCov,
  41. int[] Singular, double[] Sol, int[] Manoeuvre);
  42. public static native double TUACalcs(double ThisTime, double LastTime, double[] Ownship,
  43. double []Solution, double[] CartCov,
  44. double[] PolSolution, double[] Sigs, double[] Axis1, double[] Axis2,
  45. double[] Orientation, double[] Bdot, double[] Rdot);
  46. // public static void main(String[] args)
  47. // {
  48. // final dtestWrapper tw = new dtestWrapper("scrap");
  49. // tw.testIainState();
  50. // }
  51. // TMAHandler tm = new TMAHandler();
  52. // System.out.println("working");
  53. // System.out.println("res:" + tm.B180(-0.9));
  54. // int[] val = new int[]{33, 44, 55};
  55. // System.out.println("sum:" + tm.sumArray(val));
  56. // double[] dVal = new double[]{33, 44, 55};
  57. // System.out.println("sum:" + sumDArray(dVal));
  58. // System.out.println("new val:" + dVal[0]);
  59. // // System.out.println("val is:" + val[0]);
  60. //
  61. // boolean firstStep = true;
  62. //
  63. // // create sensor
  64. //
  65. // // create target
  66. //
  67. // // initialise TMA
  68. //
  69. // // looping through
  70. //
  71. // // first step?
  72. // if(firstStep)
  73. // {
  74. // firstStep = false;
  75. //
  76. // // initialise non frequency component
  77. // // InitialiseNonFreq
  78. // }
  79. //
  80. // // move sensor
  81. //
  82. // // move target
  83. //
  84. // // do update
  85. // // Update
  86. //
  87. // // get GUI parts
  88. // // TUACalcs
  89. // }
  90. static class ParticipantWrapper
  91. {
  92. /** the participant we are wrapping
  93. *
  94. */
  95. ParticipantType _myPart = null;
  96. /** the origin for this scenario
  97. *
  98. */
  99. WorldLocation _origin = null;
  100. /** constructor
  101. *
  102. */
  103. public ParticipantWrapper(final ParticipantType part, final WorldLocation origin)
  104. {
  105. _myPart = part;
  106. _origin = origin;
  107. }
  108. public String toString()
  109. {
  110. final double[] val = state();
  111. final String res = "x:" + df.format(val[0]) + " y:" + df.format(val[1])
  112. + " dx:" + df.format(val[2]) + " dy:" + df.format(val[3]);
  113. return res;
  114. }
  115. /** get the state of this participant
  116. *
  117. */
  118. public double[] state()
  119. {
  120. // produce an array of the current state of this object
  121. // get x and y from origin
  122. final WorldVector dist = _myPart.getStatus().getLocation().subtract(_origin);
  123. final double rng = MWC.Algorithms.Conversions.Degs2m(dist.getRange());
  124. double brg = dist.getBearing();
  125. final double x = rng * Math.sin(brg);
  126. final double y = rng * Math.cos(brg);
  127. final double spd_myps = _myPart.getStatus().getSpeed().getValueIn(WorldSpeed.M_sec);
  128. brg = MWC.Algorithms.Conversions.Degs2Rads(_myPart.getStatus().getCourse());
  129. final double dx = spd_myps * Math.sin(brg);
  130. final double dy = spd_myps * Math.cos(brg);
  131. final double[] res = new double[4];
  132. res[0] = x;
  133. res[1] = y;
  134. res[2] = dx;
  135. res[3] = dy;
  136. return res;
  137. }
  138. /** get the 5 element state for this participant
  139. *
  140. */
  141. public double[] state5element()
  142. {
  143. final double[] res = new double[5];
  144. final double[] state = state();
  145. System.arraycopy(state, 0, res, 0, 4);
  146. res[4] = 300;
  147. return res;
  148. }
  149. }
  150. /*****************************************************************
  151. * store the details for a single track held by a single participant
  152. ****************************************************************/
  153. static class SingleTrack
  154. {
  155. public final double[] target = new double[5];
  156. public final double[] sol = new double[5];
  157. public final double[] rn = new double[5];
  158. public final double[] infoMat = new double[25];
  159. public final double[] polarCov = new double[25];
  160. public final double[] cartCov = new double[25];
  161. public final int[] singular = new int[1];
  162. public final int[] manoeuvre = new int[1];
  163. public final double[] tua = new double[3];
  164. public String toString()
  165. {
  166. return "x:" + df.format(sol[0]) +
  167. " y:" + df.format(sol[1]) +
  168. " dx:" + df.format(sol[2]) +
  169. " dy:" + df.format(sol[3]) +
  170. " hz:" + df.format(sol[4]);
  171. }
  172. }
  173. //////////////////////////////////////////////////////////////////////////////////////////////////
  174. // testing for this class
  175. //////////////////////////////////////////////////////////////////////////////////////////////////
  176. // public static class dtestWrapper extends junit.framework.TestCase
  177. // {
  178. //
  179. // // todo - implement this testing, and change class name back from dTest to test,
  180. // // todo - so that it gets caught up in the automated builds
  181. // static public final String TEST_ALL_TEST_TYPE = "DEVELOPMENT";
  182. // public dtestWrapper(final String val)
  183. // {
  184. // super(val);
  185. // }
  186. //
  187. //
  188. // public void testIainState()
  189. // {
  190. //
  191. // // put ourselves on a flat earth
  192. // MWC.GenericData.WorldLocation.setModel(new MWC.Algorithms.EarthModels.FlatEarth());
  193. //
  194. // // scenario
  195. // final CoreScenario scenario = new CoreScenario();
  196. // scenario.setTime(0);
  197. // scenario.setScenarioStepTime(4000);
  198. // final WorldLocation origin = new WorldLocation(0,0,0);
  199. //
  200. // // the track
  201. // final SingleTrack track = new SingleTrack();
  202. //
  203. // // ssn
  204. // final Status status = new Status(33, 0);
  205. // status.setCourse(90);
  206. // status.setSpeed(new WorldSpeed(8, WorldSpeed.M_sec));
  207. // status.setLocation(origin);
  208. // final SimpleDemandedStatus demStatus = new SimpleDemandedStatus(1200, status);
  209. // final SSN ssn = new SSN(12, status, demStatus, "TRAF");
  210. // scenario.addParticipant(12, ssn);
  211. // final ParticipantWrapper ssn_wrapper = new ParticipantWrapper(ssn, origin);
  212. //
  213. // // ssk
  214. // final Status status2 = new Status(33, 0);
  215. // status2.setCourse(210);
  216. // status2.setSpeed(new WorldSpeed(6, WorldSpeed.M_sec));
  217. // status2.setLocation(new WorldLocation(origin.getLat() + MWC.Algorithms.Conversions.m2Degs(-6858),
  218. // origin.getLong() + MWC.Algorithms.Conversions.m2Degs(11878.4), 0));
  219. // final SimpleDemandedStatus demStatus2 = new SimpleDemandedStatus(1200, status2);
  220. // final SSK ssk = new SSK(15, status2, demStatus2, "KILO");
  221. // scenario.addParticipant(15, ssk);
  222. // final ParticipantWrapper ssk_wrapper = new ParticipantWrapper(ssk, origin);
  223. //
  224. // // initialise
  225. // setControl();
  226. //
  227. // long newTime;
  228. // long oldTime;
  229. // oldTime = newTime = scenario.getTime();
  230. //
  231. // final Vector res = new Vector(0,1);
  232. //
  233. // try
  234. // {
  235. // fo = new java.io.FileWriter("c:\\asset.rep");
  236. // }
  237. // catch (Exception e)
  238. // {
  239. // System.out.println("failed to open file!");
  240. // }
  241. //
  242. // // try the init
  243. // init(ssn_wrapper, ssk_wrapper, track, scenario.getTime());
  244. //
  245. // final StringBuffer msg = new StringBuffer();
  246. //
  247. // final int len = 600;
  248. // System.out.println();
  249. // System.out.println("Time\tTrue Tgt\tAss Tgt\tOwnship\tXY Sol\tTrue Pol\tRBSCF");
  250. // for(int i=0;i<len;i++)
  251. // {
  252. //
  253. // // do any necessary manoeuvres
  254. // if(i == 90)
  255. // {
  256. // // manoeuvre ownship
  257. //
  258. // final SimpleDemandedStatus demandedStatus = (SimpleDemandedStatus) ssn_wrapper._myPart.getDemandedStatus();
  259. // demandedStatus.setCourse(180);
  260. // }
  261. //
  262. // if(i == 205)
  263. // {
  264. // // manoeuvre ownship
  265. // final SimpleDemandedStatus demandedStatus = (SimpleDemandedStatus) ssn_wrapper._myPart.getDemandedStatus();
  266. // demandedStatus.setCourse(130);
  267. // }
  268. //
  269. // // do the step, and calculate the results
  270. // doStep(ssn_wrapper, ssk_wrapper, track, newTime, oldTime);
  271. //
  272. //
  273. // /////////////////////////////////////////
  274. // // output combined state matrix
  275. //// for(int t=0; t<4;t++)
  276. //// {
  277. //// if(t == 0)
  278. //// msg.append(newTime / 1000 + "\t");
  279. //// else
  280. //// msg.append(" " + "\t");
  281. ////
  282. //// msg.append(ssk_wrapper.state()[t] + "\t");
  283. //// msg.append(track.target[t] + "\t");
  284. //// msg.append(ssn_wrapper.state()[t] + "\t");
  285. //// msg.append(track.sol[t] + "\t");
  286. //// if(t<3)
  287. //// msg.append(track.tua[t] + "\t");
  288. ////
  289. //// msg.append(System.getProperty("line.separator"));
  290. //// }
  291. //// msg.append(System.getProperty("line.separator"));
  292. // ///////////////////////////////////////////////////////////
  293. //
  294. //
  295. //
  296. // // remember the old time
  297. // oldTime = newTime;
  298. //
  299. // final double[] newSol = new double[5];
  300. // System.arraycopy(track.sol, 0, newSol, 0, 5);
  301. // final double[] newTrueSol = new double[5];
  302. // System.arraycopy(track.target, 0, newTrueSol, 0, 5);
  303. // final double[] newPolarSol = new double[5];
  304. // System.arraycopy(track.polarCov, 0, newPolarSol, 0, 5);
  305. //
  306. // // output the information matrix
  307. //// msg.append(System.getProperty("line.separator"));
  308. //// for(int m=0;m<5;m++)
  309. //// {
  310. //// if(m == 0)
  311. //// msg.append(newTime / 1000 + "\t");
  312. //// else
  313. //// msg.append("\t");
  314. ////
  315. //// for(int n=0;n<5;n++)
  316. //// {
  317. //// msg.append(track.cartCov[m*5+n] + "\t ");
  318. //// }
  319. //// msg.append(System.getProperty("line.separator"));
  320. //// }
  321. //
  322. //
  323. //
  324. // final Object[] thisSol = new Object[]{ ssn_wrapper.state(),
  325. // ssk_wrapper.state(),
  326. // newSol,
  327. // newTrueSol,
  328. // new Long(oldTime),
  329. // newPolarSol
  330. // };
  331. // res.add(thisSol);
  332. //
  333. // // collate the data to output
  334. // String str = "";
  335. //
  336. // try
  337. // {
  338. // fo.write(writeReplay(newTime, str, "target", "@A", ssk_wrapper));
  339. // fo.write(System.getProperty("line.separator"));
  340. // str = "";
  341. // fo.write(writeReplay(newTime, str, "sensor", "@B", ssn_wrapper));
  342. // fo.write(System.getProperty("line.separator"));
  343. // }
  344. // catch (IOException e)
  345. // {
  346. // e.printStackTrace();
  347. // }
  348. //
  349. //// if(i == 82)
  350. //// ssk_wrapper._myPart.getDemandedStatus().setCourse(344);
  351. //
  352. // // lastly move the scenario forward
  353. // scenario.step();
  354. // newTime = scenario.getTime();
  355. // }
  356. //
  357. //
  358. // // put our diagnostic string on the clipboard
  359. //// java.awt.datatransfer.Clipboard cb =
  360. //// java.awt.Toolkit.getDefaultToolkit().
  361. //// getSystemClipboard();
  362. //// java.awt.datatransfer.StringSelection contents =
  363. //// new java.awt.datatransfer.StringSelection(msg);
  364. //// cb.setContents(contents, null);
  365. // System.out.println(msg);
  366. //
  367. // try
  368. // {
  369. // fo.close();
  370. // }
  371. // catch (IOException e)
  372. // {
  373. // e.printStackTrace();
  374. // }
  375. //
  376. // // ok, now run through the results
  377. // for (int thisStep = 0; thisStep < res.size(); thisStep++)
  378. // {
  379. // final Object[] objects = (Object[]) res.elementAt(thisStep);
  380. // final double[] sensor = (double[])objects[0];
  381. // final double[] tgt = (double[])objects[1];
  382. // final double[] sol = (double[])objects[2];
  383. // final double[] trueSol = (double[])objects[3];
  384. // final long time = ((Long)objects[4]).longValue();
  385. // final double[] polarSol = (double[])objects[5];
  386. //// System.out.println("time:" + time + ", sx:" + df.format(sensor[0])
  387. //// + ", sy:" + df.format(sensor[1]) + ", tx:" + df.format(tgt[0])
  388. //// + ", ty:" + df.format(tgt[1]) + ", solx:"
  389. //// + df.format(sol[0]) + ", soly:" + df.format(sol[1]) +
  390. //// ", p0:" + df.format(polarSol[0]) + ", p1:" + df.format(polarSol[1]) + ", p2:" + df.format(polarSol[2]) +
  391. //// ", p3:" + df.format(polarSol[3]) + ", p4:" + df.format(polarSol[4])
  392. //// );
  393. // }
  394. //
  395. //
  396. //
  397. // }
  398. //
  399. //
  400. //
  401. // public void testState()
  402. // {
  403. //
  404. // // put ourselves on a flat earth
  405. // MWC.GenericData.WorldLocation.setModel(new MWC.Algorithms.EarthModels.FlatEarth());
  406. //
  407. // // scenario
  408. // final CoreScenario scenario = new CoreScenario();
  409. // scenario.setTime(0);
  410. // scenario.setScenarioStepTime(4000);
  411. // final WorldLocation origin = new WorldLocation(0,0,0);
  412. //
  413. // // the track
  414. // final SingleTrack track = new SingleTrack();
  415. //
  416. // // ssn
  417. // final Status status = new Status(33, 0);
  418. // status.setCourse(27);
  419. // status.setSpeed(new WorldSpeed(7, WorldSpeed.M_sec));
  420. // status.setLocation(origin);
  421. // final SimpleDemandedStatus demStatus = new SimpleDemandedStatus(1200, status);
  422. // final SSN ssn = new SSN(12, status, demStatus, "TRAF");
  423. // scenario.addParticipant(12, ssn);
  424. // final ParticipantWrapper ssn_wrapper = new ParticipantWrapper(ssn, origin);
  425. //
  426. // // ssk
  427. // final Status status2 = new Status(33, 0);
  428. // status2.setCourse(2);
  429. // status2.setSpeed(new WorldSpeed(4, WorldSpeed.M_sec));
  430. // status2.setLocation(
  431. // origin.add(
  432. // new WorldVector(MWC.Algorithms.Conversions.Degs2Rads(90),
  433. // MWC.Algorithms.Conversions.Yds2Degs(400), 0)));
  434. // final SimpleDemandedStatus demStatus2 = new SimpleDemandedStatus(1200, status2);
  435. // final SSK ssk = new SSK(15, status2, demStatus2, "KILO");
  436. // scenario.addParticipant(15, ssk);
  437. // final ParticipantWrapper ssk_wrapper = new ParticipantWrapper(ssk, origin);
  438. //
  439. // // initialise
  440. // setControl();
  441. //
  442. // long newTime;
  443. // long oldTime;
  444. // oldTime = newTime = scenario.getTime();
  445. //
  446. // final Vector res = new Vector(0,1);
  447. //
  448. // try
  449. // {
  450. // fo = new java.io.FileWriter("c:\\asset.rep");
  451. // }
  452. // catch (Exception e)
  453. // {
  454. // System.out.println("failed to open file!");
  455. // }
  456. //
  457. // // try the init
  458. // init(ssn_wrapper, ssk_wrapper, track, scenario.getTime());
  459. //
  460. // final StringBuffer msg = new StringBuffer();
  461. //
  462. // final int len = 11;
  463. // System.out.println();
  464. // System.out.println("Time\tTrue Tgt\tAss Tgt\tOwnship\tXY Sol\tTrue Pol\tRBSCF");
  465. // for(int i=0;i<len;i++)
  466. // {
  467. // // do the step, and calculate the results
  468. // doStep(ssn_wrapper, ssk_wrapper, track, newTime, oldTime);
  469. //
  470. //
  471. // /////////////////////////////////////////
  472. // // output combined state matrix
  473. //// for(int t=0; t<4;t++)
  474. //// {
  475. //// if(t == 0)
  476. //// msg.append(newTime / 1000 + "\t");
  477. //// else
  478. //// msg.append(" " + "\t");
  479. ////
  480. //// msg.append(ssk_wrapper.state()[t] + "\t");
  481. //// msg.append(track.target[t] + "\t");
  482. //// msg.append(ssn_wrapper.state()[t] + "\t");
  483. //// msg.append(track.sol[t] + "\t");
  484. //// if(t<3)
  485. //// msg.append(track.tua[t] + "\t");
  486. ////
  487. //// msg.append(System.getProperty("line.separator"));
  488. //// }
  489. //// msg.append(System.getProperty("line.separator"));
  490. // ///////////////////////////////////////////////////////////
  491. //
  492. //
  493. // // remember the old time
  494. // oldTime = newTime;
  495. //
  496. // final double[] newSol = new double[5];
  497. // System.arraycopy(track.sol, 0, newSol, 0, 5);
  498. // final double[] newTrueSol = new double[5];
  499. // System.arraycopy(track.target, 0, newTrueSol, 0, 5);
  500. // final double[] newPolarSol = new double[5];
  501. // System.arraycopy(track.polarCov, 0, newPolarSol, 0, 5);
  502. //
  503. // // output the information matrix
  504. //// msg.append(System.getProperty("line.separator"));
  505. //// for(int m=0;m<5;m++)
  506. //// {
  507. //// if(m == 0)
  508. //// msg.append(newTime / 1000 + "\t");
  509. //// else
  510. //// msg.append("\t");
  511. ////
  512. //// for(int n=0;n<5;n++)
  513. //// {
  514. //// msg.append(track.cartCov[m*5+n] + "\t ");
  515. //// }
  516. //// msg.append(System.getProperty("line.separator"));
  517. //// }
  518. //
  519. //
  520. //
  521. // final Object[] thisSol = new Object[]{ ssn_wrapper.state(),
  522. // ssk_wrapper.state(),
  523. // newSol,
  524. // newTrueSol,
  525. // new Long(oldTime),
  526. // newPolarSol
  527. // };
  528. // res.add(thisSol);
  529. //
  530. // // collate the data to output
  531. // String str = "";
  532. //
  533. // try
  534. // {
  535. // fo.write(writeReplay(newTime, str, "target", "@A", ssk_wrapper));
  536. // fo.write(System.getProperty("line.separator"));
  537. // str = "";
  538. // fo.write(writeReplay(newTime, str, "sensor", "@B", ssn_wrapper));
  539. // fo.write(System.getProperty("line.separator"));
  540. // }
  541. // catch (IOException e)
  542. // {
  543. // e.printStackTrace();
  544. // }
  545. //
  546. //// if(i == 82)
  547. //// ssk_wrapper._myPart.getDemandedStatus().setCourse(344);
  548. //
  549. // // lastly move the scenario forward
  550. // scenario.step();
  551. // newTime = scenario.getTime();
  552. // }
  553. //
  554. //
  555. // // put our diagnostic string on the clipboard
  556. //// java.awt.datatransfer.Clipboard cb =
  557. //// java.awt.Toolkit.getDefaultToolkit().
  558. //// getSystemClipboard();
  559. //// java.awt.datatransfer.StringSelection contents =
  560. //// new java.awt.datatransfer.StringSelection(msg);
  561. //// cb.setContents(contents, null);
  562. // System.out.println(msg);
  563. //
  564. // try
  565. // {
  566. // fo.close();
  567. // }
  568. // catch (IOException e)
  569. // {
  570. // e.printStackTrace();
  571. // }
  572. //
  573. // // ok, now run through the results
  574. // for (int thisStep = 0; thisStep < res.size(); thisStep++)
  575. // {
  576. // final Object[] objects = (Object[]) res.elementAt(thisStep);
  577. // final double[] sensor = (double[])objects[0];
  578. // final double[] tgt = (double[])objects[1];
  579. // final double[] sol = (double[])objects[2];
  580. // final double[] trueSol = (double[])objects[3];
  581. // final long time = ((Long)objects[4]).longValue();
  582. // final double[] polarSol = (double[])objects[5];
  583. //// System.out.println("time:" + time + ", sx:" + df.format(sensor[0])
  584. //// + ", sy:" + df.format(sensor[1]) + ", tx:" + df.format(tgt[0])
  585. //// + ", ty:" + df.format(tgt[1]) + ", solx:"
  586. //// + df.format(sol[0]) + ", soly:" + df.format(sol[1]) +
  587. //// ", p0:" + df.format(polarSol[0]) + ", p1:" + df.format(polarSol[1]) + ", p2:" + df.format(polarSol[2]) +
  588. //// ", p3:" + df.format(polarSol[3]) + ", p4:" + df.format(polarSol[4])
  589. //// );
  590. // }
  591. //
  592. //
  593. //
  594. // }
  595. //
  596. // private String writeReplay(final long newTime, String str, final String name, final String sym, final ParticipantWrapper ssk_wrapper)
  597. // {
  598. // str += MWC.Utilities.TextFormatting.DebriefFormatDateTime.toString(newTime);
  599. // str += " " + name + " " + sym + " ";
  600. // str += MWC.Utilities.TextFormatting.DebriefFormatLocation.toString(ssk_wrapper._myPart.getStatus().getLocation());
  601. // str += " " ;
  602. // str += MWC.Utilities.TextFormatting.GeneralFormat.formatOneDecimalPlace(ssk_wrapper._myPart.getStatus().getCourse());
  603. // str += " " ;
  604. // str += MWC.Utilities.TextFormatting.GeneralFormat.formatOneDecimalPlace(ssk_wrapper._myPart.getStatus().getSpeed().getValueIn(WorldSpeed.M_sec));
  605. // str += " " ;
  606. // str += MWC.Utilities.TextFormatting.GeneralFormat.formatOneDecimalPlace(ssk_wrapper._myPart.getStatus().getLocation().getDepth());
  607. // str += " " ;
  608. // return str;
  609. // }
  610. //
  611. // private void doStep(final ParticipantWrapper sensor, final ParticipantWrapper target,
  612. // final SingleTrack track,
  613. // final long newTime,
  614. // final long oldTime)
  615. // {
  616. // update(sensor, target, track, newTime, oldTime);
  617. // }
  618. //
  619. // static final double SIG_B = MWC.Algorithms.Conversions.Degs2Rads(0.5);
  620. // static final double SIG_F = -1;
  621. // static final double SIG_C = -1;
  622. // static final double SIG_S = -1;
  623. // static final double SIG_R = -1;
  624. //// static final double SIG_C = 60;
  625. //// static final double SIG_S = 10;
  626. //// static final double SIG_R = 9144;
  627. //
  628. //
  629. // static void update(final ParticipantWrapper sensor,
  630. // final ParticipantWrapper target,
  631. // final SingleTrack track,
  632. // long time,
  633. // long lastTime)
  634. // {
  635. // final WorldVector sep = target._myPart.getStatus().getLocation().subtract(sensor._myPart.getStatus().getLocation());
  636. // final double brg = sep.getBearing();
  637. // final double brgMeasured = brg - SIG_B + ASSET.Util.RandomGenerator.nextRandom() * SIG_B * 2;
  638. // final double rng = MWC.Algorithms.Conversions.Degs2m(sep.getRange());
  639. // final double course = MWC.Algorithms.Conversions.Degs2Rads(target._myPart.getStatus().getCourse());
  640. // final double speed = target._myPart.getStatus().getSpeed().getValueIn(WorldSpeed.M_sec);
  641. // time /= 1000;
  642. // lastTime /= 1000;
  643. // double res = 4;
  644. // final double[] lastUpdateTime = new double[]{lastTime};
  645. //
  646. //// System.out.println("========= Update =============");
  647. //// System.out.println(" Sensor: " + sensor);
  648. //// System.out.println(" Target: " + target);
  649. //// System.out.println(" input: " + "singular: " + track.singular[0] + " manoeuvre:" + track.manoeuvre[0] + " new time:" + time + " last time:" + lastUpdateTime[0]);
  650. //// System.out.println(" Cut: brg:" + df.format(brg) + " (" + df.format(Math.toDegrees(brg)) + " degs)"
  651. //// + " meas brg:" + df.format(brgMeasured) + " (" + df.format(Math.toDegrees(brgMeasured)) + " degs)"
  652. //// + " rng:" + df.format(rng)
  653. //// + " crse:" + df.format(course) + " (" + df.format(Math.toDegrees(course)) + " degs)"
  654. //// + " spd:" + df.format(speed));
  655. //
  656. //
  657. // // System.out.println("polar[0] before update" + track.polarCov[0]);
  658. //
  659. //
  660. // res = TMAHandler.Update(lastUpdateTime, track.infoMat, sensor.state(),
  661. // target.state5element(), track.target, time,
  662. // brg, SIG_B, -1, SIG_F,
  663. //// rng, SIG_R,
  664. // 0, -1,
  665. // course, SIG_C, speed, SIG_S,
  666. //// 0, SIG_C, 0, SIG_S,
  667. // track.rn, track.polarCov, track.cartCov,
  668. // track.singular, track.sol, track.manoeuvre);
  669. //
  670. // // try to do TUA calcs
  671. // TUACalcs(sensor, target, track, time, lastTime);
  672. //
  673. //
  674. // System.out.println("--output: " + "singular: " + track.singular[0] + " manoeuvre:" + track.manoeuvre[0] + " new time:|| " + time + " || last time:" + lastUpdateTime[0]);
  675. // System.out.println(" Target: " + "x:" + df.format(track.target[0]) + " y:" + df.format(track.target[1])
  676. // + " dx:" + df.format(track.target[2]) + " dy:" + df.format(track.target[3]));
  677. // System.out.println(" Ownship:" + sensor);
  678. // System.out.println("Solution: " + track + "||");
  679. //
  680. // // write the information matrix
  681. // for(int k=0;k<5;k++)
  682. // {
  683. // for(int l=0;l<5;l++)
  684. // {
  685. // System.out.print(" " + df2.format(track.polarCov[k * 5 + l]));
  686. // }
  687. // System.out.println("");
  688. // }
  689. // System.out.println("=========================================");
  690. //
  691. //
  692. // }
  693. //
  694. // static void init(final ParticipantWrapper sensor,
  695. // final ParticipantWrapper target,
  696. // final SingleTrack track,
  697. // long time)
  698. // {
  699. //
  700. // final WorldVector sep = target._myPart.getStatus().getLocation().subtract(sensor._myPart.getStatus().getLocation());
  701. // final double brg = sep.getBearing();
  702. // final double rng = MWC.Algorithms.Conversions.Degs2m(sep.getRange());
  703. // final double[] sensor4 = sensor.state();
  704. // final double[] target5 = target.state5element();
  705. // final double[] lastUpdateTime = new double[1];
  706. // // convert to millis
  707. // time /= 1000;
  708. // final int seed = 3;
  709. //
  710. //
  711. // final double res = TMAHandler.InitialiseNonFreq( track.target, sensor4, target5,
  712. // track.sol, track.cartCov, track.polarCov,
  713. // brg, SIG_B,
  714. // 0, -1,
  715. // //rng, SIG_R,
  716. // track.rn, time, lastUpdateTime, track.infoMat, seed);
  717. //
  718. //// System.out.println("========= Init Non Freq =============");
  719. //// System.out.println(" Sensor: " + sensor);
  720. //// System.out.println(" Target: " + target);
  721. //// System.out.println(" Cut: brg:" + df.format(brg) + " (" + df.format(Math.toDegrees(brg)) + " degs)"
  722. //// + " rng:" + df.format(rng));
  723. //// System.out.println("Solution: " + track);
  724. //
  725. // }
  726. //
  727. //
  728. // static void setControl()
  729. // {
  730. // final double SpeedOfSound = -1;
  731. // final double RangePrior = -1;
  732. // final double SpeedPrior = -1;
  733. // final double RangePriorSigma = -1;
  734. // final double CoursePriorSigma = -1;
  735. // final double SpeedPriorSigma = -1;
  736. // final double OutOfContactTime = -1;
  737. // final double ManoeuvreDetectionSensitivity = -1;
  738. // final double CorrelationBetweenSolutions = -1;
  739. // final double MinInfoMatrixDeterminant = -1;
  740. // final double SolutionDegradationFactor = -1;
  741. //
  742. // SetControlParameters(SpeedOfSound, RangePrior, SpeedPrior, RangePriorSigma,
  743. // CoursePriorSigma,SpeedPriorSigma, OutOfContactTime,
  744. // ManoeuvreDetectionSensitivity, CorrelationBetweenSolutions,
  745. // MinInfoMatrixDeterminant, SolutionDegradationFactor);
  746. // }
  747. //
  748. // static void TUACalcs(final ParticipantWrapper sensor,
  749. // ParticipantWrapper target,
  750. // final SingleTrack track,
  751. // final long time, final long lastTime)
  752. // {
  753. // final double[] Axis1 = new double[1];
  754. // final double[] Axis2 = new double[1];
  755. // final double[] Orientation = new double[1];
  756. // final double[] BDot = new double[1];
  757. // final double[] RDot = new double[1];
  758. // final double[] sigmas = new double[5];
  759. //
  760. // final double[] polSolution = new double[5];
  761. //
  762. // double res = 1;
  763. //
  764. // res = TMAHandler.TUACalcs(time, lastTime, sensor.state(),
  765. // track.sol, track.cartCov,
  766. // polSolution, sigmas, Axis1, Axis2, Orientation,
  767. // BDot, RDot);
  768. //
  769. //// System.out.println("Sol returned, axis1:" + Axis1[0] + " axis2:" +
  770. //// Axis2[0] + " orient:" + Orientation[0] + " rng:" +
  771. //// polSolution[0] + " brgs:" + polSolution[1]);
  772. //
  773. // track.tua[0] = Axis1[0];
  774. // track.tua[1] = Axis2[0];
  775. // track.tua[2] = Math.toDegrees(Orientation[0]);
  776. //
  777. // // ok, output our solution
  778. //
  779. //// ;ELLIPSE: BD YYMMDD HHMMSS DD MM SS.SS H DD MM SS.SS H CCC XXXX YYYY xx.xx
  780. //// ;; symb, date, time, lat, long, orientation, maxima (yards), minima (yards), label
  781. //
  782. //
  783. // if(time == 360)
  784. // System.out.println("here!");
  785. //
  786. // double rng = polSolution[0];
  787. // rng = MWC.Algorithms.Conversions.m2Degs(rng);
  788. // final double brg = polSolution[1];
  789. // final WorldVector sep = new WorldVector(brg, rng, 0);
  790. // final WorldLocation origin = sensor._myPart.getStatus().getLocation().add(sep);
  791. //
  792. // String str = ";ELLIPSE: @";
  793. // if(track.manoeuvre[0] == 0)
  794. // {
  795. // str += "D ";
  796. // }
  797. // else
  798. // {
  799. // str += "E ";
  800. // }
  801. // str += MWC.Utilities.TextFormatting.DebriefFormatDateTime.toString(time * 1000);
  802. // str += " ";
  803. // str += MWC.Utilities.TextFormatting.DebriefFormatLocation.toString(origin);
  804. // str += " ";
  805. // str += MWC.Utilities.TextFormatting.GeneralFormat.formatOneDecimalPlace(MWC.Algorithms.Conversions.Rads2Degs(Orientation[0]));
  806. // str += " ";
  807. // str += MWC.Utilities.TextFormatting.GeneralFormat.formatOneDecimalPlace(Axis1[0] * 0.9144);
  808. // str += " ";
  809. // str += MWC.Utilities.TextFormatting.GeneralFormat.formatOneDecimalPlace(Axis2[0] * 0.9144);
  810. // str += " ";
  811. //
  812. // // System.out.println("orient:" + Math.toDegrees(Orientation[0]) + " axis1:" + Axis1[0] + " axis2:" + Axis2[0]);
  813. //
  814. // final java.text.SimpleDateFormat dateF = new java.text.SimpleDateFormat("mm:ss");
  815. //
  816. // str += dateF.format(new java.util.Date(time * 1000));
  817. //
  818. //
  819. // try
  820. // {
  821. // fo.write(str + System.getProperty("line.separator"));
  822. // }
  823. // catch (IOException e)
  824. // {
  825. // e.printStackTrace();
  826. // }
  827. //
  828. // // System.out.println("axis1:" + Axis1[0] + ", 2:" + Axis2[0] + " Orient:" + Orientation[0]);
  829. //
  830. // }
  831. //
  832. // }
  833. //
  834. //
  835. }