ReliaSoft API Reference: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
 
(103 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Template:API|Version 9}}
{{Template:API}}


The Synthesis API can be used to accomplish many of the same tasks as within Synthesis applications, and it also enables seamless integration of the Synthesis Platform with other systems within your organization - all through a programmer's own custom-developed code. This gives you access to more customizable and automated solution to reliability engineering problems.
<div style="border:1px solid #D0CDE8; background:#EEEDF7; border-radius:10px; width:auto; margin:0 0 1em 1em; padding:1em; float:right;">
*'''[[API Changelog|Changelog]]'''
*'''[[API Reference Documentation|API Documentation]]
*'''[[API Tutorials|Tutorials]]
</div>


This reference describes all of the programming elements in the API. The sample code and documentation have been prepared for the Microsoft Visual Studio 2010 (Visual Basic and .NET) development environment, and it is assumed that the reader is familiar with programming in that environment.
The ReliaSoft ''Application Programming Interface'' (API) enables you to programmatically read and write data to ReliaSoft repositories, as well as analyze and plot data sets from external sources. It is provided for Visual Basic for Applications (VBA) and .NET applications, allowing you to create automated solutions using popular Microsoft Office applications, such as Excel and PowerPoint, or create custom applications for your organization.  


== Requirements ==
Implementing the ReliaSoft API allows you to connect data in repositories with the systems and tools used within your organization. It provides the functionality to:


Before using the Synthesis API, note the following requirements:
*'''Transfer and synchronize data via XML'''
:Use XML files to manage structured data (such as system hierarchies/BOMs, incidents and work orders) between ReliaSoft’s [https://www.hbkworld.com/en/products/software/analysis-simulation/reliability/xfracas-failure-reporting-analysis-corrective-action-system-fracas-software XFRACAS] and a variety of different PLMs, ERPs, CMMS and other external systems. You can also use XML files to create reliability block diagrams (RBDs) in [https://www.hbkworld.com/en/products/software/analysis-simulation/reliability/blocksim-system-reliability-availability-maintainability-ram-analysis-software BlockSim].
*'''Read/write specific data elements'''
:Read or write data to resources (models, actions, URDs, etc.), system hierarchy items and FMEA records (causes, effects, failures, etc.). Initiate batch data processing and create custom solutions for importing/exporting data from ReliaSoft repositories, as well as load data into the Reliability Data Warehouse (RDW).
*'''Obtain calculated results'''
:Read data from published models and obtain calculated results such as reliability, probability of failure, BX% life, failure rate and mean time.
*'''Analyze data'''
:Use [https://hbkworld.com/en/products/software/analysis-simulation/reliability/weibull-life-data-analysis-software Weibull++'s] analysis and plotting engines to analyze data from third-party sources, and incorporate the functionality into your own custom applications. (Requires a ReliaSoft API license.)


*Your code must include a reference to the ReliaSoft Synthesis API Library. The library is located in the folder where ReliaSoft Synthesis is installed. By default, this folder is "C:\Program Files\ReliaSoft\Synthesis 9."
==Prerequisites==
** .NET developers – use the SynthesisAPI.dll library
*'''Getting the latest version'''
** VB6 / VBA developers – use the SynthesisAPI.tlb library
:The ReliaSoft API consists of a library file that contains the classes, methods and events that provide access to ReliaSoft applications. The file is located in the folder where the ReliaSoft desktop applications are installed. By default, this folder is at "C:\Program Files\ReliaSoft\ReliaSoft 2023." For VBA, you will use the '''ReliaSoftAPI23.tlb''' file; for .NET applications, you will use the '''ReliaSoftAPI23.dll''' file. Prior to Version 2019, the files to use were SynthesisAPI.tlb (VBA) and SynthesisAPI.dll (.NET).


*The version of the Synthesis Platform that you've installed (32- vs. 64-bit) must match your installed version of Microsoft Office. If they do not match, you may see an [http://www.reliasoft.com/support/rs20024.htm error] related to ActiveX controls.
:To obtain the latest version of the library file and the ReliaSoft applications, choose '''File > Help > Check for Updates''' or download the latest version from the [https://support.hbmprenscia.com HBM Prenscia Support Portal].


== API Elements ==
*'''Build environment'''
:For Visual Studio projects using Version 10 or 11, at minimum you will need Visual Studio 2010 and the .NET Framework 4.0 runtime. Version 2018 and later require Visual Studio 2015 and the .NET Framework 4.6.1 developer pack and runtime. Starting in Version 2022, .NET Framework 4.8 developer pack is required.


The Synthesis API includes a rich set of programming elements that allow you to work with any of the following components of the Synthesis Platform:
*'''32- vs. 64-bit'''
:For VBA, the bit version of the ReliaSoft applications that you've installed must match your installed version of Microsoft Office. If they do not match, you may see an error related to ActiveX controls.


*'''[[Repository Class|Repositories]]''': {{Template:Repository Class.Cmt}}
:For Visual Studio projects targeting the .NET Framework 4.5 (or later) and compiled to run an any platform (Any CPU), turn off the '''Prefer 32-bit''' property of the build configuration if you want instances of your application to run as a 64-bit process; otherwise, the application will run as a 32-bit process on both 32- and 64-bit versions of Windows. It is necessary to ensure your application bitness matches the bitness of the ReliaSoft desktop applications installed wherever your application is run due to dependencies on platform-specific libraries.
*'''[[WeibullDataSet Class|Weibull++ Standard Folio]]''': {{Template:WeibullDataSet Class.Cmt}}
*'''[[ALTADataSet Class|ALTA Standard Folio]]''': {{Template:ALTADataSet Class.Cmt}}
<!--*'''[[Global Model|Models in Weibull++/ALTA]]''': {{Template:Global Model.Cmt}}-->
*'''[[WAPlots Class|Plots in Weibull++/ALTA]]''': {{Template:WAPlots Class.Cmt}}
*'''[[Resource Classes|Resources]]''': {{Template:Resource Classes.Cmt}}
*'''[[Common Class|Displayed Language]]''': {{Template:Common Class.Cmt}}


A complete list of all the classes and enumerations in the Synthesis API is available [[Full Synthesis API|here]].
*'''Running API applications on a server
:If you plan to run the API on a Windows server, you must use [https://help.reliasoft.com/basics/content/reliasoft_installation_and_licensing.htm locally hosted licensing] with Prenscia Access.  


== Application Examples ==
*'''Access to calculations functionality
:Access to Weibull++'s analysis and plotting engines requires a ReliaSoft API license. To obtain a license, please see [https://www.hbkworld.com/en/contact-us/reliasoft-worldwide-contacts contact ReliaSoft].


'''Excel Files'''
==Getting Started==


Use the following links to download Excel files (*.xlm) with macros that call the Synthesis API. Note that to run/view the underlying code, the [http://msdn.microsoft.com/en-us/library/bb608625.aspx Developer tab should be enabled] in Excel so you can enter the Visual Basic for Applications (VBA) environment by choosing '''Developer > View Code'''. Also, you must have [http://office.microsoft.com/en-us/excel-help/enable-or-disable-macros-in-office-documents-HA010031071.aspx macros enabled] to run the example files. If Excel displays a warning regarding macros in these files, select to enable them.
====Referencing the ReliaSoft API Library File====
* [[Life Data Analysis in Microsoft Excel]] ([[Life Data Analysis in Microsoft Excel - Walkthrough |Code explanation]])
<!-- This "onlyinclude" section is transcluded into the API Tutorials page -->
* [[Accelerated Life Testing Analysis (ALTA) in Microsoft Excel]] ([[Accelerated Life Testing Analysis in Microsoft Excel - Walkthrough |Code explanation]])
<onlyinclude>To use the ReliaSoft API in your code, you must reference the ReliaSoft API library in your VBA or .NET projects. The file is located in the folder where the ReliaSoft desktop applications are installed. By default for Version 2023, this folder is at "C:\Program Files\ReliaSoft\ReliaSoft 2023." For VBA, you will use the '''ReliaSoftAPI23.tlb''' file; for .NET applications, you will use the '''ReliaSoftAPI23.dll''' file.
* Transfer Data from Excel to the Synthesis Reliability Data Warehouse (RDW)
** [[Excel to Standard Repository]]
** [[Excel to Enterprise SQL Repository]] (Requires reference to a SQL repository.)
<!--


'''To reference the library in VBA''':
:#Enter the VBA environment by clicking the '''Visual Basic''' command on the Developer tab (If the Developer tab is not visible, see [https://msdn.microsoft.com/en-us/library/bb608625.aspx this Microsoft article]).
:#In the VBA environment, choose '''Tools > References'''.
:#Click '''Browse''' and find the ReliaSoftAPI23.tlb file on your computer. Click '''OK'''.


'''To reference the library in Visual Studio:'''
:#In the Solution Explorer, right-click the '''References''' node of your project and choose '''Add References'''.
:#In the Reference Manager window, click the '''Browse''' tab and find the ReliaSoftAPI23.dll file on your computer. Click '''OK'''.
:#Edit your project file, either directly using any text editor, or by right-clicking your project and choosing '''Unload Project''', then right-clicking your project again and choosing '''Edit Project File'''
:#Insert the following line just before the last </Project> clause (change the path if necessary):
:::
::::::<Import Project="C:\Program Files\ReliaSoft\ReliaSoft 2023\ReliaSoftAPI.targets" />
:::
:::This will ensure the required files are copied into your project’s destination folder during the build.
:#<li value="5">Save the project file. If you unloaded the project in step 3, right-click the project and choose '''Reload Project'''.</li>
</onlyinclude>
====Examples====
Sample applications that you can test and tweak yourself are included with the ReliaSoft installation. The files are stored on your computer at C:\Users\Public\Public Documents\ReliaSoft\Examples23\API.
The sample applications are available for Excel VBA and VB.NET projects. (To run the Excel examples, macros must be enabled. See [http://office.microsoft.com/en-us/excel-help/enable-or-disable-macros-in-office-documents-HA010031071.aspx this Microsoft article].)


====Tutorials====
[[API Tutorials|Tutorials]] are available to help you learn the core objects of the ReliaSoft API and start coding right away. The tutorials include code samples for both VBA and VB.NET.


==Object Library ==
Below is a summary of the core objects in the ReliaSoft API library. For an alphabetical listing of all objects in the latest version, see [[API Reference Documentation]].


== Formatted Usage Examples ==
*The <code>'''[[Repository Class|Repository]]'''</code> object represents the ReliaSoft repository. All other objects use the functions in this class to read or write data to the repository. This class also contains the functions for importing/exporting XML files.  
{{APIComment|These formatted examples begin with an XML file, import it into the synthesis repository, add data, perform calculations, perform an analysis, and show results. Finally, they create a plot and display a message.}}


*The following objects represent the ReliaSoft resources. Instances of each class can be used to store data for an existing or new resource. 
**<code>'''[[CAction Class|cAction]]'''</code>
**<code>'''[[CCorrectiveTask Class|cCorrectiveTask]]'''</code>
**<code>'''[[CScheduledTask Class|cScheduledTask]]'''</code>
**<code>'''[[CCrew Class|cCrew]]'''</code>
**<code>'''[[CModel Class|cModel]]'''</code>
**<code>'''[[CPool Class|cPool]]'''</code>
**<code>'''[[CProfile Class|cProfile]]'''</code>
**<code>'''[[CURD Class|cURD]]'''</code>
**<code>'''[[CVariable Class|cVariable]]'''</code>
**<code>'''[[CXfmeaControl Class|cXfmeaControl]]'''</code>


First we will show the importation of a file into BlockSim.
*The following objects build data sets for the Reliability Data Warehouse (RDW).
**<code>'''[[RawData Class|RawData]]'''</code> represents a single data point.
**<code>'''[[RawDataSet Class|RawDataSet]]'''</code> serves as the data container for <code>RawData</code> objects.


*The <code>'''[[XfmeaItem Class|XfmeaItem]]'''</code> object represents a system hierarchy item. Instances of this class can be used to store data for a system or assembly, as well as build a multi-level system configuration.


{{APIComment|Declare a new repository connection class.}}
*The following objects represent the FMEA records. Instances of each class can be used to store data for an existing or new FMEA analysis.  
      Private WithEvents MyRepository As New Repository
**<code>'''[[XfmeaFunction Class|XfmeaFunction]]'''</code>
{{APIComment|Connect to the Synthesis repository.}}
**<code>'''[[XfmeaCause Class|XfmeaCause]]'''</code>
      Dim Success As Boolean = False
**<code>'''[[XfmeaEffect Class|XfmeaEffect]]'''</code>
      Success = MyRepository.ConnectToSQLRepository("SQLServerPath", "SQLDatabaseName")
**<code>'''[[XfmeaFailure Class|XfmeaFailure]]'''</code>
{{APIComment|Import the XML File to the Synthesis repository.}}
      Dim SuccessImportXML As Boolean
      SuccessImportXML = MyRepository.ImportXFRACASXMLFile("XMLFilePath")


*The <code>'''[[WeibullDataSet Class|WeibullDataSet]]'''</code> object represents a Weibull++ data sheet for life data analysis. Instances of this class are used to define a data set and fit a statistical distribution to the data.


The file has been imported. Now we will demonstrate the use of Synthesis API in Weibull.
*The <code>'''[[ALTADataSet Class|ALTADataSet]]'''</code> object represents an ALTA data sheet for accelerated life testing data analysis. Instances of this class are used to define a data set, and fit a distribution and life-stress relationship to the data.  


 
*The <code>'''[[WAPlots Class|WAPlots]]'''</code> object represents a plot based on a <code>cModel</code>, <code>WeibullDataSet</code> or <code>ALTADataSet</code> object. Instances of this class are used to display a plot of the analysis results.
{{APIComment|Declare the WeibullDataSet. See [[New WeibullDataSet]] for additional details.}}
        Dim WDS as New WeibullDataSet
 
{{APIComment|Add values to the raw data. See [[WeibullDataSet.AddFailure|AddFailure]] for additional details.}}
        WDS.AddFailure(1, 1)
        WDS.AddFailure(2, 1)
        WDS.AddFailure(3, 1)
 
{{APIComment|Add values to the raw data. See [[WeibullDataSet.AddSuspension|AddSuspension]] for additional details.}}
        WDS.AddSuspension(1, 1)
        WDS.AddSuspension(2, 1)
        WDS.AddSuspension(3, 1)
 
{{APIComment|Calculate the WeibullDataSet. See [[WeibullDataSet.Calculate|Calculate]] for additional details.}}
        WDS.Calculate
 
{{APIComment|Get the number of failures. In this example, NumberOfFailures will be 3. See [[WeibullDataSet.FailureCount|FailureCount]] for additional details.}}
        Dim NumberOfFailures as Integer
        NumberOfFailures = WDS.FailureCount
 
{{APIComment|Calculate the Fitted Model using the raw data. See [[WeibullDataSet.CalculateBestFit|CalculateBestFit]] for additional details.}}
        WDS.CalculateBestFit
 
{{APIComment|Use the Fitted Model using the raw data. See [[WeibullDataSet.FittedModel|FittedModel]] for additional details.}}
        Dim WDSFittedModel as cModel
        WDSFittedModel = WDS.FittedModel
 
{{APIComment|Use ClearDataSet to clear data and fitted model. See [[WeibullDataSet.ClearDataSet|ClearDataSet]] for additional details.}}
        '''WDS.ClearDataSet'''
 
{{APIComment|Get the number of failures. In this example, NumberOfFailures will be 0. See [[WeibullDataSet.FailureCount|FailureCount]] for additional details.}}
        Dim NumberOfFailures as Integer
        NumberOfFailures = WDS.FailureCount
 
The below demonstrates that plots may also be utilized.
 
{{APIComment|Create a new Weibull/ALTA Plot instance.}}
        Dim WeibullALTAPlot As New WAPlots
 
{{APIComment|Declare a WeibullDataSet. See [[New WeibullDataSet]] for additional details.}}
        Dim WDS As New WeibullDataSet
 
{{APIComment|Add values to the raw data. See [[WeibullDataSet.AddFailure|AddFailure]] for additional details.}}
        WDS.AddFailure(1, 1)
        WDS.AddFailure(2, 1)
        WDS.AddFailure(3, 1)
 
{{APIComment|Add the WeibullDataSet to the WAPlots.}}
        WeibullALTAPlot.AddDataset(WDS)
 
{{APIComment|Create the WAPlot.  In this example, it will create a Probability plot.}}
        Dim FinalPlot As Bitmap = WeibullALTAPlot.CreatePlot(WAPlotType.Probability)
 
{{APIComment|If there were any issues creating the plot, [[WAPlots.ErrorHappened|ErrorHappened]] would be True, and ErrorString will display the reason.}}
        Dim ErrorString as String
        If WeibullALTAPlot.[[WAPlots.ErrorHappened|ErrorHappened]] Then
            ErrorString = '''WeibullALTAPlot.ErrorMessage'''
        End If
-->

Latest revision as of 20:00, 12 April 2024

APIWiki.png



The ReliaSoft Application Programming Interface (API) enables you to programmatically read and write data to ReliaSoft repositories, as well as analyze and plot data sets from external sources. It is provided for Visual Basic for Applications (VBA) and .NET applications, allowing you to create automated solutions using popular Microsoft Office applications, such as Excel and PowerPoint, or create custom applications for your organization.

Implementing the ReliaSoft API allows you to connect data in repositories with the systems and tools used within your organization. It provides the functionality to:

  • Transfer and synchronize data via XML
Use XML files to manage structured data (such as system hierarchies/BOMs, incidents and work orders) between ReliaSoft’s XFRACAS and a variety of different PLMs, ERPs, CMMS and other external systems. You can also use XML files to create reliability block diagrams (RBDs) in BlockSim.
  • Read/write specific data elements
Read or write data to resources (models, actions, URDs, etc.), system hierarchy items and FMEA records (causes, effects, failures, etc.). Initiate batch data processing and create custom solutions for importing/exporting data from ReliaSoft repositories, as well as load data into the Reliability Data Warehouse (RDW).
  • Obtain calculated results
Read data from published models and obtain calculated results such as reliability, probability of failure, BX% life, failure rate and mean time.
  • Analyze data
Use Weibull++'s analysis and plotting engines to analyze data from third-party sources, and incorporate the functionality into your own custom applications. (Requires a ReliaSoft API license.)

Prerequisites

  • Getting the latest version
The ReliaSoft API consists of a library file that contains the classes, methods and events that provide access to ReliaSoft applications. The file is located in the folder where the ReliaSoft desktop applications are installed. By default, this folder is at "C:\Program Files\ReliaSoft\ReliaSoft 2023." For VBA, you will use the ReliaSoftAPI23.tlb file; for .NET applications, you will use the ReliaSoftAPI23.dll file. Prior to Version 2019, the files to use were SynthesisAPI.tlb (VBA) and SynthesisAPI.dll (.NET).
To obtain the latest version of the library file and the ReliaSoft applications, choose File > Help > Check for Updates or download the latest version from the HBM Prenscia Support Portal.
  • Build environment
For Visual Studio projects using Version 10 or 11, at minimum you will need Visual Studio 2010 and the .NET Framework 4.0 runtime. Version 2018 and later require Visual Studio 2015 and the .NET Framework 4.6.1 developer pack and runtime. Starting in Version 2022, .NET Framework 4.8 developer pack is required.
  • 32- vs. 64-bit
For VBA, the bit version of the ReliaSoft applications that you've installed must match your installed version of Microsoft Office. If they do not match, you may see an error related to ActiveX controls.
For Visual Studio projects targeting the .NET Framework 4.5 (or later) and compiled to run an any platform (Any CPU), turn off the Prefer 32-bit property of the build configuration if you want instances of your application to run as a 64-bit process; otherwise, the application will run as a 32-bit process on both 32- and 64-bit versions of Windows. It is necessary to ensure your application bitness matches the bitness of the ReliaSoft desktop applications installed wherever your application is run due to dependencies on platform-specific libraries.
  • Running API applications on a server
If you plan to run the API on a Windows server, you must use locally hosted licensing with Prenscia Access.
  • Access to calculations functionality
Access to Weibull++'s analysis and plotting engines requires a ReliaSoft API license. To obtain a license, please see contact ReliaSoft.

Getting Started

Referencing the ReliaSoft API Library File

To use the ReliaSoft API in your code, you must reference the ReliaSoft API library in your VBA or .NET projects. The file is located in the folder where the ReliaSoft desktop applications are installed. By default for Version 2023, this folder is at "C:\Program Files\ReliaSoft\ReliaSoft 2023." For VBA, you will use the ReliaSoftAPI23.tlb file; for .NET applications, you will use the ReliaSoftAPI23.dll file.

To reference the library in VBA:

  1. Enter the VBA environment by clicking the Visual Basic command on the Developer tab (If the Developer tab is not visible, see this Microsoft article).
  2. In the VBA environment, choose Tools > References.
  3. Click Browse and find the ReliaSoftAPI23.tlb file on your computer. Click OK.

To reference the library in Visual Studio:

  1. In the Solution Explorer, right-click the References node of your project and choose Add References.
  2. In the Reference Manager window, click the Browse tab and find the ReliaSoftAPI23.dll file on your computer. Click OK.
  3. Edit your project file, either directly using any text editor, or by right-clicking your project and choosing Unload Project, then right-clicking your project again and choosing Edit Project File
  4. Insert the following line just before the last </Project> clause (change the path if necessary):
<Import Project="C:\Program Files\ReliaSoft\ReliaSoft 2023\ReliaSoftAPI.targets" />
This will ensure the required files are copied into your project’s destination folder during the build.
  1. Save the project file. If you unloaded the project in step 3, right-click the project and choose Reload Project.

Examples

Sample applications that you can test and tweak yourself are included with the ReliaSoft installation. The files are stored on your computer at C:\Users\Public\Public Documents\ReliaSoft\Examples23\API.

The sample applications are available for Excel VBA and VB.NET projects. (To run the Excel examples, macros must be enabled. See this Microsoft article.)

Tutorials

Tutorials are available to help you learn the core objects of the ReliaSoft API and start coding right away. The tutorials include code samples for both VBA and VB.NET.

Object Library

Below is a summary of the core objects in the ReliaSoft API library. For an alphabetical listing of all objects in the latest version, see API Reference Documentation.

  • The Repository object represents the ReliaSoft repository. All other objects use the functions in this class to read or write data to the repository. This class also contains the functions for importing/exporting XML files.
  • The following objects build data sets for the Reliability Data Warehouse (RDW).
    • RawData represents a single data point.
    • RawDataSet serves as the data container for RawData objects.
  • The XfmeaItem object represents a system hierarchy item. Instances of this class can be used to store data for a system or assembly, as well as build a multi-level system configuration.
  • The WeibullDataSet object represents a Weibull++ data sheet for life data analysis. Instances of this class are used to define a data set and fit a statistical distribution to the data.
  • The ALTADataSet object represents an ALTA data sheet for accelerated life testing data analysis. Instances of this class are used to define a data set, and fit a distribution and life-stress relationship to the data.
  • The WAPlots object represents a plot based on a cModel, WeibullDataSet or ALTADataSet object. Instances of this class are used to display a plot of the analysis results.