Code: Select all
#include "Fwce.ch"
Function Main()
LOCAL oWnd, oGps, nCom, oTimer,cCom:='COM4'
DEFINE WINDOW oWnd TITLE "Sample GPS"
oGps := Tgps():New()
//oGps:Log(.T.)
@ 5, 5 SAY "Fecha" SIZE 53, 20 RIGHT PIXEL
@ 5, 60 GET oGps:cDate SIZE 80, 20 WHEN .f. PIXEL OF oWnd UPDATE
@ 5, 145 GET oGps:cTime SIZE 60, 20 WHEN .f. PIXEL OF oWnd UPDATE
@ 27, 5 SAY "Lat." SIZE 53,20 RIGHT PIXEL
@ 27, 60 GET oGps:cLat SIZE 80,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 27, 145 GET oGps:cNS SIZE 20,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 50, 5 SAY "Long." SIZE 53,20 RIGHT PIXEL
@ 50, 60 GET oGps:cLong SIZE 80,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 50, 145 GET oGps:cEW SIZE 20,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 72, 5 SAY "Lat dec." SIZE 50,20 RIGHT PIXEL
@ 72, 60 GET oGps:nLat SIZE 80,20 PICTURE "999.999999" RIGHT;
WHEN .f. PIXEL OF oWnd UPDATE
@ 94, 5 SAY "Lon dec." SIZE 50,20 RIGHT PIXEL
@ 94, 60 GET oGps:nLong SIZE 80,20 PICTURE "999.999999" RIGHT;
WHEN .f. PIXEL OF oWnd UPDATE
@ 118, 5 SAY "Fix" SIZE 50,20 RIGHT PIXEL
@ 116, 60 GET oGps:cFix SIZE 30,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 118, 80 SAY "Sats" SIZE 50,20 RIGHT PIXEL
@ 116, 130 GET oGps:cSats SIZE 30,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 140, 5 SAY "Alt." SIZE 50,20 RIGHT PIXEL
@ 138, 60 GET oGps:cAlt SIZE 60,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 162, 5 SAY "Veloc." SIZE 50,20 RIGHT PIXEL
@ 160, 60 GET oGps:cSpeed SIZE 60,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 184, 5 SAY "Locator." SIZE 50,20 RIGHT PIXEL
@ 182, 60 GET oGps:cLoc SIZE 60,20 WHEN .f. PIXEL OF oWnd UPDATE
@ 206, 5 SAY 'Com Gps' SIZE 50,20 RIGHT PIXEL OF oWnd
@ 204, 60 COMBOBOX cCom ITEMS {"COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9"} SIZE 50,20 PIXEL OF oWnd WHEN !oGps:lGps
@ 244, 5 BUTTON "CONECTAR" SIZE 95, 25 PIXEL;
ACTION ( oGps:Conecta( val(SubStr(cCom,4,1)) ), oTimer:Activate()) WHEN !oGps:Connect() UPDATE
@ 244, 110 BUTTON "DESCONECTAR" SIZE 95, 25 PIXEL;
ACTION ( oTimer:Deactivate(), oGps:Desconecta(),oWnd:END() ) WHEN oGps:Connect() UPDATE
ACTIVATE WINDOW oWnd;
ON INIT ( oTimer := Ttimer():New( 1000, { || oWnd:Update() }, oWnd ));
VALID ( oTimer:End(), oGps:end(), .t.)
RETURN NIL