APISynthesisResourcesTutorial2: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
(Created page with '{{DISPLAYTITLE:Synthesis Resources Tutorial}}{{Template:InProgress}}{{Template:API}} <div style="border:1px solid #AAA; background:#f9f9f9; border-radius:10px; width:auto; margin…')
 
(Redirected page to API Tutorials)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Synthesis Resources Tutorial}}{{Template:InProgress}}{{Template:API}}
#REDIRECT [[API_Tutorials]]
<div style="border:1px solid #AAA; background:#f9f9f9; border-radius:10px; width:auto; margin:0 0 1em 1em; padding:1em; float:right;">
<nowiki><<</nowiki> [[APIQuickStartGuide|Back to Quick Start Guide]]
 
'''Synthesis Resources Tutorial'''
#[[APISynthesisResourcesTutorial|Connect to a Synthesis Repository and Project]]
#Create a New Synthesis Resource
#[[APISynthesisResourcesTutorial3|Update an Existing Resource]]
#[[APISynthesisResourcesTutorial4|Calculate Results from a Model]]
</div>
 
Now that we've learned how to connect to a repository and a project, let’s try adding a new model resource to the repository.
 
 
 
 
 
 
 
 
 
 
==Part 2: Create a New Synthesis Resource==
 
1. Create a new module and begin again by connecting to the Synthesis repository and project.
 
'''VBA|VB.NET'''
{{APIComment|'Connect to the Synthesis repository and set project ID#1 as the current project.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr10"}})
  MyRepository.Project.SetCurrentProject(1)
 
2. Use the <code>cModel</code> class to create a 2-parameter Weibull reliability model with beta 1 and eta 100. Name the model, "MyNewModel."
 
For VBA, use the <code>SetModel</code> method to define the model. For VB.NET, use the parameterized constructor to create and define the model.
 
'''VBA '''
{{APIComment|'Declare a new instance of the cModel class.}}
  {{APIPrefix|Dim}} Amodel {{APIPrefix|As New}} cModel
{{APIComment|'Define the model.}}
  {{APIPrefix|Dim}} ModelType {{APIPrefix|As}} ModelTypeEnum
  {{APIPrefix|Dim}} ModelCategory {{APIPrefix|As}} ModelCategoryEnum
  {{APIPrefix|Dim}} ModelName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} ModelParams(1) {{APIPrefix|As}} Double
  ModelType = ModelTypeEnum_Weibull2
  ModelCategory = ModelCategoryEnum_Reliability
  ModelName = {{APIString|"MyNewModel"}}
  ModelParams(0) = 1
  ModelParams(1) = 100
  {{APIPrefix|Call}} AModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)
 
'''VB.NET'''
{{APIComment|'Declare a new instance of the cModel class. You can use an in-line parameter list to define the model.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As New}} cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability, {{APIString|"MyNewModel"}}, 1, 100)
3. Use the <code>AddModel</code> method to save the new model to the repository.
 
'''VBA'''
{{APIComment|'Add the new model to the current project.}}
  {{APIPrefix|Call}} MyRepository.Model.AddModel(AModel)
 
'''VB.NET'''
{{APIComment|'Add the new model to the current project.}}
  MyRepository.Model.AddModel(AModel)
 
===Test the Code===
Below are the VBA and VB.NET code lists for this example. On the Debug menu, click '''Start''' to run the application. Then in the Synthesis repository, open the project’s Resource Manager ('''Project > Synthesis> Resource Manager''') and then select the Models page. A model named "MyNewModel" should be on the list. (You may need to click the '''Refresh''' or '''Show All''' command to update the display.)
 
'''VBA'''
Sub Main()
 
{{APIComment|'Connect to the Synthesis repository and set project ID#1 as the current project.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr10"}})
  MyRepository.Project.SetCurrentProject(1)
{{APIComment|'Declare a new instance of the cModel class.}}
  {{APIPrefix|Dim}} Amodel {{APIPrefix|As New}} cModel
{{APIComment|'Define the model.}}
  {{APIPrefix|Dim}} ModelType {{APIPrefix|As}} ModelTypeEnum
  {{APIPrefix|Dim}} ModelCategory {{APIPrefix|As}} ModelCategoryEnum
  {{APIPrefix|Dim}} ModelName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} ModelParams(1) {{APIPrefix|As}} Double
  ModelType = ModelTypeEnum_Weibull2
  ModelCategory = ModelCategoryEnum_Reliability
  ModelName = {{APIString|"MyNewModel"}}
  ModelParams(0) = 1
  ModelParams(1) = 100
  {{APIPrefix|Call}} AModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)
{{APIComment|'Add the new model to the current project.}}
  {{APIPrefix|Call}} MyRepository.Model.AddModel(AModel)
End Sub
 
'''VB.NET'''
Sub Main()
 
{{APIComment|'Connect to the Synthesis repository and set the first available project in the repository as the active project.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr10"}})
  MyRepository.Project.SetCurrentProject(1)
{{APIComment|'Declare a new instance of the cModel class. You can use an in-line parameter list to define the model.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As New}} cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability, {{APIString|"MyNewModel"}}, 1, 100)
{{APIComment|'Add the new model to the current project.}}
  MyRepository.Model.AddModel(AModel)
End Sub
 
===References===
To learn more, see the reference documentation for the classes and methods discussed in this section:
 
*[[CModel Class|cModel Class]]
*[[CModel.SetModel|cModel.SetModel Method]]
*[[CModel_Constructors|cModel Constructor (VB.NET Only)]]
*[[ModelTypeEnum Enumeration]]
*[[ModelCategoryEnum Enumeration]]
*[[Repository.Model.AddModel|Repository.Model.AddModel Method]]
 
 
 
 
'''<span style="color:#808080;">Next: [[APISynthesisResourcesTutorial3|Update an Existing Resource >>]]</span>'''

Latest revision as of 23:48, 9 February 2016

Redirect to: