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
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{InProgress}}{{DISPLAYTITLE:Synthesis Data Warehouse (SDW) Tutorial}}{{Template:API}}
{{Template:API}}{{Template:BacktoPrevPage}}
<div style="border:1px solid #AAA; background:#f9f9f9; border-radius:10px; width:auto; margin:0 0 1em 1em; padding:1em; float:right;">
<nowiki><<</nowiki> [[APIQuickStartGuide|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. With the Synthesis API, you can transfer data from external sources into the SDW of a repository for use in Weibull++, ALTA or RGA standard folios.
</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.  
In this tutorial, you'll create a simple solution for copying data from a Microsoft Excel&#174; file over to the SDW. Note that the tutorial only demonstrates one particular approach for extracting data from Excel. It's for demonstration purposes only; it doesn't take efficiency into account and doesn't include any exception handling.  


==Prerequisites==
Before you begin:


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)''.
*Reference the Microsoft Excel Object Library in your code. (In Visual Studio, choose '''Project > Add Reference''', and in the COM tab, select the latest version of the Microsoft Excel Object Library. Click '''OK'''.)


== Transfer Data from an Excel File to the SDW ==
*Create a Synthesis repository for testing purposes.


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++.
*You'll also need to create a sample Excel file to complete the tutorial successfully. Copy and paste the following data to an Excel file. Be sure to select cell A1 in Sheet1 of the workbook when pasting the data. Name the Excel file, "SampleData."


Create a new module and start with the following code to create an SDW data collection.
{| {{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
|-
|}


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


'''VB.NET'''
==Tutorial: Transfer Data from an Excel File to the SDW==
{{APIComment|'Declare a new instance of the RawDataSet class.}}
The following example demonstrates how to transfer data from an Excel file to the Synthesis Data Warehouse (SDW). A discussion of the example follows.
  {{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


 
A VBA version of the code sample is available [[Transfer_Data_to_the_Synthesis_Data_Warehouse_(SDW)/VBA|here]].  
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.
 
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)
 
'''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 = 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'''
  '''VB.NET'''
   
   
  {{APIComment|'Declare a new instance of the RawData class.}}
  {{APIPrefix|Imports}} SynthesisAPI
  {{APIPrefix|Dim}} Row {{APIPrefix|As New}} RawData
{{APIPrefix|Imports}} Microsoft.Office.Interop.Excel
   
   
{{APIComment|'Read each row of data from the Excel sheet.}}
  {{APIPrefix|Public Module}} Module1
  {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
      {{APIPrefix|Sub}} Main()
  MaxRow = 100
   
   
  {{APIPrefix|For}} i = 2 to MaxRow
      {{APIComment|'Declare a new RawDataSet object.}}
      Row = {{APIPrefix|New}} RawData
        {{APIPrefix|Dim}} DataCollection {{APIPrefix|As New}} RawDataSet
 
      {{APIComment|'Name it "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|'Set the desired properties for the current row of data.}}
      {{APIComment|'Declare a RawData object.}}
      Row.StateFS = Sheet1.Cells(i, 1)
        {{APIPrefix|Dim}} Row {{APIPrefix|As}} RawData
      Row.StateTime = Sheet1.Cells(i,2)
 
      Row.FailureMode = Sheet1.Cells(i,3)
      {{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
   
   
    {{APIComment|'Add the current row to the data collection.}}
        Workbook = Excel.Workbooks.Open({{APIString|"C:\SampleData.xlsx"}})
      DataCollection.AddDataRow(Row)
        Sheet = Workbook.Sheets(1)
  {{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|'Read each row of data in the Excel file.}}
{{APIComment|'a standard repository called "RSRepository1.rsr10" exists in the C: drive.}}
        {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository 
        MaxRow = 20
  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()
        {{APIPrefix|For}} i = 2 {{APIPrefix|To}} MaxRow
            Row = {{APIPrefix|New}} RawData
{{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.}}
          {{APIComment|'Set the properties for the current data point.}}
  {{APIPrefix|Dim}} Row {{APIPrefix|As New}} RawData
            Row.StateFS = sheet.Cells(i, 1).text
            Row.StateTime = sheet.Cells(i, 2).value
            Row.FailureMode = sheet.Cells(i, 3).text
   
   
{{APIComment|'Read each row of data from the Excel sheet.}}
          {{APIComment|'Add the current data point to the data collection.}}
  {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
            DataCollection.AddDataRow(Row)
  MaxRow = 100
        {{APIPrefix|Next}} i
   
   
  {{APIPrefix|For}} i = 2 {{APIPrefix|to}} MaxRow
      {{APIComment|'Close the Excel file.}}
      {{APIPrefix|Set}} Row = {{APIPrefix|New}} RawData
        Workbook.Close()
        Excel.Quit()
   
   
    {{APIComment|'Set the desired properties for the current row of data.}}
      {{APIComment|'Connect to a Synthesis repository.}}
      Row.StateFS = Sheet1.Cells(i, 1)
        {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository 
      Row.StateTime = Sheet1.Cells(i,2)
        MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr11"}}){{APIComment|'Replace with name and path to test repository.}}
      Row.FailureMode = Sheet1.Cells(i,3)
   
   
    {{APIComment|'Add the current row to the data collection.}}
      {{APIComment|'Send the data collection to the repository.}}
      {{APIPrefix|Call}} DataCollection.AddDataRow(Row)
        MyRepository.DataWarehouse.SaveRawDataSet(DataCollection)
  {{APIPrefix|Next}} i
   
   
{{APIComment|'Connect to the Synthesis repository. The following code assumes that}}
      {{APIPrefix|End Sub}}
  {{APIComment|'a standard repository called "RSRepository1.rsr10" exists in the C: drive.}}
  {{APIPrefix|End Module}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
 
  MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr10"}})
==Discussion==
Begin by creating an SDW data collection. The [[RawDataSet Class|RawDataSet]] class represents the data collection. For this example, we've set it to contain data sets for Weibull++.  
{{APIComment|'Save the extracted data collection to the repository.}}
  {{APIPrefix|Call}} MyRepository.SaveRawDataSet(DataCollection)
End Sub


'''VB.NET'''
  {{APIComment|'Declare a new RawDataSet object.}}
Sub Main()
  {{APIComment|'Declare a new instance of the RawDataSet class.}}
   {{APIPrefix|Dim}} DataCollection {{APIPrefix|As New}} RawDataSet
   {{APIPrefix|Dim}} DataCollection {{APIPrefix|As New}} RawDataSet
 
  {{APIComment|'Name the data collection "New Data Collection," and then specify that}}
  {{APIComment|'Name it "New Data Collection," and then specify that}}
  {{APIComment|'it is for use with Weibull++.}}
  {{APIComment|'it is for use with Weibull++.}}
   DataCollection.ExtractedName = {{APIString|"New Data Collection"}}
   DataCollection.ExtractedName = {{APIString|"New Data Collection"}}
   DataCollection.ExtractedType = RawDataSetType.Weibull
   DataCollection.ExtractedType = RawDataSetType.Weibull
Next, declare a [[RawData Class|RawData]] object, which represents a single data point. We will use this object to represent each row of data in the Excel file.
{{APIComment|'Declare a RawData object.}}
  {{APIPrefix|Dim}} Row {{APIPrefix|As}} RawData
The following section of 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>, it creates a new <code>RawData</code> object and uses the values in row #2 of the Excel file to define the data point.
After the code finishes reading the row of data, it adds the data point 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 creates a new <code>RawData</code> object to represent the data point 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.
{{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
   
   
{{APIComment|'Declare a new instance of the RawData class.}}
  Workbook = Excel.Workbooks.Open({{APIString|"C:\SampleData.xlsx"}})
   {{APIPrefix|Dim}} Row {{APIPrefix|As New}} RawData
   Sheet = Workbook.Sheets(1)
   
   
  {{APIComment|'Read each row of data from the Excel sheet.}}
  {{APIComment|'Read each row of data in the Excel file.}}
   {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
   {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer, MaxRow {{APIPrefix|As}} Integer
   MaxRow = 100
   MaxRow = 20
 
   {{APIPrefix|For}} i = 2 to MaxRow
   {{APIPrefix|For}} i = 2 {{APIPrefix|To}} MaxRow
       Row = {{APIPrefix|New}} RawData
       Row = {{APIPrefix|New}} RawData
   
   
     {{APIComment|'Set the desired properties for the current row of data.}}
     {{APIComment|'Set the properties for the current data point.}}
       Row.StateFS = Sheet1.Cells(i, 1)
       Row.StateFS = sheet.Cells(i, 1).text
       Row.StateTime = Sheet1.Cells(i,2)
       Row.StateTime = sheet.Cells(i, 2).value
       Row.FailureMode = Sheet1.Cells(i,3)
       Row.FailureMode = sheet.Cells(i, 3).text
   
   
     {{APIComment|'Add the current row to the data collection.}}
     {{APIComment|'Add the current data point to the data collection.}}
       DataCollection.AddDataRow(Row)
       DataCollection.AddDataRow(Row)
   {{APIPrefix|Next}} i
   {{APIPrefix|Next}} i
   
   
  {{APIComment|'Connect to the Synthesis repository. The following code assumes that}}
  {{APIComment|'Close the Excel file.}}
  {{APIComment|'a standard repository called "RSRepository1.rsr10" exists in the C: drive.}}
  Workbook.Close()
  Excel.Quit()
 
Now that we've filled the data collection with the data points, the next step is to send the data collection to the Synthesis repository.
First, connect to a Synthesis repository (for details, see [[Connect_or_Disconnect_from_a_Synthesis_Repository|this tutorial]].) 
 
  {{APIComment|'Connect to a Synthesis repository.}}
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr10"}})
   MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr11"}}){{APIComment|'Replace with name and path to test repository.}}
 
  {{APIComment|'Save the extracted data collection to the repository.}}
Then use the [[Repository.DataWarehouse.SaveRawDataSet|Repository.DataWarehouse.SaveRawDataSet]] method to save the data collection to the Synthesis repository, as shown below.
   MyRepository.SaveRawDataSet(DataCollection)
 
  {{APIComment|'Send the data collection to the repository.}}
End Sub
   MyRepository.DataWarehouse.SaveRawDataSet(DataCollection)
 
To verify that the data were imported, launch Weibull++, open the SDW ('''Home > Synthesis > Synthesis Data Warehouse''') and then select the new data collection. (To view the data, you may need to display the StateTime, StateFS and FailureMode columns by right-clicking a column header and choosing '''Select Columns'''.)
 
==Notes==
In a secure database, you must have the "Create/edit/delete SDW data collections" permission in order to send a data collection to the database.
 
A data point (i.e., [[RawData Class|RawData]] object) for a Weibull++ data set typically requires the following properties:
* LastInspectedTime
* NumberinState
* StateFS
* StateTime
 
For an RGA data set, the properties are:
* LastInspectedTime
* StateFS
* StateTime
* TopLevelSerialNumber


===References===
===References===
To learn more, see the reference documentation for the classes and methods discussed in this section:
*[[RawData Class]]
*[[RawDataSet Class]]
*[[RawDataSet Class]]
*[[RawData Class]]
**[[AddDataRow Method|RawDataSet.AddDataRow Method]]
*[[AddDataRow Method|RawDataSet.AddDataRow Method]]
*[[Repository.DataWarehouse.SaveRawDataSet|Repository.DataWarehouse.SaveRawDataSet Method]]
*[[Repository.DataWarehouse.SaveRawDataSet|Repository.DataWarehouse.SaveRawDataSet Method]]

Latest revision as of 18:29, 3 April 2017

APIWiki.png


<< Back to Tutorials Main Page

The Synthesis Data Warehouse (SDW) — formerly called "Reliability Data Warehouse" — is a temporary data storage location in a Synthesis repository. With the Synthesis API, you can transfer data from external sources into the SDW of a repository for use in Weibull++, ALTA or RGA standard folios.

In this tutorial, you'll create a simple solution for copying data from a Microsoft Excel® file over to the SDW. Note that the tutorial only demonstrates one particular approach for extracting data from Excel. It's for demonstration purposes only; it doesn't take efficiency into account and doesn't include any exception handling.

Prerequisites

Before you begin:

  • Reference the Microsoft Excel Object Library in your code. (In Visual Studio, choose Project > Add Reference, and in the COM tab, select the latest version of the Microsoft Excel Object Library. Click OK.)
  • Create a Synthesis repository for testing purposes.
  • You'll also need to create a sample Excel file to complete the tutorial successfully. Copy and paste the following data to an Excel file. Be sure to select cell A1 in Sheet1 of the workbook when pasting the data. Name the Excel file, "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


Tutorial: Transfer Data from an Excel File to the SDW

The following example demonstrates how to transfer data from an Excel file to the Synthesis Data Warehouse (SDW). A discussion of the example follows.

A VBA version of the code sample is available here.

VB.NET

Imports SynthesisAPI 
Imports Microsoft.Office.Interop.Excel

 Public Module Module1
     Sub Main()

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

      'Declare a RawData object. 
       Dim Row As 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 data point. 
            Row.StateFS = sheet.Cells(i, 1).text
            Row.StateTime = sheet.Cells(i, 2).value
            Row.FailureMode = sheet.Cells(i, 3).text

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

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

      'Connect to a Synthesis repository.   
       Dim MyRepository As New Repository   
       MyRepository.ConnectToRepository ("C:\RSRepository1.rsr11") 'Replace with name and path to test repository. 

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

     End Sub
End Module

Discussion

Begin by creating an SDW data collection. The RawDataSet class represents the data collection. For this example, we've set it to contain data sets for Weibull++.

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

Next, declare a RawData object, which represents a single data point. We will use this object to represent each row of data in the Excel file.

 'Declare a RawData object. 
  Dim Row As RawData

The following section of 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, it creates a new RawData object and uses the values in row #2 of the Excel file to define the data point.

After the code finishes reading the row of data, it adds the data point to the data collection. When the code reaches Next i, it increases i with 1 and jumps back to the For statement, which creates a new RawData object to represent the data point 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.

 '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 data point. 
      Row.StateFS = sheet.Cells(i, 1).text
      Row.StateTime = sheet.Cells(i, 2).value
      Row.FailureMode = sheet.Cells(i, 3).text

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

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

Now that we've filled the data collection with the data points, the next step is to send the data collection to the Synthesis repository.

First, connect to a Synthesis repository (for details, see this tutorial.)

 'Connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToRepository("C:\RSRepository1.rsr11") 'Replace with name and path to test repository. 

Then use the Repository.DataWarehouse.SaveRawDataSet method to save the data collection to the Synthesis repository, as shown below.

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

To verify that the data were imported, launch Weibull++, open the SDW (Home > Synthesis > Synthesis Data Warehouse) and then select the new data collection. (To view the data, you may need to display the StateTime, StateFS and FailureMode columns by right-clicking a column header and choosing Select Columns.)

Notes

In a secure database, you must have the "Create/edit/delete SDW data collections" permission in order to send a data collection to the database.

A data point (i.e., RawData object) for a Weibull++ data set typically requires the following properties:

  • LastInspectedTime
  • NumberinState
  • StateFS
  • StateTime

For an RGA data set, the properties are:

  • LastInspectedTime
  • StateFS
  • StateTime
  • TopLevelSerialNumber

References