CModel.SetUseStress: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:cModel.SetUseStress}}
{{DISPLAYTITLE:cModel.SetUseStress}}{{Template:API}}{{Template:APIBreadcrumb|.[[CModel Class|cModel]]}}
{{Template:APIClass|CModel Class|CModel}}  
Sets use stress value for a particular stress.
== Method Syntax ==
{{APIName|SetUseStress}}
{{APIPrefix|( ByVal}}
{{APIName|Index}}
{{APIPrefix|As Integer,}}
{{APIPrefix|ByVal}}
{{APIName|StressValue}}
{{APIPrefix|As Double}}
{{APIName|)}}<br>
{{APIComment|Sets use stress value for a particular stress.}}


{{APIName|SetUseStress}}
{{APIPrefix|( ByVal}}
{{APIName|StressValues()}}
{{APIPrefix|As Double}}
{{APIName|)}}<br>
{{APIComment|Sets use stress value for a particular stress.}}


== Parameters ==
<onlyinclude>For ALTA models only. Specifies the use stress level(s) to use for calculations.</onlyinclude>
'''Index'''
{{APIComment|The 0-based index of the Stress of which to update the Use Stress.}}


'''StressValue'''
== Syntax ==
{{APIComment|The UseStress to update.}}


'''StressValues'''
'''VBA'''
{{APIComment|An array of UseStresses that correspond to the array of Stresses in the model.}}
 
'''.SetUseStress'''(''Index'', ''StressValue'')
'''.SetUseStress_2'''(''StressValues()'')


== Usage Example ==
'''VB.NET'''
{{APIComment|Declare a new repository connection class.}}
        Private WithEvents MyRepository As New Repository
'''.SetUseStress'''(''Index'', ''StressValue'')
'''.SetUseStress'''(''StressValues()'')
===Parameters===
''Index''
:Required. Integer. The 0-based index of the stress (e.g., the first stress in the model has an index = 0, the second stress has an index = 1, etc.).


{{APIComment|Connect to the Synthesis repository.}}
''StressValue''
        Dim Success As Boolean = False
:Required. Double. The value to use for the use stress level.
        Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")


{{APIComment|Get the list of Projects in the connected repository.}}
''StressValues()''
        Dim ListOfModels() As [[NameIdPair Class|NameIdPair]]
:Required. Double. An array of the use stress values. The order of the elements in the array correspond to the order of the stresses in the model (e.g., the first element of the array defines the use stress value of the first stress in the model, etc.)
        ListOfModels = MyRepository.GetAllModelsInfo()


{{APIComment|Select the ID of the model and retrieve it.}}
        Dim AModel as cModel
        AModel = MyRepository.GetModel(ListOfModels(0).ID)


{{APIComment|Get the number of stresses.  In this example, the first model is used.}}
== Example ==
        Dim MyNumStresses As Integer
This example assumes that an ALTA model with ID #47 exists in project ID #1 of a repository.
        MyNumStresses = AModel.NumStresses


{{APIComment|Create an array and fill Use Stress levels for each of the stresses.  Assume the MyNumStresses in this example is 2.}}
'''VBA'''
        Dim UseStressArray(MyNumStresses - 1) As Double
        UseStressArray(0) = 500
{{APIComment|'Add code to connect to a Synthesis repository.}}
        UseStressArray(1) = 750
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...}}
 
{{APIComment|'Get ALTA model #47 from project #1.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.Project.SetCurrentProject(1) 
  {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(47)
{{APIComment|'Get the number of stresses in the model.}}
  {{APIPrefix|Dim}} MyNumStresses {{APIPrefix|As Integer}}
  MyNumStresses = AModel.NumStresses
   
{{APIComment|'Assume that the number of stresses in this example is 2.}}
{{APIComment|'Set the use stress values for each of the stresses.}}
  {{APIPrefix|Dim}} UseStressArray() {{APIPrefix|As Double}}
  {{APIPrefix|ReDim}} UseStressArray(MyNumStresses)
  UseStressArray(0) = 500
  UseStressArray(1) = 750
{{APIComment|'Set the use stress values for the model. This is intended for calculations}}
{{APIComment|'only; it does not save the changes to the model in the repository.}}
  {{APIPrefix|Call}} AModel.SetUseStress_2(UseStressArray)
{{APIComment|'Calculations using the specified stress values are now possible. For example,}}
{{APIComment|'the following code returns the model's reliability at 100 hrs}}
{{APIComment|'at the specified use stress levels.}}
  {{APIPrefix|Dim}} ResultValue {{APIPrefix|As Double}}
  ResultValue = AModel.Reliability(100)
  MsgBox(ResultValue)


{{APIComment|Set the UseStress for the model.}}
'''VB.NET'''
        AModel.SetUseStress(UseStressArray)
{{APIComment|'Add code to connect to a Synthesis repository.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...}}
 
{{APIComment|'Get ALTA model #47 from project #1.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.Project.SetCurrentProject(1) 
  AModel = MyRepository.Model.GetModel(47)
{{APIComment|'Get the number of stresses in the model.}}
  {{APIPrefix|Dim}} MyNumStresses {{APIPrefix|As Integer}}
  MyNumStresses = AModel.NumStresses
{{APIComment|'Assume that the number of stresses in this example is 2.}}
{{APIComment|'Set the use stress values for each of the stresses.}}
  {{APIPrefix|Dim}} UseStressArray(MyNumStresses-1) {{APIPrefix|As Double}}
  UseStressArray(0) = 500
  UseStressArray(1) = 750
{{APIComment|'Set the use stress values for the model. This is intended for calculations}}
{{APIComment|'only; it does not save the changes to the model in the repository.}}
  AModel.SetUseStress(UseStressArray)
{{APIComment|'Calculations using the specified stress values are now possible. For example,}}
{{APIComment|'the following code returns the model's reliability at 100 hrs}}
{{APIComment|'at the specified use stress levels.}}
  {{APIPrefix|Dim}} ResultValue {{APIPrefix|As Double}}
  ResultValue = AModel.Reliability(100)
  MsgBox(ResultValue)

Latest revision as of 21:17, 13 November 2015

APIWiki.png


Member of: SynthesisAPI.cModel


For ALTA models only. Specifies the use stress level(s) to use for calculations.

Syntax

VBA
  
.SetUseStress(Index, StressValue)
.SetUseStress_2(StressValues())
VB.NET

.SetUseStress(Index, StressValue)
.SetUseStress(StressValues())

Parameters

Index

Required. Integer. The 0-based index of the stress (e.g., the first stress in the model has an index = 0, the second stress has an index = 1, etc.).

StressValue

Required. Double. The value to use for the use stress level.

StressValues()

Required. Double. An array of the use stress values. The order of the elements in the array correspond to the order of the stresses in the model (e.g., the first element of the array defines the use stress value of the first stress in the model, etc.)


Example

This example assumes that an ALTA model with ID #47 exists in project ID #1 of a repository.

VBA

 'Add code to connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  ... 

 
 'Get ALTA model #47 from project #1. 
  Dim AModel As cModel
  MyRepository.Project.SetCurrentProject(1)  
  Set AModel = MyRepository.Model.GetModel(47)

 'Get the number of stresses in the model. 
  Dim MyNumStresses As Integer
  MyNumStresses = AModel.NumStresses 

 'Assume that the number of stresses in this example is 2. 
 'Set the use stress values for each of the stresses. 
  Dim UseStressArray() As Double
  ReDim UseStressArray(MyNumStresses)

  UseStressArray(0) = 500
  UseStressArray(1) = 750

 'Set the use stress values for the model. This is intended for calculations 
 'only; it does not save the changes to the model in the repository. 
  Call AModel.SetUseStress_2(UseStressArray)

 'Calculations using the specified stress values are now possible. For example, 
 'the following code returns the model's reliability at 100 hrs 
 'at the specified use stress levels. 
  Dim ResultValue As Double
  ResultValue = AModel.Reliability(100)
  MsgBox(ResultValue)
VB.NET

 'Add code to connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  ... 

 
 'Get ALTA model #47 from project #1. 
  Dim AModel As cModel
  MyRepository.Project.SetCurrentProject(1)  
  AModel = MyRepository.Model.GetModel(47)

 'Get the number of stresses in the model. 
  Dim MyNumStresses As Integer
  MyNumStresses = AModel.NumStresses 

 'Assume that the number of stresses in this example is 2. 
 'Set the use stress values for each of the stresses. 
  Dim UseStressArray(MyNumStresses-1) As Double

  UseStressArray(0) = 500
  UseStressArray(1) = 750

 'Set the use stress values for the model. This is intended for calculations 
 'only; it does not save the changes to the model in the repository. 
  AModel.SetUseStress(UseStressArray)

 'Calculations using the specified stress values are now possible. For example, 
 'the following code returns the model's reliability at 100 hrs 
 'at the specified use stress levels. 
  Dim ResultValue As Double
  ResultValue = AModel.Reliability(100)
  MsgBox(ResultValue)