Transfer Data to the Synthesis Data Warehouse (SDW): Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:


'''Synthesis Data Warehouse (SDW) Tutorial'''
'''Synthesis Data Warehouse (SDW) Tutorial'''
*[[APISDWTutorialVBA|VBA]]
*[[APISDWTutorialVBNET|VB.NET]]
</div>
</div>


Line 9: Line 11:




In this tutorial, you'll learn how to use the Synthesis API to create a custom solution for moving data from an external source over to a Synthesis repository. We'll use data from an Excel file to demonstrate this capability. ''Download the sample Excel file used in this example: [http://reliasoft.com/synthesis/api/tutorials/SDW_SampleData.xls SDW_SampleData.xls] (30 KB)''.
In the following tutorial, you'll learn how to use the Synthesis API to create a custom solution for moving data from an external data source over to a Synthesis repository. To keep things simple, we'll use data from an Excel file to demonstrate this capability.  


== Transfer Data from an Excel File to the SDW ==
===Prerequisites===
1. Create an Excel file named "SampleData." If you will be working in VB.NET, save the file to your C drive.


1. Let's begin with the <code>RawDataSet</code> class, which represents an SDW data collection. In this example, we'll create a data collection for use with Weibull++.
Then copy and paste the following data to the first sheet in the Excel workbook.  
{| {{table}}
| Failure State||Time to F or S||Failure Mode
|-
| F||7380||Cracked
|-
| F||4956||Cracked
|-
| F||5451||Cracked
|-
| F||6779||Failed
|-
| F||7713||Aging
|-
| F||1807||Bending
|-
| F||5940||Chafing
|-
| F||2071||Arcing
|-
| F||8178||Loose
|-
| F||3006||Burned
|-
| F||1385||Broken
|-
| F||2432||No Contact
|-
| F||1169||No Contact
|-
| F||592||Shorted
|-
| F||24||Burned
|-
| F||453||Burned
|-
| F||382||Burned
|-
| F||774||Burned
|-
| F||53||Burned
|-
|}


Create a new module and start with the following code to create an SDW data collection.
2. You'll need to reference the Microsoft Excel Object Library.  


'''VBA'''
:For VBA, choose '''Tools > Reference''', and then select the library from the list. Click '''OK'''.
{{APIComment|'Declare a new instance of the RawDataSet class.}}
  {{APIPrefix|Dim}} DataCollection {{APIPrefix|As New}} RawDataSet
{{APIComment|'Name the data collection "New Data Collection," and then specify that}}
{{APIComment|'it is for use with Weibull++.}}
  DataCollection.ExtractedName = {{APIString|"New Data Collection"}}
  DataCollection.ExtractedType = RawDataSetType_Weibull


'''VB.NET'''
:For VB.NET, choose '''Project > Add Reference''', and then select the library from the COM tab. Click '''OK'''. On the code page, add an Imports statement for Microsoft.Office.Interop.Excel.
{{APIComment|'Declare a new instance of the RawDataSet class.}}
  {{APIPrefix|Dim}} DataCollection {{APIPrefix|As New}} RawDataSet
{{APIComment|'Name the data collection "New Data Collection," and then specify that}}
{{APIComment|'it is for use with Weibull++.}}
  DataCollection.ExtractedName = {{APIString|"New Data Collection"}}
  DataCollection.ExtractedType = RawDataSetType.Weibull




2. Next, we'll use the <code>RawData</code> class to represent a single row of data, and then use the <code>AddDataRow</code> method to add the row to the data collection.
Now that we're set up, select which language you want to work with:'''


The following code demonstrates one way to extract a row of data from the Excel sheet. For <code>i = 2</code>, the code creates a new <code>RawData</code> object, sets the object's properties with the data from row #2 of the Excel file, and then adds that object to the data collection. When the code reaches <code>Next i</code>, it increases <code>i</code> with 1 and jumps back to the <code>For</code> statement, which adds another new <code>RawData</code> object, sets its properties with the data from row #3 of the Excel sheet, and adds the row to the data collection. The loop continues until <code>i</code> reaches the specified number of rows (MaxRow). 
[[APISDWTutorialVBA|Start the SDW tutorial for VBA >>]]


'''VBA'''
[[APISDWTutorialVBNET|Start the SDW tutorial for VB.NET >>]]
{{APIComment|'Declare a new instance of the RawData class.}}
  {{APIPrefix|Dim}} Row {{APIPrefix|As New}} RawData
{{APIComment|'Read each row of data from the Excel sheet.}}
  {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
  MaxRow = 100
  {{APIPrefix|For}} i = 2 {{APIPrefix|to}} MaxRow
      {{APIPrefix|Set}} Row = {{APIPrefix|New}} RawData
    {{APIComment|'Set the desired properties for the current row of data.}}
      Row.StateFS = Sheet1.Cells(i, 1)
      Row.StateTime = Sheet1.Cells(i,2)
      Row.FailureMode = Sheet1.Cells(i,3)
    {{APIComment|'Add the current row to the data collection.}}
      {{APIPrefix|Call}} DataCollection.AddDataRow(Row)
  {{APIPrefix|Next}} i
 
'''VB.NET'''
{{APIComment|'Declare a new instance of the RawData class.}}
  {{APIPrefix|Dim}} Row {{APIPrefix|As New}} RawData
{{APIComment|'Read each row of data from the Excel sheet.}}
  {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
  MaxRow = 100
  {{APIPrefix|For}} i = 2 to MaxRow
      Row = {{APIPrefix|New}} RawData
    {{APIComment|'Set the desired properties for the current row of data.}}
      Row.StateFS = Sheet1.Cells(i, 1)
      Row.StateTime = Sheet1.Cells(i,2)
      Row.FailureMode = Sheet1.Cells(i,3)
    {{APIComment|'Add the current row to the data collection.}}
      DataCollection.AddDataRow(Row)
  {{APIPrefix|Next}} i
 
3. Now that the data from the Excel file have been added to the data collection, the next step is to save the data collection to the Synthesis repository.
 
First, connect to the Synthesis repository and then use the <code>SaveRawDataSet</code> method to save the data collection to the repository.
 
'''VBA'''
{{APIComment|'Connect to the Synthesis repository. The following code assumes that}}
{{APIComment|'a standard repository called "RSRepository1.rsr10" exists in the C: drive.}} 
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository 
  MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr10"}})
{{APIComment|'Save the extracted data collection to the repository.}}
  {{APIPrefix|Call}} MyRepository.SaveRawDataSet(DataCollection)
 
'''VB.NET'''
{{APIComment|'Connect to the Synthesis repository. The following code assumes that}}
{{APIComment|'a standard repository called "RSRepository1.rsr10" exists in the C: drive.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr10"}})
{{APIComment|'Save the extracted data collection to the repository.}}
  MyRepository.SaveRawDataSet(DataCollection)
 
=== Test the Code ===
Let's verify whether the code can import the data successfully into the SDW.
 
Below are the VBA and VB.NET code lists for this example. On the Debug menu, click '''Start''' to run the application. Then verify that the data were imported by launching Weibull++, opening the SDW ('''Home > Synthesis > Synthesis Data Warehouse''') and then selecting the new data collection.
 
'''VBA'''
 
Sub Main()
{{APIComment|'Declare a new instance of the RawDataSet class.}}
  {{APIPrefix|Dim}} DataCollection {{APIPrefix|As New}} RawDataSet
{{APIComment|'Name the data collection "New Data Collection," and then specify that}}
{{APIComment|'it is for use with Weibull++.}}
  DataCollection.ExtractedName = {{APIString|"New Data Collection"}}
  DataCollection.ExtractedType = RawDataSetType_Weibull
{{APIComment|'Declare a new instance of the RawData class.}}
  {{APIPrefix|Dim}} Row {{APIPrefix|As New}} RawData
{{APIComment|'Read each row of data from the Excel sheet.}}
  {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
  MaxRow = 100
  {{APIPrefix|For}} i = 2 {{APIPrefix|to}} MaxRow
      {{APIPrefix|Set}} Row = {{APIPrefix|New}} RawData
    {{APIComment|'Set the desired properties for the current row of data.}}
      Row.StateFS = Sheet1.Cells(i, 1)
      Row.StateTime = Sheet1.Cells(i,2)
      Row.FailureMode = Sheet1.Cells(i,3)
    {{APIComment|'Add the current row to the data collection.}}
      {{APIPrefix|Call}} DataCollection.AddDataRow(Row)
  {{APIPrefix|Next}} i
{{APIComment|'Connect to the Synthesis repository. The following code assumes that}}
{{APIComment|'a standard repository called "RSRepository1.rsr10" exists in the C: drive.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr10"}})
{{APIComment|'Save the extracted data collection to the repository.}}
  {{APIPrefix|Call}} MyRepository.SaveRawDataSet(DataCollection)
End Sub
 
'''VB.NET'''
Sub Main()
{{APIComment|'Declare a new instance of the RawDataSet class.}}
  {{APIPrefix|Dim}} DataCollection {{APIPrefix|As New}} RawDataSet
{{APIComment|'Name the data collection "New Data Collection," and then specify that}}
{{APIComment|'it is for use with Weibull++.}}
  DataCollection.ExtractedName = {{APIString|"New Data Collection"}}
  DataCollection.ExtractedType = RawDataSetType.Weibull
{{APIComment|'Declare a new instance of the RawData class.}}
  {{APIPrefix|Dim}} Row {{APIPrefix|As New}} RawData
{{APIComment|'Read each row of data from the Excel sheet.}}
  {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
  MaxRow = 100
  {{APIPrefix|For}} i = 2 to MaxRow
      Row = {{APIPrefix|New}} RawData
    {{APIComment|'Set the desired properties for the current row of data.}}
      Row.StateFS = Sheet1.Cells(i, 1)
      Row.StateTime = Sheet1.Cells(i,2)
      Row.FailureMode = Sheet1.Cells(i,3)
    {{APIComment|'Add the current row to the data collection.}}
      DataCollection.AddDataRow(Row)
  {{APIPrefix|Next}} i
{{APIComment|'Connect to the Synthesis repository. The following code assumes that}}
{{APIComment|'a standard repository called "RSRepository1.rsr10" exists in the C: drive.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr10"}})
{{APIComment|'Save the extracted data collection to the repository.}}
  MyRepository.SaveRawDataSet(DataCollection)
End Sub
 
===References===
To learn more, see the reference documentation for the classes and methods discussed in this section:
*[[RawDataSet Class]]
*[[RawData Class]]
*[[AddDataRow Method|RawDataSet.AddDataRow Method]]
*[[Repository.DataWarehouse.SaveRawDataSet|Repository.DataWarehouse.SaveRawDataSet Method]]

Revision as of 16:20, 28 October 2015

Template:InProgress

APIWiki.png


<< Back to Quick Start Guide

Synthesis Data Warehouse (SDW) Tutorial

The Synthesis Data Warehouse (SDW) — formerly called "Reliability Data Warehouse" — is a temporary data storage location in a Synthesis repository. It allows you to connect to external data sources and extract data for use in Weibull++, ALTA or RGA standard folios.


In the following tutorial, you'll learn how to use the Synthesis API to create a custom solution for moving data from an external data source over to a Synthesis repository. To keep things simple, we'll use data from an Excel file to demonstrate this capability.

Prerequisites

1. Create an Excel file named "SampleData." If you will be working in VB.NET, save the file to your C drive.

Then copy and paste the following data to the first sheet in the Excel workbook.

Failure State Time to F or S Failure Mode
F 7380 Cracked
F 4956 Cracked
F 5451 Cracked
F 6779 Failed
F 7713 Aging
F 1807 Bending
F 5940 Chafing
F 2071 Arcing
F 8178 Loose
F 3006 Burned
F 1385 Broken
F 2432 No Contact
F 1169 No Contact
F 592 Shorted
F 24 Burned
F 453 Burned
F 382 Burned
F 774 Burned
F 53 Burned

2. You'll need to reference the Microsoft Excel Object Library.

For VBA, choose Tools > Reference, and then select the library from the list. Click OK.
For VB.NET, choose Project > Add Reference, and then select the library from the COM tab. Click OK. On the code page, add an Imports statement for Microsoft.Office.Interop.Excel.


Now that we're set up, select which language you want to work with:

Start the SDW tutorial for VBA >>

Start the SDW tutorial for VB.NET >>