Jump to content

Object Oriented design Help


Recommended Posts

I am new to object oriented and I am interested in learning it. I have a problem that I am not sure what is the best way to solve in OOP design. For my test I use a Scope. I create a class called Scope and define the data type of my base class as Address, Set Horizontal settings. I will now create a inherited class from my base class for Model 1. The Model one is having the class datatype as my base class so I create overriding VIs that will let me set the values for Address and Set Horizontal Settings. 3 weeks later, customer wants to change the power supply from Model 1 to model 2. This model now has a new configuration called, Channel Range. I have written all my test code using the base class. Now my software has to support both my Model 1 and Model 2 at any time. What is the best way to handle this? Is there a simple way to add new configuration without much changes to my Test code that uses my base class. At any time I need to be able to swap between Model 1 and Model 2.

The ways that I can think of are, In test code have a Case statement for just Model specific settings and where ever base class is applicable use the base VIs. I am not sure if it is the best way to do it.

Thanks in advance

Link to comment

I am new to object oriented and I am interested in learning it. I have a problem that I am not sure what is the best way to solve in OOP design. For my test I use a Scope. I create a class called Scope and define the data type of my base class as Address, Set Horizontal settings. I will now create a inherited class from my base class for Model 1. The Model one is having the class datatype as my base class so I create overriding VIs that will let me set the values for Address and Set Horizontal Settings. 3 weeks later, customer wants to change the power supply from Model 1 to model 2. This model now has a new configuration called, Channel Range. I have written all my test code using the base class. Now my software has to support both my Model 1 and Model 2 at any time. What is the best way to handle this? Is there a simple way to add new configuration without much changes to my Test code that uses my base class. At any time I need to be able to swap between Model 1 and Model 2.

The ways that I can think of are, In test code have a Case statement for just Model specific settings and where ever base class is applicable use the base VIs. I am not sure if it is the best way to do it.

Thanks in advance

If your instruments differ in configuration settings, but behave similarly (?) then the following may help:

  • You could use a case structure, but if I do this with LVOOP, I usually think I am doing something wrong or I could do it better.
  • Load the configuration information from disk, internal to a class. Have a method that e.g. accepts a path which loads config info and updates that instance's data. The file structure can be different for each Model.
  • Have a configuration object as a data member of the Scope class. Create accessors for the configuration object. This config object would have children for Model 1 and 2 that would contain the correct data for that Model (and the base config class could contain shared settings). You would need to upcast to the correct configuration class when you use it inside each Model but that shouldn't be a big deal. This will separate your config stuff from your how your instrument actually works which can be handy.
  • I am sure there are other ways to implement this too.

Link to comment

I have also just started to learn LVOOP. You might find this of particular interest with regard to implementing classes for different instruments:

1) http://zone.ni.com/devzone/cda/epd/p/id/6307 (This is a good white paper and provides examples similar to what I think you are trying to implement).

2) http://vishots.com/hardware-emulation-using-labview-classes/

3) http://vishots.com/005-visv-labview-class-factory-pattern/

Also the following provide additional resource:

1) http://zone.ni.com/wv/app/doc/p/id/wv-1766

2) http://zone.ni.com/wv/app/doc/p/id/wv-2003

3) https://decibel.ni.com/content/docs/DOC-15014

4) http://zone.ni.com/wv/app/doc/p/id/wv-2820/nextonly/y

1 and 2 provide a very good overview if you are just getting started with LVOOP, 3 and 4 start getting quite involved.

I hope this helps

Ian

  • Like 1
Link to comment

Now my software has to support both my Model 1 and Model 2 at any time. What is the best way to handle this? Is there a simple way to add new configuration without much changes to my Test code that uses my base class. At any time I need to be able to swap between Model 1 and Model 2.

The root of your problem is your scope abstraction layer api is too specific. Your main application code shouldn't be setting specific configuration options. You need to break it down into larger steps as described in the Hardware Abstraction Layer white paper Ian linked to.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.