Control *hbtablesdata_init() { Control *Ctl9,*Ctl12,*Ctl13,*Ctl1,*Ctl2,*Ctl3,*Ctl7; RECT rt; TFILE *pHead; ReadFile("abmtablesdata.rc", (TFILE **)&pHead); GetSiteInfo( pHead, 0, &rt); Ctl9 = CtlInit(BOX ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 1, &rt); Ctl12 = CtlInit(LABEL ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 2, &rt); Ctl13 = CtlInit(EDIT ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 3, &rt); Ctl1 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 4, &rt); Ctl2 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 5, &rt); Ctl3 = CtlInit(LIST ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 6, &rt); Ctl7 = CtlInit(LABEL ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); strcpy( Ctl12 ->sData , "查询表数据:" ); strcpy( Ctl7 ->sData , "当前位置: abmaccess菜单>>HB系统表名浏览>>列表>>查询数据" ); // strcpy( Ctl1 ->sData , "1.查看" ); strcpy( Ctl2 ->sData , "q.退出" ); Ctl13 ->pKeyPress = (KEYPRESS)&hbtablesdataCtl13Press; Ctl1 ->pKeyPress = (KEYPRESS)&hbtablesdataCtl1Press; Ctl2 ->pKeyPress = (KEYPRESS)&hbtablesdataCtl2Press; Ctl3 ->pKeyPress = (KEYPRESS)&hbtablesdataCtl3Press; Ctl13 ->pHotKeyPress = (KEYPRESS)&hbtablesdata_SysHotKeyPress; Ctl1 ->pHotKeyPress = (KEYPRESS)&hbtablesdata_SysHotKeyPress; Ctl2 ->pHotKeyPress = (KEYPRESS)&hbtablesdata_SysHotKeyPress; Ctl3 ->pHotKeyPress = (KEYPRESS)&hbtablesdata_SysHotKeyPress; Ctl1 ->iHotKey = '1' ; Ctl2 ->iHotKey = 'q' ; Ctl9 ->bFrame = 1 ; Ctl3 ->bFrame = 1 ; Ctl3 ->bSingle = 0 ; CtlSetDir(Ctl9 , NULL, NULL, NULL, NULL, NULL, Ctl12); CtlSetDir(Ctl12 , NULL, NULL, NULL, NULL, NULL, Ctl13); CtlSetDir(Ctl13 , Ctl1, Ctl1, Ctl1, Ctl2, Ctl1, Ctl1); CtlSetDir(Ctl1 , Ctl3, NULL, Ctl2, Ctl2, Ctl2, Ctl2); CtlSetDir(Ctl2 , Ctl3, NULL, Ctl1, Ctl1, Ctl13, Ctl3); CtlSetDir(Ctl3 , Ctl13, Ctl1, Ctl1, Ctl2, Ctl1, Ctl7); CtlSetDir(Ctl7 , NULL, NULL, NULL, NULL, NULL, NULL); FreeFileMem( pHead ); hbtablesdata_entry((Control *)Ctl9); return ((Control *)Ctl9) ; }
Control *sharedmemory_init() { Control *Ctl11,*Ctl7,*Ctl9,*Ctl1,*Ctl5,*Ctl6; RECT rt; TFILE *pHead; ReadFile("sharedmemory.rc", (TFILE **)&pHead); GetSiteInfo( pHead, 0, &rt); Ctl11 = CtlInit(LABEL ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 1, &rt); Ctl7 = CtlInit(LABEL ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 2, &rt); Ctl9 = CtlInit(BOX ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 3, &rt); Ctl1 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 4, &rt); Ctl5 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 5, &rt); Ctl6 = CtlInit(LIST ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); strcpy( Ctl11 ->sData , "共享内存ID 名称 状态 占用(bite)" ); strcpy( Ctl7 ->sData , "当前位置: ABM监控>> 共享内存>>" ); strcpy( Ctl1 ->sData , "1.刷新" ); strcpy( Ctl5 ->sData , "q.退出" ); Ctl1 ->pKeyPress = (KEYPRESS)&sharedmemoryCtl1Press; Ctl5 ->pKeyPress = (KEYPRESS)&sharedmemoryCtl5Press; Ctl6 ->pKeyPress = (KEYPRESS)&sharedmemoryCtl6Press; Ctl1 ->pHotKeyPress = (KEYPRESS)&sharedmemory_SysHotKeyPress; Ctl5 ->pHotKeyPress = (KEYPRESS)&sharedmemory_SysHotKeyPress; Ctl6 ->pHotKeyPress = (KEYPRESS)&sharedmemory_SysHotKeyPress; Ctl1 ->iHotKey = '1' ; Ctl5 ->iHotKey = 'q' ; Ctl9 ->bFrame = 1 ; Ctl6 ->bFrame = 1 ; Ctl6 ->bSingle = 0 ; CtlSetDir(Ctl11 , NULL, NULL, NULL, NULL, NULL, Ctl7); CtlSetDir(Ctl7 , NULL, NULL, NULL, NULL, NULL, Ctl9); CtlSetDir(Ctl9 , NULL, NULL, NULL, NULL, NULL, Ctl1); CtlSetDir(Ctl1 , Ctl6, NULL, Ctl5, Ctl5, Ctl5, Ctl5); CtlSetDir(Ctl5 , Ctl6, NULL, Ctl1, Ctl1, Ctl6, Ctl6); CtlSetDir(Ctl6 , NULL, Ctl1, Ctl1, Ctl5, Ctl1, NULL); FreeFileMem( pHead ); sharedmemory_entry((Control *)Ctl11); return ((Control *)Ctl11) ; }
rapicThread::rapicThread(float lp_dly, char *comminifile, char *dbinifile) : ThreadObj(lp_dly) { NextCommPollTime = 0; timenow = time(0); CommPollPeriod = 1; GetSiteInfo(DISABLE_COVERAGE_LOAD); FreeListMng = new free_list_mng; ScanMng = new scan_mng; string dbIniFile = "rpdb.ini"; if (dbinifile) dbIniFile = dbinifile; if (FileExists(dbIniFile.c_str())) { if (InitISAM(10,30,12)) fprintf(stderr,"CTree InitISAM ERROR"); else { DBMngr = new DBMng(true,dbinifile ); // don't allow db purge if cache copy mode if (DBMngr) { if (ScanMng) { ScanMng->AddClient(DBMngr); if ((ScanMng->recentCachePeriod > 0) && ScanMng->keepScansInCache) { fprintf(stdout, "Loading last %dmins of data from database into recent scan cache\n", ScanMng->recentCachePeriod); DBMngr->loadInitialSeq(NULL, 1, true); ScanMng->startupLatestTime = ScanMng->mostRecentScanTime(); //latest time from db on startup ScanMng->PrintScanUsage(stdout, true); } } } } } string commIniFile = "rpcomm.ini"; if (comminifile) commIniFile = comminifile; if (FileExists(commIniFile.c_str())) CommMngr = new RPCommMng((char *)commIniFile.c_str()); }
int main ( int argc, char **argv ) { //FILE *testarena; char tempstr[256]; setDefaultLogName("rapicDS.log"); RapicStartedTime = time(0); mainpid = getpid(); sprintf(arenaname,"%s.arena",argv[0]); sprintf(Title,"%s %s",argv[0], versionStr()); sprintf(tempstr,"%s - Starting as pid %d\n",Title, mainpid); RapicLog(tempstr, LOG_WARNING); init_signals(); if (FileExists("rapicquitflag", true, true)) { sprintf(tempstr,"%s - Warning - rapicquitflag detected on startup, deleting",Title); RapicLog(tempstr, LOG_WARNING); } #ifdef THREAD_SPROC usptr_t *arena = 0; if (testarena = fopen(arenaname,"r")) { fprintf(stderr,"WARNING - IRIX ARENA ALREADY EXISTS - %s\n",arenaname); // fprintf(stderr,"FATAL ERROR - 3D Rapic CANNOT RUN"); // exit(-1); } else fclose(testarena); int ret; if (ret = usconfig(CONF_INITSIZE,256000)) { perror("usconfig(CONF_INITSIZE)"); }; if (ret = usconfig(CONF_LOCKTYPE,US_DEBUGPLUS)) { perror("usconfig(CONF_LOCKTYPE)"); }; // usconfig(CONF_LOCKTYPE,US_DEBUG); // usconfig(CONF_LOCKTYPE,US_NODEBUG); if (ret = usconfig(CONF_ARENATYPE,US_SHAREDONLY)) { perror("usconfig(CONF_ARENATYPE)"); }; if (ret = usconfig(CONF_INITUSERS,150)) { perror("usconfig(CONF_INITUSERS)"); }; // usconfig(CONF_STHREADIOOFF); if (!(arena = usinit(arenaname))) { fprintf(stderr,"usinit(%s) - FAILED ", arenaname); perror(0); fprintf(stderr,"FATAL ERROR - %s CANNOT RUN", argv[0]); exit(-1); } #endif GetSiteInfo(DISABLE_COVERAGE_LOAD); FreeListMng = new free_list_mng; ScanMng = new scan_mng; rpdbCacheCopyMode = argFound(argc, argv, "cache_path"); if (InitISAM(10,30,12)) fprintf(stderr,"CTree InitISAM ERROR"); else { DBMngr = new DBMng(!rpdbCacheCopyMode); // don't allow db purge if cache copy mode if (DBMngr) { if (ScanMng) { ScanMng->AddClient(DBMngr); if ((ScanMng->recentCachePeriod > 0) && ScanMng->keepScansInCache) { fprintf(stdout, "Loading last %dmins of data from database into recent scan cache\n", ScanMng->recentCachePeriod); DBMngr->loadInitialSeq(NULL, 1, true); ScanMng->startupLatestTime = ScanMng->mostRecentScanTime(); //latest time from db on startup ScanMng->PrintScanUsage(stdout, true); } } } } CommMngr = new RPCommMng; if (FileExists(defaultreplayinifile)) { if (ReplayMngr) { delete ReplayMngr; ReplayMngr = 0; } ReplayMngr = new replay(defaultreplayinifile); } if (FileExists("nexrad.ini")) { NexRadManager = new NexRadMgr(); if (NexRadManager) { NexRadManager->StartNexRadStnHdlrs(); } } if (FileExists("uf.ini")) { ufManager = new ufMgr(); if (ufManager) { ufManager->StartUfStnHdlrs(); } } if (FileExists("fileReaders.ini")) initGlobalFileReaderMng(argv[0], "fileReaders.ini"); check_rpdbCacheCopyMode(argc, argv); if (DBMngr && DBMngr->rpdbCache && cacheCopyReq) { if (rpdbCacheStatsMode) { DBMngr->rpdbCache->dumpCacheContents("rpdb_cache_contents.txt"); DBMngr->rpdbCache->dumpStats(*cacheCopyReq, "cache_stats.txt"); } else if (rpdbCacheCopyMode) { DBMngr->rpdbCache->dumpCacheContents("rpdb_cache_contents.txt"); DBMngr->rpdbCache->copyDB(*cacheCopyReq); } } while (!quitRapicConvert && !rpdbCacheCopyMode) { timenow = time(0); if (CommMngr) { if (time(0) >= NextCommPollTime) { CommMngr->CheckComms(); NextCommPollTime = timenow + CommPollPeriod; } } if (DBMngr && (timenow > DBMngr->DBCheckTime)) { if (DBMngr->CheckScans()) // false if scan check not yet complete DBMngr->DBCheckTime = timenow + DBMngr->DBCheckPeriod; } if (ReplayMngr && (timenow > ReplayCheckTime)) { ReplayMngr->check_replay(); ReplayCheckTime = timenow + time_t(float(ReplayCheckPeriod)/ReplayMngr->getTimeScale()); } if (ScanMng && (timenow > ScanMng->CheckTime)) ScanMng->Check(); if (reqMemCheck || (MemoryStatusDumpTime <= timenow) || FileExists("memdump.flag", 1, 1)) { AppendMemoryStatus(); MemoryStatusDumpTime = time(0) + MemoryStatusDumpPeriod; reqMemCheck = false; } sec_delay(0.5); if (FileExists("rapicquitflag", true, false)) { quitRapicConvert = true; fprintf(stdout,"%s - Detected rapicquitflag - Shutting down - pid %d",Title, mainpid); } } fprintf(stdout,"%s - Shutting down - pid %d",Title, mainpid); if (CommMngr) { delete CommMngr; CommMngr = 0; } if (ufManager) { delete ufManager; ufManager = 0; } if (NexRadManager) { delete NexRadManager; NexRadManager = 0; } if (DBMngr) { delete DBMngr; DBMngr = 0; } if (ScanMng) { delete ScanMng; ScanMng = 0; } if (ReplayMngr) { delete ReplayMngr; ReplayMngr = 0; } closeGlobalFileReaderMng(); if (FileExists("rapicquitflag", true, true)) { fprintf(stdout,"%s - Shut down complete - pid %d - Removing rapicquitflag",Title, mainpid); } return 0; }
Control *msgqueue_init() { Control *Ctl11,*Ctl7,*Ctl9,*Ctl1,*Ctl2,*Ctl3,*Ctl4,*Ctl5,*Ctl6,*Ctl12,*Ctl13,*Ctl0; RECT rt; TFILE *pHead; ReadFile("msgqueue.rc", (TFILE **)&pHead); GetSiteInfo( pHead, 0, &rt); Ctl11 = CtlInit(LABEL ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 1, &rt); Ctl7 = CtlInit(LABEL ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 2, &rt); Ctl9 = CtlInit(BOX ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 3, &rt); Ctl1 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 4, &rt); Ctl2 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 5, &rt); Ctl3 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 6, &rt); Ctl4 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 7, &rt); Ctl5 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 8, &rt); Ctl6 = CtlInit(LIST ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 9, &rt); Ctl12 = CtlInit(LABEL ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead,10, &rt); Ctl13 = CtlInit(EDIT ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); strcpy( Ctl11 ->sData , "APP号 进程 程序名 队列ID 状态 消息数 占用(%)" ); strcpy( Ctl7 ->sData , "当前位置: ABM监控>> 队列管理>>" ); strcpy( Ctl1 ->sData , "1.刷新" ); strcpy( Ctl2 ->sData , "2.实时刷新" ); strcpy( Ctl3 ->sData , "3.创建队列" ); strcpy( Ctl4 ->sData , "4.删除队列" ); strcpy( Ctl5 ->sData , "q.退出" ); strcpy( Ctl12 ->sData , "APP号过滤:" ); Ctl1 ->pKeyPress = (KEYPRESS)&msgqueueCtl1Press; Ctl2 ->pKeyPress = (KEYPRESS)&msgqueueCtl2Press; Ctl3 ->pKeyPress = (KEYPRESS)&msgqueueCtl3Press; Ctl4 ->pKeyPress = (KEYPRESS)&msgqueueCtl4Press; Ctl5 ->pKeyPress = (KEYPRESS)&msgqueueCtl5Press; Ctl6 ->pKeyPress = (KEYPRESS)&msgqueueCtl6Press; Ctl13 ->pKeyPress = (KEYPRESS)&msgqueueCtl13Press; Ctl1 ->pHotKeyPress = (KEYPRESS)&msgqueue_SysHotKeyPress; Ctl2 ->pHotKeyPress = (KEYPRESS)&msgqueue_SysHotKeyPress; Ctl3 ->pHotKeyPress = (KEYPRESS)&msgqueue_SysHotKeyPress; Ctl4 ->pHotKeyPress = (KEYPRESS)&msgqueue_SysHotKeyPress; Ctl5 ->pHotKeyPress = (KEYPRESS)&msgqueue_SysHotKeyPress; Ctl6 ->pHotKeyPress = (KEYPRESS)&msgqueue_SysHotKeyPress; Ctl13 ->pHotKeyPress = (KEYPRESS)&msgqueue_SysHotKeyPress; Ctl1 ->iHotKey = '1' ; Ctl2 ->iHotKey = '2' ; Ctl3 ->iHotKey = '3' ; Ctl4 ->iHotKey = '4' ; Ctl5 ->iHotKey = 'q' ; Ctl9 ->bFrame = 1 ; Ctl6 ->bFrame = 1 ; Ctl6 ->bSingle = 0 ; CtlSetDir(Ctl11 , NULL, NULL, NULL, NULL, NULL, Ctl7); CtlSetDir(Ctl7 , NULL, NULL, NULL, NULL, NULL, Ctl9); CtlSetDir(Ctl9 , NULL, NULL, NULL, NULL, NULL, Ctl1); CtlSetDir(Ctl1 , Ctl6, NULL, Ctl5, Ctl2, Ctl2, Ctl2); CtlSetDir(Ctl2 , Ctl6, NULL, Ctl1, Ctl3, Ctl3, Ctl3); CtlSetDir(Ctl3 , Ctl6, NULL, Ctl2, Ctl4, Ctl4, Ctl4); CtlSetDir(Ctl4 , Ctl6, NULL, Ctl3, Ctl5, Ctl5, Ctl5); CtlSetDir(Ctl5 , Ctl6, NULL, Ctl4, Ctl1, Ctl13, Ctl6); CtlSetDir(Ctl6 , Ctl13, Ctl1, Ctl1, Ctl5, Ctl1, Ctl12); CtlSetDir(Ctl12 , NULL, NULL, NULL, NULL, NULL, Ctl13); CtlSetDir(Ctl13 , Ctl1, Ctl6, NULL, NULL, Ctl6, NULL); FreeFileMem( pHead ); msgqueue_entry((Control *)Ctl11); return ((Control *)Ctl11) ; }
Control *test1_init() { Control *Ctl9,*Ctl12,*Ctl1,*Ctl2,*Ctl3,*Ctl4,*Ctl5; RECT rt; TFILE *pHead; ReadFile("test1.rc", (TFILE **)&pHead); GetSiteInfo( pHead, 0, &rt); Ctl9 = CtlInit(BOX ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 1, &rt); Ctl12 = CtlInit(LABEL ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 2, &rt); Ctl1 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 3, &rt); Ctl2 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 4, &rt); Ctl3 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 5, &rt); Ctl4 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); GetSiteInfo( pHead, 6, &rt); Ctl5 = CtlInit(BUTTON ,rt.iId,rt.iTop,rt.iLeft,rt.iWidth,rt.iHeight); strcpy( Ctl12 ->sData , "abmaccess菜单" ); strcpy( Ctl1 ->sData , "1.ABM系统表名浏览" ); strcpy( Ctl2 ->sData , "2.SQL功能" ); strcpy( Ctl3 ->sData , "3.应用命令" ); strcpy( Ctl4 ->sData , "4.清理过期文件" ); strcpy( Ctl5 ->sData , "q.退出" ); Ctl1 ->pKeyPress = (KEYPRESS)&test1Ctl1Press; Ctl2 ->pKeyPress = (KEYPRESS)&test1Ctl2Press; Ctl3 ->pKeyPress = (KEYPRESS)&test1Ctl3Press; Ctl4 ->pKeyPress = (KEYPRESS)&test1Ctl4Press; Ctl5 ->pKeyPress = (KEYPRESS)&test1Ctl5Press; Ctl1 ->pHotKeyPress = (KEYPRESS)&test1_SysHotKeyPress; Ctl2 ->pHotKeyPress = (KEYPRESS)&test1_SysHotKeyPress; Ctl3 ->pHotKeyPress = (KEYPRESS)&test1_SysHotKeyPress; Ctl4 ->pHotKeyPress = (KEYPRESS)&test1_SysHotKeyPress; Ctl5 ->pHotKeyPress = (KEYPRESS)&test1_SysHotKeyPress; Ctl1 ->iHotKey = '1' ; Ctl2 ->iHotKey = '2' ; Ctl3 ->iHotKey = '3' ; Ctl4 ->iHotKey = '4' ; Ctl5 ->iHotKey = 'q' ; Ctl9 ->bFrame = 1 ; CtlSetDir(Ctl9 , NULL, NULL, NULL, NULL, NULL, Ctl12); CtlSetDir(Ctl12 , NULL, NULL, NULL, NULL, NULL, Ctl1); CtlSetDir(Ctl1 , Ctl4, Ctl2, NULL, NULL, Ctl2, Ctl2); CtlSetDir(Ctl2 , Ctl1, Ctl3, NULL, NULL, Ctl3, Ctl3); CtlSetDir(Ctl3 , Ctl2, Ctl4, NULL, NULL, Ctl4, Ctl4); CtlSetDir(Ctl4 , Ctl2, Ctl4, NULL, NULL, Ctl4, Ctl5); CtlSetDir(Ctl5 , Ctl3, Ctl1, NULL, NULL, Ctl1, NULL); FreeFileMem( pHead ); test1_entry((Control *)Ctl9); return ((Control *)Ctl9) ; }
int PutChannelData ( FILE *ptr , DBlist tree ) { char sta[6], chan[4], auxid[ 5 ] , lat[ 10 ] , lon[ 11 ] , elev[ 8 ] , depth[ 7 ] , hang[ 7 ], vang[ 6 ], samprat[ 12 ], inst[8], ondate[25], offdate[25]; int dots = 0; float fLat , fLon , fElev ; struct CSStree *Tree = (struct CSStree *) tree ; struct sitechanList *sc = Tree->scHead ; if(!sc) return -1 ; printf("Writing channel data "); fprintf(ptr,"DATA_TYPE CHANNEL\n"); fprintf(ptr, "Sta Chan Aux Latitude Longitude Elev Depth Hang Vang Sample_Rate Inst On Date Off Date\n"); while(sc){ struct siteList *si = Tree->slHead ; struct wfdiscList *wf = Tree->wfHead ; putchar('.'); dots++; if(dots == 80){ putchar('\n'); dots = 0; } fflush(stdout); /* sta */ if ( isValidString ( dbl_LIST_SITECHAN, dbl_SITEC_STA , sc->element->sta ) && strcmp( sc->element->sta , "- " ) ) sprintf ( sta , "%-5.5s" , sc->element->sta ) ; else strcpy ( sta , " " ) ; /* 5 spaces */ /* chan */ if ( isValidString ( dbl_LIST_SITECHAN, dbl_SITEC_CHAN , sc->element->chan ) && strcmp( sc->element->chan , "- " ) ) sprintf ( chan , "%-3.3s" , sc->element->chan ) ; else strcpy ( chan , " " ) ; /* 3 spaces */ /* auxid */ strcpy ( auxid , " " ) ; /* 4 spaces */ /* lat, lon, & elev */ GetSiteInfo ( si , sc->element->sta , sc->element->ondate , sc->element->offdate , &fLat , &fLon , &fElev ) ; if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_LAT , fLat ) ) sprintf ( lat , "%9.5f" , fLat ) ; else strcpy ( lat , " " ) ; /* 9 spaces */ if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_LON , fLon ) ) sprintf ( lon , "%10.5f" , fLon ) ; else strcpy ( lon , " " ) ; /* 10 spaces */ if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_ELEV , fElev ) ) sprintf ( elev , "%7.3f" , fElev ) ; else strcpy ( elev , " " ) ; /* 7 spaces */ /* depth */ if ( isValidFloat ( dbl_LIST_SITECHAN, dbl_SITEC_EDEPTH , sc->element->edepth ) ) sprintf ( depth , "%6.3f" , sc->element->edepth ) ; else strcpy ( depth , " " ) ; /* 6 spaces */ /* hang & vang */ if ( isValidFloat ( dbl_LIST_SITECHAN, dbl_SITEC_HANG , sc->element->hang ) ) sprintf ( hang , "%6.1f" , sc->element->hang ) ; else strcpy ( hang , " " ) ; /* 6 spaces */ if ( isValidFloat ( dbl_LIST_SITECHAN, dbl_SITEC_VANG , sc->element->vang ) ) sprintf ( vang , "%5.1f" , sc->element->vang ) ; else strcpy ( vang , " " ) ; /* 5 spaces */ /* samprat */ strcpy ( samprat , " " ) ; /* 11 spaces */ /* inst */ GetWfdiscInfo ( wf, sta , chan , sc->element->ondate , sc->element->offdate , inst ) ; if ( isValidString ( dbl_LIST_WFDISC, dbl_WFDIS_INSTYPE , inst ) && strcmp( inst , "- " ) ) { if ( strlen ( inst ) < 7 ) { int kdx ; for ( kdx = strlen ( inst ) ; kdx < 7 ; kdx++ ) { inst[ kdx ] = ' ' ; } inst[ 7 ] = '\0' ; } } else sprintf ( inst , " " ) ; /* 7 spaces */ /* ondate */ if ( isValidInt ( dbl_LIST_SITECHAN, dbl_SITEC_ONDATE , sc->element->ondate ) ) { int doy, mm, id, iyyy , jdate = sc->element->ondate ; iyyy = jdate / 1000 ; doy = jdate - ( iyyy * 1000 ) ; mnday ( doy , isleap ( iyyy ) , &mm , &id ) ; sprintf(ondate, "%04d/%02d/%02d" , iyyy, mm, id ); } else strcpy ( ondate , " " ) ; /* 10 spaces */ /* offdate */ if ( isValidInt ( dbl_LIST_SITECHAN, dbl_SITEC_OFFDATE , sc->element->offdate ) ) { int doy, mm, id, iyyy , jdate = sc->element->offdate ; iyyy = jdate / 1000 ; doy = jdate - ( iyyy * 1000 ) ; mnday ( doy , isleap ( iyyy ) , &mm , &id ) ; sprintf(offdate, "%04d/%02d/%02d" , iyyy, mm, id ); } else strcpy ( offdate , " " ) ; /* 10 spaces */ fprintf(ptr,"%s %s %s %s %s %s %s %s %s %s %s %s %s\n", sta, chan, auxid, lat, lon, elev, depth, hang, vang, samprat, inst, ondate, offdate ); sc = sc->next; } fprintf(ptr,"\n"); printf("\n"); return 0 ; } /* end PutChannelData */