Results 1 to 7 of 7

Thread: Polymorhism

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    Tulsa,Ok
    Posts
    262

    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

  2. #2
    Junior Member
    Join Date
    Mar 2000
    Location
    Louisville, KY
    Posts
    21
    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.

    Shubhabrata De

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    Tulsa,Ok
    Posts
    262
    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:
    1. Public gControl as Object

    then in the program when I control ControlSet1

    VB Code:
    1. Set gControl = new ControlSet1
    2. gControl.MoveLeft

    then in the program when I control ControlSet2

    VB Code:
    1. Set gControl = new ControlSet2
    2. 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?

  4. #4
    Junior Member
    Join Date
    Mar 2000
    Location
    Louisville, KY
    Posts
    21
    Cant You use an interface and Make these CONTROLSETS implement that Interface. So then you can have an object of the interface and at runtime set it to the CONTROLSET you want to use.

    Just some wild ideas....Happens when you have to think of something without knowing it fully...Found your topic interesting, that's why trying to think.


    Shubhabrata De

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    Tulsa,Ok
    Posts
    262
    I figured it out.

    I am using the globally declared object: gSysControl then instantiating it like so.

    VB Code:
    1. 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

  6. #6
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253
    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:
    1. GetPicture()
    2. TurnOn
    3. TurnOff

    You can then create an instantiation of that interface for each individual camera:

    VB Code:
    1. Implements MyCameraInterface
    2.  
    3. MyCameraInterface_GetPicture()
    4.  
    5. etc etc

    This way you can treat all cameras equally, which means less client code, therefore less pain.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    Tulsa,Ok
    Posts
    262
    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
  •  



Click Here to Expand Forum to Full Width