![Yoctopuce Yocto-GPS Скачать руководство пользователя страница 47](http://html1.mh-extra.com/html/yoctopuce/yocto-gps/yocto-gps_user-manual_3415557047.webp)
YAPI and YLatitude Import
These two import provide access to functions allowing you to manage Yoctopuce modules.
YAPI
is
always needed,
YLatitude.js
is necessary to manage modules containing a latitude sensor,
such as Yocto-GPS. Other imports can be useful in other cases, such as
YModule
which can let
you enumerate any type of Yoctopuce device.
YAPI.RegisterHub
The
RegisterHub
method allows you to indicate on which machine the Yoctopuce modules are
located, more precisely on which machine the VirtualHub software is running. In our case, the
127.0.0.1:4444
address indicates the local machine, port
4444
(the standard port used by
Yoctopuce). You can very well modify this address, and enter the address of another machine on
which the VirtualHub software is running, or of a YoctoHub. If the host cannot be reached, this
function will trigger an exception.
YLatitude.FindLatitude
The
FindLatitude
method allows you to find a latitude sensor from the serial number of the
module on which it resides and from its function name. You can also use logical names, as long as
you have initialized them. Let us imagine a Yocto-GPS module with serial number
YGNSSMK1-123456
which you have named "
MyModule
", and for which you have given the
latitude
function the name "
MyFunction
". The following five calls are strictly equivalent, as long as
"
MyFunction
" is defined only once.
latitude = YLatitude.
FindLatitude
(
"YGNSSMK1-123456.latitude"
)
latitude = YLatitude.
FindLatitude
(
"YGNSSMK1-123456.MaFonction"
)
latitude = YLatitude.
FindLatitude
(
"MonModule.latitude"
)
latitude = YLatitude.
FindLatitude
(
"MonModule.MaFonction"
)
latitude = YLatitude.
FindLatitude
(
"MaFonction"
)
YLatitude.FindLatitude
returns an object which you can then use at will to control the
latitude sensor.
isOnline
The
isOnline()
method of the object returned by
FindLatitude
allows you to know if the
corresponding module is present and in working order.
get_latitude
The
get_latitude()
method of the object returned by
YGps.FindGps
provides the latitude
currently measured by the Yocto-GPS. The value returned is a string, the format will vary according
to the Yocto-GPS configuration. To get a floating point value, no matter the configuartion, use the
YLatitude Class.
A real example
Open a command window (a terminal, a shell...) and go into the directory
example_node/Doc-
GettingStarted-Yocto-GPS
within Yoctopuce EcmaScript library. In there, you will find a
subdirectory
src
with the sample code below, which uses the functions explained above, but this
time used with all side materials needed to make it work nicely as a small demo.
If your Yocto-GPS is not connected on the host running the browser, replace in the example the
address
127.0.0.1
by the IP address of the host on which the Yocto-GPS is connected and where
you run the VirtualHub.
import
{
YAPI, YErrorMsg, YGps
}
from
'yoctolib-es'
;
var
gps;
async
function
startDemo
()
{
await
YAPI.
LogUnhandledPromiseRejections
()
;
await
YAPI.
DisableExceptions
()
;
7. Using Yocto-GPS with JavaScript / EcmaScript
www.yoctopuce.com
41
Содержание Yocto-GPS
Страница 1: ...Yocto GPS User s guide...
Страница 2: ......
Страница 6: ...22 Characteristics 557 Blueprint 559 Index 561...
Страница 10: ...4 www yoctopuce com...
Страница 14: ...8 www yoctopuce com...
Страница 18: ...12 www yoctopuce com...
Страница 22: ...16 www yoctopuce com...
Страница 38: ...32 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 54: ...48 www yoctopuce com...
Страница 72: ...66 www yoctopuce com...
Страница 92: ...86 www yoctopuce com...
Страница 122: ...116 www yoctopuce com...
Страница 132: ...126 www yoctopuce com...
Страница 159: ...20 High level API Reference On failure throws an exception or returns a negative error code www yoctopuce com 153...
Страница 564: ...22 Characteristics 558 www yoctopuce com...
Страница 565: ......
Страница 566: ......