⚠ Forum Archived — The THSCC forums were discontinued (last post: 2024-05-18). This read-only archive preserves club history. Visit thscc.com →  |  Search this archive with Google: site:forums.thscc.com your search terms

THSCC Forums

Tarheel Sports Car Club Forums
It is currently Tue Apr 07, 2026 10:06 am

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 55 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: Thu Mar 03, 2005 2:41 pm 
Offline
Got Powah?
User avatar

Joined: Wed Aug 20, 2003 9:15 pm
Posts: 4724
Can anyone point me to a good VBS reference site that includes I/O commands for accessing files on the directory?

I could write this in BASIC if I had something to do it with! Unfortunately all the rest of my fading programming knowlege is Pascal and FORTRAN. Lots of good that does me...

Or if someone can suggest the VBS commands to use to watch a file modification time/date and open the file, read the contents into a string... That would take care of 75% of the hurdle I have :)

_________________
Mike Whitney
whit32@gmail.com, 919-454-5445
V10, V8, V8t, I6, I6, V6, F4t, I4, I4, I4, I4, I2, 1, 1


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 4:01 pm 
Offline
Mr. Wizard
User avatar

Joined: Thu Apr 01, 2004 3:15 pm
Posts: 85
Presuming you've got the following set of .wav files
Code:
0.wav
1.wav
2.wav
3.wav
4.wav
5.wav
6.wav
7.wav
8.wav
9.wav
a.wav
b.wav
c.wav
DOT.wav
d.wav
e.wav
f.wav
g.wav
h.wav
i.wav
j.wav
k.wav
l.wav
m.wav
n.wav
NUMBER.wav
o.wav
PLUS.wav
p.wav
q.wav
RUN.wav
r.wav
speaker.sh
s.wav
TIME.wav
t.wav
u.wav
v.wav
w.wav
x.wav
y.wav
z.wav
The following shell script will watch whatever you specify for the output file and will generate and run a winamp command like what Whitney posted earlier, and it will ignore lines placed in the output file that don't match the timing format. It will run until you kill it.
Code:
#!/bin/bash
INFILE=/path/to/OUTPUT/file
SOUNDDIR=/path/to/directory/with/wav/sound/files
PREV_COMMAND=placeholder
cd $SOUNDDIR

while [ 0 ]; do
   COMMAND=`tail -n 1 $INFILE |grep -e "^Run" |sed -e "s/\([0-9]*\.[0-9]*\)/TIME\1/"| sed -e "s/\(\:\ \ *[a-z][a-z0-9]*\)\ \([0-9][0-9]*\)/\1 NUMBER \2/g" | sed -e "s/\( \[a-z][a-z0-9]*\ [0-9][0-9]*\)/TIME &/" |sed -e "s/[ \:]//g" |sed -e "s/Run/RUN/" |sed -e "s/\+/PLUS/" |sed -e "s/\./DOT/" |sed -e "s/[A-Z][A-Z]*/ & /g" |sed -e "s/[a-z0-9]/ & /g" |sed -e "s/[A-Za-z0-9][A-Za-z0-9]*/ &\.wav/g" |sed -e "s/^/winamp /"`
   if [ "$COMMAND" != "$PREV_COMMAND" ]; then
      $COMMAND;   
   fi
   PREV_COMMAND=$COMMAND;
   sleep 1;
done

Now all you need to do is find bash, grep and sed for windows. :(

EDIT: removed the echo.


Last edited by joedobner on Thu Mar 03, 2005 5:15 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 4:15 pm 
Offline
JACKASS!!!
User avatar

Joined: Mon Oct 27, 2003 9:47 am
Posts: 3683
Now there's a first post for you! :shock:

_________________
Has no responsibility whatsoever.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 5:48 pm 
Offline
I got a SUX2000!
User avatar

Joined: Sun Aug 31, 2003 12:07 am
Posts: 2443
Location: In the garage, under a big old Mercedes
joedobner wrote:
Now all you need to do is find bash, grep and sed for windows. :(


Cygwin tools? Or maybe I can coerce the GPL'd versions to build in Visual Studio?

Two thumbs up on the script.

--Karl, also familiar with 'while [ 0 ]'...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 6:04 pm 
Offline
Mr. Wizard
User avatar

Joined: Thu Apr 01, 2004 3:15 pm
Posts: 85
Karl Shultz wrote:
Cygwin tools? Or maybe I can coerce the GPL'd versions to build in Visual Studio?
I've got that lying around. If I could my mittens on an actual output file, I could simulate it and make sure that it handles appropriate cases like DNFs and re-runs.

Also, I could just try noodle around with the output and use the 'accessibility' screenreader functions windows bundles instead of piping a bunch of .wav's through winamp.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 6:25 pm 
Offline
I did stay at a Holiday Inn Express.
User avatar

Joined: Thu Aug 28, 2003 7:08 pm
Posts: 1524
Location: Raleigh NC
Pardon my ignorance, I'm not a serious geek, but wouldn't it be a LOT easier and more efficient to use a live announcer? A program can't adjust for noise, repeat itself as necessary, or give the wealth of information the timing software is capable of sending to an announcer's computer station such as did they improve, what place the finisher is in, who is ahead of them and by how much as well as make general announcements. Having the times automatically read isn't really significantly different than looking at the scoreboard as far as adding some "life" to the event. Certainly we can't be that hard up for personel that we can't spare 4 people per event (or raise the entry limit by 4 if we are) to announce.

_________________
SPIN or WIN!
there's no glory for going slow.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 7:37 pm 
Offline

Joined: Thu Jun 10, 2004 10:30 am
Posts: 69
Chuck Frank wrote:
Pardon my ignorance, I'm not a serious geek, but wouldn't it be a LOT easier and more efficient to use a live announcer?.


In defense of all fellow engineers (no I don't know a thing about programing) in the club. The problem with a live announcer is that they're human and naturally get distracted when it's time to call out the time for the great run you just had. I know good and well I'd space out after about the 40th car crossed the line. I love the idea of having an automated anouncer primarily because it's just that, automatic.

_________________
Emmett

Chevrolet Cobalt SS


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 8:39 pm 
Offline
Pseudo cautious/nervous guy

Joined: Fri Aug 29, 2003 8:05 am
Posts: 733
Location: Rockville, MD
You can definitely find opensource unix shell tools for windows - using cygwin is not necessary. We all run them here, and a co-worker is our resident opensource detective. I'll find out where he got them. Worst case, I can send a zip file to whomever.

I couldn't live day to day at work w/o grep...

_________________
Tom Freeman
'98 M3/4/5 | '93 Spec3 325i | '12 TSX sport wagon | '03 Tahoe
Team Silver Bullets '91 240SX


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 8:58 pm 
Offline
I got a SUX2000!
User avatar

Joined: Sun Aug 31, 2003 12:07 am
Posts: 2443
Location: In the garage, under a big old Mercedes
TomFreeman wrote:
I couldn't live day to day at work w/o grep...


Or tab completion.

Isn't the cygwin stuff GPL'd nowdays? I thought Redhat picked them up and is selling support agreements for people shipping it in non-OSS offerings...

Anyway, Tom's right...this is one of those things that the OSS community has most definitely already solved. Mike, if this can solve your problem, we can get it going.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 10:27 pm 
Offline
Totally Lacking an Inner Alien
User avatar

Joined: Thu Aug 28, 2003 10:09 pm
Posts: 2548
Location: In a margaritta with a hammock!!!!
There really needs to be a smilie with a plane flying over his head, because you guys have TOTALLY lost me. :shock:

_________________
Todd Breakey
STS 42 - 1992 Sunburst Miata
Dammit!
"You souldn't play leap frog with a porcupine. You might get hurt." - Eliza


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 1:26 am 
Offline
Got Powah?
User avatar

Joined: Wed Aug 20, 2003 9:15 pm
Posts: 4724
Code:
#!/bin/bash
INFILE=/path/to/OUTPUT/file
SOUNDDIR=/path/to/directory/with/wav/sound/files
PREV_COMMAND=placeholder
cd $SOUNDDIR

while [ 0 ]; do
   COMMAND=`tail -n 1 $INFILE |grep -e "^Run" |sed -e "s/\([0-9]*\.[0-9]*\)/TIME\1/"| sed -e "s/\(\:\ \ *[a-z][a-z0-9]*\)\ \([0-9][0-9]*\)/\1 NUMBER \2/g" | sed -e "s/\( \[a-z][a-z0-9]*\ [0-9][0-9]*\)/TIME &/" |sed -e "s/[ \:]//g" |sed -e "s/Run/RUN/" |sed -e "s/\+/PLUS/" |sed -e "s/\./DOT/" |sed -e "s/[A-Z][A-Z]*/ & /g" |sed -e "s/[a-z0-9]/ & /g" |sed -e "s/[A-Za-z0-9][A-Za-z0-9]*/ &\.wav/g" |sed -e "s/^/winamp /"`
   if [ "$COMMAND" != "$PREV_COMMAND" ]; then
      $COMMAND;   
   fi
   PREV_COMMAND=$COMMAND;
   sleep 1;
done


Very interesting. I don't know unix shell scripting but I can make some sense out of that code! One question though - wouldn't it be slightly more efficient to pull the text out into a string and compare THAT to decide whether to build the $COMMAND? Something like...

Code:
#!/bin/bash
INFILE=/path/to/OUTPUT/file
SOUNDDIR=/path/to/directory/with/wav/sound/files
PREV_INFILE=placeholder
cd $SOUNDDIR
while [ 0 ]; do
   if [ "$INFILE" != "$PREV_INFILE" ]; then
      COMMAND=`tail -n 1 $INFILE |grep -e "^Run" |sed -e "s/\([0-9]*\.[0-9]*\)/TIME\1/"| sed -e "s/\(\:\ \ *[a-z][a-z0-9]*\)\ \([0-9][0-9]*\)/\1 NUMBER \2/g" | sed -e "s/\( \[a-z][a-z0-9]*\ [0-9][0-9]*\)/TIME &/" |sed -e "s/[ \:]//g" |sed -e "s/Run/RUN/" |sed -e "s/\+/PLUS/" |sed -e "s/\./DOT/" |sed -e "s/[A-Z][A-Z]*/ & /g" |sed -e "s/[a-z0-9]/ & /g" |sed -e "s/[A-Za-z0-9][A-Za-z0-9]*/ &\.wav/g" |sed -e "s/^/wina   
      $COMMAND   
   fi
   PREV_INFILE=$INFILE;
   sleep 1;
done


Then you're not building COMMAND every second, right? I'd also put a sleep 5 into the if block so a driver has a chance to slow down and turn up the radio.

And regarding shell scripting - to me, trying to do it on Windows is like trying to do a motor swap. Might perform better, but wasn't meant to go in there in the first place. Since VBS is native to Win2k, that's the way to go. I still think it should be easy once I find a code reference.

Thanks for the code Joe. I might ask you to explain the various computations in the COMMAND statement out of curiosity.

_________________
Mike Whitney
whit32@gmail.com, 919-454-5445
V10, V8, V8t, I6, I6, V6, F4t, I4, I4, I4, I4, I2, 1, 1


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 1:48 pm 
Offline
Mr. Wizard
User avatar

Joined: Thu Apr 01, 2004 3:15 pm
Posts: 85
It is, in fact, building $COMMAND every second, but that's not exactly demanding. sed, tail, and grep are very nearly instantaneous, and they're all being executed on one line of text, if anything.

From start to finish, the pseudocode for $COMMAND is as follows:

Read the last line of the output file.
If it doesn't start with "Run", ignore it.
Insert "TIME" in front of the run time.
Insert "NUMBER" between class and number.
Extraneous TIME insertion, whoops! Doesn't have any effect on operation, though, since there's nothing to match.
Strip out all the spaces and colons.
Change "Run" to all caps.
Change "+" to "PLUS".
Change "." to "DOT".
Put spaces around all the all caps words.
Put spaces around every lowercase letter and number.
Add a ".wav" to each token (uppercase words, lowercase letters and numbers).
Add "winamp" to the start of the line.

The reason I just tail the file instead of checking the timestamp is that I can't be sure that only run times are getting added to it. If you check the timestamp every second and snarf in the last line when it changes, you've still got to make sure the last line is a new run time and that whatever's writing to the output file hasn't updated the timestamp without adding anything, hasn't added a line of whitespace, etc. The only reason not to tail it is if tailing it would be a performance hit, which it really isn't. Even if it were, comparing one string to a stored string in memory is no more demanding than comparing two files for equality.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 9:30 pm 
Offline
Queen of the Guinea Hens
User avatar

Joined: Sat Sep 20, 2003 11:32 pm
Posts: 3122
Location: Chapel Hill, NC
Richard Casto wrote:
Semi related question...

Does AXWare support iCard? I have no idea, but how expensive would it be to support iCard at our events? I looked at http://www.icardus.com/ and couldn't find info on how much a transmitter costs.


AxWare does support iCard transmission. I saw the option at the T&T. Like you, however, I couldn't find information on how much the transmitter costs. I wonder if it isn't possible to get the transmitter pretty cheap or *free*, though, since I'm sure they make a lot more money selling the cards than the transmitters anyway and nobody will buy cards unless their event has a transmitter.

If there's much cost involved with the transmitter, I see very little reason for the club to buy it. The cards are expensive enough I doubt many people would buy them. That makes me sad, but that's because I already have two iCards because I road race. :) I'd love for us to have that. I'd love for the SCCA to have it for national events. But I'm not going to hold my breath for that one, either. They promised it two years ago at Nationals and didn't deliver then and never said another word about it.

I'd buy the USB version for *sure* if SCCA autocrosses had a transmitter.

Anyway, I can't even find contact info for the iCard folks on the website. Looks like valid phone numbers in their whois record, though, so I may try to call them and see about the transmitter side unless someone more official wants. to.


--Donnie


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 9:56 pm 
Offline
Retired Admin
User avatar

Joined: Tue Aug 19, 2003 1:34 pm
Posts: 3276
Location: Durham, NC
Donnie Barnes wrote:
The cards are expensive enough I doubt many people would buy them.


That is the real problem with the iCard for Autocross. I had asked because the "coolness" factor for doing this would be very high and I was curious if others would be interested. I would buy a card, but who knows how many other participants would. Something like this will be more of the norm some day, but will it be 5, 10 or more years before this happens is anyones guess.

_________________
Richard Casto
1972 Porsche 914
2013 Honda Fit Sport
2015 Honda Fit EX
http://motorsport.zyyz.com
Money can't buy happiness, but somehow it's more comfortable to cry in a Porsche than a Kia.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 06, 2005 10:57 pm 
Offline
Honda >> Ford
User avatar

Joined: Fri Aug 29, 2003 1:54 am
Posts: 2052
I agree with Charles Frank.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 55 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group