Hello.
I am trying to read in a datetime string, format YYMMDDhhmmss, but would prefer it in a more human readable format such as
YY-MM-DD hh:mm:ss
My protocol file is fine if I just read the string as YYMMDDhhmmss and the checksum passes.
Then I can insert the extra characters with a regular _expression_ to give the string I want but the checksum now fails.
I am forced to omit the checksum and just ignore extra input.
Is this the expect behaviour or might I be doing something wrong?
If so, can someone suggest a more elegant solution for the format conversion instead of a regular _expression_, perhaps with an sCalcout record?
I’m sure someone will ask for my code so here it is. I’m actually using redirection to put the date and time into two separate records, $1:DATE and $1:TIME. I’ve shown the evolution of my protocol attempts.
readTime {
out BEL "01ZR \$CS" ETX;
# Basic input with no reformatting.
# in BEL "01ZR","%(\$1:DATE)6s%(\$1:TIME)6s\$CS" ETX;
# Next line works but actually does nothing in the regular _expression_.
# in BEL "01ZR","%#/([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1\2\3\4\5\6/%(\$1:DATE)6s%(\$1:TIME)6s\$CS" ETX;
# Next line gives a checksum error.
# in BEL "01ZR","%#/([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1:\2:\3\4-\5-\6/%(\$1:DATE)8s%(\$1:TIME)8s\$CS" ETX;
# So this is my best solution so far but omitting the checksum.
in BEL "01ZR","%#/([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1:\2:\3\4-\5-\6/%(\$1:DATE)8s%(\$1:TIME)8s";
ExtraInput = Ignore; #Suspect checksum calculated after regex so will not match input.
}
If I can get the regular _expression_ to work with a checksum, maybe someone could also suggest a more elegant regular _expression_.
Thanks,
Keith Baker
Diamond Light Source Ltd
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt
by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.