void UIInputAmount::FormAmount(unsigned char *pucOut,unsigned long ulAmount,unsigned char ucDecimalPos) { unsigned char i; unsigned char j; unsigned char aucBuf[10] = {0}; short space = 0; memset(aucBuf,0,sizeof(aucBuf)); long_str(aucBuf, 9, &ulAmount);//8 j = ucDecimalPos; for (i = 8; j; i--, j--) //7 aucBuf[i + 1] = aucBuf[i]; if (ucDecimalPos) { aucBuf[i + 1] ='.'; aucBuf[i + 1 + ucDecimalPos + 1] = 0; } for (j = 0; ((j < i) && (aucBuf[j]=='0')); space++,aucBuf[j++]=' '); memcpy(pucOut,&aucBuf[space],strlen((char *)aucBuf)-space); }
main ( int argc, char **argv ) { char orbname[20]="zagsun6"; int orb; tstations_struc stations ; char name[5] = "ORB" ; char sname[5] = "Q003" ; short int data_mask = CSIM_DATA ; pclient_struc client ; pclient_station station ; pdata_user data ; boolean alert_flag ; int ret ; int i, j ; Steim *blockette; int *sdata, npts; PktChannel pktchan; unsigned short int quality = 0; unsigned short int pinno = 0; char *packet = NULL; int nbytes = 0; int bufsiz = 0; char srcname[256]; int fix_MOTA=0; int fix_WATA=0; int fix_SQTA=0; /* double fouryears=epoch(2004000)-epoch(1996000); double eightyears=epoch(2004000)-epoch(1996000); double twelveyears=epoch(2008000)-epoch(1996000); double twentyyears=epoch(2016000)-epoch(1996000); */ double sixteenyears=epoch(2012000)-epoch(1996000); Pf *mypf; /* Niko, leap second July 2012 */ /* subtract another second for the leap-second 2006-01-01 */ /* no more... Udo corrected the time again... eightyears -= 1; sixteenyears -= 1.0; */ /*schaltsekunde 2009-01-01*/ /*double twokohnine=epoch(2009001); */ elog_init ( argc, argv ) ; if (argc < 2) { usage(); exit (1); } /*strcpy(orbname,"zagsun6");*/ /*orbname = argv[2];*/ strncpy (sname, argv[1], 4); sname[4] = '\0'; for (argc-=3,argv+=3; argc>0; argc--,argv++) { if (!strcmp(*argv, "-v")) { verbose = 1; } else { fprintf (stderr, "cs2orb: Unrecognized option '%s'.\n", *argv); usage(); exit (1); } } putenv("PFPATH=/home/comserv/pf"); if ( pfread ( "cs2orb", &mypf ) != 0 ) die ( 1, "Can't read parameter file\n" ) ; fix_MOTA=pfget_int(mypf,"MOTA"); fix_WATA=pfget_int(mypf,"WATA"); fix_SQTA=pfget_int(mypf,"SQTA"); /* orb setup stuff */ orb = orbopen (orbname, "w&"); if (orb < 0) { clear_register (1); fprintf (stderr, "cs2orb: orbopen() error for '%s'.\n", orbname); exit (1); } /* comserv setup stuff */ cs_setup (&stations, name, sname, TRUE, TRUE, 10, 5, data_mask , 6000) ; client = cs_gen ( &stations ) ; /* Trace setup stuff */ blockette = newsteim(); blockette->record_size = 512 ; /* Data packet read loop */ while (1) { /* Look for a packet */ ret = cs_scan ( client , &alert_flag ) ; /* Sleep and loop if nothing there */ if (ret == -1) { sleep (1); continue; } /* Grab the station structure pointer */ station = (pclient_station) ((long int) client + client->offsets[ret]) ; /* Printout station status */ if (alert_flag) { complain (0, "Station %4s status: %s\n", long_str(station->name.l), &(stats[station->status])) ; } /* Sleep and loop if no valid data */ if (!(station->valdbuf)) { sleep (1); continue; } /* Grab the data buffer pointer */ data = (pdata_user) ((long int) client + station->dbufoffset) ; /* Loop over number of data buffers */ for (i=0; i<station->valdbuf; i++,data=(pdata_user) ((long int)data + station->dbufsize)) { /* Set data blockette record */ blockette->record = (pvoid) &(data->data_bytes) ; /* Parse the SEED header */ if ( parse_seed_data_header( blockette ) ) { complain ( 0, "Problems parsing SEED header or 1000 blockette.\n" ) ; continue ; } /* niko netzname at fuer antelope */ strcpy (blockette->sdh.net,"OE"); sprintf (srcname, "%s_%s_%s", blockette->sdh.net, blockette->sdh.sta, blockette->sdh.chan); if (verbose) printf ("%s:", srcname); /* Not a data packet */ if (!(blockette->sdh.nsamp) || !(blockette->sdh.samprate_factor)) { if (verbose) printf (" No data\n"); continue; } if (verbose) printf ("%s", strtime(blockette->sdh.epoch)); /* Uncompress the data */ if ( usteim (blockette, &sdata, &npts) ) { clear_register (1); continue; } if (verbose) { for (j=0; j<10; j++) printf (" %5d", sdata[j]); printf ("\n"); } /* Stuff packet for orb */ strcpy (pktchan.net, blockette->sdh.net); strcpy (pktchan.sta, blockette->sdh.sta); strcpy (pktchan.chan, blockette->sdh.chan); /* pktchan.time = blockette->sdh.epoch+eightyears; pktchan.time = blockette->sdh.epoch+twelveyears; */ pktchan.time = blockette->sdh.epoch+sixteenyears; /*pktchan.time = blockette->sdh.epoch+twentyyears;*/ pktchan.samprate = blockette->sdh.samprate; switch (pktchan.chan[0]) { case 'H': pktchan.calib = 1.589446; break; /* case 'E': pktchan.calib = 0.06/0.707; changed to 0.257 (~0.36*0.707) */ case 'E': pktchan.calib = 0.257; /* incl. dämpfung -> stimmt wenn antelope diesen wert mit TF multipl. */ break; default: pktchan.calib = 1.0; break; } if (!strcmp(pktchan.sta,"GAGA")) { /*Uhrenkorrektur template */ pktchan.time -= 1.0; } if (!strcmp(pktchan.sta,"no-MOTA")) { /*Uhrenkorrektur MOTA */ pktchan.time -= 1.0; } if ( fix_MOTA != 0 && !strcmp(pktchan.sta,"MOTA")) { /*Uhrenkorrektur MOTA */ pktchan.time += (double)(fix_MOTA); } if (fix_SQTA != 0 && !strcmp(pktchan.sta,"SQTA")) { /*Uhrenkorrektur SQTA */ pktchan.time += (double)(fix_SQTA); } if ( fix_WATA !=0 && !strcmp(pktchan.sta,"WATA")) { /*Uhrenkorrektur WATA */ pktchan.time += (double)(fix_WATA); } /* solve the problem with omitted segtype, which chops the db */ if (!strcmp(pktchan.sta,"OBKA")) { switch (pktchan.chan[1]) { case 'H': strcpy(pktchan.segtype,"V"); break; case 'L': strcpy(pktchan.segtype,"A"); break; default: ; break; } } /* pktchan.calib = 1.0; */ pktchan.nsamp = blockette->sdh.nsamp; pktchan.data = sdata; pktchan.nbytes = 4*pktchan.nsamp; pktchan.datatype = trINT; if (!stuff_iwc_tracebuf ( quality, pinno, &pktchan, &packet, &nbytes, &bufsiz ) ) { complain (0, "stuff_iwc_tracebuf error.\n"); exit (1); } /* Put to orb */ if ( orbput ( orb, srcname, pktchan.time, packet, nbytes ) ) { complain (0, "orbput error.\n"); exit (1); } orbflush (orb); } } }