Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/11/2013 in all areas

  1. Not used UML myself, but it seems to me that the terminals of a VI are much better specified in this way (not that available UML tools will support this ):
    1 point
  2. Making a new “MoveStrategy” class tree is my first thought also, but another possibility is to create a HysteresisCapableAxis child class that by default has a Move method that just calls the parent method, but that can also enable hysteresis (via some “Enable” boolean). You can then enable or disable hysteresis without changing the class.
    1 point
  3. What you have is that you want to equip an axis instance with a particular algorithm (BasicMove or HandleBacklash) for motion (e.g., Move), and you want to specify that algorithm dynamically without overriding the Axis.move() method, for instance. The Strategy Pattern does just that, by encapsulating algorithms in a separate family. See http://lavag.org/topic/14213-strategy-pattern-example/?hl=%2Bstrategy+%2Bpattern for a LabVIEW discussion and example. Good luck!
    1 point
  4. It may be obvious and you already are doing it, but make sure you are releasing those queue refs you obtain by name or you can create a small but sometimes consequential memory leak. It's bitten me in the past. Mark
    1 point
  5. The only one of these that I'm on board for would be constructors. Although it is possible to create a VI that is called something like "initialize.vi" or even "classname.vi" there is no way to guarantee that someone calls it. They can still just drop a class constant. It's possible to enforce something like this if you use a by reference scheme (using the "Restrict References of this class....." checkbox) but then you're doing things by reference. If there was a checkbox that made it illegal to drop a class constant (except for in the class's methods) on the block diagram, then we'd be able to enforce this rule. Since we're adding OO features, my vote would be for abstract classes, interfaces and final methods/classes (I don't know the generic word for this).
    1 point
  6. I don't remember the error code, but I know I received an error when trying to write an empty array. My solution was to delete everything in the existing array except for the last one.
    1 point
  7. I have an application that contains the following objects: Database.lvclass Signal.lvclass Diagnostic Signal.lvclass Input Signal.lvclass Output Signal.lvclass A "Signal" object array is initially created, but it is possible for an attribute to be added at run-time to these signals which makes the object a more "specific" class (diagnostic/input/output). The class type is specified by an attribute that is set AFTER a signal object is created. The creation of the Signal Object contains a lot of accessors (around 20). Initially I was thinking I could "cast" the Signal Object to a more specific class that would copy the Signal Object data to the appropriate descendant Diganostic/Input/Output Object. However, this will return error: Error 1448 occurred at To More Specific Class in CAN Signal.lvclass:Cast Signal To Type.vi Possible reason(s): LabVIEW: Bad type cast. LabVIEW cannot treat the run-time value of this LabVIEW class as an instance of the given LabVIEW class. According to the information from here, this is not possible and the current procedure for creating a descendant from an ancestor is to use accessors for every possible data item up the chain. However, a LAVA thread posted here seems to state otherwise, except it is an "old" lava post and the example cannot be downloaded! 1. What best procedure for creating a descendant from an ancestor? If more data items are added to the ancestor, is there a technique that will warn/errror if the descendant creator does not include? I have attached my initial attempt that has caused the Error 1448. Any help would be appreciated!
    1 point
  8. Thanks for the example. I completely understand that creating a manual "constructor" to "deep copy" the parent to child is possible. I see two issues with this approach: 1. For objects of large size and multiple inheritance, a lot of manual work will be required to create the CopyParentToChild method. 2. There is no error checking if new private data is added to any objects in the inheritance chain. My main concern would be issue #2 stated above. It would be great if there was some method of "flagging" that I want to make sure ALL data from ancestors is copied. Any ideas on how this could be done?
    1 point
  9. No can do. Once you create a Signal object it will forever be a Signal object. You can't downcast a parent object into a child object--it opens the door to too many problems. (Here's a post from AQ with some more details.) I can't say this is the best procedure, but it's how I've solved the problem in the past. Create a child class with the attributes you want. The parent data in the child class will all be set to the default values. Then copy the parent data from the existing parent object into the new child object's parent data. I've attached an example using 2010. DowncastingObjects.zip
    1 point
×
×
  • Create New...

Important Information

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