![RedRat RedRat-X Скачать руководство пользователя страница 11](http://html.mh-extra.com/html/redrat/redrat-x/redrat-x_integration-manual_1430056011.webp)
7
Porting RedRat3-II Applications to the RedRat-X
Generally, the same interface is maintained across all RedRat devices, with additions to support new
functionality as its added to newer products. This means that code developed for an older device should
work with a newer one with minimal code modification.
When porting code developed for use with a RedRat3-II device to the RedRat-X, the primary
modifications are in the way the device is discovered and the fact that explicit connect/disconnect steps
are needed.
7.1
USB Device Discovery
The most straightforward method of finding RedRat USB devices of any type is using the RRUtil class:
var
lis =
RRUtil
.FindRedRats(
LocationInfo
.
RedRatType
.USB );
if
( lis.Length == 0 )
{
Console
.WriteLine(
"No USB RedRat devices found."
);
return
;
}
Where ‘l
is
’ is a list of
LocationInfo
objects, i.e. objects describing the device and its location.
Code developed for the RedRat3-II device will use the
IRedRat3
interface, which is also implemented by
the RedRat-X. So by creating an object of this type, it can be used regardless of whether the underlying
implementation is a RedRat3-II or RedRat-X:
IRedRat3
rr =
null
;
if
(
LocationInfo
.IsRedRatX( lis[0].RRType ) )
{
rr =
RedRatX
.GetInstance( lis[0] );
}
else
if
(
LocationInfo
.IsRedRat3( lis[0].RRType ) )
{
rr = lis[0].GetRedRat()
as
IRedRat3
;
}
else
{
Console
.WriteLine(
"Unknown USB RedRat type."
);
return
;
}
One point to note is that the way a
LoctionInfo
object is used to obtain the actual
IRedRat3
device
object is slightly different. This is a result of the fact that RedRat-X code has to handle both USB and
network communication mechanisms, so a bit of underlying complexity is hidden in the
GetInstance()
method.
Содержание RedRat-X
Страница 1: ...The RedRat X Integration Guide ...