User:Kate Racaza/test page

From ReliaWiki
Revision as of 22:25, 23 June 2016 by Kate Racaza (talk | contribs)
Jump to navigation Jump to search

DRAFT

VBA versions of the new tutorials.


Upload XML File to XFRACAS

VBA

Sub Main()

  'Connect to the Synthesis enterprise repository. 
   Dim MyRepository As New Repository
   Call MyRepository.ConnectToSQLRepository("ServerName", "DatabaseName") 'Replace with values for test repository. 

  'Get a list of all available XFRACAS entities. 
   Dim ListOfEntities() As NameIdPair
   ListOfEntities = MyRepository.XFRACAS.GetAllXfracasEntities

  'Select an XFRACAS entity. This example gets the first available entity in the array. 
   Dim EntityID As Integer
   EntityID = ListOfEntities(0).ID

  'Upload the XML file to the import queue of the XFRACAS entity. This code assumes that an XML file  
  'called XMLData.xml contains XFRACAS incidents and is saved in the C drive. 
   Dim j As Integer
   j = MyRepository.XFRACAS.ImportXfracasXmlFile(EntityID, XFRACASImportType_Incident, "C:\XMLData.xml", "My new data")
 
End Sub


Perform Life Data Analysis on External Data Source

VBA

Sub Main()

  'Declare a new WeibullDataSet object.  
   Dim WDS As New WeibullDataSet
  
  'Add the failure times to the data set. 
   Call WDS.AddFailure(16, 1)
   Call WDS.AddFailure(34, 1)
   Call WDS.AddFailure(53, 1)  
   Call WDS.AddFailure(75, 1)
   Call WDS.AddFailure(93, 1)
  
  'Add the suspensions to the data set. 
   Call WDS.AddSuspension(120, 5)   

  'Use the 2-parameter Weibull distribution and the rank regression on X (RRX) analysis method. 
  'Keep all other analysis settings at default. 
   WDS.AnalysisSettings.Distribution = WeibullSolverDistribution_Weibull
   WDS.AnalysisSettings.Parameters = WeibullSolverNumParameters_MS_2Parameter
   WDS.AnalysisSettings.Analysis = WeibullSolverMethod_RRX
 
  'Analyze the data set. 
   Call WDS.Calculate()

  'Calculate the probability of failure at 226 hrs and display the result. 
   Dim r As Double
   r = WDS.FittedModel.unreliability(226)
   MsgBox("Prob. Fail: " & r)

End Sub


Perform Accelerated Life Testing Data Analysis on External Data Source

VBA

Sub Main()

  'Declare a new ALTADataSet object.  
   Dim ADS As New ALTADataSet

  'Define a stress type with use stress level = 300.  
   Call ADS.AddStressDefinition("Stress1",,300)

  'Add the failure times to the data set. 
   Call ADS.AddFailure_2(245, 1, 353)
   Call ADS.AddFailure_2(110, 1, 373)
   Call ADS.AddFailure_2(180, 1, 373)  
   Call ADS.AddFailure_2(200, 1, 373)
   Call ADS.AddFailure_2(50, 1, 393)
   Call ADS.AddFailure_2(70, 1, 393)
   Call ADS.AddFailure_2(88, 1, 393)
   Call ADS.AddFailure_2(112, 1, 393)
   Call ADS.AddFailure_2(140, 1, 393)
   Call ADS.AddFailure_2(160, 1, 393)
   
  'Add the suspensions to the data set. 
   Call ADS.AddSuspension_2(250, 5, 353)   
   Call ADS.AddSuspension_2(250, 3, 373) 
 
  'Use the Arrhenius-Weibull model. Keep all other analysis settings at default. 
   ADS.AnalysisSettings.ModelType = ALTASolverModel_Arrhenius
   ADS.AnalysisSettings.Distribution = ALTASolverDistribution_Weibull
 
  'Analyze the data set. 
   Call ADS.Calculate()

  'Calculate the B10 life and display the result. 
   Dim r As Double
   r = ADS.FittedModel.Time(.90)
   MsgBox("B10 Life: " & r)

End Sub


Perform Accelerated Life Testing Data Analysis with Stress Profiles

VBA

Sub Main()
 
  'Declare a new stress profile and define its segments.  
   Dim sp As New ALTAStressProfile
   Call sp.AddSegment(200, 125) 
   Call sp.AddSegment(300, 175)
   Call sp.AddSegment(350, 200)
   Call sp.AddSegment(375, 250)
   sp.RepeatCycle = False

  'Declare a new ALTADataSet object.  
   Dim ADS As New ALTADataSet

  'Assign the stress profile to the data set.  
   Call ADS.AddStressProfile(sp)

  'The stress profile uses the logarithmic (power LSR) stress transformation 
  'and has a use stress level = 100.  
   Call ADS.AddStressDefinition("Stress1", ALTASolverLSR_Power, 100)
 
  'Add the failure times to the data set. 
   Call ADS.AddFailure_2(252, 1, sp)
   Call ADS.AddFailure_2(280, 1, sp)
   Call ADS.AddFailure_2(320, 1, sp)
   Call ADS.AddFailure_2(335, 1, sp)
   Call ADS.AddFailure_2(354, 1, sp)
   Call ADS.AddFailure_2(361, 1, sp)
   Call ADS.AddFailure_2(362, 1, sp)
   Call ADS.AddFailure_2(368, 1, sp)
   
  'Add the suspensions to the data set. 
   Call ADS.AddSuspension_2(328, 1, sp)   
   Call ADS.AddSuspension_2(375, 3, sp) 
 
  'Use the cumulative damage - Weibull model to analyze the data set. 
  'Keep all other analysis settings at default. 
   ADS.AnalysisSettings.ModelType = ALTASolverModel_CumDamage
   ADS.AnalysisSettings.Distribution = ALTASolverDistribution_Weibull
 
  'Analyze the data set. 
   Call ADS.Calculate()

  'Calculate the B1 life and display the result. 
   Dim r As Double
   r = ADS.FittedModel.Time(.99)
   MsgBox("B1 Life: " & r)

End Sub

Create Plots

VBA

Sub Main()

  'Create a Weibull++ data set.  
   Dim WDS As New WeibullDataSet
   Call WDS.AddFailure(16, 1)
   Call WDS.AddFailure(34, 1)
   Call WDS.AddFailure(53, 1)  
   Call WDS.AddFailure(75, 1)
   Call WDS.AddFailure(93, 1)
   Call WDS.AddSuspension(120, 5)   

  'Analyze the data set using the 2-parameter Weibull distribution and  
  'the RRX analysis method. Keep all other analysis settings at default. 
   WDS.AnalysisSettings.Distribution = WeibullSolverDistribution_Weibull
   WDS.AnalysisSettings.Parameters = WeibullSolverNumParameters_MS_2Parameter
   WDS.AnalysisSettings.Analysis = WeibullSolverMethod_RRX
 
  'Analyze the data set. 
   Call WDS.Calculate()

  'Declare a new WAPlots object. 
   Dim WPlot As New WAPlots

  'Add the analyzed data set to the plot. 
   Call WPlot.AddDataset(WDS)

  'Create a probability plot and display it in an Image control in the current Excel sheet. 
   Image1.Picture = WPlot.CreatePlotVB6(WAPlotType_Probability)

  'Resize the picture (optional). 
   Image1.Height = 600
   Image1.Width = 865
 
End Sub