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

From ReliaWiki
Jump to navigation Jump to search
m (moved APISDWTutorial to Transfer data to the Synthesis Data Warehouse (SDW): Moved to more appropriate page name.)
No edit summary
Line 1: Line 1:
{{InProgress}}{{DISPLAYTITLE:Synthesis Data Warehouse (SDW) Tutorial}}{{Template:API}}
{{Template:API}}
<div style="border:1px solid #AAA; background:#f9f9f9; border-radius:10px; width:auto; margin:0 0 1em 1em; padding:1em; float:right;">
<div style="border:1px solid #D0CDE8; background:#EEEDF7; border-radius:10px; width:auto; margin:0 0 1em 1em; padding:1em; float:right;">
<nowiki><<</nowiki> [[APIQuickStartGuide|Back to Quick Start Guide]]
'''[[API_Tutorials|<< Back to API Tutorials]]'''


'''Synthesis Data Warehouse (SDW) Tutorial'''
'''Transfer Data to the SDW Tutorial'''
*[[APISDWTutorialVBA|VBA]]  
*[[Transfer_data_to_the_Synthesis_Data_Warehouse_(SDW)#VBA Tutorial: Transfer Data from an Excel File to the SDW|VBA Tutorial]]
*[[APISDWTutorialVBNET|VB.NET]]
*[[Transfer_data_to_the_Synthesis_Data_Warehouse_(SDW)#VB.NET Tutorial: Transfer Data from an Excel File to the SDW|VB.NET Tutorial]]
*[[Transfer_data_to_the_Synthesis_Data_Warehouse_(SDW)#References|References]]
</div>
</div>


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.  
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 the SDW. To keep things simple, we'll use data from an Excel file to demonstrate this capability.


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 the SDW of a Synthesis repository. To keep things simple, we'll use data from an Excel file to demonstrate this capability.  
The tutorial is available for both VBA and VB.NET. Note that the tutorial demonstrates one particular approach to read data from an Excel file and extract it for the SDW. It is for demonstration purposes only; the approach does not take efficiency into account and does not include any exception handling. To complete the tutorial successfully, please use the sample Excel data given below.  


===Create an Excel file for this tutorial===
===Create an Excel file for this tutorial===
Before you begin, create an Excel file named "SampleData." If you will be working in VBA, use this file to write your code; if working in VB.NET, save this file to your C drive.  
Before you begin the tutorial, please create an Excel file to use as your sample data.


Copy and paste the following data to the Excel file. Be sure to select cell A1 in Sheet1 of the workbook when pasting the data.
Create an Excel file, then copy and paste the following data to the file. Be sure to select cell A1 in Sheet1 of the workbook when pasting the data.  
Save the Excel file as "SampleData."
{| {{table}}
{| {{table}}
| Failure State||Time to F or S||Failure Mode
| Failure State||Time to F or S||Failure Mode
Line 60: Line 63:
|}
|}


Now that we're set up, select which language you will be working with:'''


[[APISDWTutorialVBA|Start the SDW tutorial for VBA >>]]
== VBA Tutorial: Transfer Data from an Excel File to the SDW==


[[APISDWTutorialVBNET|Start the SDW tutorial for VB.NET >>]]
Before you begin, be sure to reference the Microsoft Excel Object Library. Choose '''Tools > Reference''', and then select the library from the list. Click '''OK'''.
 
1. Create a new module and start with the following code to create an SDW data collection. The code uses an <code>RawDataSet</code> object to represent the SDW data collection, and the <code>ExtractedType</code> property to specify that the data collection is for use with Weibull++.
 
'''VBA'''
{{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
 
3. Next, 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.
 
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, and then sets its properties by using the values from row #2 of the Excel file. After the code finishes reading the row of data, it adds the 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 for the data in row #3 of the Excel sheet, and so on. The loop continues until <code>i</code> reaches the specified number of rows (MaxRow). 
 
'''VBA'''
{{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 = 20
  {{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
 
4. Now that the data from the Excel sheet have been copied to the data collection, the next step is to save the data collection to the Synthesis repository.
 
Connect to the Synthesis repository and then use the <code>DataWarehouse.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.DataWarehouse.SaveRawDataSet(DataCollection)
 
=== Test the Code ===
Let's verify whether the code can import the data successfully into the SDW.
 
Below is the complete code list 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. (You may need to display the StateTime, StateFS and FailureMode columns by right-clicking a column header and choosing '''Select Columns'''.)
 
'''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 = 20
  {{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.DataWarehouse.SaveRawDataSet(DataCollection)
End Sub
 
 
== VB.NET Tutorial: Transfer Data from an Excel File to the SDW ==
Before we begin, be sure to reference the Microsoft Excel Object Library. Choose '''Project > Add Reference''', and then select the library from the COM tab. Click '''OK'''.
 
1. Create a new form. On the code page, add an Imports statement for <code>Microsoft.Office.Interop.Excel</code>, then start with the following code to create an SDW data collection. The code uses the <code>RawDataSet</code> class to represent an SDW data collection, and the <code>ExtractedType</code> property to specify that the data collection is for use with Weibull++.
 
'''VB.NET'''
{{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
 
3. Next, 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.
 
The following code demonstrates one way to extract a row of data from the Excel file. First, the code opens a connection to the Excel file and specifies the active sheet (in this case, Sheet1). Then <code>For i = 2</code>, the code creates a new <code>RawData</code> object and sets its properties by using the values from row #2 of the Excel file. After the code finishes reading the row of data, it adds the 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 for the data in row #3 of the Excel sheet, and so on. The loop continues until <code>i</code> reaches the specified number of rows (MaxRow).  Finally, the code closes the connection to the Excel file.
 
'''VB.NET'''
{{APIComment|'Declare a new instance of the RawData class.}}
  {{APIPrefix|Dim}} Row {{APIPrefix|As New}} RawData
{{APIComment|'Open the Excel file. The following code assumes that the}}
{{APIComment|'Excel file is saved in the C drive.}}
  {{APIPrefix|Dim}} Excel {{APIPrefix|As New}} Application
  {{APIPrefix|Dim}} Workbook {{APIPrefix|As}} Workbook
  {{APIPrefix|Dim}} Sheet {{APIPrefix|As}} Worksheet
  Workbook = Excel.Workbooks.Open({{APIString|"C:\SampleData.xlsx"}})
  Sheet = Workbook.Sheets(1)
{{APIComment|'Read each row of data in the Excel file.}}
  {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
  MaxRow = 20
  {{APIPrefix|For}} i = 2 {{APIPrefix|To}} MaxRow
      Row = {{APIPrefix|New}} RawData
    {{APIComment|'Set the properties for the current row of data.}}
      Row.StateFS = sheet.Cells(i, 1).text
      Row.StateTime = sheet.Cells(i, 2).value
      Row.FailureMode = sheet.Cells(i, 3).text
    {{APIComment|'Add the current row to the data collection.}}
      {{APIPrefix|Call}} DataCollection.AddDataRow(Row)
  {{APIPrefix|Next}} i
{{APIComment|'Close the Excel file.}}
  Workbook.Close()
  Excel.Quit()
 
4. Now that the data from the Excel file have been copied to the data collection, the next step is to save the data collection to the Synthesis repository.
 
Connect to the Synthesis repository and then use the <code>DataWarehouse.SaveRawDataSet</code> method to save the data collection to the repository.
 
'''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.DataWarehouse.SaveRawDataSet(DataCollection)
 
=== Test the Code ===
Let's verify whether the code can import the data successfully into the SDW.
 
Below is the complete code list 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. (You may need to display the StateTime, StateFS and FailureMode columns by right-clicking a column header and choosing '''Select Columns'''.)
 
'''VB.NET'''
{{APIPrefix|Imports}} SynthesisAPI
{{APIPrefix|Imports}} Microsoft.Office.Interop.Excel
  {{APIPrefix|Public Class}} Form1
      {{APIPrefix|Private Sub}} Button1_Click(sender {{APIPrefix|As}} System.Object, e {{APIPrefix|As}} System.EventArgs) {{APIPrefix|Handles}} Button1.Click
      {{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|'Open the Excel file. The following code assumes that the}}
      {{APIComment|'Excel file is saved in the C drive.}}
        {{APIPrefix|Dim}} Excel {{APIPrefix|As New}} Application
        {{APIPrefix|Dim}} Workbook {{APIPrefix|As}} Workbook
        {{APIPrefix|Dim}} Sheet {{APIPrefix|As}} Worksheet
        Workbook = Excel.Workbooks.Open({{APIString|"C:\SampleData.xlsx"}})
        Sheet = Workbook.Sheets(1)
      {{APIComment|'Read each row of data in the Excel file.}}
        {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
        MaxRow = 20
 
        {{APIPrefix|For}} i = 2 {{APIPrefix|To}} MaxRow
            Row = {{APIPrefix|New}} RawData
          {{APIComment|'Set the properties for the current row of data.}}
            Row.StateFS = sheet.Cells(i, 1).text
            Row.StateTime = sheet.Cells(i, 2).value
            Row.FailureMode = sheet.Cells(i, 3).text
          {{APIComment|'Add the current row to the data collection.}}
            {{APIPrefix|Call}} DataCollection.AddDataRow(Row)
        {{APIPrefix|Next}} i
      {{APIComment|'Close the Excel file.}}
        Workbook.Close()
        Excel.Quit()
      {{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.DataWarehouse.SaveRawDataSet(DataCollection)
      {{APIPrefix|End Sub}}
{{APIPrefix|End Class}}
 
 
==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 17:53, 10 February 2016

APIWiki.png


<< Back to API Tutorials

Transfer Data to the 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 the SDW. To keep things simple, we'll use data from an Excel file to demonstrate this capability.

The tutorial is available for both VBA and VB.NET. Note that the tutorial demonstrates one particular approach to read data from an Excel file and extract it for the SDW. It is for demonstration purposes only; the approach does not take efficiency into account and does not include any exception handling. To complete the tutorial successfully, please use the sample Excel data given below.

Create an Excel file for this tutorial

Before you begin the tutorial, please create an Excel file to use as your sample data.

Create an Excel file, then copy and paste the following data to the file. Be sure to select cell A1 in Sheet1 of the workbook when pasting the data. Save the Excel file as "SampleData."

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


VBA Tutorial: Transfer Data from an Excel File to the SDW

Before you begin, be sure to reference the Microsoft Excel Object Library. Choose Tools > Reference, and then select the library from the list. Click OK.

1. Create a new module and start with the following code to create an SDW data collection. The code uses an RawDataSet object to represent the SDW data collection, and the ExtractedType property to specify that the data collection is for use with Weibull++.

VBA

 'Declare a new instance of the RawDataSet class. 
  Dim DataCollection As New RawDataSet

 'Name the data collection "New Data Collection," and then specify that 
 'it is for use with Weibull++. 
  DataCollection.ExtractedName = "New Data Collection"
  DataCollection.ExtractedType = RawDataSetType_Weibull

3. Next, use the RawData class to represent a single row of data, and then use the AddDataRow method to add the row to the data collection.

The following code demonstrates one way to extract a row of data from the Excel sheet. For i = 2, the code creates a new RawData object, and then sets its properties by using the values from row #2 of the Excel file. After the code finishes reading the row of data, it adds the object to the data collection. When the code reaches Next i, it increases i with 1 and jumps back to the For statement, which adds another new RawData object for the data in row #3 of the Excel sheet, and so on. The loop continues until i reaches the specified number of rows (MaxRow).

VBA

 'Declare a new instance of the RawData class. 
  Dim Row As New RawData

 'Read each row of data from the Excel sheet. 
  Dim i As Integer, MaxRow As Integer
  MaxRow = 20

  For i = 2 to MaxRow
      Set Row = New RawData

     '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)

     'Add the current row to the data collection. 
      Call DataCollection.AddDataRow(Row)
  Next i

4. Now that the data from the Excel sheet have been copied to the data collection, the next step is to save the data collection to the Synthesis repository.

Connect to the Synthesis repository and then use the DataWarehouse.SaveRawDataSet method to save the data collection to the repository.

VBA

 'Connect to the Synthesis repository. The following code assumes that 
 'a standard repository called "RSRepository1.rsr10" exists in the C: drive.   
  Dim MyRepository As New Repository   
  MyRepository.ConnectToRepository ("C:\RSRepository1.rsr10")

 'Save the extracted data collection to the repository. 
  Call MyRepository.DataWarehouse.SaveRawDataSet(DataCollection)

Test the Code

Let's verify whether the code can import the data successfully into the SDW.

Below is the complete code list 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. (You may need to display the StateTime, StateFS and FailureMode columns by right-clicking a column header and choosing Select Columns.)

VBA
 
Sub Main()

 'Declare a new instance of the RawDataSet class. 
  Dim DataCollection As New RawDataSet

 'Name the data collection "New Data Collection," and then specify that 
 'it is for use with Weibull++. 
  DataCollection.ExtractedName = "New Data Collection"
  DataCollection.ExtractedType = RawDataSetType_Weibull

 'Declare a new instance of the RawData class. 
  Dim Row As New RawData

 'Read each row of data from the Excel sheet. 
  Dim i As Integer, MaxRow As Integer
  MaxRow = 20

  For i = 2 to MaxRow
      Set Row = New RawData

     '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)

     'Add the current row to the data collection. 
      Call DataCollection.AddDataRow(Row)
  Next i

 'Connect to the Synthesis repository. The following code assumes that 
 'a standard repository called "RSRepository1.rsr10" exists in the C: drive. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToRepository ("C:\RSRepository1.rsr10")

 'Save the extracted data collection to the repository. 
  Call MyRepository.DataWarehouse.SaveRawDataSet(DataCollection)

End Sub


VB.NET Tutorial: Transfer Data from an Excel File to the SDW

Before we begin, be sure to reference the Microsoft Excel Object Library. Choose Project > Add Reference, and then select the library from the COM tab. Click OK.

1. Create a new form. On the code page, add an Imports statement for Microsoft.Office.Interop.Excel, then start with the following code to create an SDW data collection. The code uses the RawDataSet class to represent an SDW data collection, and the ExtractedType property to specify that the data collection is for use with Weibull++.

VB.NET

 'Declare a new instance of the RawDataSet class. 
  Dim DataCollection As New RawDataSet

 'Name the data collection "New Data Collection," and then specify that 
 'it is for use with Weibull++. 
  DataCollection.ExtractedName = "New Data Collection"
  DataCollection.ExtractedType = RawDataSetType.Weibull

3. Next, use the RawData class to represent a single row of data, and then use the AddDataRow method to add the row to the data collection.

The following code demonstrates one way to extract a row of data from the Excel file. First, the code opens a connection to the Excel file and specifies the active sheet (in this case, Sheet1). Then For i = 2, the code creates a new RawData object and sets its properties by using the values from row #2 of the Excel file. After the code finishes reading the row of data, it adds the object to the data collection. When the code reaches Next i, it increases i with 1 and jumps back to the For statement, which adds another new RawData object for the data in row #3 of the Excel sheet, and so on. The loop continues until i reaches the specified number of rows (MaxRow). Finally, the code closes the connection to the Excel file.

VB.NET

 'Declare a new instance of the RawData class. 
  Dim Row As New RawData

 'Open the Excel file. The following code assumes that the 
 'Excel file is saved in the C drive. 
  Dim Excel As New Application
  Dim Workbook As Workbook
  Dim Sheet As Worksheet

  Workbook = Excel.Workbooks.Open("C:\SampleData.xlsx")
  Sheet = Workbook.Sheets(1)

 'Read each row of data in the Excel file. 
  Dim i As Integer, MaxRow As Integer
  MaxRow = 20

  For i = 2 To MaxRow
      Row = New RawData

     'Set the properties for the current row of data. 
      Row.StateFS = sheet.Cells(i, 1).text
      Row.StateTime = sheet.Cells(i, 2).value
      Row.FailureMode = sheet.Cells(i, 3).text

     'Add the current row to the data collection. 
      Call DataCollection.AddDataRow(Row)
  Next i

 'Close the Excel file. 
  Workbook.Close()
  Excel.Quit()

4. Now that the data from the Excel file have been copied to the data collection, the next step is to save the data collection to the Synthesis repository.

Connect to the Synthesis repository and then use the DataWarehouse.SaveRawDataSet method to save the data collection to the repository.

VB.NET

 'Connect to the Synthesis repository. The following code assumes that 
 'a standard repository called "RSRepository1.rsr10" exists in the C: drive.   
  Dim MyRepository As New Repository   
  MyRepository.ConnectToRepository ("C:\RSRepository1.rsr10")

 'Save the extracted data collection to the repository. 
  MyRepository.DataWarehouse.SaveRawDataSet(DataCollection)

Test the Code

Let's verify whether the code can import the data successfully into the SDW.

Below is the complete code list 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. (You may need to display the StateTime, StateFS and FailureMode columns by right-clicking a column header and choosing Select Columns.)

VB.NET

Imports SynthesisAPI 
Imports Microsoft.Office.Interop.Excel

 Public Class Form1
     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

      'Declare a new instance of the RawDataSet class. 
       Dim DataCollection As New RawDataSet
 
      'Name the data collection "New Data Collection," and then specify that 
      'it is for use with Weibull++. 
       DataCollection.ExtractedName = "New Data Collection"
       DataCollection.ExtractedType = RawDataSetType.Weibull

      'Declare a new instance of the RawData class. 
       Dim Row As New RawData
 
      'Open the Excel file. The following code assumes that the 
      'Excel file is saved in the C drive. 
       Dim Excel As New Application
       Dim Workbook As Workbook
       Dim Sheet As Worksheet

       Workbook = Excel.Workbooks.Open("C:\SampleData.xlsx")
       Sheet = Workbook.Sheets(1)

      'Read each row of data in the Excel file. 
       Dim i As Integer, MaxRow As Integer
       MaxRow = 20
 
       For i = 2 To MaxRow
           Row = New RawData

           'Set the properties for the current row of data. 
            Row.StateFS = sheet.Cells(i, 1).text
            Row.StateTime = sheet.Cells(i, 2).value
            Row.FailureMode = sheet.Cells(i, 3).text

          'Add the current row to the data collection. 
           Call DataCollection.AddDataRow(Row)
       Next i

      'Close the Excel file. 
       Workbook.Close()
       Excel.Quit()

      'Connect to the Synthesis repository. The following code assumes that 
      'a standard repository called "RSRepository1.rsr10" exists in the C: drive.   
       Dim MyRepository As New Repository   
       MyRepository.ConnectToRepository ("C:\RSRepository1.rsr10")

      'Save the extracted data collection to the repository. 
       MyRepository.DataWarehouse.SaveRawDataSet(DataCollection)

     End Sub
End Class


References

To learn more, see the reference documentation for the classes and methods discussed in this section: