FW: connection between reference-ports

GME GME
Wed Dec 10 19:47:40 CST 2003



----------
From: 	Feng Shi
Sent: 	Wednesday, December 10, 2003 1:47:39 PM
To: 	GME Group
Subject: 	RE: connection between reference-ports
Auto forwarded by a Rule

Sandeep,

 

I just read your mail and recalled that I had such similar problem before and Peter helped me to write a piece of code which can make the connection between reference ports. Thanks God that I can retrieve it from the VSS history. Here is the code and how to use it, hope it could give you some help.

 

bool CInvoke::UpdateSubscribe(CBuilderObject *pubPort,CBuilderModel *eventType, CBuilderConnection *subscribe)

{ 

      CBuilderObject *subPort = subscribe->GetDestination();

      CComponentType *subCom = GetComponent(subPort);

 

      const CBuilderModel *sprocessor = GetProcess(subCom)->GetParent();

 

      if(sprocessor!= receptacleProcess->GetParent()) return false;

      

      CBuilderModelReference *subCom_ref = NULL;

      CBuilderModelReference *event_ref = NULL;

      

      if(!shortcutMap.Lookup(eventType, event_ref))

      {

            event_ref = MakeNewEventChRef(eventType);

            shortcutMap[eventType] = event_ref;

      }

      if(!shortcutMap.Lookup(subCom, subCom_ref))     return false;

 

      MakeNewConnection("Subscribe",event_ref,subCom_ref,eventType,subPort);

      return true;

}

 

template<class SrcCls, class DstCls> 

void CInvoke::MakeNewConnection(CString connType, SrcCls *srcObj, DstCls *dstObj, CBuilderObject *srcPort,CBuilderObject *dstPort)

{

      CComPtr<IMgaSimpleConnection> mgaConn;

      CComPtr<IMgaFCOs> srcrefs, dstrefs;

 

      srcrefs.CoCreateInstance(OLESTR("Mga.MgaFCOs"));

      dstrefs.CoCreateInstance(OLESTR("Mga.MgaFCOs"));

      COMTHROW(srcrefs->Append(srcObj->GetIObject()));

      COMTHROW(dstrefs->Append(dstObj->GetIObject()));

 

      CComPtr <IMgaModel> mgaIM = newIM->GetIModel();

      CComPtr <IMgaMetaModel> metaIM;

      COMTHROW(newIM->GetMeta().QueryInterface(&metaIM));

      CComBSTR connMetaName(connType);

      CComPtr <IMgaMetaRole> metaConnRole;

      COMTHROW(metaIM->get_RoleByName(connMetaName, &metaConnRole));

      CComPtr<IMgaFCO> mgaSimpleConn;

      COMTHROW(mgaIM->CreateSimpleConn(metaConnRole, srcPort->GetIObject(),

                        dstPort->GetIObject(), srcrefs, dstrefs, &mgaSimpleConn));

}

 

Feng

 

-----Original Message-----
From: GME Group 
Sent: Wednesday, December 10, 2003 1:29 PM
To: GME List
Subject: FW: connection between reference-ports

 

 

>

>----------

>From:      Sandeep Neema

>Sent:      Wednesday, December 10, 2003 1:29:08 PM

>To: GME Group

>Subject:   RE: connection between reference-ports

>Auto forwarded by a Rule

>

Thanks Endre, 

I traced thru the CreateNewConnection function, and what I could tell was that a call to CreateCollection (which is a function on the IFCO interface) was not doing what it should have done, even though the result reported was success. I could not quite figure out how else to create such a collection. I looked in your code and saw that you use "CreateInstance" function, however there is no such function for the CComPtr class which BON uses.

 

Anyhow for the time-being I fixed my problem by using instances, instead of references, since no brave GME soul responded till yet.

 

Thanks

Sandeep

 

--

Sandeep Neema

Research Scientist,

Institute of Software Integrated Systems, Vanderbilt University

Phone: 615-343-9996

Email: sandeep.k.neema at vanderbilt.edu

 

-----Original Message-----

From: GME Group 

Sent: Wednesday, December 10, 2003 12:09 PM

To: GME List

Subject: FW: connection between reference-ports

 

 

>

>----------

>From:      Endre Magyari

>Sent:      Wednesday, December 10, 2003 12:11:04 PM

>To: GME Group

>Subject:   Re: FW: connection between reference-ports

>Auto forwarded by a Rule

>

>

>

I had this problem with UDM,I think the connection itself is between 

atoms/models and when setting up the connection you have to provide the 

list of reference ports, through the connection is established.

 

I have the following code snipplet in UDM:

 

IMgaSimpleConnectionPtr conn; //the connection

IMgaFCOsPtr src_references;         //the list of references through the 

connecting source

IMgaFCOsPtr dst_references;         //the list of references through the 

connecting destination

 

COMTHROW(conn->SetSrc(src_references, self));

COMTHROW(conn->SetDst(dst_references, self));

 

 

This is not BON code, but that should be similar.

 

 

Hope this helps,

Endre

 

 

 

On Wed, 10 Dec 2003 07:22:36 -0600, GME Group 

<gmegroup at isis.vanderbilt.edu> wrote:

 

>

>

> ----------

>

> From: Sandeep Neema

> Sent: Wednesday, December 10, 2003 7:22:36 AM

> To: GME Group

> Subject: connection between reference-ports

> Auto forwarded by a Rule

>

> Gentlemen,

>

> I am trying to use BON to create a new connection between ports of two 

> model

> references. I retreive the CBuilderReferencePort object from my two

> BuilderModelReference-s, and pass that to the CreateNewConnection 

> function.

> However, it seems to not want to do it. The error code is the following:

>

> [helpstring("%o is not in a connectible position")]

> E_MGA_NOT_CONNECTIBLE = 0x87650146,

>

> I know for sure that the connection that I am trying to make is legal as 

> per the

> meta. Any thoughts on this, any one encountered this situation before?

>

> Pl. do le me know.

>

> Thanks,

>

> Sandeep

>

 

 




More information about the gme-users mailing list