
}
}
13.4. Control of the module part
Each module can be controlled in a similar manner, you can find below a simple sample program
displaying the main parameters of the module and enabling you to activate the localization beacon.
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
ConsoleApplication1
{
class
Program
{
static
void
usage
()
{
string
execname =
System
.
AppDomain
.
CurrentDomain
.
FriendlyName
;
Console
.
WriteLine
(
"Usage:"
)
;
Console
.
WriteLine
(
ex
" <serial or logical name> [ON/OFF]"
)
;
System.
Threading
.
Thread
.
Sleep
(
2500
)
;
Environment
.
Exit
(
0
)
;
}
static
void
Main
(
string
[]
args
)
{
YModule m;
string
errmsg =
""
;
if
(
YAPI.
RegisterHub
(
"usb"
,
ref
errmsg
)
!= YAPI.
SUCCESS
)
{
Console
.
WriteLine
(
"RegisterHub error: "
+ errmsg
)
;
Environment
.
Exit
(
0
)
;
}
if
(
args.
Length
<
1
)
usage
()
;
m = YModule.
FindModule
(
args
[
0
])
;
// use serial or logical name
if
(
m.
isOnline
())
{
if
(
args.
Length
>=
2
)
{
if
(
args
[
1
]
.
ToUpper
()
==
"ON"
)
{
m.
set_beacon
(
YModule.
BEACON_ON
)
;
}
if
(
args
[
1
]
.
ToUpper
()
==
"OFF"
)
{
m.
set_beacon
(
YModule.
BEACON_OFF
)
;
}
}
Console
.
WriteLine
(
"serial: "
+ m.
get_serialNumber
())
;
Console
.
WriteLine
(
"logical name: "
+ m.
get_logicalName
())
;
Console
.
WriteLine
(
"luminosity: "
+ m.
get_luminosity
()
.
ToString
())
;
Console
.
Write
(
"beacon: "
)
;
if
(
m.
get_beacon
()
== YModule.
BEACON_ON
)
Console
.
WriteLine
(
"ON"
)
;
else
Console
.
WriteLine
(
"OFF"
)
;
Console
.
WriteLine
(
"upTime: "
+
(
m.
get_upTime
()
/
1000
)
.
ToString
()
+
" sec"
)
;
Console
.
WriteLine
(
"USB current: "
+ m.
get_usbCurrent
()
.
ToString
()
+
" mA"
)
;
Console
.
WriteLine
(
"Logs:
\r\n
"
+ m.
get_lastLogs
())
;
}
else
{
Console
.
WriteLine
(
args
[
0
]
+
" not connected (check identification and USB cable)"
)
;
}
YAPI.
FreeAPI
()
;
}
}
}
13. Using Yocto-RangeFinder with C#
80
www.yoctopuce.com
Содержание Yocto-RangeFinder
Страница 1: ...Yocto RangeFinder User s guide...
Страница 2: ......
Страница 18: ...12 www yoctopuce com...
Страница 26: ...20 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Страница 90: ...84 www yoctopuce com...
Страница 120: ...114 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...21 High level API Reference On failure throws an exception or returns a negative error code 152 www yoctopuce com...
Страница 484: ...478 www yoctopuce com...
Страница 488: ...482 www yoctopuce com...
Страница 490: ...23 Characteristics 484 www yoctopuce com...
Страница 491: ......
Страница 492: ......