void ICVM_write(void){ R_R0=i_write( rSTKs32(0), Nptr(rSTKu32(1)), rSTKu32(2)); icvm_returnerr(); }
int i_job_header(i_job_info_t *job_info) { char temp_string[256]; char *ts; int e; /* libjpeg.doc: step 3 of 7 */ job_info->cinfo->image_width = job_info->pixel_h; job_info->cinfo->image_height = 128; job_info->cinfo->input_components = job_info->components; if(job_info->components == 1) { job_info->cinfo->in_color_space = JCS_GRAYSCALE; } else { job_info->cinfo->in_color_space = JCS_RGB; /* colorspace of input image */ } jpeg_set_defaults(job_info->cinfo); job_info->cinfo->jpeg_color_space = JCS_JETREADY; ts = temp_string; /* PJL */ ts += sprintf(ts, "\x01b%%-12345X@PJL SET STRINGCODESET=UTF8\x00a"); if (job_info->components == 1) { ts += sprintf(ts, "@PJL SET PLANESINUSE=1\x00a"); } ts += sprintf(ts, "@PJL SET COPIES=%d\x00a",job_info->copies); if (job_info->duplex) { ts += sprintf(ts, "@PJL SET DUPLEX=ON\x00d\x00a"); if (job_info->tumble) { ts += sprintf(ts, "@PJL SET BINDING=SHORTEDGE\x00d\x00a"); } else { ts += sprintf(ts, "@PJL SET BINDING=LONGEDGE\x00d\x00a"); } } else { ts += sprintf(ts, "@PJL SET DUPLEX=OFF\x00d\x00a"); } ts += sprintf(ts, "@PJL SET RESOLUTION=600\x00a"); ts += sprintf(ts, "@PJL SET TIMEOUT=90\x00a"); ts += sprintf(ts, "@PJL ENTER LANGUAGE=PCLXL\x00a"); ts += sprintf(ts, ") HP-PCL XL;3;0;Comment, PCL-XL JetReady generator\x00a"); /* PCL XL */ ts += sprintf(ts, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", PXL_ubyte(PXL_eInch), PXL_Measure, PXL_ubyte(PXL_eBackChAndErrPage), PXL_ErrorReport, PXL_uint16_xy(600, 600), PXL_UnitsPerMeasure, PXL_BeginSession); e = i_write(job_info, temp_string, ts - temp_string); return 0; }
/**************************************************************************** REMARKS: VxD implementation of the ANSI C fwrite function. Note that the VxD file I/O functions are layered on DOS, so can only read up to 64K at a time. Since we are expected to handle much larger chunks than this, we handle larger blocks automatically in here. ****************************************************************************/ size_t fwrite( const void *ptr, size_t size, size_t n, FILE *f) { const char *buf = ptr; WORD error; int bytes,writtenbytes,totalbytes = 0; /* Flush anything already in the buffer */ if (!f->writemode) return 0; fflush(f); bytes = size * n; while (bytes > 0x10000) { if (initComplete) { writtenbytes = R0_WriteFile(false,(HANDLE)f->handle,buf,0x8000,f->offset,&error); writtenbytes += R0_WriteFile(false,(HANDLE)f->handle,buf+0x8000,0x8000,f->offset+0x8000,&error); } else { writtenbytes = i_write(f->handle,buf,0x8000); writtenbytes += i_write(f->handle,buf+0x8000,0x8000); } totalbytes += writtenbytes; f->offset += writtenbytes; buf += 0x10000; bytes -= 0x10000; } if (initComplete) writtenbytes = R0_WriteFile(false,(HANDLE)f->handle,buf,bytes,f->offset,&error); else writtenbytes = i_write(f->handle,buf,bytes); totalbytes += writtenbytes; f->offset += writtenbytes; if (f->offset > f->filesize) f->filesize = f->offset; return totalbytes / size; }
int i_job_footer(i_job_info_t *job_info) { char temp_string[256]; char *ts; int e; ts = temp_string; ts += sprintf(ts, "%c", PXL_EndSession); ts += sprintf(ts, "\x01b%%-12345X@PJL EOJ\x00a"); ts += sprintf(ts, "\x01b%%-12345X"); e = i_write(job_info, temp_string, ts - temp_string); return 0; }
/**************************************************************************** REMARKS: VxD implementation of the ANSI C fflush function. ****************************************************************************/ int fflush( FILE *f) { WORD error; int bytes; /* First copy any data already written into our buffer */ if (f->writemode && (bytes = (f->curp - f->startp)) > 0) { if (initComplete) bytes = R0_WriteFile(false,(HANDLE)f->handle,f->startp,bytes,f->offset,&error); else bytes = i_write(f->handle,f->startp,bytes); f->offset += bytes; if (f->offset > f->filesize) f->filesize = f->offset; f->startp = f->curp = f->buf; } return 0; }
int i_page_footer(i_job_info_t *job_info) { char temp_string[256]; char *ts; int e; ts = temp_string; ts += sprintf(ts, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", PXL_uint32(JR3EndImage), PXL_VUExtension, PXL_uint32(0x00040000), PXL_VUVersion, PXL_VendorUnique); ts += sprintf(ts, "%c", PXL_EndPage); e = i_write(job_info, temp_string, ts - temp_string); return 0; }
static void do_sdf(char *fnNDX,char *fnTPS,char *fnTRX, char *fnSDF, char *fnREF, bool bRef, rvec cutoff, real binwidth, int mode, rvec triangle, rvec dtri) { FILE *fp; int status; int ng,natoms,i,j,k,l,X,Y,Z,lc,dest; ivec nbin; int ***count; /* real ***sdf; */ real sdf,min_sdf=1e10,max_sdf=0; char **grpname; int *isize; int isize_cg=0; int isize_ref=3; int ref_resind[3]; int nrefmol=0,refc=0; atom_id **index; atom_id *index_cg=NULL; atom_id *index_ref=NULL; real t,boxmin,hbox,normfac; real invbinw; rvec tri_upper,tri_lower; rvec *x,xcog,dx,*x_i1,xi,*x_refmol; matrix box; matrix rot; /* rotation matrix := unit vectors for the molecule frame */ rvec k_mol,i1_mol,i2_mol,dx_mol; real delta; atom_id ix,jx; t_topology top; int ePBC=-1; t_pbc pbc; bool bTop=FALSE,bRefDone=FALSE,bInGroup=FALSE; char title[STRLEN]; /* Read Topology */ if (fnTPS) { bTop=read_tps_conf(fnTPS,title,&top,&ePBC,&x,NULL,box,TRUE); } if ( !bTop ) { fprintf(stderr,"\nNeed tpr-file to make a reference structure.\n"); fprintf(stderr,"Option -r will be ignored!\n"); bRef = FALSE; } /* Allocate memory for 4 groups, 3 dummy groups and a group for the ref structure if needed */ ng = 4; snew(grpname,ng); /* the dummy groups are used to dynamically store triples of atoms */ /* for molecular coordinate systems */ if ( bRef ) { snew(isize,ng+4); snew(index,ng+4); } else { snew(isize,ng+3); snew(index,ng+3); } /* Read the index groups */ fprintf(stderr,"\nSelect the 3 reference groups and the SDF group:\n"); if (fnTPS) get_index(&top.atoms,fnNDX,ng,isize,index,grpname); else rd_index(fnNDX,ng,isize,index,grpname); isize[NDX_REF1]=isize[G_REF1]; for (i=NDX_REF1; i<=NDX_REF3; i++) snew(index[i],isize[NDX_REF1]); /* Read first frame and check it */ natoms=read_first_x(&status,fnTRX,&t,&x,box); if ( !natoms ) gmx_fatal(FARGS,"Could not read coordinates from statusfile!\n"); /* check with topology */ if (fnTPS) if ( natoms > top.atoms.nr ) gmx_fatal(FARGS,"Trajectory (%d atoms) does not match topology (%d atoms)!\n", natoms,top.atoms.nr); /* check with index groups */ for (i=0; i<ng; i++) for (j=0; j<isize[i]; j++) if ( index[i][j] >= natoms ) gmx_fatal(FARGS,"Atom index (%d) in index group %s (%d atoms) larger " "than number of atoms in trajectory (%d atoms)!\n", index[i][j],grpname[i],isize[i],natoms); /* check reference groups */ if ( mode == 1 ) { if ( isize[G_REF1] != isize[G_REF2] || isize[G_REF1] != isize[G_REF3] || isize[G_REF2] != isize[G_REF3] ) gmx_fatal(FARGS,"For single particle SDF, all reference groups" "must have the same size.\n"); /* for single particle SDF dynamic triples are not needed */ /* so we build them right here */ /* copy all triples from G_REFx to NDX_REFx */ for (i=0; i<isize[G_REF1]; i++) { /* check if all three atoms come from the same molecule */ for (j=G_REF1; j<=G_REF3; j++) ref_resind[j] = top.atoms.atom[index[j][i]].resind; if ( ref_resind[G_REF1] != ref_resind[G_REF2] || ref_resind[G_REF2] != ref_resind[G_REF3] || ref_resind[G_REF3] != ref_resind[G_REF1] ) { fprintf(stderr,"\nWarning: reference triple (%d) will be skipped.\n",i); fprintf(stderr, " resnr[1]: %d, resnr[2]: %d, resnr[3]: %d\n", ref_resind[G_REF1],ref_resind[G_REF2], ref_resind[G_REF3]); isize[NDX_REF1]--; for (j=NDX_REF1; j<=NDX_REF3; j++) srenew(index[j],isize[NDX_REF1]); continue; } else /* check if all entries are unique*/ if ( index[G_REF1][i] == index[G_REF2][i] || index[G_REF2][i] == index[G_REF3][i] || index[G_REF3][i] == index[G_REF1][i] ) { fprintf(stderr,"Warning: reference triple (%d) will be skipped.\n",i); fprintf(stderr, " index[1]: %d, index[2]: %d, index[3]: %d\n", index[G_REF1][i],index[G_REF2][i],index[G_REF3][i]); isize[NDX_REF1]--; for (j=NDX_REF1; j<=NDX_REF3; j++) srenew(index[j],isize[NDX_REF1]); continue; } else /* everythings fine, copy that one */ for (j=G_REF1; j<=G_REF3; j++) index[j+4][i] = index[j][i]; } } else if ( mode == 2 ) { if ( isize[G_REF1] != isize[G_REF2] ) gmx_fatal(FARGS,"For two particle SDF, reference groups 1 and 2" "must have the same size.\n"); for (i=0; i<isize[G_REF1]; i++) { /* check consistency for atoms 1 and 2 */ for (j=G_REF1; j<=G_REF2; j++) ref_resind[j] = top.atoms.atom[index[j][i]].resind; if ( ref_resind[G_REF1] != ref_resind[G_REF2] || index[G_REF1][i] == index[G_REF2][i] ) { if ( ref_resind[G_REF1] != ref_resind[G_REF2] ) { fprintf(stderr,"\nWarning: bond (%d) not from one molecule." "Will not be used for SDF.\n",i); fprintf(stderr, " resnr[1]: %d, resnr[2]: %d\n", ref_resind[G_REF1],ref_resind[G_REF2]); } else { fprintf(stderr,"\nWarning: atom1 and atom2 are identical." "Bond (%d) will not be used for SDF.\n",i); fprintf(stderr, " index[1]: %d, index[2]: %d\n", index[G_REF1][i],index[G_REF2][i]); } for (j=NDX_REF1; j<=NDX_REF2; j++) { for (k=i; k<isize[G_REF1]-1; k++) index[j][k]=index[j][k+1]; isize[j]--; srenew(index[j],isize[j]); } } } } /* Read Atoms for refmol group */ if ( bRef ) { snew(index[G_REFMOL],1); for (i=G_REF1; i<=G_REF3; i++) ref_resind[i] = top.atoms.atom[index[i][0]].resind; for (i=0; i<natoms; i++) { if ( ref_resind[G_REF1] == top.atoms.atom[i].resind || ref_resind[G_REF2] == top.atoms.atom[i].resind || ref_resind[G_REF3] == top.atoms.atom[i].resind ) nrefmol++; } srenew(index[G_REFMOL],nrefmol); isize[G_REFMOL] = nrefmol; nrefmol = 0; for (i=0; i<natoms; i++) { if ( ref_resind[G_REF1] == top.atoms.atom[i].resind || ref_resind[G_REF2] == top.atoms.atom[i].resind || ref_resind[G_REF3] == top.atoms.atom[i].resind ) { index[G_REFMOL][nrefmol] = i; nrefmol++; } } } /* initialize some stuff */ boxmin = min( norm(box[XX]), min( norm(box[YY]), norm(box[ZZ]) ) ); hbox = boxmin / 2.0; for (i=0; i<DIM; i++) { cutoff[i] = cutoff[i] / 2; nbin[i] = (int)(2 * cutoff[i] / binwidth) + 1; invbinw = 1.0 / binwidth; tri_upper[i] = triangle[i] + dtri[i]; tri_upper[i] = sqr(tri_upper[i]); tri_lower[i] = triangle[i] - dtri[i]; tri_lower[i] = sqr(tri_lower[i]); } /* Allocate the array's for sdf */ snew(count,nbin[0]+1); for(i=0; i<nbin[0]+1; i++) { snew(count[i],nbin[1]+1); for (j=0; j<nbin[1]+1; j++) snew(count[i][j],nbin[2]+1); } /* Allocate space for the coordinates */ snew(x_i1,isize[G_SDF]); snew(x_refmol,isize[G_REFMOL]); for (i=0; i<isize[G_REFMOL]; i++) for (j=XX; j<=ZZ; j++) x_refmol[i][j] = 0; normfac = 0; do { /* Must init pbc every step because of pressure coupling */ set_pbc(&pbc,ePBC,box); rm_pbc(&top.idef,ePBC,natoms,box,x,x); /* Dynamically build the ref tripels */ if ( mode == 2 ) { isize[NDX_REF1]=0; for (j=NDX_REF1; j<=NDX_REF3; j++) srenew(index[j],isize[NDX_REF1]+1); /* consistancy of G_REF[1,2] has already been check */ /* hence we can look for the third atom right away */ for (i=0; i<isize[G_REF1]; i++) { for (j=0; j<isize[G_REF3]; j++) { /* Avoid expensive stuff if possible */ if ( top.atoms.atom[index[G_REF1][i]].resind != top.atoms.atom[index[G_REF3][j]].resind && index[G_REF1][i] != index[G_REF3][j] && index[G_REF2][i] != index[G_REF3][j] ) { pbc_dx(&pbc,x[index[G_REF1][i]],x[index[G_REF3][j]],dx); delta = norm2(dx); if ( delta < tri_upper[G_REF1] && delta > tri_lower[G_REF1] ) { pbc_dx(&pbc,x[index[G_REF2][i]],x[index[G_REF3][j]],dx); delta = norm2(dx); if ( delta < tri_upper[G_REF2] && delta > tri_lower[G_REF2] ) { /* found triple */ index[NDX_REF1][isize[NDX_REF1]]=index[G_REF1][i]; index[NDX_REF2][isize[NDX_REF1]]=index[G_REF2][i]; index[NDX_REF3][isize[NDX_REF1]]=index[G_REF3][j]; /* resize groups */ isize[NDX_REF1]++; for (k=NDX_REF1; k<=NDX_REF3; k++) srenew(index[k],isize[NDX_REF1]+1); } } } } } } else if ( mode ==3 ) { isize[NDX_REF1]=0; for (j=NDX_REF1; j<=NDX_REF3; j++) srenew(index[j],isize[NDX_REF1]+1); /* consistancy will be checked while searching */ for (i=0; i<isize[G_REF1]; i++) { for (j=0; j<isize[G_REF2]; j++) { /* Avoid expensive stuff if possible */ if ( top.atoms.atom[index[G_REF1][i]].resind != top.atoms.atom[index[G_REF2][j]].resind && index[G_REF1][i] != index[G_REF2][j] ) { pbc_dx(&pbc,x[index[G_REF1][i]],x[index[G_REF2][j]],dx); delta = norm2(dx); if ( delta < tri_upper[G_REF3] && delta > tri_lower[G_REF3] ) { for (k=0; k<isize[G_REF3]; k++) { if ( top.atoms.atom[index[G_REF1][i]].resind != top.atoms.atom[index[G_REF3][k]].resind && top.atoms.atom[index[G_REF2][j]].resind != top.atoms.atom[index[G_REF3][k]].resind && index[G_REF1][i] != index[G_REF3][k] && index[G_REF2][j] != index[G_REF3][k]) { pbc_dx(&pbc,x[index[G_REF1][i]],x[index[G_REF3][k]],dx); delta = norm2(dx); if ( delta < tri_upper[G_REF1] && delta > tri_lower[G_REF1] ) { pbc_dx(&pbc,x[index[G_REF2][j]],x[index[G_REF3][k]],dx); delta = norm2(dx); if ( delta < tri_upper[G_REF2] && delta > tri_lower[G_REF2] ) { /* found triple */ index[NDX_REF1][isize[NDX_REF1]]=index[G_REF1][i]; index[NDX_REF2][isize[NDX_REF1]]=index[G_REF2][j]; index[NDX_REF3][isize[NDX_REF1]]=index[G_REF3][k]; /* resize groups */ isize[NDX_REF1]++; for (l=NDX_REF1; l<=NDX_REF3; l++) srenew(index[l],isize[NDX_REF1]+1); } } } } } } } } } for (i=0; i<isize[NDX_REF1]; i++) { /* setup the molecular coordinate system (i',j',k') */ /* because the coodinate system of the box forms a unit matrix */ /* (i',j',k') is identical with the rotation matrix */ clear_mat(rot); /* k' = unitv(r(atom0) - r(atom1)) */ pbc_dx(&pbc,x[index[NDX_REF1][i]],x[index[NDX_REF2][i]],k_mol); unitv(k_mol,rot[2]); /* i' = unitv(k' x (r(atom2) - r(atom1))) */ pbc_dx(&pbc,x[index[NDX_REF3][i]],x[index[NDX_REF2][i]],i1_mol); cprod(i1_mol,rot[2],i2_mol); unitv(i2_mol,rot[0]); /* j' = k' x i' */ cprod(rot[2],rot[0],rot[1]); /* set the point of reference */ if ( mode == 2 ) copy_rvec(x[index[NDX_REF3][i]],xi); else copy_rvec(x[index[NDX_REF1][i]],xi); /* make the reference */ if ( bRef ) { for (j=0; j<isize[G_REFMOL]; j++) { pbc_dx(&pbc,xi,x[index[G_REFMOL][j]],dx); mvmul(rot,dx,dx_mol); rvec_inc(x_refmol[j],dx_mol); for(k=XX; k<=ZZ; k++) x_refmol[j][k] = x_refmol[j][k] / 2; } } /* Copy the indexed coordinates to a continuous array */ for(j=0; j<isize[G_SDF]; j++) copy_rvec(x[index[G_SDF][j]],x_i1[j]); /* count the SDF */ for(j=0; j<isize[G_SDF]; j++) { /* Exclude peaks from the reference set */ bInGroup=FALSE; for (k=NDX_REF1; k<=NDX_REF3; k++) if ( index[G_SDF][j] == index[k][i] ) bInGroup=TRUE; if ( !bInGroup ) { pbc_dx(&pbc,xi,x_i1[j],dx); /* transfer dx to the molecular coordinate system */ mvmul(rot,dx,dx_mol); /* check cutoff's and count */ if ( dx_mol[XX] > -cutoff[XX] && dx_mol[XX] < cutoff[XX] ) if ( dx_mol[YY] > -cutoff[YY] && dx_mol[YY] < cutoff[YY] ) if ( dx_mol[ZZ] > -cutoff[ZZ] && dx_mol[ZZ] < cutoff[ZZ] ) { X = (int)(floor(dx_mol[XX]*invbinw)) + (nbin[XX]-1)/2 +1; Y = (int)(floor(dx_mol[YY]*invbinw)) + (nbin[YY]-1)/2 +1; Z = (int)(floor(dx_mol[ZZ]*invbinw)) + (nbin[ZZ]-1)/2 +1; count[X][Y][Z]++; normfac++; } } } } } while (read_next_x(status,&t,natoms,x,box)); fprintf(stderr,"\n"); close_trj(status); sfree(x); /* write the reference strcture*/ if ( bRef ) { fp=ffopen(fnREF,"w"); fprintf(fp,"%s\n",title); fprintf(fp," %d\n",isize[G_REFMOL]); for (i=0; i<isize[G_REFMOL]; i++) fprintf(fp,"%5d%5s%5s%5d%8.3f%8.3f%8.3f\n", top.atoms.resinfo[top.atoms.atom[index[G_REFMOL][i]].resind].nr, *(top.atoms.resinfo[top.atoms.atom[index[G_REFMOL][i]].resind].name), *(top.atoms.atomname[index[G_REFMOL][i]]),i+1, -1*x_refmol[i][XX],-1*x_refmol[i][YY],-1*x_refmol[i][ZZ]); /* Inserted -1* on the line above three times */ fprintf(fp," 10.00000 10.00000 10.00000\n"); ffclose(fp); fprintf(stderr,"\nWrote reference structure. (%d Atoms)\n",isize[G_REFMOL]); } /* Calculate the mean probability density */ fprintf(stderr,"\nNumber of configuations used for SDF: %d\n",(int)normfac); normfac = nbin[0]*nbin[1]*nbin[2] / normfac; fprintf(stderr,"\nMean probability density: %f\n",1/normfac); /* normalize the SDF and write output */ /* see http://www.csc.fi/gopenmol/index.phtml for documentation */ fp=ffopen(fnSDF,"wb"); /* rank */ i_write(fp,3); /* Type of surface */ i_write(fp,42); /* Zdim, Ydim, Xdim */ for (i=ZZ; i>=XX; i--) i_write(fp,nbin[i]); /* [Z,Y,X][min,max] (box corners in Angstroem)*/ for (i=ZZ; i>=XX; i--) { f_write(fp,-cutoff[i]*10); f_write(fp,cutoff[i]*10); } /* Original Code for (i=1; i<nbin[2]+1; i++) for (j=1; j<nbin[1]+1; j++) for (k=1; k<nbin[0]+1; k++) { sdf = normfac * count[k][j][i]; if ( sdf < min_sdf ) min_sdf = sdf; if ( sdf > max_sdf ) max_sdf = sdf; f_write(fp,sdf); }*/ /* Changed Code to Mirror SDF to correct coordinates */ for (i=nbin[2]; i>0; i--) for (j=nbin[1]; j>0; j--) for (k=nbin[0]; k>0; k--) { sdf = normfac * count[k][j][i]; if ( sdf < min_sdf ) min_sdf = sdf; if ( sdf > max_sdf ) max_sdf = sdf; f_write(fp,sdf); } fprintf(stderr,"\nMin: %f Max: %f\n",min_sdf,max_sdf); ffclose(fp); /* Give back the mem */ for(i=0; i<nbin[0]+1; i++) { for (j=0; j<nbin[1]+1; j++) { sfree(count[i][j]); } sfree(count[i]); } sfree(count); }
void ClearLCD() { i_write(0x01); }
void LCDLine_2(void) { i_write(0xc0); }
void LCDLine_1(void) { i_write(0x80); }
void Clear_LCD(void ) /* Erases the LCD display */ { i_write(0b00000001);/* Display Clear*/ }