This project is read-only.

GridTrak Open Source PMU (GTosPMU) to openPDC Data in 5 Easy Steps

This document is derived from the openPDC project's document:  Device to Data in 5 Easy Steps
The procedure is the same. There are only a few minor code changes.

  1. Create a project
  2. Add references
  3. Copy in the code snippet
  4. Set up your data source
  5. Run the application

Step 1: Create a project

The first thing you need to do is create a console application in Microsoft Visual Studio 2008. The following are detailed steps to guide you through the process.

  1. Launch Microsoft Visual Studio
  2. In the toolbar, go to "File > New > Project..."
  3. Under "Project Types", click on "Windows".
  4. Under "Templates", click on "Console Application".
  5. In the text box labeled "Name", enter the name of your application (e.g. "DeviceToData").
  6. Click the button labeled "Browse..." and select a directory to store the project.
  7. Click the "OK" button
  8. Right Click on your new project and select "Properties"
  9. In the Application settings, change the Target Framework to ".NET Framework 4"

Step 2: Add references

In order to get the code to run, you will need to add references to the openPDC assemblies. The following are detailed steps to guide you through the process.
Note: In order to complete this step, you will need to build openPDC.

  1. In your project's Solution Explorer on the right, right-click "References", select "Add Reference...", then click the Browse button
  2. Navigate to "SOURCEDIR\Main\Build\Output\Debug\Libraries" (SOURCEDIR is the directory where you extracted and built the openPDC source code files).
  3. Select "TVA.Communication.dll", "TVA.Core.dll", "TVA.PhasorProtocols.dll", and "TimeSeriesFramework.dll" then click the "OK" button

Step 3: Copy in the code snippet

Now you are ready to copy the source code that will interface with your device. Remove everything in Program.cs and replace it with the following code snippet.

using System;
using System.Collections.Generic;
using System.Text;
using TVA;
using TVA.PhasorProtocols;

namespace GTosPMUtoData
  /// <summary>
  /// Sample Program adapted for the GridTrak Open Source SynchroPhasor PMU
  /// from openPDC sample: Device to Data in 5 Easy Steps.
  /// References: and
  /// Mar 28, 2011  Updated
  /// </summary>
  class Program
    static MultiProtocolFrameParser parser;
    static long frameCount;

    static void Main(string[] args)
      Console.WriteLine("GTosPMU to Data for openPDC Test");
      // Create a new protocol parser
      parser = new MultiProtocolFrameParser();

      // Attach to desired events
      parser.ConnectionAttempt += parser_ConnectionAttempt;
      parser.ConnectionEstablished += parser_ConnectionEstablished;
      parser.ConnectionException += parser_ConnectionException;
      parser.ParsingException += parser_ParsingException;
      parser.ReceivedConfigurationFrame += parser_ReceivedConfigurationFrame;
      parser.ReceivedDataFrame += parser_ReceivedDataFrame;

      // Define the connection string
      parser.ConnectionString = "phasorProtocol=IeeeC37_118V1; transportProtocol=Serial; accessID=2; "
                                + "port=COM1; baudrate=115200; parity=None; stopbits=One; databits=8; "
                                + "dtrenable=False; rtsenable=False; autoStartDataParsingSequence = false;";

      // Start frame parser
      parser.AutoStartDataParsingSequence = true;

      // Hold the console open until the operator hits the <Enter> key

    static void parser_ReceivedDataFrame(object sender, EventArgs<IDataFrame> e)
      // Increase the frame count each time a frame is received

      // Print information each time we receive 60 frames (every 2 seconds @ 30 fps)
      // Also check to make sure we have at least one protocol cell in the DataFrame; else ignore processing it.
      if ((frameCount % 60 == 0) && (e.Argument.Cells.Count > 0))
        IDataCell device = e.Argument.Cells[0];
        Console.WriteLine("Received data frames so far =  " + frameCount.ToString());
        Console.WriteLine("  Last frequency =  ", device.FrequencyValue.Frequency.ToString("00.0000") + " Hz");
        for (int ii= 0; ii < device.PhasorValues.Count; ii++)
          Console.WriteLine("  Last phase angle[" + ii.ToString() + "] =  " 
                            + device.PhasorValues[ii].Angle.ToString("##0.0000") + " rad");

          Console.WriteLine("  Last magnitude[" + ii.ToString() + "] =  " 
                            + device.PhasorValues[ii].Magnitude.ToString("##0.000") + " {device units}");
        Console.WriteLine("    Last Timestamp =  " +((DateTime)device.Timestamp).ToString("yyyy-MM-dd HH:mm:ss.fff"));

    static void parser_ReceivedConfigurationFrame(object sender, EventArgs<IConfigurationFrame> e)
      // Notify the user when a configuration frame is received
      Console.WriteLine("Received configuration frame with {0} device(s)", e.Argument.Cells.Count);

    static void parser_ParsingException(object sender, EventArgs<Exception> e)
      // Output the exception to the user
      Console.WriteLine("Parsing exception: {0}", e.Argument);

    static void parser_ConnectionException(object sender, EventArgs<Exception, int> e)
      // Display which connection attempt failed and the exception that occurred
      Console.WriteLine("Connection attempt {0} failed due to exception: {1}", e.Argument2, e.Argument1);

    static void parser_ConnectionEstablished(object sender, EventArgs e)
      // Notify the user when the connection is established
      Console.WriteLine("Initiating {0} {1} based connection...",

    static void parser_ConnectionAttempt(object sender, EventArgs e)
      // Let the user know we are attempting to connect
      Console.WriteLine("Attempting connection...");


Step 4: Set up your PMU Sensor

Just connect the GTosPMU sensor to the host PC serial or USB port and and plug in the transformer.

Step 5: Run the application

If you followed all the other steps correctly, you should be able to run the project by pressing "F5" from within Microsoft Visual Studio. The result should look something like the example image below.


Last edited Jan 15, 2012 at 3:32 AM by ajstadlin, version 7


ajstadlin Mar 21, 2015 at 4:49 AM 
Thank you jramirez for the above comments and corrections!

jramirez Mar 29, 2011 at 9:42 PM 
About the "ToGrads" method:

This method gives mistakes in the measurements, I have done conversions to degrees with it and its mistakes are around of 11%.

The error was calculated with E=|Vref-Vdata|/Vref .... where Vref is the data given by the PhasorPoint developed by Psymetrix.

If I do the procedure with the explicit equation ( X[°]=180[°] * X[Rad] / Pi ), it gives the same value that the PhasorPoint.

jramirez Mar 29, 2011 at 4:14 PM 
you should update the version Visual Studio 2008 to Visual Studio 2010 in Step 1.

The frequency value does not appear due to you forgot write {0} before quotes after equal sign ...........
Console.WriteLine(" Last frequency ={0} ", device.FrequencyValue.Frequency.ToString("00.0000") + " Hz");