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

OpenPDC OutputStream Adapter

May 31, 2012 at 7:50 PM
Edited May 31, 2012 at 7:51 PM

All,
I'm attempting to route data from an input PMU to a custom outputstream adapter.  I built a naive version to test and I have been unsuccessful at getting it to run correctly.  Here is what I’m doing.  I downloaded Visual Studio 10 Express and created the code (shown below) following the instructions on: http://openpdc.codeplex.com/wikipage?title=Custom%20Adapter.

The code compiles.  I then open the OpenPDC manager and navigate to: Adapters->Output Adapters.  I add a unique name in the “name” field.  I choose the “Default” node as all I want to do is test the output adapter against SHELBY.  I enter in the DLL release directory in the Adapter Type->Search Directory and choose my derived class name “OpenPDCOutputAdapter1” from the combo box.  Since my naïve adapter will only write to a hardcoded file name, I don’t enter any information into the Connection String information.  I enable the newly created output adapter and save it.  After saving, I click the “Initialize” button in OpenPDC manager.  My understanding is that this button click will execute the code in my overridden “Initialize” function.  Is this correct?  When I click “Initialize”, then I would expect the file “output.txt” to be created.  I don’t see that happening.  I would also expect that the output.txt would have data from SHELBY written to it as the capture replays.  Have I registered or implemented something incorrectly?

Any help is appreciated,

TJ

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using TimeSeriesFramework.Adapters;

 

 

//OpenPDC Output Adapter Path: C:\Users\...\OpenPDCOutputAdapter1\bin\Release

namespace OpenPDCOutputAdapter1

{

    public class MyOutputAdapter1 : OutputAdapterBase

    {

        private string filePath = @"C:\Temp\New folder\output.txt";

        private System.IO.StreamWriter writer;

 

 

        public override void Initialize()

        {

            base.Initialize();

            writer = new System.IO.StreamWriter(filePath);

            writer.WriteLine("Hey!  I'm alive.");

        }

 

        protected override void AttemptConnection()

        {

            OnConnected();

            //throw new NotImplementedException();

        }

 

        protected override void AttemptDisconnection()

        {

            OnDisconnected();

            //throw new NotImplementedException();

        }

 

        public override bool OutputIsForArchive

        {

            get { return false; }

        }

 

        protected override void ProcessMeasurements(TimeSeriesFramework.IMeasurement[] measurements)

        {

            for(int ii=0; ii<measurements.Length; ii++){

                writer.WriteLine(measurements[ii].Value);

            }

        }

 

        protected override bool UseAsyncConnect

        {

            get { return true; }

        }

 

        public override string GetShortStatus(int maxLength)

        {

            return "Currently Processing";

        }

    }

}

Developer
May 31, 2012 at 7:56 PM

Hi TJ,

Could you tell me a little bit more about what you want to simple adapter to do? What are you trying to accomplish? Are you just trying to familiarize yourself with the process?

I have written a tutorial that I distribute to other graduate students at my school when they begin developing custom applications in openPDC. It is slightly more detailed than the instructions in the online documentation. Mine actually walks you through writing and running some code. I have simple versions and more complex versions. Now for the adding measurements to the output stream, I prefer to do this manually.

If you think this will be helpful I can send you a PDF. What is your email? Mine is kdjones@vt.edu

Kevin