Top Banner
AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes version 2.0.0.0 of AZInterface
51

AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Mar 11, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

AZInterface:OOP Interfaces in LabVIEWSolution and Implementations

Andrei Zagorodni2019-04-02 Krakow

This presentation describes version 2.0.0.0 of AZInterface

Page 2: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Content

• Interfaces in OOP– multiple inheritance– concept of interface– available solutions– benchmarking

• AZInterfaces– how to– what do we get– how does it work– how to use– pitfalls

• What do we need more?

www.azinterface.net

Page 3: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Common Abstraction Layer: Superclass

Not a real project, of course.

Page 4: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

LabVIEW: Common Superclass

Does it work?

We wish

Page 5: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

LabVIEW: Common Superclass

Does it work?

We wish

Ya, right…

We got

Page 6: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Multiple Inheritance

Page 7: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Interfaces

Interface can be considered as a class without attributes,and with all methods being abstract.

Page 8: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Interface

Available in LabVIEW?

• Interface is a definition class– No code– No data structures– Only empty methods to override– Own data type

Page 9: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Creating GOOP Interface

Two types of interfaces• Why two?

• Because no one of them isstraightforward

Page 10: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

GOOP Interface by Aggregation

Our wish

Page 11: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

GOOP Interface by Aggregation

Our wish

What do we get

Page 12: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

GOOP Interface by VI server

Our wish

Page 13: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

GOOP Interface by VI server

It works! But…Our wishWe get.

There is no interface data type

Page 14: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Interface by VI Server: Service Code

Page 15: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Interface by VI Server: Scripting

Page 16: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Benchmarking

Page 17: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Comparing Different Solutions

?NoToo muchAdditional code

Yes

Good

No

No

Super-slow30000 %

GOOP by VI Server

?BadReadability

?NoCode in VI.lib

?StraightDependency

?YesInterface data type

?OK100 %

Benchmarking:time spent

AZInterfacev.2

GOOP byAggregation

Common superclass (GOOP): Benchmarking 25-30 %

Page 18: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Disclaimer

• What a LabVIEW programmer does when he is not working writingLabVIEW programs?• He writes hobby LabVIEW programs

• AZInterface is a hobby project with all fun andconsequenceswww.azinterface.net

Page 19: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

AZ Interfaces

• LVOOP class is defined as an Interface.– Otherwise it is a class supplied with few specific members.

• Any class can implement such an Interface.• Relationships between classes and Interfaces are defined byCommunity scope. Interface is added in list of Friends of theinterface-implementing class.

– Anyhow, I newer met a developer who used Community scope for anythingbut quick fixes

Page 20: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Create Interface

Page 21: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

New AZInterface

Interface

cast_to_Interface – method automaticallyincluded in BD of corresponding methods ofinterface-implementing classes

read_Object – double-purpose method: providesaccess to original class instance and destroysinterface instance (only if the interface hasreentrant methods).

Page 22: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

New Interface Method: Create

Page 23: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

New Interface Method: FP

• Think about terminal patterntwice.• It will be difficult to alter atlater stages.• As usual in OOP

Page 24: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

New Interface Method: BDmodified when first implemented in a class

Page 25: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Terminal pattern limitation

• Use only 20-connetor terminal patterns in allAZI methods!• Anyhow, using the same pattern through thewhole project is a good practice.• And I hate such a mess.

Page 26: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Apply Interface

Attention!• If you implement interface method but the methodalready exists in the class, the methodsmust havecomplimentary terminal patterns.• There is no build-in protection from errors here(v.2.0.0)!• I believe this issue should be prioritized in nextversion.

Page 27: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Applied Interfaces defined as Friends

Page 28: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Method Implemented in Class

BD is empty

Page 29: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Code of the Interface Methodmodified when first implemented in a class

…But?• Created class method has object terminals of the class• Interface method keeps object cast to LabVIEW Object type• Call By Reference does not support Dynamic Dispatch

Page 30: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Wrapping utility method (“middleman”)

• Belongs to the class (CAN_SIM:util_GUI_cls_show.vi)• Has object terminals of LabVIEW Object type• Invoked by interface method (GUI:how.vi)• Invokes actual class method (CAN_SIM:show.vi)

Transfers call from interfaceto class“Provides” terminals ofnecessary data type

Page 31: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Method cast_to_<interface name>.vi

1. Interface is applied to class– The method is created butbroken so far

Page 32: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Method cast_to_<interface name>.vi

1. Interface is applied to class– The method is created butbroken so far2. First method is implemented

Page 33: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Method cast_to_<interface name>.vi

1. Interface is applied to class– The method is created butbroken so far2. First method is implemented3. Second method isimplemented4. And so on…

Page 34: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Intermediate summary• Interface (INTF.lvclass)– Custom methods– Method read_Object– Utility cast_to_Interface• Class (CLS.lvclass)– Custom methods– Method cast_to_INTF– Utilities util_INTF_cls_MTD

• Utilities must not becustomized– They are automatically created– They are automatically modified– They are automatically includedin the codeBut?! How to use?

Page 35: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Method execution at interface abstraction level

Page 36: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Comparing Different Solutions

SomeNoToo muchAdditional code

Yes

Good

No

No

Super-slow30000 %

GOOP by VI Server

GoodBadReadability

NoNoCode in VI.lib

StraightStraightDependency

YesYesInterface data type

Good20 %

OK100 %

Benchmarking:time spent

AZInterface2.0.0

GOOP byAggregation

Common superclass (GOOP): Benchmarking 25-30 %

Page 37: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Is it it?Not yet

Reentrant VI-s

Real challenge!

Page 38: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

New Reentrant Interface Method: Create

• Shared clone reentrant execution isselected for this method• All corresponding class methods shallhave the same reentrancy setting

– That is good to be frank

Page 39: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Method cast_to_<interface name>.vi

Page 40: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Method cast_to_<interface name>.vi

Page 41: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Interface method read_Object.vi

• If Interface has no reentrantmethods, both cases (Falseand True) contain the samecode.

Page 42: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Interface method read_Object.vi

• If Interface has no reentrantmethods, both cases (Falseand True) contain the samecode.• If Interface has no reentrantmethods, both cases (Falseand True) contain the samecode.• Case True closes referencesto reentrant methods

– Thus read_Object.vi works asdestructor– It MUST be used when theinterface instance is notneeded any more

Page 43: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Reentrant method execution at interface abstraction level

Page 44: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Reentrant method execution at interface abstraction level

We create another copy that must be destroyed

Page 45: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Is it it?Almost

Page 46: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

One more advantage

• You can apply the same Interface within the same project to anytype of class– GOOP4 classes– GOOP3 classes– G# classes– Native LVOOP classes

• This means you can create common abstraction level for anycombination of OOP models

Page 47: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Consistency Tool

• I had presented Consistency tool when we discussedprototype version (v.0.0.0) of AZInterface at CLA-E 2018.• There was no Consistency tool any more in v.1 and v.2.0because there was no need in it.• But probably we need it.• There is Consistency tool in v.2.1.

Page 48: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Consistency Tool

Page 49: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Consistency Tool: Alter terminal pattern of AZI method

Page 50: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

Fix Interface method first and Class methods after

Page 51: AZInterface: OOP Interfaces in LabVIEW · 2019-04-13 · AZInterface: OOP Interfaces in LabVIEW Solution and Implementations Andrei Zagorodni 2019-04-02 Krakow This presentation describes

It is itThank you!

www.azinterface.net