cf app for any device - how to develop?

  • Thread starter Thread starter Matteo Cima
  • Start date Start date
M

Matteo Cima

Hi,
my application will run on very different devices,
everyone has its own .dll provided by its very own sdk... to access
bluetooth, print, use coms, activate barcode, leds... and so on.
Unfortunately the great opennetcf's sdf is not enough mature to supply all
these with my devices.

The best approach is to build a wrapper dll that calls the correct functions
depending on the device (i can provide the type of device via a settings
file, so i don't have the problem to probe exactly on which device i'm
running on).

what should i do?
solution a: more .dlls (one for each device type)
solution b: different .dlls but named with the same name on device

and then, how can i keep everything in the same vs2003 solution? Or what?

Matteo Cima
Senior Developer, Mobile Expert, Project Manager, Lead Analyst,
Digisoft srl Italy
mdm.listISTHENAME and digisoft.itISTHESERVER
 
Matteo,

I'm sure there's an appropriate design pattern for this type of situation.
Basically I think you want separate classes for the different devices but a
common class used by the rest of your app that hides these details by
instantiating the right sort of object based on the settings in your
configuration file. If you program in the rest of your app against an
interface that is implemented by all the different device classes, that
would probably be the simplest way to go while still allowing you to have
all your code in one project.
 
Personally I'd build a single DLL that supported all the devices. Have
classes that wrap the feature you're after and that check the device at
run-time in the object constructor to see if it's a supported device.

I'm also a bit surprised that you consider the SDF as "not mature enough"
yet you think that starting from zero will get you there faster. Why not
start with the SDF and add and/or test what you need?
 
Sorry, I didn't mean to offend you... i wrote that part quickly and didn't
mean that!
I need to p/invoke custom dlls, so the sdf as it is it's not an already
ready solution (for me)
of course i will add in it what i need, i love the way it works.
adding support for every device i am gonna use it's a pain in the a..
but right now i don't see any other solution...
i'll let you know if i end up with something interesting!

Matteo Cima
 
No argument - it sounds like a pain, but I don't see any way around it
either. The lack of standardization on components is never a good thing.
 
I'm not sure in your case, is it a standart win32 function you want to call
or are they different on each device ?

anyway in my case I write interop code which work on both the device and the
desktop this way:

public class WinAPI
{
public const string GDI32 = "GDI32";
public const string USER32 = "USER32";
public const string KERNEL32 = "KERNEL32";
public const string CORECE = "coredll";

public static bool IsDevice
{
get
{
return IsDevice = Environment.OSVersion.Platform ==
PlatformID.WinCE;
}
}

[DllImport(USER32, EntryPoint="GetDC", SetLastError=true)]
static extern IntPtr GetDC_D(IntPtr hWnd);
[DllImport(CORECE, EntryPoint="GetDC", SetLastError=true)]
static extern IntPtr GetDC_P(IntPtr hWnd);
public static IntPtr GetDC(IntPtr hWnd)
{
if(IsDevice)
return GetDC_P(hWnd);
else
return GetDC_D(hWnd);
}
}
 
Thank you for you reply,
i need to use different devices and every device has its own "way" to
provide functions...
e.g. for barcode:
- Intermec700, has a laser barcode reader and intermec provides its .net
sdk, within intermec namespace
- hhp9500, has a ccd barcode reader and (afaik) has evc4 dll i can
p/invoke...
and others...
i don't want to add support to every device inside my app, but i want to
provide some sort of standardization in a way that i can call the barcode
function in just one way, and then my component takes care on how to
interact with the device...

I like the way you implemented it, thanks!

Matteo.


Lloyd Dupont said:
I'm not sure in your case, is it a standart win32 function you want to call
or are they different on each device ?

anyway in my case I write interop code which work on both the device and the
desktop this way:

public class WinAPI
{
public const string GDI32 = "GDI32";
public const string USER32 = "USER32";
public const string KERNEL32 = "KERNEL32";
public const string CORECE = "coredll";

public static bool IsDevice
{
get
{
return IsDevice = Environment.OSVersion.Platform ==
PlatformID.WinCE;
}
}

[DllImport(USER32, EntryPoint="GetDC", SetLastError=true)]
static extern IntPtr GetDC_D(IntPtr hWnd);
[DllImport(CORECE, EntryPoint="GetDC", SetLastError=true)]
static extern IntPtr GetDC_P(IntPtr hWnd);
public static IntPtr GetDC(IntPtr hWnd)
{
if(IsDevice)
return GetDC_P(hWnd);
else
return GetDC_D(hWnd);
}
}

Matteo Cima said:
Hi,
my application will run on very different devices,
everyone has its own .dll provided by its very own sdk... to access
bluetooth, print, use coms, activate barcode, leds... and so on.
Unfortunately the great opennetcf's sdf is not enough mature to supply all
these with my devices.

The best approach is to build a wrapper dll that calls the correct functions
depending on the device (i can provide the type of device via a settings
file, so i don't have the problem to probe exactly on which device i'm
running on).

what should i do?
solution a: more .dlls (one for each device type)
solution b: different .dlls but named with the same name on device

and then, how can i keep everything in the same vs2003 solution? Or what?

Matteo Cima
Senior Developer, Mobile Expert, Project Manager, Lead Analyst,
Digisoft srl Italy
mdm.listISTHENAME and digisoft.itISTHESERVER
 
Most unlikely you will find a unified BarcodeReader class for all the
devices with a barcode scanner.
Just curious, I know how the Intermec.DataCollection.BarcodeReader class
works, but how does Symbols' work? or for that matter, all the other .NET
implementations?

Ronald.
 
But e.g. for barcode,
let's say that for a device (intermec700) i have a .net sdk and so i have to
reference it, and then wrap into sdf,
and i have another device that exposes me barcode functionality via
p/invoke...
and maybe another device with .net sdk...

ok, matteo, we got it, get to the point!

do i have to reference everything, so everything is copied on every
device... so i'll have intermec dlls installed on hhp handheld... and so
on...
is this true?

and the declaration of p/invokes won't be correct on intermec (the one with
..net sdk) ...

what a mess!

Matteo.
 
Robert,

Symbol's .Net wrapper for barcode reading wrapper uses a Barcode.Reader
class, which internally uses a ReaderData class to manage the different
types of barcode data. You set up a delegate to handle read events and then
enable the Reader. That's an oversimplification, but you get the idea. You
can choose to handle Read events however you want, but I choose to handle
Read events at the form level so users can read a barcode no matter which
control has focus. I believe that other implementations barcode readers are
different though, so I'm also curious as to all the different flavors out
there.
 
Would an alternative to directly programming the barcode process be to have
the data wedged into the keyboard stream and then just treat it as though
the user typed it? Obviously, you might need a configuration program to
select symbologies, lengths, and options on a given device (and maybe a
startup application to program the reader that way on restart), but, after
that, the input would be the same no matter what device it was on, it seems
to me...

Paul T.
 
Back
Top