cancel
Showing results for 
Search instead for 
Did you mean: 

FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Creator
Creator

Hello community!

Through the Automation in Test.Lab I can acess to recorded data and manage them. It's OK.

But I want to get data in recording process or in preview process. Is it possible? I think it is possible.

 

I use C# for writing automation programm. When I add refer to LMS Test.Lab Automation 13A Type Library, I get three libriraries in Object browser: LMSTestLabAutomation.lib, FIFO.lib, PDATA.lib. 
For LMSTestLabAutomation.lib we have some examples and instructions, and I can use it to manipulation with Test.Lab and data in it. But I can't get acess to "Online Data" in Explorer (where I can see prview meanurment data before recording). 

I have interesting question: what is it FIFO.lib? Maybe it's File Input File Output, then it is exactly what I need.

By means of this code I can create new object from FifoBuffer class:

 FIFOLib.FifoBuffer bufer;
 bufer = new FIFOLib.FifoBufferClass();

For this object we have next intresting commands:

  1. Bytes In Fifo
  2. Data Output
  3. Strat Dispatch

And others. Besides FIFO.lib has many other interesting classes and interfaces.

 

Unfortunately, I can not see or get data from buffer during recording. I don't understend, how I can use FIFO.lib. 

I will be glad to any help to work with this tool. I am interested in any ideas or examples.

Thank you for you help, 

Ivan.

11 REPLIES

Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

I think FIFO.lib is almost never used, except maybe by Test.Lab developers.  I have never seen any documentation for it.  If you really want to know more about it, I suggest you contact your local Test.Lab support office.

As an alternative, you may be able to access the "Online Data" during an acqisition using the demo code below.  Note that the real-time rate using this method is not very fast, and it is possible for you to miss some data blocks, depending on the number of channels and sampling frequency.

 Dim TL As LMSTestLabAutomation.Application

' Declare a watch object for each online data block we want to access
' One is dimensioned 'WithEvents' to allow for automatic handling whenever the data changes
Dim WithEvents TLOnlineWatch1 As LMSTestLabAutomation.Watch
Dim TLOnlineWatch2 As LMSTestLabAutomation.Watch
Dim TLOnlineWatch3 As LMSTestLabAutomation.Watch


''' <summary>
''' Setup Test.Lab Watch objects for each block of Online Data to be accessed
''' </summary>
''' <remarks></remarks>
Private Sub InitOnlineDataAccess()
Dim TLOnlineDataPort As LMSTestLabAutomation.DataWatch
Dim TLOnlineData As LMSTestLabAutomation.ISignatureAcquisitionCtr
Dim PathToOnlineData_Stub As String

TL = New LMSTestLabAutomation.Application

' Example PathToOnlineData: Online Data_00-dc58b80d-8318-4e2c-85b1-b65c484a4137/Fixed sampling/Monitor/Time/Input1
PathToOnlineData_Stub = "Online Data_" & TL.ActiveBook.ID & "/Fixed sampling/Monitor/Time/Input"

TLOnlineDataPort = TL.ActiveBook.FindDataWatch("SignatureAcquistion\/AutomationBridge")
TLOnlineData = TLOnlineDataPort.Data
TLOnlineWatch1 = TLOnlineData.GetOnlineDataWatch(PathToOnlineData_Stub & "1")
TLOnlineWatch2 = TLOnlineData.GetOnlineDataWatch(PathToOnlineData_Stub & "2")
TLOnlineWatch3 = TLOnlineData.GetOnlineDataWatch(PathToOnlineData_Stub & "3")

End Sub


''' <summary>
''' Read data blocks from each of the Watch objects previously initialized.
''' To demonstrate it is working, we write the first value of each block to the gui.
''' </summary>
''' <remarks></remarks>
Private Sub ReadOnlineDataBlocks()
Dim myYvalues() As Double
Dim myValue As String
Dim TLOnlineBlock() As LMSTestLabAutomation.IBlock2
ReDim TLOnlineBlock(2)

' make sure watch objects have already been initialized
If TLOnlineWatch1 Is Nothing Then
MsgBox("Online data access has not been initialized yet", MsgBoxStyle.Exclamation)
Exit Sub
End If

' get a datablock from each of the online watches
TLOnlineBlock(0) = TLOnlineWatch1.Data
TLOnlineBlock(1) = TLOnlineWatch2.Data
TLOnlineBlock(2) = TLOnlineWatch3.Data


' Demo: read the first value of each block to display in gui
myValue = ""
For i As Integer = 0 To TLOnlineBlock.Length - 1
myYvalues = TLOnlineBlock(i).RealYValues
' if the system is not armed, the data blocks will be empty
If myYvalues.Length > 0 Then
myValue = myValue & TLOnlineBlock(i).RealYValues(0).ToString & vbCrLf
Else
MsgBox("No data found in block " & i + 1)
End If
Next

' write the values to the gui
RefreshGUI(myValue)

End Sub

 

Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Creator
Creator

PTM, thank you for your reply.

 

I have some questions on your note and code.

 

  1. Main question.

    You said:
    "Note that the real-time rate using this method is not very fast, and it is possible for you to miss some data blocks, depending on the number of channels and sampling frequency."

    What determines the speed of this method? Is it related to "MaxUpdateFrequency" in datawatch argument? How to determine the update rate?

  2. Questions by code.

    1) Why I don't see interface "ISignatureAcquisitionCtr
    " when I address to namespase "LMSTestLabAutomation" by "." ? What is this interface responsible for?

    2) Where I can find this datawtach?
     "SignatureAcquistion\/AutomationBridge"
    Why I don't see it in "Automation Workbook and Port Documentation"?

    3) I don't quite understend how this works: "WithEvents". How I know that Watch updated?

    Oh, I have so many questions, I'm sorry. But I'm very interested in how it works and where some ideas come from.

     

    Thank you for you attention!


Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Sorry, I don't really know the answers to these questions.  I only know I have used the code and it works.

I recommend you contact your local LMS Support office if you need more details.

 

Regarding declaring variables "WithEvents", this is a standard construct often used in VB.NET.  In this case, the Watch will generate an "Event" whenever its data changes, and you can create a subroutine and desginate it as an "Event Handler".  The subroutine will be automatically called whenever the Event is generated.  Try searching for "vb.net event" in google.

Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Creator
Creator

PLM, thank you for you reply.

I translated your VB code to C# and got next code (for 1 measuring channel):
 

LMSTestLabAutomation.Watch TLOnlineWatch1;
LMSTestLabAutomation.ISignatureAcquisitionCtr TLOnlineData;           
String PathToOnlineData_Stub;

PathToOnlineData_Stub = "Online Data_" + TL.ActiveBook.ID + "/Fixed sampling/Monitor/Time/Input";

LMSTestLabAutomation.DataWatch TLOnlineDataPort;
           
TLOnlineDataPort = TL.ActiveBook.FindDataWatch ("SignatureAcquistion\\/AutomationBridge", 1, 1, 1);

TLOnlineData = (LMSTestLabAutomation.ISignatureAcquisitionCtr)
TLOnlineDataPort.Data;
            
TLOnlineWatch1 = TLOnlineData.GetOnlineDataWatch
(PathToOnlineData_Stub + "1", 1, 1, 1);

LMSTestLabAutomation.IBlock2 TLOnlineBlock;
         
TLOnlineBlock = (LMSTestLabAutomation.IBlock2)TLOnlineWatch1.Data;

string label = TLOnlineBlock.Label;//Time Point 1 - I can receive access to TLOnlineWatch1 in the form of TLOnlineBlock 

//Create static array with 100 elements
 Array YValues;
 int length = 100;

YValues = Array.CreateInstance(typeof(double), length);
 
YValues = TLOnlineBlock.RealYValues;


int lengthYValues = YValues.GetLength(0); // lengthYValues = 0. I can't get value from TLOnlineBlock.

 

I can't get value from TLOnlineBlock (length of YVallues = 0).  I think this can be due to two things:

 

  1. I use static array for YValues.  But then I must to get message about the mismatch of arrays sizes.
  2. I don't understend, how I can use "Event Handler". Maybe "TLOnlineWatch1" didn't contain data at then moment when I asked it.
    Can you demonstate, how create "EventHandler" with function of "ReadOnlineDataBlocks"?

Thank you for you attention!

 

Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Here is the VB code for event handling:

 ''' <summary>
''' This sub runs whenever the data in TLOnlineWatch1 changes.
''' It allow automatic handling each time a new data block appears.
''' </summary>
''' <param name="NewValue"></param>
''' <remarks></remarks>
Private Sub TLOnlineWatch1_ValueChanged(ByVal NewValue As Object) Handles TLOnlineWatch1.ValueChanged

ReadOnlineDataBlocks()

End Sub

Also, here are some subs to enable or disable the event handling:

 Private Sub EnableAutoRead()
If TLOnlineWatch1 Is Nothing Then
MsgBox("Online data access has not been initialized yet", MsgBoxStyle.Exclamation)
Exit Sub
End If
AddHandler TLOnlineWatch1.ValueChanged, AddressOf TLOnlineWatch1_ValueChanged
End Sub

Private Sub DisableAutoRead()
If TLOnlineWatch1 Is Nothing Then
MsgBox("Online data access has not been initialized yet", MsgBoxStyle.Exclamation)
Exit Sub
End If
RemoveHandler TLOnlineWatch1.ValueChanged, AddressOf TLOnlineWatch1_ValueChanged
End Sub

 

Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Creator
Creator

PLM, thank you for you reply. You gave a very clear example.
But I have a few more questions:
1) You are getting "Online data" when acqusition are started or in preview mode?
2) "Measure" in Test.Lab has many different settings. Do settings affect to ability retrieve "Online data"? What are settings must be activated?

Thank you.

Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Creator
Creator

 

Hello, community!

Again I would like to say thank you to PTM! I was able to transfer his code to C# and it's worked. 

 

My code:

        //Define objects
LMSTestLabAutomation.IApplication TL;
LMSTestLabAutomation.Watch TLOnlineWatch1;
LMSTestLabAutomation.ISignatureAcquisitionCtr TLOnlineData;
LMSTestLabAutomation.DataWatch TLOnlineDataPort;

int counter;

public Form1() { InitializeComponent(); //Open workbook TL = new LMSTestLabAutomation.Application(); if (TL.Name == "") TL.Init("-w SignatureRealTimeAcquisitionFSStandard");
//Select active sheet TL.ActiveBook.SheetOnTop = "Measure";
//Define path to data String PathToOnlineData_Stub; PathToOnlineData_Stub = "Online Data_" + TL.ActiveBook.ID + "/Fixed sampling/Monitor/Time/Input"; //Define first Datawatch
TLOnlineDataPort = TL.ActiveBook.FindDataWatch("SignatureAcquistion\\/AutomationBridge", 1, 1, 1); //Select data from first Ddatawatch as second Datawatch
TLOnlineData = (LMSTestLabAutomation.ISignatureAcquisitionCtr)TLOnlineDataPort.Data;
//Get OnlineDatawatch (second Datawatch) TLOnlineWatch1 = TLOnlineData.GetOnlineDataWatch(PathToOnlineData_Stub + "1", 1, 1, 1);
//Subscribe to update event of data in OnlineDatawatch TLOnlineWatch1.ValueChanged += TLOnlineWatch1_ValueChanged;
}

//Define event handler
public void TLOnlineWatch1_ValueChanged(object NewValue)
{
firstValue = ReadValue(); //method ReadValue() return first value of OnlineDataBlock

counter++; //counter determines the speed of the event call
}

//Define method to read value from OnlineDatawatch
public string ReadValue()
{
LMSTestLabAutomation.IBlock2 TLOnlineBlock;

//Get data from OnlineDatawatch as IBlock2
TLOnlineBlock = (LMSTestLabAutomation.IBlock2)TLOnlineWatch1.Data;

Array YValues;

//Get data from IBlock2 as Array
YValues = TLOnlineBlock.RealYValues;

string first;

//Return first value from YValues if length of YValues > 0
if (YValues.GetLength(0) > 0)
first = (YValues.GetValue(0)).ToString();
else
first = "Error";

return first;
}

 

PTM was writing about slow speed of this method. According to my experiments, I can get the maximum data refresh rate about 4-5 Hz (time interval is 200-250 ms). I have one active measurment channel.

 

Method "GetOnlineDataWatch" has next signature:

GetOnlineDataWatch(string PathToOnlineData, int MaxFrequency, int IsAutoBuffered, int InitialFiring);

 where MaxFrequency must define time interval before data refresh. If I set MaxFrequency > 250 (500, 1000, etc) then it's work correctly and event "TLOnlineWatch1_ValueChanged" are called through MaxFrequency interval in ms. But if I set MaxFrequency < 200 (200, 100, 1)  then it's work incorrectly and event "TLOnlineWatch1_ValueChanged" are called through 200-250 ms time interval. I measure time interval by class Stopwatch in C#.

 

How can I improve  speed of data acquisition? Maybe there are some additional settings? 
After all, the Test.Lab itself writes data at a much higher speed. 

Or maybe there is another way to get Online data? 

 

Thank you for you help,

Ivan.

Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Dear,

 

Here maybe some answers on your question about online data and Automation.

 

If you open the Data Explorer in Test.Lab you can see there are 3 kinds of Online Data:

  1. Instantaneous data: This data will update whenever a new tracking point is dectected. It shows the data that is related with that tracking Point. Data is available when system is Armed & Measuring.

  2. Monitor data: Updates happen on a regular base AND are independent from the selected tracking settings. Data is available when system is Armed. This is update rate is currently 5x/second or every 200 ms fixed.
  3. Time / Runup / Rundown / Event / Stationary: The node name depends on the selected tracking settings. The data updated whenever a new tracking point was found. Data is available when system is Armed & Measuring.

In your code example, you use the following online data path:  ".../Fixed Sampling/Monitor/Time/Input1", so it's normal that you get a new block on +/- 200ms.

If you want to have this a higher speed then you need to use the
".../Fixed Sampling/Instantaneous/Vibration/Input1", this online data path follows the speed of the Test.Lab tracking settings. 

In attached file you can find a small code snippet with 2 types of online data. With simple time counter inside.

 

And indeed in the DataWatch and GetOnlineDataWatch, there is a property called "MaxUpdateFrequency", but you need to give a value Time (ms), this is not the best naming of the property.

 

Kind regards,

 

bvlassa

Re: FIFO.lib in Test.Lab Automation: can I acess measurment data in real time?

Creator
Creator

bvlassa, thank you for your reply.

 

You presented detailed description types of Online data. It's very useful!

 

But I still have a few more questions.

I use Instantaneous data for getting TimePoints online. I use the following settings for tracking:

Measurment mode - Tracked.

Tracking method - Time.

Duration - value.

Increment - value.

As I understand it, the "Increment" determines the step of updating the data in time. When Increment > 0.1s (10x/second), it's working correctly and OnlineDataPort_ValueChanged is updating (10x/second). But when Increment < 0.1s (0.05s) OnlineDataPort_ValueChanged is updating more slower, than Increment. Why is that? How I can increase updating frequency? 

 

bvlassa, what maximum updating frequency you have?

Thank you!