Jump to content

if then on an error message/redlight


---
 Share

Recommended Posts

Hey all,
looking to notify the operator if the machine stops from an error and or red light.
i am already using some code to play a bell when the program is done running. just looking to take that to the next level.
any ideas are welcome.

TIA,
JG
Link to comment
Share on other sites

This can not be achived with pcm, since the execution of the measurement plan stops.

But since it's Yuletide...

Batch-file:
@echo off
set count=0
:start
set NUM=0
for /F %%N in ('find /C "CNC Disabled" ^< "C:\Users\Public\Documents\Zeiss\CALYPSO\sm_events.dat"') do set "NUM=%%N"
if %NUM% gtr %count% (echo "We have a issue" & set count=%NUM% & goto:start) ELSE (timeout /T 10 /NOBREAK >NUL & goto:start)
Merry Christmas!
Link to comment
Share on other sites

Make sure the paths match yours or change them to suit your environment.
You might like to do something more drastic then show "something went wrong" on the display, so change that to what ever you wish to do.
Save it in a txt-file with extension .bat or .cmd and
let it run in the background.
Link to comment
Share on other sites

This is the code i want to replace the "Something went Wrong" This is written in PCM i dont know enough about batch file syntax to insert this in. now that i think of it I believe you came up with this code for me a while back 🙂
if p1==p2 then
batFil="C:\Temp\mPlay.bat"
addToFile(batFil,"@echo off")
addToFile(batFil,"set file="+qm()+"N:\JPG files\Boxing Bell.wav"+qm())
addToFile(batFil," "+chr(40)+" echo Set Sound = CreateObject"+chr(40)+qm()+"WMPlayer.OCX.7"+qm()+"^"+chr(41))
addToFile(batFil," echo Sound.URL = %file%")
addToFile(batFil," echo Sound.Controls.play" )
addToFile(batFil," echo do while Sound.currentmedia.duration = 0" )
addToFile(batFil," echo wscript.sleep 100" )
addToFile(batFil," echo loop")
addToFile(batFil," echo wscript.sleep "+chr(40)+"int"+chr(40)+"Sound.currentmedia.duration^"+chr(41)+"+1^"+chr(41)+"*1000"+chr(41)+" "+chr(62)+"sound.vbs")
addToFile(batFil,"start /min sound.vbs" )
addToFile(batFil,"del "+batFil)
systemCall("C:\Temp\mPlay.bat")
endif
Link to comment
Share on other sites

Mm that looks familar.

You can strip the pcm from that and execute it as a subroutine.

CODE: SELECT ALL
@echo off
set count=0
:start
set NUM=0
for /F %%N in ('find /C "CNC Disabled" ^< "C:\Users\Public\Documents\Zeiss\CALYPSO\sm_events.dat"') do set "NUM=%%N"
if %NUM% gtr %count% (call :subroutine & set count=%NUM% & goto:start) ELSE (timeout /T 10 /NOBREAK >NUL & goto:start)

:subroutine
set "file=N:\JPG files\Boxing Bell.wav"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
  echo Sound.URL = "%file%"
  echo Sound.Controls.play
  echo do while Sound.currentmedia.duration = 0
  echo wscript.sleep 100
  echo loop
  echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs
start /min sound.vbs
exit /b
That should work, but I'm postning from my Phone so it's untested.
Link to comment
Share on other sites

your the man Eric!

From my initial test just now it seemed to work. I am going to let the operators test it more to see how it goes.

Thanks,
JG
Link to comment
Share on other sites

  • 2 weeks later...
Hey Eric,
after having the operators test the bat file. it seemed to work at first but not repeatably there were times that it made the sounds and other times it didn't. do you know why this would happen? There was also a delay before I heard the sound maybe 45-1min delay when it did work. not that that's a big deal. any thoughts to improve it?

Thanks,
JG
Link to comment
Share on other sites

Toughts of improvements?
Hahaha, where to start, Well as it is now you only use one token, there might be more error codes that cause a stop then "cnc disabled". So use more tokens. But I think "find" is limited to one (might be wrong). How ever "findstr" is actually pretty powerful but somewhat more cumbersome to work with in my personal opinion. But it might suit better.
You might also face a minor issu with the "counter". I don't know how sm_events "clean" it's self up, but if the batch-file is running for a long time, sm_events migh clean out lines that contain a "sound" trigger command leaving you with a counter that it higher then errors in sm_events. That will make you miss the next error, and so on.
So, everytime you are paring the file, you should save the last timestamp in memory. And and always continiue from there, that solves this issue. But to get the timestamps, you need to convert the file from binary to ascii.

If the delay is to big, decrease the timeout, but then it will parse the sm_events.dat file more often.

If this is something that need to work 100% write it in a proper language. Pearl fits like a glove in cases like this, personally I find my self use Python for almost everything these days. Since I have admin rights on all CMM computers now days, Its the first thing that gets installed.

But the most neat solution imo is to run a second session on rtc code inside the calypso environment. 100% stealth! Not sure how legal that would be, so Im going to stick with previous suggestions.
Link to comment
Share on other sites

yeah this isn't my area of expertise...
I'm not certain whats exactly happening, but from observation it works at first then doesn't until i close and re-open the bat file. would incorporating the time/date stamp help make this more full proof to get around some issues you mentioned with the "counter"?

on my previous note about a delay, its actually spot on haha. looking at the status window while its running, cnc disabled doesn't appear until 30-40 secs after the error that caused the cnc disabled.
Link to comment
Share on other sites

 Share

×
×
  • Create New...