Wednesday, November 19, 2008

SEQOOP Implementation Details



Organization on Disk

With LabVIEW 8.x the LabVIEW Project can be used to designate folders as public or private. That feature is not available in LabVIEW 7.x, so the software developer must keep VI’s organized in folders. A basic rule is that every class gets a separate folder. The main folder of the class might contain demonstration or test VI’s used to demonstrate how to use the class or to test the functionality of the class. It might also contain a Catalog VI that presents the VI’s of the class in an organized manner, as below.



Below is an example of a folder structure. Note that there are public and private folders.






Public Methods

The Public folder contains VI’s that are intended to be used in an application. Examples would be Set Voltage_PowerSupply.vi, Set Current Limit_PowerSupply.vi, Output On_PowerSupply.vi. Examples of method VI’s for a base class are below.








Private Methods

The Private folder contains VI’s that are only intended to be accessed by VI’s of the class, and not by other VI’s or classes. An example would be a VI for data storage class that converted a tab-delimited text file to an XML file. The VI might be called Tab-Text to XML_DataStorage.vi.

Data Access VI’s

A sub-folder usually present in the Private folder is a folder named Internals. It usually contains three VI’s that other VI’s of the class use to access data. Names of these VI’s would be similar to Get Data_PowerSupply.vi, Get Data To Modify_PowerSupply.vi, and Set Modified Data_PowerSupply.vi. Examples of Data Access VI’s are below. Every time Get Data to Modify_PowerSupply.vi is run it should be followed with Set Modified Data_PowerSupply.vi. Be aware that the data is locked and not accessible by other VI’s until Set Modified Data_PowerSupply.vi is run.



The Data Component

A sub-folder of the Internals folder is the Data Component folder. It contains a VI similar to Data Component_PowerSupply.vi. It also contains a typedef that is used as a constant to control the action the Data Component takes when run. The typedef would have a name similar to Data Component Action_PowerSupply.ctl. The data access VI’s wrap this component to handle data access.

The data that is being accessed is the data contained in the queue. The data type is the type of “cluster of class private data.” This is the data for the PowerSupply class.

The Data Component extracts the class name contained within the object ID from the object reference and compares it to a constant that is the same as the name of the class. In this case it is the PowerSupply class. If the class name is not found within the object ID, an error is generated.

The Data Component has five cases, corresponding to the settings of the Action control. The first case is Create. The Create case creates a named single element queue. The name of the queue is the object ID. The data type of the queue is the data type of the “cluster of class private data” input. The Create case then enqueues an element to set the initial value of the data.


The next case is the Get Data case. It previews the queue element. This allows the data to be read without removing it from the queue, so the data values in the queue are unaffected.




The next case is the Get Data to Modify case. It removes an element from the queue. Since this is a single element queue, the data is unavailable until it is again enqueued using the Set Modified Data case. We have a mutex without having to use a semaphore or other protection.


The Set Modified Data case enqueues the data. The data is again available .


The last case is Destroy. It releases the queue reference.


Object References
The object reference is a cluster made up of two components, Object ID and Class Data Type.

Object ID

The Object Id is a string. An example of the string for a base class would be: “PowerSupply:123456”. The string contains the name of the class, in this case the PowerSupply class, and a numerical portion that is uniquely generated each time a “Create” VI is run.

An example for an Object ID string for a class with two levels of inheritance would be: N6700:234567ProgrammablePowerSupply:345678PowerSupply:456789

The Object ID string is parsed by the Data Component to determine if it contains a valid reference to the class that the Data Component is a member of.

Class Data Type

The class data type is typedef that is a Datalog control containing an Enum control. The Enum is set to the name of the class. A Datalog control is the only way to make a unique data type in LabVIEW. Including this gives the object reference control a unique data type, which prevents inadvertently wiring VI’s from different classes together. Note in the example below that we get a broken wire when an object reference from the ATEConfig class is wired to a VI from the ConfigStorage class.



Creative Commons License
LabviewGeek Blog by C. Allen Weekley is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Permissions beyond the scope of this license may be available at http://www.weekleysystems.com/.

No comments: