void gprintf(const char *fmt,...) { char s[BUFFER_SIZE]; va_list marker; sprintf(s,"%s | ",TimeStr(GetTime())); va_start(marker,fmt); vsprintf(s+strlen(s),fmt,marker); va_end(marker); char *excludedword1 = "account"; char *excludedword2 = "ACCOUNT"; char *excludedword3 = "email"; if (strstr(s, excludedword1) != NULL || strstr(s, excludedword2) != NULL || strstr(s, excludedword3) != NULL) { sprintf(s, "%s | Line excluded due to personal information.", TimeStr(GetTime())); } if (s[strlen(s)-1] != '\n') strcat(s,"\r\n"); WriteStrChannel(CHANNEL_G,s); }
void SaveControlFile(int save_time) { char save_name[MAX_PATH+FILENAME_MAX]; FILE *savefile; sprintf(save_name,"%s%s",ConfigStr(PATH_LOADSAVE),SAVE_CONTROL_FILE); if ((savefile = fopen(save_name,"wt")) == NULL) { eprintf("SaveContrtolFile can't open %s to save date/time of successful save!!!\n", save_name); return; } fprintf(savefile,"#\n"); fprintf(savefile,"# Control file for last successful save\n"); fprintf(savefile,"#\n"); fprintf(savefile,"# Files written:\n"); fprintf(savefile,"# %s%s%i\n",ConfigStr(PATH_LOADSAVE),GAME_FILE_SAVE,save_time); fprintf(savefile,"# %s%s%i\n",ConfigStr(PATH_LOADSAVE),ACCOUNT_FILE_SAVE,save_time); fprintf(savefile,"# %s%s%i\n",ConfigStr(PATH_LOADSAVE),STRING_FILE_SAVE,save_time); fprintf(savefile,"# %s%s%i\n",ConfigStr(PATH_LOADSAVE),DYNAMIC_RSC_FILE_SAVE,save_time); fprintf(savefile,"#\n"); fprintf(savefile,"# Last successful save was at %s\n",TimeStr(save_time)); fprintf(savefile,"#\n"); fprintf(savefile,"\n"); fprintf(savefile,"LASTSAVE %i\n",save_time); fclose(savefile); }
// update statistics-information for observation-data plot ------------------ void __fastcall TPlot::UpdateInfoObs(void) { AnsiString msgs0[]={" NSAT"," GDOP"," PDOP"," HDOP"," VDOP","",""}; AnsiString msgs1[]={" OBS=L1/2 "," L1 "," L2 "," L1/2/5 "," L1/5 ",""," L5 "}; AnsiString msgs2[]={" SNR=...45.","..40.","..35.","..30.","..25 ",""," <25 "}; AnsiString msgs3[]={" SYS=GPS ","GLO ","GAL ","QZS ","BDS ","SBS ",""}; AnsiString msgs4[]={" MP=..0.6","..0.3","..0.0..","-0.3..","-0.6..","",""}; AnsiString msg,msgs[8]; gtime_t ts={0},te={0},t,tp={0}; int i,n=0,ne=0; char s1[64],s2[64]; trace(3,"UpdateInfoObs:\n"); if (BtnSol1->Down) { for (i=0;i<Obs.n;i++) { t=Obs.data[i].time; if (ts.time==0) ts=t; te=t; if (tp.time==0||timediff(t,tp)>TTOL) ne++; n++; tp=t; } } if (n>0) { TimeStr(ts,0,0,s1); TimeStr(te,0,1,s2); msg.sprintf("[1]%s-%s : EP=%d N=%d",s1,s2+(TimeLabel?5:0),ne,n); for (i=0;i<7;i++) { if (PlotType==PLOT_DOP) { msgs[i]=msgs0[i]; } else if (PlotType<=PLOT_SKY&&ObsType->ItemIndex==0) { msgs[i]=SimObs?msgs3[i]:msgs1[i]; } else if (PlotType==PLOT_MPS) { msgs[i]=msgs4[i]; } else { msgs[i]=SimObs?msgs3[i]:msgs2[i]; } } } ShowMsg(msg); ShowLegend(msgs); }
void PauseTimers(void) { if (pause_time != 0) { eprintf("PauseTimers called when they were already paused at %s\n",TimeStr(pause_time)); return; } pause_time = GetTime(); }
Bool SuspendAccountAbsolute(account_node *a, int suspend_time) { session_node *s; int now = GetTime(); /* validate arguments */ if (suspend_time < 0) { eprintf("SuspendAccountAbsolute: invalid suspend time %d; ignored\n",suspend_time); return False; } if (a == NULL || a->account_id == 0 || a->type == GUEST_ACCOUNT) { eprintf("SuspendAccountAbsolute: cannot suspend account\n"); return False; } /* check for lifting suspension */ if (suspend_time <= now) { if (a->suspend_time <= now) { /* no report for lifting suspension on unsuspended account */ } else { lprintf("Suspension of account %i (%s) lifted\n", a->account_id, a->name); } a->suspend_time = 0; return True; } /* suspension going into effect or remaining in effect */ a->suspend_time = suspend_time; lprintf("Suspended account %i (%s) until %s\n", a->account_id, a->name, TimeStr(suspend_time)); s = GetSessionByAccount(a); if (s != NULL) { HangupSession(s); PollSession(s->session_id); if (GetSessionByAccount(a) != NULL) { eprintf("SuspendAccountAbsolute: tried to hangup account %i but failed\n", a->account_id); } } return True; }
/* 系统辅助-在Log信息台打印Log信息 */ void addLog(char *msg, int whichBox, int pHdl){ char msgTemp[256]; Fmt(msgTemp,"[%s] -%c ", TimeStr(), 62); strcat(msgTemp, msg); strcat(msgTemp, "\n"); if(0 == whichBox){ //Show Log on Main Panel's Log Box InsertTextBoxLine(panelHdl, MainPanel_MainLogBox, 0, msgTemp); }else{ int i = getGraphIndex(pHdl, 1); InsertTextBoxLine(PopPanels[i], PopupPanel_PopLogBox, 0, msgTemp); } }
// update time-information for observation-data plot ------------------------ void __fastcall TPlot::UpdateTimeObs(void) { AnsiString msgs1[]={" OBS=L1/2 "," L1 "," L2 "," L1/2/5 "," L1/5 ",""," L5 "}; AnsiString msgs2[]={" SNR=...45.","..40.","..35.","..30.","..25 ",""," <25 "}; AnsiString msgs3[]={" SYS=GPS ","GLO ","GAL ","QZS ","BDS ","SBS ",""}; AnsiString msgs4[]={" MP=..0.6","..0.3","..0.0..","-0.3..","-0.6..","",""}; AnsiString msg,msgs[8],s; double azel[MAXOBS*2],dop[4]={0}; int i,ns=0,no=0,ind=ObsIndex; char tstr[64]; trace(3,"UpdateTimeObs\n"); if (BtnSol1->Down&&0<=ind&&ind<NObs) { for (i=IndexObs[ind];i<Obs.n&&i<IndexObs[ind+1];i++,no++) { if (SatMask[Obs.data[i].sat-1]||!SatSel[Obs.data[i].sat-1]) continue; if (El[i]<ElMask*D2R) continue; if (ElMaskP&&El[i]<ElMaskData[(int)(Az[i]*R2D+0.5)]) continue; azel[ ns*2]=Az[i]; azel[1+ns*2]=El[i]; ns++; } } if (ns>=0) { dops(ns,azel,ElMask*D2R,dop); TimeStr(Obs.data[IndexObs[ind]].time,3,1,tstr); msg.sprintf("[1]%s : N=%d ",tstr,no); if (PlotType==PLOT_DOP) { msgs[0].sprintf("NSAT=%d",ns); msgs[1].sprintf(" GDOP=%.1f",dop[0]); msgs[2].sprintf(" PDOP=%.1f",dop[1]); msgs[3].sprintf(" HDOP=%.1f",dop[2]); msgs[4].sprintf(" VDOP=%.1f",dop[3]); } else if (PlotType<=PLOT_SKY&&ObsType->ItemIndex==0) { msg+=s.sprintf("NSAT=%d ",ns); for (i=0;i<7;i++) msgs[i]=SimObs?msgs3[i]:msgs1[i]; } else if (PlotType==PLOT_MPS) { msg+=s.sprintf("NSAT=%d ",ns); for (i=0;i<7;i++) msgs[i]=msgs4[i]; } else { msg+=s.sprintf("NSAT=%d ",ns); for (i=0;i<7;i++) msgs[i]=SimObs?msgs3[i]:msgs2[i]; } } ShowMsg(msg); ShowLegend(msgs); }
void eprintf(const char *fmt,...) { char s[BUFFER_SIZE]; va_list marker; sprintf(s,"%s | ",TimeStr(GetTime())); va_start(marker,fmt); vsprintf(s+strlen(s),fmt,marker); va_end(marker); WriteStrChannel(CHANNEL_E,s); }
void M_get_rnd_seed(M_APM mm) { double timer0; int millisec; char *cvi_time, *cvi_date, buf1[64], buf2[32]; M_APM atmp; atmp = M_get_stack_var(); cvi_date = DateStr(); cvi_time = TimeStr(); timer0 = Timer(); /* * note that Timer() is not syncronized to TimeStr(), * but we don't care here since we are just looking * for a random source of digits. */ millisec = (int)(0.01 + 1000.0 * (timer0 - floor(timer0))); sprintf(buf1, "%d", millisec); buf2[0] = cvi_time[6]; /* time format: "HH:MM:SS" */ buf2[1] = cvi_time[7]; buf2[2] = cvi_time[3]; buf2[3] = cvi_time[4]; buf2[4] = cvi_time[0]; buf2[5] = cvi_time[1]; buf2[6] = cvi_date[3]; /* date format: "MM-DD-YYYY" */ buf2[7] = cvi_date[4]; buf2[8] = cvi_date[0]; buf2[9] = cvi_date[1]; buf2[10] = cvi_date[8]; buf2[11] = cvi_date[9]; buf2[12] = cvi_date[7]; buf2[13] = '4'; buf2[14] = '7'; buf2[15] = '\0'; strcat(buf1, buf2); m_apm_set_string(atmp, buf1); atmp->m_apm_exponent = 15; m_apm_integer_divide(mm, atmp, MM_One); M_restore_stack(1); }
// update information for current-cursor position --------------------------- void __fastcall TPlot::UpdatePoint(int x, int y) { gtime_t time; TPoint p(x,y); double enu[3]={0},rr[3],pos[3],xx,yy,r,xl[2],yl[2],q[2],az,el,snr; int i; char tstr[64]; AnsiString msg; trace(4,"UpdatePoint: x=%d y=%d\n",x,y); if (PlotType==PLOT_TRK) { // track-plot if (norm(OPos,3)>0.0) { GraphT->ToPos(p,enu[0],enu[1]); ecef2pos(OPos,pos); enu2ecef(pos,enu,rr); for (i=0;i<3;i++) rr[i]+=OPos[i]; ecef2pos(rr,pos); msg=LatLonStr(pos,8); } } else if (PlotType==PLOT_SKY||PlotType==PLOT_MPS) { // sky-plot GraphS->GetLim(xl,yl); GraphS->ToPos(p,q[0],q[1]); r=(xl[1]-xl[0]<yl[1]-yl[0]?xl[1]-xl[0]:yl[1]-yl[0])*0.45; if ((el=90.0-90.0*norm(q,2)/r)>0.0) { az=el>=90.0?0.0:ATAN2(q[0],q[1])*R2D; if (az<0.0) az+=360.0; msg.sprintf("AZ=%5.1f" CHARDEG " EL=%4.1f" CHARDEG,az,el); } } else if (PlotType==PLOT_SNRE) { // snr-el-plot GraphE[0]->ToPos(p,q[0],q[1]); msg.sprintf("EL=%4.1f " CHARDEG,q[0]); } else { GraphG[0]->ToPos(p,xx,yy); time=gpst2time(Week,xx); if (TimeLabel==2) time=utc2gpst(time); // UTC else if (TimeLabel==3) time=timeadd(gpst2utc(time),-9*3600.0); // JST TimeStr(time,0,1,tstr); msg=tstr; } Panel22->Visible=true; Message2->Caption=A2U(msg); }
// update time-information for solution plot -------------------------------- void __fastcall TPlot::UpdateTimeSol(void) { const char *unit[]={"m","m/s","m/s2"},*u; const char *sol[]={"","FIX","FLOAT","SBAS","DGPS","Single","PPP"}; AnsiString msg,msgs[8],s; sol_t *data; double xyz[3],pos[3],r,az,el; int sel=BtnSol1->Down||!BtnSol2->Down?0:1,ind=SolIndex[sel]; char tstr[64]; trace(3,"UpdateTimeSol\n"); if ((BtnSol1->Down||BtnSol2->Down||BtnSol12->Down)&& (data=getsol(SolData+sel,ind))) { if (!ConnectState) msg.sprintf("[%d]",sel+1); else msg="[R]"; TimeStr(data->time,2,1,tstr); msg+=tstr; msg+=" : "; if (PLOT_SOLP<=PlotType&&PlotType<=PLOT_SOLA) { PosToXyz(data->time,data->rr,data->type,xyz); u=unit[PlotType-PLOT_SOLP]; msg+=s.sprintf("E=%7.4f%s N=%7.4f%s U=%7.4f%s Q=", xyz[0],u,xyz[1],u,xyz[2],u); } else if (PlotType==PLOT_NSAT) { msg+=s.sprintf("NS=%d AGE=%.1f RATIO=%.1f Q=",data->ns,data->age, data->ratio); } else if (!data->type) { ecef2pos(data->rr,pos); msg+=LatLonStr(pos,9)+s.sprintf(" %9.4fm Q=",pos[2]); } else { r=norm(data->rr,3); az=norm(data->rr,2)<=1E-12?0.0:atan2(data->rr[0],data->rr[1])*R2D; el=r<=1E-12?0.0:asin(data->rr[2]/r)*R2D; msg+=s.sprintf("B=%.3fm D=%6.2f" CHARDEG " %5.2f" CHARDEG " Q=", r,az<0.0?az+360.0:az,el); } if (1<=data->stat&&data->stat<=6) { msgs[data->stat-1]=s.sprintf("%d:%s",data->stat,sol[data->stat]); } } ShowMsg(msg); ShowLegend(msgs); }
void eprintf(const char *fmt,...) { char s[2000]; va_list marker; sprintf(s,"%s | ",TimeStr(GetTime())); va_start(marker,fmt); vsprintf(s+strlen(s),fmt,marker); va_end(marker); TermConvertBuffer(s,sizeof(s)); /* makes \n's into CR/LF pairs */ WriteStrChannel(CHANNEL_E,s); }
void dprintf(const char *fmt,...) { char s[BUFFER_SIZE]; va_list marker; sprintf(s,"%s|",TimeStr(GetTime())); va_start(marker,fmt); vsprintf(s+strlen(s),fmt,marker); va_end(marker); if (s[strlen(s)-1] != '\n') strcat(s,"\r\n"); WriteStrChannel(CHANNEL_D,s); }
void lprintf(const char *fmt,...) { char s[1000]; va_list marker; sprintf(s,"%s | ",TimeStr(GetTime())); va_start(marker,fmt); vsprintf(s+strlen(s),fmt,marker); va_end(marker); TermConvertBuffer(s,sizeof(s)); /* makes \n's into CR/LF pairs */ if (s[strlen(s)-1] != '\n') strcat(s,"\r\n"); WriteStrChannel(CHANNEL_L,s); }
void DeleteAccountAndAssociatedUsersByID(int account_id) { account_node *a; session_node *s; /* called from timer loop */ a = GetAccountByID(account_id); if (a == NULL) { eprintf("DeleteAccountAndAssociatedUsersByID: can't delete account %i\n",account_id); return; } s = GetSessionByAccount(a); if (s != NULL) { HangupSession(s); PollSession(s->session_id); if (GetSessionByAccount(a) != NULL) { eprintf("DeleteAccountAndAssociatedUsersByID: tried to hangup account %i but failed\n", account_id); return; } } lprintf("Attempting delete of account %i (%s) (last login %s)\n", account_id, a->name, TimeStr(a->last_login_time)); ForEachUserByAccountID(AdminDeleteEachUserObject,account_id); DeleteUserByAccountID(account_id); if (!DeleteAccount(account_id)) { eprintf("DeleteAccountAndAssociatedUsersByID: unable to delete account %i - unknown reason\n", account_id); lprintf("Delete of account %i failed - unknown reason\n", account_id); } else { lprintf("Delete of account %i successful\n", account_id); } }
void InterfaceDrawText(HWND hwnd) { char s[500]; kod_statistics *kstat; if (TryEnterServerLock()) { sprintf(s,"%lu bytes",GetMemoryTotal()); SetDlgItemText(HWND_STATUS,IDC_MEMORY_VALUE,s); kstat = GetKodStats(); sprintf(s,"%s",TimeStr(kstat->system_start_time)); SetDlgItemText(HWND_STATUS,IDC_STARTED_VALUE,s); sprintf(s,"%-200s",RelativeTimeStr(GetTime()-kstat->system_start_time)); SetDlgItemText(HWND_STATUS,IDC_UP_FOR_VALUE,s); if (kstat->interpreting_time/1000.0 < 0.01) sprintf(s,"0/second"); else sprintf(s,"%i/second",(int)(kstat->num_interpreted/(kstat->interpreting_time/1000.0))); SetDlgItemText(HWND_STATUS,IDC_SPEED_VALUE,s); if (IsGameLocked()) SetDlgItemText(hwndMain,IDC_GAME_LOCKED,"The game is locked."); else SetDlgItemText(hwndMain,IDC_GAME_LOCKED,""); SetDlgItemInt(HWND_STATUS,IDC_OBJECTS_VALUE,GetObjectsUsed(),FALSE); SetDlgItemInt(HWND_STATUS,IDC_LISTNODES_VALUE,GetListNodesUsed(),FALSE); SetDlgItemInt(HWND_STATUS,IDC_STRINGS_VALUE,GetStringsUsed(),FALSE); SetDlgItemInt(HWND_STATUS,IDC_TIMERS_VALUE,GetNumActiveTimers(),FALSE); LeaveServerLock(); } }
// update statistics-information for solution plot -------------------------- void __fastcall TPlot::UpdateInfoSol(void) { AnsiString msg,msgs[8],s; TIMEPOS *pos=NULL,*pos1,*pos2; sol_t *data; gtime_t ts={0},te={0}; double r[3],b,bl[2]={1E9,0.0}; int i,j,n=0,nq[8]={0},sel=BtnSol1->Down||!BtnSol2->Down?0:1; char s1[64],s2[64]; trace(3,"UpdateInfoSol:\n"); if (BtnSol1->Down||BtnSol2->Down) { pos=SolToPos(SolData+sel,-1,0,0); } else if (BtnSol12->Down) { pos1=SolToPos(SolData ,-1,0,0); pos2=SolToPos(SolData+1,-1,0,0); pos=pos1->diff(pos2,0); delete pos1; delete pos2; } if (pos) { for (i=0;i<pos->n;i++) { if (ts.time==0) ts=pos->t[i]; te=pos->t[i]; nq[pos->q[i]]++; n++; } delete pos; } for (i=0;data=getsol(SolData+sel,i);i++) { if (data->type) { b=norm(data->rr,3); } else if (norm(SolData[sel].rb,3)>0.0) { for (j=0;j<3;j++) r[j]=data->rr[j]-SolData[sel].rb[j]; b=norm(r,3); } else b=0.0; if (b<bl[0]) bl[0]=b; if (b>bl[1]) bl[1]=b; } if (n>0) { if (!ConnectState) msg.sprintf("[%d]",sel+1); else msg="[R]"; TimeStr(ts,0,0,s1); TimeStr(te,0,1,s2); msg+=s.sprintf("%s-%s : N=%d",s1,s2+(TimeLabel?5:0),n); if (bl[0]+100.0<bl[1]) { msg+=s.sprintf(" B=%.1f-%.1fkm",bl[0]/1E3,bl[1]/1E3); } else { msg+=s.sprintf(" B=%.1fkm",bl[0]/1E3); } msg+=" Q="; for (i=1;i<=6;i++) { if (nq[i]<=0) continue; msgs[i-1].sprintf("%d:%d(%.1f%%) ",i,nq[i],(double)nq[i]/n*100.0); } } ShowMsg(msg); ShowLegend(msgs); }