Re: Issuing XWin-NMR commands from an UPS system: SUMMARY

From: Rainer Kerssebaum (Rainer.Kerssebaum@bruker-biospin.de)
Date: Sat Mar 27 2004 - 22:57:38 PST


Dear Bob and all other BUM-List members,

I would like to clarify a few things which obviously have been
misunderstood.

> A short while ago, I posted a question concerning issuing an XWin-NMR
> command from outside of the XWin-NMR program, in particular from our
> UPS system. I received a number of responses, and I wish to thank you
> all. Because about half of the responses wanted to learn what I found
> out, I am posting this summary.
>
> Firstly, no one provided a way to issue an XWin-NMR command (such as
> HALT) from outside of the program. It would seem, therefore, that
> this is impossible.
>
> One person was concerned about how the PWRDWN proceedure was
> implemented. He suggested that it would be better if the amps were
> powered down, but the console should continue to operate so that the
> fans could dissipate any heat. I agree that this would be
> preferable. It may be possible to modify the PWRDWN.BAT to include
> such functionality, but I do not know how to do so.
>
> I did receive numerous messages that suggested ways to minimize the
> amount of lost data when the system was shut-down as a result of a
> power failure. These solutions loosely fall into two catagories: 1.
> modify the pulse program to include a write statement, and 2. make use
> of an AU program such as "interleave".
>
> Modifying a typical 1D-NMR pulse program to include a write statement
> (2D experiments already have such a statement) is pretty
> straightforward. However, because there are so many different 1D
> pulse programs (eg. zg30, zgpg, dept135, etc.), each one would need to
> be similarly modified.
>
> The "interleave" AU program makes use of the TD0 parameter. When the
> interleave AU is executed, then the parameters NS and TDO are read
> from the current dataset, and NS scans are acquired, TD0 times, giving
> a total number of scans equal to NS*TD0. So, if NS = 256, and TD0 =
> 10, then the total number of scans will be 2560. If a power failure
> occurs during this experiment, then the maximum number of scans lost
> will be 255.

The interleave AU program does not make use of TD0. It is splitting
NS into parts itself and is obsolete since XWinNMR 3.5.
If you have XWinNMR 3.5 you don't need to modify any pulse program,
basically all 1D PP's are written to make use of TD0. As explained
above, NS*TD0 scans are acquired and after each NS the FID is written
to disk.

> Because we operate our centre as a multi-user, hands-on facility, and
> since we are often making use of an autosampler, and ICON-NMR, I have
> decided to write my own AU program and have incorporated it into our
> standard 1D-NMR datasets as the AUNM parameter. The intent was that
> the program would work transparently: if a user submits an experiment
> with 5000 scans, then the program will execute 19 loops of 256 scans
> each, and then a 20th loop of 136 scans. The data is written after
> each loop.

If you want to use the TD0 feature in automation, you simply have to
modify the acquisition AU programs (AUNM) in a way that the NS
entered by the user is split into TD0*NS just before the start of
acquisition. In the above example this would either lead to 5120 or
4864 scans, depending on how you round. If you use 64 instead of 256
as the basic cycle, the deviation from the number entered by the user
is getting small. But, as a "goodie" this would lead to a full phase
cycle executed. In the example above 5000 is not a multiple of 16 (16
is the basic phase cycle in a lot of experiments).
There are not that many AU programs to be modified, only those which
may control long acquisitions, i.e. with a lot of scans.

Directly sending a command to XWinNMR is not possible. Our new
program TopSpin offers this possiblity.
However, there is a little workaround how you can achive this within
XWinNMR. I attach a small AU program which runs infinitely and
periodically checks a file. If an external event writes into this
file, the content is passed to XWinNMR as a command.

Nevertheless if you use this to issue a 'halt' to the acquisition,
you will stop most likely within a phase cycle, which I wouldn't like
to happen. For some experiments this may lead to garbage.

Regards

Rainer

================================================================
     ... ... Dr. Rainer Kerssebaum
    . * . . Bruker BioSpin GmbH
     . . . . NMR Applications
     B R U K E R D-76287 Rheinstetten
     . . . . Voice: +49-721-5161-139
    . * . . Fax: +49-721-5161-297
     ... ... EMail: Rainer.Kerssebaum@bruker-biospin.de
================================================================

-- 
__________________________________________________________________________

To subscribe/unsubscribe: Please send a note to

bruker-users-request (at) purcell(dot)cchem(dot)berkeley(dot)edu

For subscriptions, please include a list of Bruker instruments you are using, see http://www.cchem.berkeley.edu/nmr/BUM.txt E-mail archives are at http://calmarc3.cchem.berkeley.edu/archives/bum.html __________________________________________________________________________

/****************************************************************/ /* wait4cmd 24.03.2004 */ /****************************************************************/ /* Short Description : */ /* AU program waits for XWinNMR commands. */ /****************************************************************/ /* Keywords : */ /* remote commands */ /****************************************************************/ /* Description/Usage : */ /* AU program periodically creates and checks an input file */ /* 'xwin_cmd.dat' in the users home directory. The content of */ /* this file is send as commands to XWinNMR. */ /* If this file is modified by an external program, it allows */ /* to send remote commands to XWinNMR. */ /****************************************************************/ /* Author(s) : */ /* Name : Rainer Kerssebaum */ /* Organisation : Bruker BioSpin */ /* Email : Rainer.Kerssebaum@bruker-biospin.de */ /****************************************************************/ /* Name Date Modification: */ /* rke 040324 created */ /****************************************************************/ /* $Id: $ */

/* Some definitions and declarations */

int ret; char cmd_fname[PATH_MAX],line[PATH_MAX]; FILE *fptr;

/* check cmd file and run in infinite loop */

(void) sprintf( cmd_fname, "%s/xwin_cmd.dat", PathSystemHome() );

while(1) {

fptr = fopen(cmd_fname, "rt"); if (fptr == NULL) { fptr = fopen(cmd_fname, "wt"); if (fptr != NULL) { fclose(fptr); fptr = fopen(cmd_fname, "rt"); } else { STOPMSG("Cannot create command file"); } }

/* get first entry */

if (fgets(line,sizeof(line),fptr) ) { fclose(fptr); /* Proc_err(ERRORH_OPT,"%s",line); */ CPR_exec(line,WAIT_TERM); RemoveFirstLine(cmd_fname); } else { fclose(fptr); /* Proc_err(ERRORH_OPT,"empty"); */ sleep(15); } } QUIT

static int RemoveFirstLine(const char* path) { struct stat stb; char* buf; char* cp; int fd = open(path, O_RDWR);

if (fd == -1) { Perror(DEF_ERR_OPT, path); return -1; }

if (fstat(fd, &stb)) { Perror(DEF_ERR_OPT, path); (void)close(fd); return -1; }

if (stb.st_size == 0) { (void)close(fd); return 0; } buf = malloc(stb.st_size + 1); if (buf == 0) { Proc_err(DEF_ERR_OPT, "not enough buffer space available"); (void)close(fd); return -1; }

if (read(fd, buf, stb.st_size) != stb.st_size) { Perror(DEF_ERR_OPT, path); free(buf); (void)close(fd); return -1; }

(void)close(fd); buf[stb.st_size] = 0; cp = strchr(buf, '\n'); if (cp == 0) { Proc_err(DEF_ERR_OPT, "no CRLF found in %s", path); free(buf); return -1; }

cp++; stb.st_size -= cp - buf;

fd = open(path, O_RDWR | O_TRUNC);

if (fd == -1) { Perror(DEF_ERR_OPT, path); free(buf); return -1; } if (write(fd, cp, stb.st_size) != stb.st_size) { Perror(DEF_ERR_OPT, path); free(buf); (void)close(fd); return -1; } free(buf); (void)close(fd); return 0; }



This archive was generated by hypermail 2b29 : Sat Jan 15 2005 - 11:43:16 PST