' Alarm | Ring
Sub Alarm_Ring
iAHour = Controls.GetTextBoxText(oHour)
iAMin = Controls.GetTextBoxText(oMin)
If (iHour = iAHour) And (iMin = iAMin) Then
Sound.PlayChimesAndWait()
EndIf
EndSub
' Analog | Draw hour numerals
' in: rAke6, rKure6 - ake 6 and kure 6 [JST hour]
' in: iHX, iHY - font size for hour numerals
Sub Analog_DrawHourNumerals
GraphicsWindow.BrushColor = sFGColor
GraphicsWindow.FontSize = iHY
For iHour = 0 To 22 Step 2
If iHour > 9 Then
idX = - iHX
Else
idX = - iHX / 2
EndIf
rHour = iHour
Edo_HourToRadian()
iX = iXC - Math.Round(iR * 1.1 * Math.Sin(rEdoRadian) - idX)
iY = iYC + Math.Round(iR * 1.1 * Math.Cos(rEdoRadian) - iHY / 2)
GraphicsWindow.DrawText(iX, iY, iHour)
EndFor
EndSub
' Analog | Initialization
Sub Analog_Init
' time table initialization
sCity[9] = "Tokyo"
rDelta[9] = 9
iCities = 24
' selected city
iCity = 9
GraphicsWindow.BrushColor = sFGColor
If rDelta[iCity] > 0 Then
sSign = "+"
Else
sSign = ""
EndIf
GraphicsWindow.DrawText(iAX * 3 + iTX0, iAY * 7, sCity[iCity] + " (" + sSign + rDelta[iCity] + ")")
' show clock face
iR = 100 ' radius for analog clock face
iXC = 50 + iR ' center of analog clock
iYC = 40 + iR
uDialPlate = uFolder + "EdoDialPlate.png"
GraphicsWindow.DrawImage(uDialPlate, iXC - iR, iYC - iR)
' add hour hand as shape
uHour = uFolder + "EdoHourHand.png"
oHour = Shapes.AddImage(uHour)
Shapes.Move(oHour, iXC - iR, iYC - iR)
EndSub
' Analog | Rotate hour hand
' in: iHour, iMin, iSec - current hour, minute, second [JST]
Sub Analog_RotateHourHand
rHour = iHour + iMin / 60 + iSec / 3600
Edo_HourToRadian()
rEdoDegree = Math.GetDegrees(rEdoRadian)
rDegree = rEdoDegree + 12 * 360 / 24
Shapes.Rotate(oHour, rDegree)
EndSub
' Astronomy | Convert date to alpha (heriocentric longitude)[degree]
' in: sDate - "yyyy/mm/dd" (JST)
' work: rAreaVelocity - area velocity [km^2]
' out: rAlphaDegree - sun angle 0..360 [degree]
' 0[degree] - the vernal equinox
' 90[degree] - the summer solstice
' 180[degree] - the autumnal equinox
' 270[degree] - the winter solstice
Sub Astron_DateToAlpha
sBuf = sDate
iBufPtr = 1
Parse_GetDate() ' get iDaysIn2011
rDays = iDaysIn2011 + 0.5 - rNearDate
rAreaVelocity = rAreaPerYear * rDays / rDaysPerYear
' rThetaC is calculated as if Earth orbit is circle
rThetaC = rDays * 360 / rDaysPerYear
' rDegree is calculated as if Earth orbit is circle
rDegree = rThetaC
rAlphaDegree = rDegree - rSEDegree
EndSub
' Astronomy | Initialization
' out: rA - Earth orbit major radius (mean radius) [km]
' out: rB - Earth orbit minor radius [km]
' out: rE - eccentricity of Earth orbit
' out: rL - distance between Sun and orbit on line parallel to minor axis [km]
' out: rAreaPerYear - velocity area / solar year [km^2/year]
' out: rDaysPerYear - days / solar year [day/year]
' work: rNearDegree - perihelion degree from spring equinox (nearest point)
' out: rNearDays - days between winter solistice and perihelion [day]
' work: rSEDate - "2011/03/21 08:21:00" spring equinox date (JST) [day]
' out: rNearDate - perihelion date and time (JST) [day]
Sub Astron_Init
rA = 1.496 * Math.Power(10, 8)
rE = 0 ' assumes circle orbit (real ellipse orbit case: 0.0167)
rB = rA * Math.SquareRoot(1 - Math.Power(rE, 2))
rL = rA * (1 - Math.Power(rE, 2))
rAreaPerYear = rA * rB * Math.Pi
rDaysPerYear = 365.24219
rNearDegree = 180 + 102.976
rSEDegree = 360 - rNearDegree
rSERadian = Math.GetRadians(rSEDegree)
rRSE = rL / (1 + rE * Math.Cos(rSERadian)) ' distance between Sun and Earth in spring equinox
rNumarator = rA * rRSE * Math.Sin(rSERadian) / rB
rDenominator = rA * rE + rRSE * Math.Cos(rSERadian)
rTanCSE = rNumarator / rDenominator
rCSERadian = Math.ArcTan(rTanCSE) ' center angle of spring equinox
rCSEDegree = Math.GetDegrees(rCSERadian)
rAFanECN = rA * rB * rCSERadian / 2 ' area of fan ECN
rATriECS = rA * rE * rRSE * Math.Sin(rSERadian) / 2 ' area of triangle ECS
rSEArea = rAFanECN - rATriECS
rSEDays = rSEArea * rDaysPerYear / rAreaPerYear
sBuf = "2011/03/21" ' spiring equinox date in 2011
iBufPtr = 1
Parse_GetDate()
sBuf = "08:21:00" ' spring equinox time in 2011
iBufPtr = 1
Parse_GetTime()
rSEDate = iDaysIn2011 + rDays
rNearDate = rSEDate - rSEDays
EndSub
' Calender | Format date
Sub Cal_FormatDate
sDate = iYear + "/"
If iMonth < 10 Then
sDate = sDate + "0"
EndIf
sDate = sDate + iMonth + "/"
If iDay < 10 Then
sDate = sDate + "0"
EndIf
sDate = sDate + iDay
EndSub
' Caleder | Get date today
' out: sDate - "yyyy/mm/dd" today
Sub Cal_GetDate
iYear = Clock.Year
iMonth = Clock.Month
iDay = Clock.Day
Cal_FormatDate()
EndSub
' Calender | Get leap from year
Sub Cal_GetLeapFromYear
If Math.Remainder(iYear, 4) = 0 And Math.Remainder(iYear, 100) > 0 Or Math.Remainder(iYear, 400) = 0 Then
iDoM[2] = 29
Else
iDoM[2] = 28
Endif
iNoL = Math.Floor((iYear - 1) / 4) - Math.Floor((iYear - 1) / 100) + Math.Floor((iYear - 1) / 400) ' number of leap year
EndSub