|
-
Sep 17th, 2003, 11:16 AM
#1
Thread Starter
Hyperactive Member
Polymorhism
Got a question and I hope get an answer other than what I expect.
I am re-writing an application I wrote a few years ago and as always I am thinking, why in the world did I do it like this. I know we all have been there.
Anyway, the program controls remote cameras through the comm ports and I have created several dll's to help me accomplish this. Over the past few years, we have added new cameras and different ways of controlling them so the dll has grown with its class files. Currently there are 5 class files in the dll.
I would like to be able to have one global variable the use this as the means to interface with the dll. I currently cant get it work like I want it to and I dont want to have to declare 5 global variables just to be able to run everything.
Thanks in advance for your help,
Jerel
-
Sep 17th, 2003, 12:40 PM
#2
Junior Member
Hi Jeryl !
As far as i can understand your problem, you want to have one global object to interface with all the cameras. Now if it is not much of an effort, then you can add a CONTROLLER class to your scheme of designs. The CAMERA objects would be a (private) collection inside this class. You can have an ADDCAMERA Member to CONTROLLER Class, to add cameras when ever you require one. The CONTROLLER Class can then expose methods that take the CAMERA_ID and the action to be performed on it.
So if a member of the CONTROLLER class can be
ROTATE(CAMERA_ID)
and the collection of CAMERA objects are in a collection M_COLCAMERAS
Then you can within the CONTROLLER class's ROTATE method say something like
M_COLCAMERAS.ITEM(CAMERA_ID).ROTATE
Just thinking wild.
The CAMERA_ID would have to come from the UI that you give for controlling the APPLICATION.
-
Sep 17th, 2003, 12:58 PM
#3
Thread Starter
Hyperactive Member
I think I see where you are going but the dll file contains 5 classes that are all unique with there own control sets.
So I have say
ControlSet1
ControlSet2
etc.
I want to be able to do this
in a module
VB Code:
Public gControl as Object
then in the program when I control ControlSet1
VB Code:
Set gControl = new ControlSet1
gControl.MoveLeft
then in the program when I control ControlSet2
VB Code:
Set gControl = new ControlSet2
gControl.MoveLeft
That way the code reads the same and the only thing that is changing is the way the commands are sent to the camera.
Does that make sense?
-
Sep 17th, 2003, 01:06 PM
#4
Junior Member
-
Sep 17th, 2003, 04:19 PM
#5
Thread Starter
Hyperactive Member
I figured it out.
I am using the globally declared object: gSysControl then instantiating it like so.
VB Code:
Set gSysControl = CreateObject("prjmsrcdll.IStandardCam")
I had to search the registry to find the library code name then late bind it so I can only use one variable to access all 5 control sets.
Glad I got one figured out.
Jerel
-
Sep 19th, 2003, 10:07 AM
#6
Frenzied Member
Maybe you could do it another way:
Say you declare an interface with all of the methods on which you want to control a camera (an abstraction, not a physical reality)
So, you might have
VB Code:
GetPicture()
TurnOn
TurnOff
You can then create an instantiation of that interface for each individual camera:
VB Code:
Implements MyCameraInterface
MyCameraInterface_GetPicture()
etc etc
This way you can treat all cameras equally, which means less client code, therefore less pain.
-
Sep 19th, 2003, 10:13 AM
#7
Thread Starter
Hyperactive Member
That is something I can look into. I am still in the baby stages of coding so its not to late to change.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|