예제 #1
0
void __fastcall TfrmRetrievalJobList::btnResetJobsClick(TObject *Sender) {
/** for debugging: set all retrieval jobs back to their initial states */
    ostringstream oss; oss<<__FUNC__<<": reset jobs"; debugLog(oss.str().c_str());

    // might be good to be able to delete specific jobs,
    // though would have to iterate through boxes to delete lcr records
    LCDbCryoJob * job = ((LCDbCryoJob *)(sgJobs->Objects[0][sgJobs->Row]));
    if (NULL == job) return;

    LQuery qc(LIMSDatabase::getCentralDb()), qc2(LIMSDatabase::getCentralDb());
    qc.setSQL("select rj_box_cid from c_box_retrieval where retrieval_cid = :rtid");
    qc.setParam("rtid", job->getID());
    qc.open();
    while (!qc.eof()) {
        int rj_box_cid = qc.readInt("rj_box_cid");
        qc2.setSQL("delete from l_cryovial_retrieval where rj_box_cid = :rjbid");
        qc2.setParam("rjbid", rj_box_cid);
        qc2.execSQL();
        qc.next();
    }
    qc.setSQL("delete from c_box_retrieval where retrieval_cid = :rtid");
    qc.setParam("rtid", job->getID());
	qc.execSQL();
	qc.setSQL("update c_retrieval_job set status = :new where retrieval_cid = :rtid");
    qc.setParam("rtid", job->getID());
	qc.setParam("new", LCDbCryoJob::NEW_JOB); // NEW_JOB, INPROGRESS, DONE
    qc.execSQL();
    loadJobs();
}
예제 #2
0
	/*NP*/
void write_vis_data( float tim, float ang, int ulx, int uly, int vwid )
	/*************************************************************/
	/*  WRITE_VIS_DATA                                           */
	/*  John Hart  NSSFC KCMO                                    */
	/*                                                           */
	/*  Writes the numeric data on the storm visualization chart */
	/*************************************************************/
{
	short tr, tl;
	char st[10];

	setcolor(31);

	tr = ulx + 5;
	tl = uly + 5;
	strcpy( st, qc2( tim, " s", 0 ));
	disp_param( st, tr, tl);

	tr = ulx + vwid-5;
	strcpy( st, qc2( ang, " deg", 0 ));
	disp_param( st, tr, tl);
}
예제 #3
0
/*NP*/
void write_file2( char *filename )
/*************************************************************/
/*  WRITE_FILE                                               */
/*  John Hart  NSSFC KCMO                                    */
/*                                                           */
/*  Writes contents of sndg array into SHARP95 file.         */
/*************************************************************/
{
    short i, j;
    short idx[7];
    float sfctemp, sfcdwpt, sfcpres, j1, j2, ix1;
    struct _parcel pcl;
    char st[80];
    FILE *fout;

    idx[1]  = getParmIndex("PRES");
    idx[2]  = getParmIndex("HGHT");
    idx[3]  = getParmIndex("TEMP");
    idx[4]  = getParmIndex("DWPT");
    idx[5]  = getParmIndex("DRCT");
    idx[6]  = getParmIndex("SPED");

    fout = fopen( filename, "wt" );
    if (fout==NULL)
    {
        printf("Unable to write output file!\n" );
        return;
    }
    fputs( "%TITLE%\n", fout );
    fputs( raobtitle, fout );
    fputs( "\n\n", fout );
    fprintf( fout, "   LEVEL       HGHT       TEMP       DWPT       WDIR       WSPD\n");
    fprintf( fout, "-------------------------------------------------------------------\n");
    fputs( "%RAW%\n", fout );
    for(i=0; i<numlvl; i++)
    {
        for(j=1; j<=5; j++) fprintf( fout, "%8.2f,  ", sndg[i][idx[j]]);
        fprintf( fout, "%8.2f\n", sndg[i][idx[6]]);
    }
    fputs( "%END%\n\n", fout );

    if ((numlvl<4) || (!qc(i_dwpt(700, I_PRES)))) return;

    fprintf( fout, "----- Parcel Information-----\n");

    /* ----- Calculate Parcel Data ----- */
    sfctemp = lplvals.temp;
    sfcdwpt = lplvals.dwpt;
    sfcpres = lplvals.pres;

    strcpy( st, "*** " );
    strcat( st, lplvals.desc );
    strcat( st, " ***" );
    fprintf( fout, "%s\n", st);
    ix1 = parcel( -1, -1, sfcpres, sfctemp, sfcdwpt, &pcl);

    fprintf( fout, "LPL:  P=%.0f  T=%.0fF  Td=%.0fF\n", sfcpres, ctof(sfctemp), ctof(sfcdwpt));
    fprintf( fout, "CAPE:            %6.0f J/kg\n", pcl.bplus);
    fprintf( fout, "CINH:            %6.0f J/kg\n", pcl.bminus);

    fprintf( fout, "LI:              %6.0f C\n", pcl.li5);
    fprintf( fout, "LI(300mb):       %6.0f C\n", pcl.li3);

    fprintf( fout, "3km Cape:        %6.0f J/kg\n", pcl.cape3km);
    j1 = pcl.bplus;
    j2 = i_hght(pcl.elpres, I_PRES) - i_hght(pcl.lfcpres, I_PRES);
    fprintf( fout, "NCAPE:           %6.2f m/s2\n\n", j1/j2);

    fprintf( fout, "LCL:    %6.0fmb     %6.0fm\n", pcl.lclpres, agl(i_hght(pcl.lclpres, I_PRES)));
    fprintf( fout, "LFC:    %6.0fmb     %6.0fm\n", pcl.lfcpres, agl(i_hght(pcl.lfcpres, I_PRES)));
    fprintf( fout, "EL:     %6.0fmb     %6.0fm\n", pcl.elpres, agl(i_hght(pcl.elpres, I_PRES)));
    fprintf( fout, "MPL:    %6.0fmb     %6.0fm\n", pcl.mplpres, agl(i_hght(pcl.mplpres, I_PRES)));
    fprintf( fout, "All heights AGL\n\n" );

    fprintf( fout, "----- Moisture -----\n" );
    strcpy( st, qc2( precip_water( &ix1, -1, -1), " in", 2 ));
    fprintf( fout, "Precip Water:    %s\n", st);
    strcpy( st, qc2( mean_mixratio( &ix1, -1, -1 ), " g/Kg", 1 ));
    fprintf( fout, "Mean W:          %s\n\n", st);

    fprintf( fout, "----- Lapse Rates -----\n" );
    j1 = delta_t(&ix1);
    j2 = lapse_rate( &ix1, 700, 500);
    fprintf( fout, "700-500mb   %.0f C      %.1f C/km\n", j1, j2);

    j1 = vert_tot(&ix1);
    j2 = lapse_rate( &ix1, 850, 500);
    fprintf( fout, "850-500mb   %.0f C      %.1f C/km\n", j1, j2);

    fclose( fout );
}
예제 #4
0
	/*NP*/
void plot_thetae(void)
	/*************************************************************/
	/*  PLOT_THETAE                                              */
	/*  John Hart  NSSFC KCMO                                    */
	/*                                                           */
	/*  Plots vertical profile of Theta-E (sfc-500mb)            */
	/*************************************************************/
{
	float bothgt, tophgt, h, cthe, ix1;
	short x1, y1, x2, y2, i, tlx, tly;
	short pIndex, zIndex, tIndex, tdIndex;
	char st[10];

	pIndex = getParmIndex("PRES");
	zIndex = getParmIndex("HGHT");
	tIndex = getParmIndex("TEMP");
	tdIndex = getParmIndex("DWPT");

	if (!sndg || pIndex == -1 || tIndex == -1 || tdIndex == -1 ||
	    zIndex == -1)
	  return;

	/* tlx = hov.brx - 150;
	tly = hov.tly; */

	tlx = hov.tlx + 120;
	tly = hov.bry;

	setcliprgn(tlx, tly, tlx+134, tly+120);
	setcolor(0);
	setlinestyle( 1, 1 );
	rectangle(1,tlx, tly, tlx+134, tly+120); 
	setcolor(1);
	rectangle(0, tlx, tly, tlx+134, tly+120);

	/* ----- Set Layer (AGL) ----- */
	bothgt = 0;
	tophgt = agl(i_hght(500, I_PRES));

	/* ----- Plot Label ----- */
	setcolor(1);
	set_font(4);
	outgtext("Theta-E vs", tlx+55, tly+3);
	outgtext("Pressure",  tlx+55, tly+15);

	/* ----- Plot horizontal legend ----- */
        if (800 < pIndex < 850){
                cthe = (thetae(800, i_temp(800, I_PRES), i_dwpt(800, I_PRES)) +
                        thetae(650, i_temp(650, I_PRES), i_dwpt(650, I_PRES)) +
                        thetae(sndg[sfc()][pIndex], sndg[sfc()][tIndex],
                        sndg[sfc()][tdIndex])) / 3.0;
                        }
        if (750 < pIndex < 800){
                cthe = (thetae(750, i_temp(750, I_PRES), i_dwpt(750, I_PRES)) +
                        thetae(600, i_temp(600, I_PRES), i_dwpt(600, I_PRES)) +
                        thetae(sndg[sfc()][pIndex], sndg[sfc()][tIndex],
                        sndg[sfc()][tdIndex])) / 3.0;
                        }
        if (700 < pIndex < 750){
                cthe = (thetae(700, i_temp(700, I_PRES), i_dwpt(700, I_PRES)) +
                        thetae(500, i_temp(500, I_PRES), i_dwpt(500, I_PRES)) +
                        thetae(sndg[sfc()][pIndex], sndg[sfc()][tIndex],
                        sndg[sfc()][tdIndex])) / 3.0;
                        }
        if (pIndex >= 850){
                cthe = (thetae(850, i_temp(850, I_PRES), i_dwpt(850, I_PRES)) +
                        thetae(700, i_temp(700, I_PRES), i_dwpt(700, I_PRES)) +
                        thetae(sndg[sfc()][pIndex], sndg[sfc()][tIndex],
                        sndg[sfc()][tdIndex])) / 3.0;
                        }
	setcolor(19);
	set_font(5);
	for(h=cthe - 30.0; h<=cthe + 30.0; h += 10) {
	   x1 = (short)(tlx + 60 + ((h-cthe)*2.5));
	   y1 = tly+120;
	   moveto( x1, y1);
	   lineto( x1, y1-5);
	   sprintf(st, "%.0f", h + 273.15);
	   outgtext(st, x1-6, y1-14);
	   }

	/* ----- Plot vertical theta-e profile ----- */
	setlinestyle(1, 2);
	setcolor(2);
	x2 = 999;
        if (sndg[numlvl-1][pIndex] < 500) {
	   for (i=0; sndg[i][pIndex] >= 500; i++) {
	      /*printf ("i = %d,    PRES = %.1f\n", i, sndg[i][pIndex]);*/
	      if (qc(sndg[i][tdIndex])) {
	         x1 = (short)(tlx + 60 + ((thetae(sndg[i][pIndex], 
	              sndg[i][tIndex], sndg[i][tdIndex])-cthe)*2.5));
   	         y1 = vert_coords(agl(sndg[i][zIndex]), tophgt, tly);
	         if(x2 == 999) { x2=x1; y2=y1; }

	         moveto(x1, y1);
	         lineto(x2, y2);

	         x2=x1;
	         y2=y1;
	      }
	   }
	}


	/* ----- Plot Vertical Legend ----- */
	setlinestyle(1, 1);
	setcolor(1);
	set_font(5);
	x2 = 999;
	for(i=1000; i >= 600; i -= 100) {
	   x1 = tlx;
	   y1 = vert_coords(agl(i_hght(i, I_PRES)), tophgt, tly);
	   moveto( x1, y1);
	   lineto( x1+5, y1);
	   sprintf(st, "%d", i);
	   if (i<1000) outgtext(st, x1+6, y1-5);
	}

	setcliprgn(1, 1, xwdth, xhght);
	copytodisplay();

	/* plot theta-e index */
	setcolor(19);
	set_font(4);
	sprintf( st, "TEI = %s", qc2( ThetaE_diff(&ix1), "", 0));
        outgtext( st, tlx + 80, tly + 50);
}