;---------------------------------------------- ; Script for UPMC DAS HD110410, Sept. 2011 ; HOBI Labs ; Logs data from a-Sphere, HydroScat-6, ; Gamma-4, and SBE-49 CTD ; Each instrument's data into separate file. ; First release version 100 ; Version 101 ; sets time of a-Sphere and Gamma-4 on every cast. ; Does not turn off salinity on every CTD cast. ;---------------------------------------------- sendstring s 0 "Running script v101\r\n" ; strings to console should have \r\n for HyperTerminal ; Ports define consPort 0 define aPort 1 define aBaud 57600 define aHost 16 define GammaPort 2 define GammaBaud 57600 define GammaHost 32 define HS6Port 3 define HS6Baud 57600 define HS6Host 48 define CTDPort 4 define CTDBaud 9600 define CTDHost 64 define AnalogPort 5 define AnalogHost 80 ; Files define aFile 1 define GammaFile 2 define HS6File 3 define CTDFile 4 define logFile 5 define AnalogFile 6 define StatusFile 7 ; Misc define green 1 define red 2 define off 0 ;----------------------------------------- sendstring s consPort "Turning on a-Sphere, checking for warm-up.\r\n" ; Connect to aSphere and turn it on openserial aPort aBaud "N81" routeserial aPort h aHost setpower,aPort,1 routeserial aPort s consPort repeatuntilstring aPort "a-Sphere>" 1500 sendstring s aPort "\r" waitticks 50 endrepeat waitticks 10 sendstring s aPort "time " senddate s aPort "/" 0 sendstring s aPort "\r" sendstring s aPort "power,1\r" ;Wait until aSphere says it's ready 'UNLESS the user flips the switch on-off-on ;to signal to start immediately repeatuntilstring aPort "READY" 90000 sendstring s aPort "warmup\r" sendstring s consPort "." waitticks 100 setled green waitticks 40 setled red onswitchoff startCast ;user can skip out with switch endrepeat ;------------------------------------------- ;------------------------------------------- ; Signal that the system is ready, but wait for ; user to confirm by flipping switch ;------------------------------------------- sendstring s consPort "\ra-Sphere warmed up. Waiting for switch.\r\n" readyForCast: setled green waitticks 20 setled red waitticks 10 onswitchoff startCast goto readyForCast ;------------------------------------------- ; CAST SETUP ;------------------------------------------- startCast: setled red sendstring s ConsPort "\r\nSTARTING CAST " sendseqnum s ConsPort sendstring s ConsPort " at " sendtime s ConsPort ":" sendstring s ConsPort "\r\n" ;------------------------------------------- ;Put starting time in cast log appendfile logFile "Casts.log" sendseqnum f logFile gosub logTime closefile logFile ;------------------------------------------- ;------------------------------------------- ; Open file for logging HDAS status openfileseq StatusFile "Stat.txt" gosub logStatus ;------------------------------------------- ;------------------------------------------- ; a-Sphere startup ; sendstring s consPort "Starting a-Sphere logging.\r\n" sendString aPort "setstart log,auto,0,,0,-1,2\r" ;send data out serial, not log on a-Sphere openfileseq aFile "aSph.bin" sendstring h aHost "Starting file capture of a-Sphere.\r" routeserial aPort F aFile ; sendstring s aPort "start\r" ;------------------------------------------- ;------------------------------------------- ;Connect to HS6 and wake it (but don't turn it on-it has batteries) sendstring s consPort "Waking HS6.\r\n" openserial HS6Port HS6Baud "N81" openfileseq HS6File "HS6.raw" routeserial HS6Port FILE HS6File repeat 4 sendstring s HS6Port "\x03" waitticks 30 endrepeat sendstring s HS6Port "power,1\r" sendstring s HS6Port "date," sendDate s HS6Port sendString s HS6Port "\r" waitticks 50 sendstring HOST HS6Host "Starting file capture of HydroScat-6.\r" sendstring s consPort "Opening HS6 file.\r\n" sendstring FILE HS6File "Starting " sendDate FILE HS6File sendString FILE HS6File "\r\n" ;------------------------------------------- ;------------------------------------------- ;Connect to Gamma, open file, power it. sendstring s consPort "Powering Gamma-4.\r\n" openserial GammaPort GammaBaud "N81" routeserial GammaPort HOST GammaHost setpower GammaPort 1 ; power on waitticks 200 sendstring s GammaPort "\rTime " senddate s GammaPort "" 0 sendstring s GammaPort "\r" sendstring s GammaPort "start /n\r" ; /n means don't log internally openfileseq GammaFile "Gam.raw" sendString FILE GammaFile "Start:" sendDate FILE GammaFile sendString FILE GammaFile "\r\n" sendString HOST GammaHost "Starting file capture of Gamma-4.\r" sendString s consPort "Starting logging of Gamma-4.\r\n" routeserial GammaPort FILE GammaFile ;------------------------------------------- ;------------------------------------------- ;Connect to CTD, open file, power it. sendstring s consPort "Powering CTD.\r\n" openserial CTDPort CTDBaud "N81" routeserial CTDPort HOST CTDHost setpower CTDPort 1 ; power on waitticks 200 sendstring s CTDPort "outputSV=n\r" waitticks 50 sendstring s CTDPort "startnow\r" openfileseq CTDFile "CTD.txt" sendString FILE CTDFile "Start:" sendDate FILE CTDFile sendString FILE CTDFile "\r\n" sendString HOST CTDHost "Starting file capture of CTD.\r" sendString s consPort "Starting logging of CTD.\r\n" routeserial CTDPort FILE CTDFile ;------------------------------------------- ;------------------------------------------- ; Power spare port and open file setpower AnalogPort 1 openfileseq AnalogFile "Ana.txt" ;------------------------------------------- ;------------------------------------------- ;Start HS6 sendstring s consPort "Starting HS6.\r\n" sendstring s HS6Port "start\r" ;------------------------------------------- ;------------------------------------------- ;Turn on the a-Sphere pump sendstring s consPort "Starting a-Sphere logging and pump.\r\n" sendstring s aPort "pump 1\r" sendstring s aPort "start 1\r" ;------------------------------------------- ;------------------------------------------- ; Increment the sequence number for next cast NextSeqNum ;------------------------------------------- ;------------------------------------------- ; Loop until the user flips the switch to end ;------------------------------------------- waitticks 100 ;wait to allow switch-on continueCast: sendDate FILE CTDFile "#" 20 ;insert a time tag gosub logStatus ; save DAS status to file repeat 25 waitticks 20 senddate FILE AnalogFile "," 17 sendanalog 1 FILE AnalogFile sendstring FILE AnalogFile "\r\n" onSwitchOff endCast endrepeat goto continueCast ;------------------------------------------- ;------------------------------------------- ; CAST TERMINATION ;------------------------------------------- endCast: sendstring s consPort "ENDING CAST AT " sendtime s consPort ":" sendstring s consPort "\r\n" gosub logStatus closefile StatusFile ; leave a-Sphere powered but stop its cast and turn off pump sendstring s consPort "Turning off a-Sphere pump.\r\n" sendstring s aPort "\x03" waitticks 10 sendstring s aPort "\x03" waitticks 10 sendstring s aPort "\x03\rPump 0\r" closefile aFile routeserial aPort HOST aHost ; put HS6 to sleep and close its capture file sendstring s consPort "Putting HS6 to sleep.\r\n" routeSerial HS6Port h HS6Host sendstring s HS6Port "stop\r" sendstring s HS6Port "sleep\r" closeFile HS6File ; turn off Gamma, close its capture file sendstring s consPort "Stopping Gamma-4.\r\n" sendstring s GammaPort "stop\r" waitticks 100 routeserial GammaPort HOST GammaHost sendString FILE GammaFile "End\r\n" closeFile GammaFile sendstring HOST GammaHost "Ending Gamma File Capture.\r" setpower GammaPort 0 ; turn off CTD, close its capture file senddate FILE CTDFile "#" 20 ; insert a final time tag sendstring s consPort "Stopping CTD.\r\n" sendstring s CTDPort "stop\r" waitticks 100 routeserial CTDPort HOST CTDHost sendString FILE CTDFile "End:" sendDate FILE CTDFile sendString FILE CTDFile "\r\n" closefile CTDFile sendstring HOST CTDHost "Ending CTD File Capture.\r" setpower CTDPort 0 ; turn off Analog, close its capture file closefile AnalogFile setpower AnalogPort 0 ; put ending time in cast log appendfile logFile "Casts.log" gosub logTime sendstring f logFile,"\r\n" closefile logFile endscript logTime: sendstring FILE logFile,"," senddate FILE logFile,"/",2 sendstring FILE logFile,"," sendtime FILE logFile,":" return logStatus: ; store a line of status information to the status file sendDate FILE StatusFile, "/", 2 sendstring FILE StatusFile, "," sendtime FILE StatusFile, ":" sendstring FILE StatusFile, "," sendstatus FILE StatusFile ; no line terminator needed, status has /r/n already return