F
Frank K. Jensen
Hi guys,
I need to control 3 different measurement devices. They are all very
different and need to be controlled differently. However they all measure
the same thing, and will never be used at the same time, hence I would like
to be able to just call 'measure()' regardless of with device I use.
My idea is (and I am completely new to C#) to make three different static
classes (they don't have to be static, but I plan on using properties for
setting up the devices, so two instances of the same class will be a mess
(also, there is only one physical device pr. class)). These classes will be
called e.g. device1, device2 and device3, and as mentioned they will have
different properties and perhaps some methods for setting up the device.
However they will all have one method called 'measure()'. Setting up the
device will of cause be done by calling the proper class, but how can I
access the 'measure()' method without calling the individual classes (e.g.
device1.measure())? I would like to be able to just call 'measure()' or
'device.measure()' (i.e. without a number).
If I could make an alias for the class I could do something like this:
if (device2 selected) set device = device2
and then just call device.measure() which then would be an alias for
device2.measure()
Of cause I can make a separate method just for choosing which class to call
measure() from, and I will properly just do that, if you guys can't find a
better solution.
Any ideas/suggestions?
Best regards,
Frank
I need to control 3 different measurement devices. They are all very
different and need to be controlled differently. However they all measure
the same thing, and will never be used at the same time, hence I would like
to be able to just call 'measure()' regardless of with device I use.
My idea is (and I am completely new to C#) to make three different static
classes (they don't have to be static, but I plan on using properties for
setting up the devices, so two instances of the same class will be a mess
(also, there is only one physical device pr. class)). These classes will be
called e.g. device1, device2 and device3, and as mentioned they will have
different properties and perhaps some methods for setting up the device.
However they will all have one method called 'measure()'. Setting up the
device will of cause be done by calling the proper class, but how can I
access the 'measure()' method without calling the individual classes (e.g.
device1.measure())? I would like to be able to just call 'measure()' or
'device.measure()' (i.e. without a number).
If I could make an alias for the class I could do something like this:
if (device2 selected) set device = device2
and then just call device.measure() which then would be an alias for
device2.measure()
Of cause I can make a separate method just for choosing which class to call
measure() from, and I will properly just do that, if you guys can't find a
better solution.
Any ideas/suggestions?
Best regards,
Frank