IMateriaClientAdapter Interface

Interface to be implemented by the adapter class used for Materia-TS integration. Note: Dispose method should be called on app shutdown to disconnect and clean up the states

Namespace:  Tekla.Structures.TeklaStructuresInternal.MateriaClient
Assembly:  Tekla.Structures (in Tekla.Structures.dll) Version: 2023.0.3
Syntax
public interface IMateriaClientAdapter : IDisposable

The IMateriaClientAdapter type exposes the following members.

Methods
  NameDescription
Public methodConnect
Tries to connect to the Materia server. Note: this method must be called from the UI thread
Public methodDisconnect
Disconnect from Materia server
Public methodIsConnectionActive
Returns the value whether connection to Materia server is active or not.
Public methodLoadGraph(Asset)
Loads the graph corresponding to the specified uri and retrieves it's GUID
Public methodLoadGraph(Asset, ListGraphParameter)
Loads the graph corresponding to the specified uri providing the explicit parameter values and retrieves it's GUID
Public methodSearchAssets
Searches for materia assets by name and retrieves a list of asset names and guids.
Top
Events
  NameDescription
Public eventConnectionChanged
Event for notifying about connection changes
Top
Examples
The following example shows how to use the IMateriaClientAdapter functionalities
using System;
using Tekla.Structures.TeklaStructuresInternal.MateriaClient;

public class MateriaClientAdapterExample
{
   // Checks if the connection is active and if not, connects to Materia sever
   public async void ConnectToMateria()
   {
       var materiaClientAdapter = MateriaClientAdapter.Instance;
       if (!materiaClientAdapter.IsConnectionActive())
       {
           // set up the event to be called once the connection changed notification gets called
           materiaClientAdapter.ConnectionChanged += this.MateriaClientAdapter_ConnectionChanged;
           await materiaClientAdapter.Connect();
       }
   }

   private void MateriaClientAdapter_ConnectionChanged(object sender, ConnectionChangedEventArgs e)
   {
       if (e.Connected and !e.Busy)
       {
           // the connection is successful
       }
   }

   // Loads the graph using the default values for the parameters
   public async void LoadValveGraph()
   {
       var asset = new Asset { Uri = "whp:c9021c17-e077-4315-a683-9a1c3bc5b6b5" }; /* Tekla MEP - Globe Valve */
       var graph = await materiaClientAdapter.LoadGraph(asset);

       if (graph == null)
       {
           return;
       }
   }

   // Loads the graph using the specified values for the parameters
   public async void LoadValveGraphWithKnownParameters()
   {
       var asset = new Asset { Uri = "whp:c9021c17-e077-4315-a683-9a1c3bc5b6b5" }; /* Tekla MEP - Globe Valve */
       // List of parameters (key-value)  <seealso cref="T:Tekla.Structures.TeklaStructuresInternal.MateriaClient.GraphParameter" />
       var parameters = GetParameters();

       var graph = await materiaClientAdapter.LoadGraph(asset, parameters);

       if (graph == null)
       {
           return;
       }
   }

   // Retrieves the list of the assets using the specified string
   public async void SearchAsset()
   {
       var AssetList = await materiaClientAdapter.SearchAssets("Valve");
   }
}
See Also

Reference

Tekla.Structures.TeklaStructuresInternal.MateriaClientIMateriaClientAdapter
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next