This project has moved. For the latest updates, please go here.

Issues for "Device to Data in 5 Easy Steps

Feb 7, 2010 at 5:16 AM

Hi,

I followed the “Device to Data in 5 Easy Steps” in the document to create the sample Console Application and to connect to the sample file Sample1344.PmuCaptue. I observed the following issues:

1)      The program does not receive any events except the parser_ConnectionEstablished event. However, if I run with debug and set the break point in the OpenFile() of FileClient.cs to slow down the process, All events fired normally and I received all data correctly. Finally I added 0.1 second sleep just after open file in OpenFile() of FileClient.cs and run it without debug again. It works OK. It sems to me there are some timing issue in the file opening and need to slow down to make sure the file is open completely before continue the process. Adding 0.1 second sleep to slow down the process is only a temperary solution. We need to find a more reliable permanent solution.

2)     In the same sample program, I try to access the Binary Image data in the event handler parser_ReceivedDataFrame, usiing  the following code:

 byte[] BinaryImage = e.Argument.BinaryImage;

However this causes an “Index was outside the bounds of the array.” Exception. The exception is throw in the function SwapCopy of file EndianOrder.cs at the following line:

destinationBuffer[offset - (x - sourceIndex)] = sourceBuffer[x];

 I add a protetive statement before this line as follow:

            if (offset - (x - sourceIndex) >= destinationBuffer.Length)

                    continue;

      After that the exception is no longer occured.

Please investigate these two issues and take the necessary corrective measure.

Thank you very much.

Hongtao Chen

 

  

Coordinator
Feb 9, 2010 at 5:35 PM

Hello Hongtao Chen,

I am able to reproduce your second issue, and I have found the cause. We are working on a solution now.

Your first issue, on the other hand, is one I have not been able to reproduce. The only time I ever came close was when I didn't have the sample file in the project's build folder. I was wondering if you could clarify some things.

1) What operating system are you using for your tests?

2) Are you receiving the parser.ConnectionAttempt event in addition to the parser.ConnectionEstablished event?

3) Can you verify that you are still able to reproduce your first issue?

Thanks!

Stephen Wills

Feb 10, 2010 at 2:02 AM
Hi, Staphen.

Thank for looking into that.
Attached is my Test console program.

1) I am using XP profresional.
2) Yes, I receive the parser.ConnectionAttempt event in addition to the parser.ConnectionEstablished event? No more other events.
3) I am still ablelto reproduce the problem.

I think this kind of timing issue may depends on the machine's process power and/or the file system IO speed. Try to get a more powerful PC to see if you can reproduce it.

Thanks

Hongtao



From: [email removed]
To: [email removed]
Date: Tue, 9 Feb 2010 10:35:20 -0800
Subject: Re: Issues for "Device to Data in 5 Easy Steps [openpdc:83396]

From: staphen
Hello Hongtao Chen,
I am able to reproduce your second issue, and I have found the cause. We are working on a solution now.
Your first issue, on the other hand, is one I have not been able to reproduce. The only time I ever came close was when I didn't have the sample file in the project's build folder. I was wondering if you could clarify some things.
1) What operating system are you using for your tests?
2) Are you receiving the parser.ConnectionAttempt event in addition to the parser.ConnectionEstablished event?
3) Can you verify that you are still able to reproduce your first issue?
Thanks!
Stephen Wills
Read the full discussion online.
To add a post to this discussion, reply to this email (openpdc@discussions.codeplex.com)
To start a new discussion for this project, email openpdc@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Hotmail: Trusted email with powerful SPAM protection. Sign up now.
Developer
Feb 10, 2010 at 7:15 PM

Hi, Hongtao,

I could not reproduce your first issue. But I suspect the problem is in the Start() of MultiProtocolFrameParser.cs:

{....

<font size="2">

 

</font>

// Establish data channel connection - must be defined.

InitializeDataChannel(settings);

<font size="2">

 

</font>

// Start parsing engine

m_frameParser.Start();

}

Could you switch the sequence as following:

{....

   // Start parsing engine

   m_frameParser.Start();

   // Establish data channel connection - must be defined.

   InitializeDataChannel(settings);

<font size="2">

 

</font>

}

and see if your first issue still exist.

Thanks,

Ryan

Coordinator
Feb 11, 2010 at 12:57 AM
Edited Feb 11, 2010 at 12:58 AM

On your first issue, I believe the example should set the "DefinedFrameRate", without this the system will load the file data too quickly. Simply add the following to the code before starting the parser:

parser.DefinedFrameRate = 30;

If this corrects your issue, we will update the sample as appropriate.

On your second issue, you are trying to use the "bi-directional" features of the parsing class. All phasor protocol implementations in the openPDC can both "consume" and "produce" binary frame images - this way you can be a consumer or a producer of the phasor protocol data. The code example you are using is setup to "consume" binary data from an incoming data stream - there is not enough code defined to "produce" the binary frame image as you were requesting by calling the "BinaryImage" property (i.e., you were asking the protocol to "generate" a binary image, but there are more steps required to do this).

If you want a copy of the incoming binary frame as it was received by the protocol, subscribe to the "ReceivedFrameBufferImage" event, which will provide the frame type and binary image you are looking for:

/// <summary>
/// Occurs when a frame buffer image has been received.
/// </summary>
/// <remarks>
/// <see cref="EventArgs{T1,T2,T3,T4}.Argument1"/> is the <see cref="FundamentalFrameType"/> of the frame buffer image that was received.<br/>
/// <see cref="EventArgs{T1,T2,T3,T4}.Argument2"/> is the buffer that contains the frame image that was received.<br/>
/// <see cref="EventArgs{T1,T2,T3,T4}.Argument3"/> is the offset into the buffer that contains the frame image that was received.<br/>
/// <see cref="EventArgs{T1,T2,T3,T4}.Argument4"/> is the length of data in the buffer that contains the frame image that was received.
/// </remarks>
public event EventHandler<EventArgs<FundamentalFrameType, byte[], int, int>> ReceivedFrameBufferImage;

Thanks!

Ritchie

Feb 11, 2010 at 4:24 AM
Ritchie & Ryan,

I try both of your sugestions. Unfortunately, neither one works.

Finally I try to set

parser.ExecuteParseOnSeparateThread = true;

And it works.

On the second issue, I try to subscribe the "ReceivedFrameBufferImage" as you suggested and I receive the event with 4 arguments. Could you explain more detail of how to use the argument 3 and argument 4?

Thanks

Hongtao

From: [email removed]
To: [email removed]
Date: Wed, 10 Feb 2010 17:57:30 -0800
Subject: Re: Issues for "Device to Data in 5 Easy Steps [openpdc:83396]

From: ritchiecarroll
On your first issue, I believe the example should set the "DefinedFrameRate", without this the system will load the file data too quickly. Simply add the following to the code before starting the parser:
parser.DefinedFrameRate = 30;
If this corrects your issue, we will update the sample as appropriate.
On your second issue, you are trying to use the "bi-directional" features of the parsing class. All phasor protocol implementations in the openPDC can both "consume" and "produce" binary frame images - this way you can be a consumer or a producer of the phasor protocol data. The code example you are using is setup to "consume" binary data from an incoming data stream - there is not enough code defined to "produce" the binary frame image as you were requesting by calling the "BinaryImage" property (i.e., you were asking the protocol to "generate" a binary image, but there are more steps required to do this).
If you want a copy of the incoming binary frame as it was received by the protocol, subscribe to the "ReceivedFrameBufferImage" event, which will provide the frame type and binary image you are looking for:<font size="2">


</font>

/// <summary> 
/// Occurs when a frame buffer image has been received. 
/// </summary> 
/// <remarks> 
/// <see cref="EventArgs{T1,T2,T3,T4}.Argument1"/> is the <see cref="FundamentalFrameType"/> of the frame buffer image that was received.
/// <see cref="EventArgs{T1,T2,T3,T4}.Argument2"/> is the buffer that contains the frame image that was received.
/// <see cref="EventArgs{T1,T2,T3,T4}.Argument3"/> is the offset into the buffer that contains the frame image that was received.
/// <see cref="EventArgs{T1,T2,T3,T4}.Argument4"/> is the length of data in the buffer that contains the frame image that was received. /// </remarks> public event EventHandler<EventArgs<FundamentalFrameType, byte[], int, int>> ReceivedFrameBufferImage;


Thanks!
Ritchie

Read the full discussion online.
To add a post to this discussion, reply to this email (openpdc@discussions.codeplex.com)
To start a new discussion for this project, email openpdc@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now.
Coordinator
Feb 12, 2010 at 8:41 PM

Hi Hongtao,

Can you download the source code in change set 41486 and try the sample application against this build? Hopefully we've fixed the timing issue you reported. Please let us know what you find since we can't seem to reproduce the issue on our machines.

- Pinal

Feb 13, 2010 at 4:50 PM

Pinal & Ryan,

This change set works. The problem is fixed. Thank you all very much.

Hongtao

From: [email removed]
To: [email removed]
Date: Fri, 12 Feb 2010 13:41:48 -0800
Subject: Re: Issues for "Device to Data in 5 Easy Steps [openpdc:83396]

From: pinalpatel
Hi Hongtao,
Can you download the source code in change set 41486 and try the sample application against this build? Hopefully we've fixed the timing issue you reported. Please let us know what you find since we can't seem to reproduce the issue on our machines.
- Pinal
Read the full discussion online.
To add a post to this discussion, reply to this email (openpdc@discussions.codeplex.com)
To start a new discussion for this project, email openpdc@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now.