vendredi 20 janvier 2023

What is this kind of interface hierarchy?

Context: The IVI Visa Specification defines a standardized interface for compliant instruments from various vendors. (oszilloscopes, multimeters,...)

From some VB code example I knew I had to do something like this in C#

var resManager = new VisaComLib.ResourceManager();
var io = new BASICFORMATTEDIOLib.FormattedIO488();

IVisaSession session = resManager.Open("some instrument id");
io.IO = (IMessage)session;
io.IO.WriteString("*IDN?");
string ident = io.IO.ReadString(100);

On the last page of the VISA specification I found this image:

enter image description here

Is this just weird design or is there something I'm missing. Is this something necessary for COM? Why would a message extend a session? Is it common practice to return some very basic interface and cast it to whatever extension you might need?

As a beginner I find it weird that a message class would also have to implement a session interface.

Aucun commentaire:

Enregistrer un commentaire