File Parsing example - SuperTrend


I thought I had everything figure out, until I started running the program, I find out that my top row is always modified, somehow it puts the newest line on top, and then all the time and date are in order but the last data received is put in the first row


for my software to work it should look like this and the top row should always stay

Date,Time,Temp East,Temp West,Work Order

is there anyway to change it that the top row will never be modified? or that my top row data will always be rewritten to this [B]Date,Time,Temp East,Temp West,Work Order[/B] cause I use the keywords on top to Filter the data.



that file parsing is working now as I needed, and in my PAC SIM it works good, buy when I load it to the controller it can’t open the connection, I believe it’s code -417 that it gives, I have my files on C:\Oven_Data\STRENT.T0004 and output sLog.csv I don’t see and error on the output but the input, I’m wondering is it related to the 8 - 3 file length cause it’s extension is longer then 3 characters. if I is than how can I make Supertrend to save the file to File.T01,
any help would be appreciated.
Time to stop working for this week.

have a good long weekend.


The controller, unlike PAC Sim, is not aware of your C: drive… It can not navigate across your network, make a connection to your PC where the trend file is, and navigate your directory structure to the file.
This is one of the really powerful features of both PAC Sim and SoftPAC, the fact that its running on the PC means it can access the local file system.
Changing the file name wont make the file accessible to the controller. Its the location, not the name that is the problem.
You could try and set up some sort of batch job that FTP’s the file from the PC to the controller, then change the code on the controller to access the file on its local file space, but I suspect that running SoftPAC would be a better solution.


Ok I had not heard of SoftPAC before. thats a sign I’m new at this, the [B]SNAP PAC R1[/B] controller that I build 2 to 3 years ago works good, but the company wants the data logging now, if I can use SoftPAC with my current controller so I can just change over without changing hardware, I will ask for the money and purchase it.
can you tell me if I buy a license, is it only for 1 controller or can I use it on more than 1 controller? currently we have 2 Opto22 controllers running and looking to build some more in the near future.

do I still need PAC Control basic or pro running if I have SnapPAC?



I have come in right at the end here, so sorry if I dont get your setup straight up…

SoftPAC lets you run 64 charts on a PC. A pac R1/2 can run 16 charts, an S1/2 can run 32 charts.
The main difference is of course is that your PC does not have any IO, and must be running all the time to ensure your strategy keeps running…

That said, your SoftPAC strategy can have the IO on the rack that your R1 is running, just configure the points and IP address.
In other words, your R1 can keep doing what its doing and the SoftPAC strategy can just take over your PAC Sim strategy.
The main difference between PAC Sim and SoftPAC is that the sim will only run for 12 hours and then stop, where as SoftPAC will run as long as your PC is up. (There are a couple other things, but that’s the big one).

So, do you need to run the logging all the time? Or can you run it as you need it?
If it its only needed now and then, just call up PAC Sim when you need it and do like you have. (For example, start it at the start of each day and it will run for your usual 8-9 hour day and then some?).
If it needs to be parsing the file all the time, then SoftPAC might be the go.

The license is for one instance of SoftPAC, but if you need more, ring presales or your local Opto guy and they can help you out.


Ok that helps thanks for the explanation.

I will try to schedule the SIM to start up for the 3 hours at night when the shop is down see how it works. but I can see that in the future we will be needing SoftPAC if those bigger projects come that have been talk about.

thanks for your help this will help me to finish the project.


OK, I’m must be missing something. I’m using SoftPac, but getting the -417 error when trying to write to anything other than the “root” of my file system. For example:

sOutputFileName = "h:/RD140702.T0003.csv";
sOutputCommHandleValue = "file:w," + sOutputFileName;

Doesn’t work. However, if I leave out the h:/, it does work, but puts the file here:

This is a Windows 7 Pro machine. Am I just messing up the syntax somehow?


Do you know the name of your networked drive, with some slashes in the other direction? You’ll want to use that.

For example, around here we found:

Network Drives use the “/” character, like this example:

Drives that are local to the Windows computer use the “” character, like these examples:
Hard Drives local to my computer:

USB Flash Drive local to my computer:

Here’s how you might be able to find that name using Explorer:

I hope that helps!

SoftPAC Creating a Log File

Thanks! Using your example, specifying a local drive path is working. However, the network drive location is still not recognized even with the syntax suggested. It isn’t a show stopper, just a speed bump.


One more question on this thread… has anybody tried writing a converter that will read the binary format of SuperTrend logs, so that they don’t need to be converted to text first through PAC Display?


It looks like the format is like this:

0x55 {8 bit pen number} {64 bit windows filetime timestamp} {32 bit IEEE 754}

Not sure if the first byte changes, all the ones I looked at started with 0x55.


C# console program to convert Supertrend to CSV.

ConvertSuperTrendToCSV.exe < RD160328.T0002 > new.csv (2.29 KB)

using System;
using System.IO;

namespace ConvertSuperTrendToCSV
    class Program
        static void Main(string[] args)
            using (Stream stdin = Console.OpenStandardInput())
                int Pen;
                DateTime TimeStamp;
                Single Value;


                byte[] buffer = new byte[16];
                int bytes;
                while ((bytes = stdin.Read(buffer, 0, buffer.Length)) > 0)
                    Pen = buffer[1];
                    TimeStamp = DateTime.FromFileTimeUtc(BitConverter.ToInt64(buffer, 2));
                    Value = BitConverter.ToSingle(buffer, 10);
                    Console.WriteLine("{0},{1},{2}", Pen, TimeStamp, Value);


Reviving an old thread…this is exactly the function I was looking for! Having some issues though: when I hit “Debug” to download the strategy, I get the error “controller out of memory” as per screenshot. Any ideas what could be wrong? Your help is greatly appreciated! (I’m new to PAC).

Running the latest versions of both: PAC Sim R9.5d and PAC Control Basic R9.6d

Error msg

PAC Sim configuration is kept at its automatically populated settings (Standard,