F.open and CSV Files/Datalogging

Discuss issues and ideas you have to configuring displays with PowerVision
CustomFP
Posts: 41
Joined: Thu Mar 22, 2012 4:12 pm

F.open and CSV Files/Datalogging

Post by CustomFP » Thu Aug 29, 2013 10:32 pm

Hello all,

I am trying to display datalog entries to the PV450 screen from a snapshot logger however I am having some troubles.

I am working from Murphy Sample code which can be seen below, it was taken from another thread that was having a similar problem.

What I would like to know is does the 'f.open' function read from the internal memory on the PV450 or is it reading from a USB stick?

I currently have a logger called LadderLog.csv however f.open is not returning a value, leading me to believe it isn't opening.

Is there any extra information you could profile me that might help me work through problems with the datalogger and file objects?

Regards,

//---------------------------------------------------------------------------------------------
// Murphy Scripting
// - Leave EventName as $Faults.Status.ViewEntryReady$ for main script method
//---------------------------------------------------------------------------------------------
void $Faults.Status.ViewEntryReady$ ()
{
file f;

if( f.open( "EntryFile2.csv", "r" ) >= 0 )
{
int n = 0;
int i = 0;
string line = "";
string str = "";

smRead( VariableIDs.Faults_NumberEntries, n);

for( i = 0; i < n ; i++ )
{
f.readLine( line );
str += i + line + ". ";
}

cultureSetString( StringIDs.Faults_Entry, str, true);

f.close();
}

cultureSetString( StringIDs.Faults_Status, "Faults.ViewEntryReady", true);
}
ksaenz
Enovation Controls Development
Enovation Controls Development
Posts: 263
Joined: Thu Aug 19, 2010 7:53 am

Re: F.open and CSV Files/Datalogging

Post by ksaenz » Fri Aug 30, 2013 7:56 am

Hello CustomFP,

The function f.open() will open a file from internal memory.

What is the Logger Mode of your loader? Standard or Snapshot?

If it is a Standard logger you need to pass the file name you specified to f.open(), in your case it seems to be LadderLog.csv so it would look like this:

Code: Select all

if( f.open( "LadderLog.csv", "r" ) >= 0 )
instead of this:

Code: Select all

if( f.open( "EntryFile2.csv", "r" ) >= 0 )
If it is a Snapshot logger you can use this to open the entries file:

Code: Select all

if( f.open( "EntryFile2.csv", "r" ) >= 0 )
And this to open the records file:

Code: Select all

if( f.open( "RecordFile2.csv", "r" ) >= 0 )
And the number corresponsd to the position of the logger on the list of data loggers so if that is your only logger the number would be 1 instead of 2.

Regards,
ksaenz
CustomFP
Posts: 41
Joined: Thu Mar 22, 2012 4:12 pm

Re: F.open and CSV Files/Datalogging

Post by CustomFP » Fri Aug 30, 2013 9:34 am

Hello Ksaenz,

The logger I am using is a snapshot logger with the ladderlog.csv file. Ok so it is from the internal memory, that is good for this application.

Do I need to initialize the "EntryFile2.csv" file anywhere?
ksaenz
Enovation Controls Development
Enovation Controls Development
Posts: 263
Joined: Thu Aug 19, 2010 7:53 am

Re: F.open and CSV Files/Datalogging

Post by ksaenz » Tue Sep 03, 2013 10:40 am

The file "EntryFile2.csv" is created automatically.

The number corresponds to the position of the logger in the list of data loggers so if that is the first logger in the list the name of the file will be "EntryFile1.csv" instead of "EntryFile2.csv".

Do you have the box "Store on Active Fault Message" or are you storing the snapshots manually?

Regards,
ksaenz
CustomFP
Posts: 41
Joined: Thu Mar 22, 2012 4:12 pm

Re: F.open and CSV Files/Datalogging

Post by CustomFP » Wed Sep 04, 2013 8:48 pm

Thanks Ksaenz, this is working now.

I have another question regarding string variables, can you store them in the non-volatile memory like you can with normal variables? A customer would like to store a machine ID on the DMC that is made up of numbers and letters.

Please let me know if I need to create a new thread of this question.
ksaenz
Enovation Controls Development
Enovation Controls Development
Posts: 263
Joined: Thu Aug 19, 2010 7:53 am

Re: F.open and CSV Files/Datalogging

Post by ksaenz » Thu Sep 05, 2013 8:17 am

If the ID is short you can save the ASCII value of the individial characgters in numerical variables or you can write the whole string to a text file and read it when you need it but string variables don't have the option to save to non-volatile memory.
CustomFP
Posts: 41
Joined: Thu Mar 22, 2012 4:12 pm

Re: F.open and CSV Files/Datalogging

Post by CustomFP » Mon Sep 09, 2013 8:14 pm

Thanks for your help Ksaenz