Champak Posted April 10, 2014 Share Posted April 10, 2014 (edited) ...OK, not really an external program, but an object. This object is a third party wmp visualizer. Its compiled in Microsoft Visual Studio and Xcode/gcc using C++. It apparently uses sin and cos to do its calculations to do its visualization. My issue is it seems to be hijacking my calculations to determine gps distances between coordinates. (This is where things go wrong in the second code box below) ;==How many miles away POI Coord are from current coord $MILES = $DistCalc * ACos(Sin($LT1) * Sin($LT2) + Cos($LT1) * Cos($LT2) * Cos($LG2 - $LG1)) ;==Notification distance (feet) converted to miles/kilometers $POIDNOTIFY = $NAV_OPTIONS_ARRAY[13][0] * $MathCalc ;==Convert distance between current coord and current POI from miles/kilometers to feet $DISTANCENOTIFY = $MILES / $MathCalc My function searches through a list of location coordinates, and if it sees one is within a specified distance from me it alerts me to how far it is. Problem is like I said, this visualization seems to be interrupting me. When I change the visualization to any other one of MS own stock ones, the issue goes away. What can I do? I really want to use this particular visualization. The only thing I came up with that I don't really want to do, is separate this particular gps function into an external app and have it communicate with the main app. The other thing I thought of, but don't know the equations involved, is to take the cos and sin out a functions "environment" and write out the actual equation and hope that wont get interrupted. Here are the two portions involved, hopefully that is enough for someone to give me some insight. The first is the wmp visualization object being created, and the second is the gps coordinate search. Here is a link to the website with the visualization so you can see what I'm using. https://www.soundspectrum.com/whitecap/faq.html#customize Thanks for any help. $MEDIA_PLAYER_ARRAY[18] = GUICtrlCreateObj($OIE_AD2, 0, 0, $MVWidth, $MVHeight-95) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0x000000) _IENavigate($OIE_AD2, "about:blank", 1) _IELoadWait($OIE_AD2, 180, 4000) Do Sleep(50) $ODOC_AD2 = $OIE_AD2.document Until IsObj($ODOC_AD2) Sleep(25) $OBODY_AD2 = $ODOC_AD2.body $OBODY_AD2.scroll = "no" $OBODY_ADSTYLE2 = $OBODY_AD2.style With $OBODY_ADSTYLE2 .margin = "0px" .border = "0px" .padding = "0px" .backgroundcolor = "#ff0000" EndWith $OPLAYER1 = $ODOC_AD2.createElement("OBJECT") With $OPLAYER1 .style.width = $MVWidth .style.height = $MVHeight .style.background = "#000000" .classid = "CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" .uiMode = "none" .settings.setMode("loop", "false") .settings.autostart = True EndWith $OBODY_AD2.appendChild($OPLAYER1) expandcollapse popupFunc _POI_SEARCH() If $READFIXGOOD = True Then ;==Check if the proper amount of time passed between each POI notification, if not then return $POIDNOTIFYDELAY = $NAV_OPTIONS_ARRAY[14][0] * 1000 If TimerDiff($ITIMERPOINODIFY) <= $POIDNOTIFYDELAY Then Return $SkipPOI = False If $GPSTEST = False Then $LT1 = StringTrimRight($READLAT, 4) / $RADIANS $LG1 = StringtrimLeft(StringTrimRight($READLONG, 4),1) / $RADIANS _ConsoleWrite("> " & StringTrimRight($READLAT, 4)) _ConsoleWrite("> " & StringtrimLeft(StringTrimRight($READLONG, 4),1)) Else $LT1 = $TESTLAT / $RADIANS $LG1 = $TESTLONG / $RADIANS EndIf For $X = 0 To UBound($NAV_POI_ARRAY) - 1 ;_ConsoleWrite($X) If $NAV_POI_ARRAY[$X][0] = "" Or $NAV_POI_ARRAY[$X][1] = "" Then ContinueLoop $LT2 = $NAV_POI_ARRAY[$X][0] / $RADIANS $LG2 = $NAV_POI_ARRAY[$X][1] / $RADIANS #cs _ConsoleWrite("!=========================================") _ConsoleWrite(StringTrimRight($NAV_POI_ARRAY[$X][0], 1)) _ConsoleWrite(StringTrimRight($NAV_POI_ARRAY[$X][1], 1)) _ConsoleWrite($LT1) _ConsoleWrite($LT2) _ConsoleWrite($LG1) _ConsoleWrite($LG2) _ConsoleWrite(ACos(Sin($LT1))) _ConsoleWrite(Sin($LT2)) _ConsoleWrite(Cos($LT1)) _ConsoleWrite(Cos($LT2)) _ConsoleWrite(Cos($LG2 - $LG1)) _ConsoleWrite("!=========================================") #ce If $SPEEDSETTING = 0 Then $DistCalc = 3963.191 $MathCalc = 0.000189393939393939 Else $DistCalc = 6378.137 $MathCalc = 0.0003048 EndIf ;==How many miles away POI Coord are from current coord $MILES = $DistCalc * ACos(Sin($LT1) * Sin($LT2) + Cos($LT1) * Cos($LT2) * Cos($LG2 - $LG1)) ;==Notification distance (feet) converted to miles/kilometers $POIDNOTIFY = $NAV_OPTIONS_ARRAY[13][0] * $MathCalc ;==Convert distance between current coord and current POI from miles/kilometers to feet $DISTANCENOTIFY = $MILES / $MathCalc #cs _ConsoleWrite($X & "---- 1 Range = " & $POIDNOTIFY & _ ", 2 Miles = " & $MILES & _ ", 3 Feet = " & $DISTANCENOTIFY & _ ", 4 Current Lat = " & $LT1 & _ ", 5 Current Long = " & $LG1 & _ ", 6 POI Lat = " & $LT2 & _ ", 7 POI Long = " & $LG2) #ce ;================DONT REALLY NEED THIS ANYMORE, COME BACK AND ELIMINATE THIS AND ITS DEPENDENTS If $Skip_POI_Pressed = True And $CURRENTPOI = $NAV_POI_ARRAY[$X][3] Then _ConsoleWrite("+ POI SKIP PRESSED") ; $ITIMERPOINODIFY = TimerInit() $SkipPOI = True EndIf If $SkipPOI = False Then ;_CONSOLEWRITE("next 1 " & $NAV_OPTIONS_ARRAY[13][0]) If $MILES < $POIDNOTIFY Then ;_CONSOLEWRITE("POI within " & $NAV_OPTIONS_ARRAY[13][0] & " feet - : - (Line = " & @ScriptLineNumber & ")") If TimerDiff($ITIMERPOINODIFY) >= $POIDNOTIFYDELAY Then $DISTANCENOTIFY = Round($DISTANCENOTIFY, 0) If StringInStr($DISTANCENOTIFY, ".") Then $DISTANCENOTIFY = StringSplit($DISTANCENOTIFY, ".") $DISTANCENOTIFY1 = $DISTANCENOTIFY[1] $FRAC = $DISTANCENOTIFY[2] Else $DISTANCENOTIFY1 = $DISTANCENOTIFY EndIf $RESULT = "" While StringLen($DISTANCENOTIFY1) > 3 $RESULT = "," & StringStripWS(StringRight($DISTANCENOTIFY1, 3), 3) & $RESULT $DISTANCENOTIFY1 = StringTrimRight($DISTANCENOTIFY1, 3) WEnd $DISTANCENOTIFY1 = StringFormat("%s%s%s", $DISTANCENOTIFY1, $RESULT, "." & Eval("frac")) If StringRight($DISTANCENOTIFY1, 1) = "." Then $DISTANCENOTIFY1 = StringTrimRight($DISTANCENOTIFY1, 1) SplashTextOn("", $NAV_POI_ARRAY[$X][3] & " - " & $DISTANCENOTIFY1 & " feet away.", 640, 50, 0, -$MVHeight, 1 + 32, "", 13, 700) HotKeySet("{DELETE}", "_POI_Delete") $DELETEPOI = $NAV_POI_ARRAY[$X][0] & "," & $NAV_POI_ARRAY[$X][1] & "," & $NAV_POI_ARRAY[$X][2] & "," & $NAV_POI_ARRAY[$X][3] $CURRENTPOI = $NAV_POI_ARRAY[$X][3] _WinAPI_Beep(400, 200) Sleep(200) _WinAPI_Beep(400, 200) Sleep(200) _SPEAKTOME($NAV_POI_ARRAY[$X][2] & " detected, at " & $NAV_POI_ARRAY[$X][3]) $POI_Available = True $Skip_POI_Pressed = False SplashOff() HotKeySet("{DELETE}") $ITIMERPOINODIFY = TimerInit();reset timer for next go round ExitLoop EndIf EndIf EndIf Next EndIf ;_ConsoleWrite("! POI SEARCH END") EndFunc ;==>_POI_SEARCH Edited April 10, 2014 by Champak Link to comment Share on other sites More sharing options...
Champak Posted April 10, 2014 Author Share Posted April 10, 2014 Also note, this external app/object writes to scite when exiting the script if that means anything. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now