# example.tcl -- # Configuration file for the Fews PI services # package require SOAP # # Set up the services: one Tcl command for each method # Assume that we are running on the same machine as FEWS # (hence the host is simply "localhost") set host "localhost" ::SOAP::create getClientConfigFile -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {fileName string fileExtension string} ::SOAP::create getSystemTime -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string} ::SOAP::create getLogMessages -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string taskId string} ::SOAP::create getAvailableStateTimes -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string id string} ::SOAP::create getColdStateIds -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string id string} ::SOAP::create getEnsembleMemberIndices -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string ensembleId string} ::SOAP::create getModuleStateBinary -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string id string stateTime dateTime ensembleId string ensembleMemberIndex int} ::SOAP::create getLocations -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string} ::SOAP::create createTask -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string} ::SOAP::create getTimeSeries -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string id string taskId string startTime dateTime timeZero dateTime endTime dateTime parameterIds string() locationIds string() ensembleId string ensembleMemberIndex int includeThresholds boolean} # # This method is not implemented on the FEWS side # ::SOAP::create getTimeSeriesBytes -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string id string taskId string startTime dateTime timeZero dateTime endTime dateTime parameterIds string() locationIds string() ensembleId string ensembleMemberIndex int includeThresholds boolean} # # Methods for running tasks # ::SOAP::create createTask -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string} ::SOAP::create runTask -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string taskId string workflowId string startTime dateTime timeZero dateTime endTime dateTime coldStateId string scenarioId string userId string description string} ::SOAP::create waitForTask -uri Fews -proxy http://$host:8100/FewsPiService \ -parameters {clientId string taskRunId string waitMillis int} # # Run the various tests # # Note: if the clientId is not needed "aa" is used # puts "Current system time: [getSystemTime aa]" puts "State times: [getAvailableStateTimes TestConfig RSNWELEV_DETO3I]" puts "Cold states: [getColdStateIds TestConfig RSNWELEV_DETO3I]" set stateTimes [getAvailableStateTimes TestConfig RSNWELEV_DETO3I] if {0} { set zipContents [getModuleStateBinary TestConfig SNOW17_LSMO3U [lindex $stateTimes 0] null -1] set outf [open "statefile.bin" w] fconfigure $outf -encoding binary puts $outf $zipContents close $outf } # Note: name of file, extension of file set textContents [getClientConfigFile MyClientConfigFile txt] set outf [open "client.txt" w] puts $outf $textContents close $outf puts "Locations:" puts "---begin---" puts [getLocations aa] puts "---end---" puts "Ensemble members: [getEnsembleMemberIndices aa ESP]" puts "Log message: [getLogMessages aa NWSNWMC00:0000026]" # # Date/time manipulation: # Using Tcl 8.4 (last part is the timezone) # set now [clock seconds] # set dateTimeNow [clock -format "%Y-%m-%dT%T+00:00] # # Using Tcl 8.5 # set now [clock seconds] # set dateTimeNow [clock -format "%Y-%m-%dT%T%z] # set start "2009-04-01T00:00:00+00:00" set end "2009-04-11T00:00:00+00:00" set systemTime [getSystemTime aa] puts "Timeseries:" puts "---begin---" puts [getTimeSeries TestConfig Reservoir null $start $systemTime $end \ {QIN RQIN} {DETO3 GPRO3 FOSO3} null -1 0] puts "---end---" # # Running a task ... # puts "Running Santiam_Forecast ..." set taskId [createTask aa] set date [getSystemTime aa] set taskRunId [runTask aa $taskId "Santiam_Forecast" $date $date $date null null "Test user" "PiWebservice taskrun"] set success [waitForTask aa $taskRunId 120000] ;# Wait for 120 seconds = 120000 ms puts [expr {$success? "OK!" : "Problem!"]