LV User Posted March 20, 2012 Report Share Posted March 20, 2012 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 Quote Link to comment
jgcode Posted March 20, 2012 Report Share Posted March 20, 2012 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. Quote Link to comment
LV User Posted March 20, 2012 Author Report Share Posted March 20, 2012 Thanks, Now if I have to add a UI to be able to configure this configuration what is the best way to do it. Quote Link to comment
Ian Posted March 21, 2012 Report Share Posted March 21, 2012 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 1 Quote Link to comment
Daklu Posted March 22, 2012 Report Share Posted March 22, 2012 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.