Help!

EUREKA!!!!!!!

You guys got me to thinking about the fact that the datediff dosent know if the moonrise has occured or not! There is a 3rd variable in the script that is the heart of all the calculations, and propegates the virtual devices. It reports the status of the moon, either up or down. Using this new variable as an error trap, I think I got it working!!!!!!!!!!


Here is the final code, that seems to be working now:

Code:
Moonstatus = hs.deviceString("m3")
Moonrise = hs.deviceString("m1")

CurrentTime = time


      if Moonstatus = "Moonstatus: Up" then
         MoonUpTime = DateDiff("h", Moonrise, CurrentTime)
         if MoonUpTime < 0 then MoonUpTime = MoonUpTime +24
      end if

if MoonUpTime > 14 then MoonUpTime = 0
if MoonUpTime < 0 then MoonUpTime =0
hs.SetDeviceString "M4",MoonUpTime

You can have a look at the page now, on my site, and it SHOULD be a fairly accurate representation of the moon as it traverses the sky from rise to set.
again, its at johnwpb.com and follow the "MyHomeseer" link then login and go to the "Moon Phase" link at the bottom.

Shew!!!!!!!!!!!!!!

MANY, Many, MANY, Many, MANY, Many, MANY, Many, thanks to all that helped on this one! I will NEVER take on a project that involves times witout having a date to work with as well! Thats for sure!
 
Congratulations. Glad to hear it's working.

That wasn't so tough, was it? Only 2 days and 45 posts in the thread. :)
 
Only 2 days! Thats all you guys saw! I was working on this for a week before the "Call for Help", I was about to call Leo! hahahahahhah

If anyone is interested in the asp page, let me know and I can put it up on my site. It involves 2 scripts, the asp page 14 custom graphics for the moon traverse, and another 28 for the moon phases for it to all come together. (Around a meg of stuff).
 
I should have thought about this earlier but there's the moonphase script that someone wrote many moons ago. :) It actually calculates the phase of the moon based on the Julian calendar. It's a fairly simple script.

It's designed to place a moon Icon in the header of the HS generated pages.


Code:
Sub main()
    Dim FSO, strPath, strCurrent, intYear, intMonth, intDay, intJulian
    Set FSO = CreateObject("Scripting.FileSystemObject")
    
    strPath = hs.GetAppPath
    intYear = year(Date)
    intMonth = month(Date)
    intDay = day(Date)
    
    YY = intYear - Int((12 - intMonth) / 10)
    MM = intMonth + 9
    
    If MM >= 12 Then MM = MM - 12
    K1 = Int(365.25 * (YY + 4712))
    K2 = Int(30.6 * MM + 0.5)
    K3 = Int(Int((YY / 100) + 49) * 0.75) - 38
    
    '  JD for dates in Julian calendar
    intJulian = K1 + K2 + intDay + 59
    
    ' For Gregorian calendar
    If intJulian > 2299160 Then intJulian = intJulian - K3
    
    intJulian = (intJulian - 2451550.1) / 29.530588853
    intJulian = intJulian - Int(intJulian)
    If intJulian < 0 Then intJulian = intJulian + 1
    
    ' build a filename
    strCurrent = strPath + "\html\moons\moon" & Int(intJulian * 29.530588853) & ".gif"
    strCurrent2 = strPath + "\html\moons\moon" & Int(intJulian * 29.530588853) & ".gif"


    ' verify file exists
    If Not FSO.FileExists(strCurrent) Then
        hs.WriteLog "Web", "Moon file " + strCurrent + " missing!"
        Exit Sub
    End If

  ' copy the correct file over clock.gif
  If FSO.FileExists(strPath + "\html\sunset.gif") Then FSO.DeleteFile strPath + "\html\sunset.gif"
  FSO.CopyFile strCurrent, strPath + "\html\sunset.gif"
  FSO.CopyFile strCurrent2, strPath + "\html\touchpad\skins\common\moon.gif"

End Sub
 
I beleive that script was written by Hunter Green, as you said many moons ago :)

Calculating the phase of the moon was not problem, I have been doing that one for years. I was looking to do something a bit different with lunar information. Now that the page is working, it will show the location of the moon, if up, in relation to the horizon. Here is an image to show what I mean:



MoonTraverse04.jpg
 
Just visited your site then walked outside - sure looks accurate to me! I really love that graphic you made. Notice I haven't shown myself until you made it through all that frustration and got it to work. :)

Thanks again for your help with the aquarium project.

Stan
 
John,

Glad you got it all working and it looks neat. I might have to see if I can include that in my pages as well.

Rick
 
John,

This is probably one of my more favorite ideas that i have ever seen. Would you mind putting your work in the CocoonTech.com Software Download section instead of on your site. This way people can talk about it and improve it as needed.

Great Job!
 
Sure I can put it up here on the site, not a problem from my end. I didnt really think this was something that anyone else would really want.

Will the DL section handle a 1 meg file though? Thats the only thing I see holding it back. In the mean time, I will put all the files and brief instructions together and get it ready to post.
 
Back
Top