source: ntrip/trunk/clock_and_orbit/readVtec.c@ 10460

Last change on this file since 10460 was 5664, checked in by stoecker, 11 years ago

SSR update

File size: 2.8 KB
RevLine 
[5664]1#include "clock_orbit_rtcm.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5
6/* prototype, don't use any of this code in a final application */
7
8void printVtec(struct VTEC vtec) {
9 int i, j, k;
10 for (i = 0; i < vtec.NumLayers; ++i) {
11 printf("%d layer %d height %f degree %d order %d\n",
12 vtec.EpochTime, i,
13 vtec.Layers[i].Height,
14 vtec.Layers[i].Degree,
15 vtec.Layers[i].Order);
16 for (j = 0; j <= vtec.Layers[i].Degree; ++j) {
17 printf("Cn%d ", j);
18 for (k = 0; k <= vtec.Layers[i].Order; ++k) {
19 printf(" %7.3f", vtec.Layers[i].Cosinus[k][j]);
20 }
21 printf("\n");
22 }
23 for (j = 0; j <= vtec.Layers[i].Degree; ++j) {
24 printf("Sn%d ", j);
25 for (k = 0; k <= vtec.Layers[i].Order; ++k) {
26 printf(" %7.3f", vtec.Layers[i].Sinus[k][j]);
27 }
28 printf("\n");
29 }
30 }
31}
32
33
34
35int main(void) {;
36 char obuffer[CLOCKORBIT_BUFFERSIZE];
37 //////////////////////////
38 // VTEC //
39 //////////////////////////
40
41 struct VTEC v;
42 memset(&v, 0, sizeof(v));
43 v.EpochTime = 218764;
44 v.NumLayers = 1;
45 v.UpdateInterval = 1;
46 v.Layers[0].Height = 450000;
47 v.Layers[0].Degree = 4;
48 v.Layers[0].Order = 4;
49 v.Layers[0].Cosinus[0][0] = 24.435;
50 v.Layers[0].Cosinus[1][0] = 4.495;
51 v.Layers[0].Cosinus[2][0] = -7.805;
52 v.Layers[0].Cosinus[3][0] = -1.900;
53 v.Layers[0].Cosinus[4][0] = 2.045;
54 v.Layers[0].Cosinus[1][1] = -9.960;
55 v.Layers[0].Cosinus[2][1] = 0.845;
56 v.Layers[0].Cosinus[3][1] = 2.260;
57 v.Layers[0].Cosinus[4][1] = -0.315;
58 v.Layers[0].Cosinus[2][2] = 3.730;
59 v.Layers[0].Cosinus[3][2] = -0.780;
60 v.Layers[0].Cosinus[4][2] = -0.055;
61 v.Layers[0].Cosinus[3][3] = -0.020;
62 v.Layers[0].Cosinus[4][3] = 1.150;
63 v.Layers[0].Cosinus[4][4] = 0.990;
64
65 v.Layers[0].Sinus[1][1] = -6.070;
66 v.Layers[0].Sinus[2][1] = -3.105;
67 v.Layers[0].Sinus[3][1] = 1.310;
68 v.Layers[0].Sinus[4][1] = 1.545;
69 v.Layers[0].Sinus[2][2] = 0.325;
70 v.Layers[0].Sinus[3][2] = -1.050;
71 v.Layers[0].Sinus[4][2] = -0.750;
72 v.Layers[0].Sinus[3][3] = 0.170;
73 v.Layers[0].Sinus[4][3] = -0.690;
74 v.Layers[0].Sinus[4][4] = -0.705;
75 fprintf(stderr, "VTEC INPUT\n");
76 printVtec(v);
77 FILE *f;
78 int l = MakeVTEC(&v, 0, obuffer, sizeof(obuffer));
79 if (!l)
80 fprintf(stderr, "BUILD ERROR\n");
81 else {
82 int nl, ns;
83 struct VTEC vv;
84
85 if ((f = fopen("outfile.raw", "ab+"))) {
86 fwrite(obuffer, l, 1, f);
87 fclose(f);
88 } else
89 fprintf(stderr, "SAVE ERROR\n");
90 //fwrite(obuffer, l, 1, stdout);
91 memset(&vv, 0, sizeof(vv));
92 nl = GetSSR(0, 0, &vv, 0, obuffer, l, &ns);
93 if (nl < 0)
94 fprintf(stderr, "EXTRACT ERROR %d\n", nl);
95 else if (nl > 0)
96 fprintf(stderr, "MULTIBLOCK UNSUPPORTED IN TEST\n");
97 else if (ns != l)
98 fprintf(stderr, "SIZE MISMATCH (%d/%d)\n", ns, l);
99 else {
100 fprintf(stderr, "VTEC OUTPUT\n");
101 printVtec(vv);
102 }
103 }
104 return 0;
105}
106
107
Note: See TracBrowser for help on using the repository browser.