Repository.Model.GetAllModelsInfo: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
Line 7: Line 7:
== Usage Example ==
== Usage Example ==
<div style="margin-right: 150px;">
<div style="margin-right: 150px;">
In this usage example, the API is used to connect to a repository, retrieve one of the models in it and then calculate the reliability at a specified time, based on that model.
  {{APIComment|'Declare a new repository connection class.}}
  {{APIComment|'Declare a new repository connection class.}}
   Dim MyRepository As New Repository
   Dim MyRepository As New Repository
    
    
  {{APIComment|'Connect to the Synthesis repository.}}
  {{APIComment|'Connect to a Synthesis repository.}}
   Dim Success As Boolean = False
   Dim Success As Boolean = False
   Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
   Success = MyRepository.ConnectToRepository("C:\Users\Name\Documents\ReliaSoft\Files\repository.rsr9")
    
    
  {{APIComment|'Get the list of Models in the connected repository.}}
  {{APIComment|'Get a list of the names/IDs of projects in the connected repository.}}
   Dim ListOfModels() As [[NameIdPair Class|NameIdPair]]
   Dim ListOfProjects() As NameIdPair
  ListOfProjects = MyRepository.GetAllProjects
 
{{APIComment|'Open the first project in the list.}}
  MyRepository.SetCurrentProject(ListOfProjects(0).ID)
 
{{APIComment|'Get a list of the names/IDs of models in the current project.}}
  Dim ListOfModels() As NameIdPair
   ListOfModels = MyRepository.GetAllModelsInfo()
   ListOfModels = MyRepository.GetAllModelsInfo()
 
{{APIComment|'Retrieve the first model in the list.}}
  Dim AModel as cModel
  AModel = MyRepository.GetModel(ListOfModels(0).ID)
 
{{APIComment|'Calculate the reliability at time &#61; 50 and save the result. See [[CModel.Reliability|Reliability]].}}
  Dim Rel as Double
  Rel = AModel.Reliability(50)
 
{{APIComment|'Disconnect from the repository.}}
  MyRepository.DisconnectFromRepository


</div>
</div>

Revision as of 20:06, 27 May 2014


Returns an array containing all model names and their IDs from the current project.

Syntax

Usage Example

In this usage example, the API is used to connect to a repository, retrieve one of the models in it and then calculate the reliability at a specified time, based on that model.

 'Declare a new repository connection class. 
 Dim MyRepository As New Repository
 
 'Connect to a Synthesis repository. 
 Dim Success As Boolean = False
 Success = MyRepository.ConnectToRepository("C:\Users\Name\Documents\ReliaSoft\Files\repository.rsr9")
 
 'Get a list of the names/IDs of projects in the connected repository. 
 Dim ListOfProjects() As NameIdPair
 ListOfProjects = MyRepository.GetAllProjects 
 
 'Open the first project in the list. 
 MyRepository.SetCurrentProject(ListOfProjects(0).ID)
 
 'Get a list of the names/IDs of models in the current project. 
 Dim ListOfModels() As NameIdPair
 ListOfModels = MyRepository.GetAllModelsInfo()
 
 'Retrieve the first model in the list. 
 Dim AModel as cModel
 AModel = MyRepository.GetModel(ListOfModels(0).ID)
 
 'Calculate the reliability at time = 50 and save the result. See Reliability. 
 Dim Rel as Double
 Rel = AModel.Reliability(50)
 
 'Disconnect from the repository. 
 MyRepository.DisconnectFromRepository