'this routine will download, cut, and process the latest radar frame to be sent to the unit.
Sub ProcessRegionalRadarFrame(Slot As Int, OffsetX As Int, OffsetY As Int) As ResumableSub
Dim CurrentFileName As String
'Download the latest radar image from the server
Dim job1 As HttpJob
job1.Initialize("", Me)
job1.Download("http://xxxxxxxxxxxx")
Wait For (job1) JobDone(job1 As HttpJob)
If job1.Success Then
CurrentFileName = job1.GetString
Else
Log(job1.ErrorMessage)
Return False
End If
job1.Release
'Now that we have the filename for the latest frame, lets download this frame.
job1.Download("http://xxxxxxxxxx" & CurrentFileName)
Wait For (job1) JobDone(job1 As HttpJob)
If job1.Success Then
Dim out As OutputStream = File.OpenOutput(File.DirApp, "temp.tif", False)
File.Copy2(job1.GetInputStream, out)
out.Close
Else
Log(job1.ErrorMessage)
Return False
End If
job1.Release
'Once we have the image, we need to chop this image and save it for conversion.
Dim shl As Shell
shl.Initialize("shl", "convert", Array As String("temp.tif", "-filter", "point", "-resize", "4182x1848!", "temp.gif")) 'Perform an ImageMagic Conversion.
shl.WorkingDirectory = File.DirApp
shl.Run(10000) 'set a timeout of 10 seconds
Wait For sh1_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log("Are we getting past here?") 'Thats a big nope
If Success And ExitCode = 0 Then
Log("Success")
Log(StdOut)
Else
Log("Error: " & StdErr)
End If
Return True
End Sub