Saving a log to text file with frequently appended file name

I am currently using an Epic Controller to operate a machine, I have a string table that get created and populated at the end of specific run time, I am working on saving the table to a text file for future viewing by other users. I saw couple posts about writing text file or save to file which were really helpful, the challenge for me is appending the file name with the run name that get assigned to a variable at the start of each run.

  1. is it possible to append the file name in a way like the following ? file:w,run name.txt where run name is a string?
  2. I have also noticed quite alot of posts involve functions that are non existing under command help on Pac Control Pro, one quick example that comes to mind which I saw when I was reviewing other posts is ā€œsInfoToLogā€ function. Is there an additional location for command library beside the PAC Commands Help?

I am fairly new to the system (just a bit over 10 days), I understand it highly likely that the answers to these question exist somewhere in the software. Any pointers would be much appreciated.

Thank you

Hello and welcome to the forums.

  1. Yes. (More to come - Just on a Zoom call right now).
  2. Going to have to dig into this as I am not sure what commands you mean. Got some posts you can share as an example?

Will get you pointed on the first one shortly.
Again, welcome to the forums.

Thank you for the quick reply.

I have looked into getting you examples. I apologize, I must have read the examples incorrectly. I went back and turned out I was confusing string variables with function names.

Again, sorry for the delay getting back to you, bit slammed in here at the momentā€¦

Its a two step process if I understand your question.
First, you have your string variable that is the name of the batch or run time stamp. Another part of your code makes that string that we will use to write the fileā€¦ Will leave that to you. Just remember it will end up the file name, so no spaces or / in it. Think of it as a Linux file name and you will be on the right track.

Then, step one, make the string that will become the communication handle.

fileHandleString = "file:w,"+ batchName + ".txt";

Then, step two, set the communication handle.

SetCommunicationHandleValue(fileHandleString, fileHandle);

Here is a screenshot of what I mean.

Feel free to ask any questions if its not clear.

1 Like

Thank you so much,

This is what I have not been able to understand, this makes really clear. I will test it out.

You suggestion really helped a lot. I am wondering since you mentioned there should be extra caution paid to spaces, would this be viable?

NumberToString(StringToInt32(Current_Recipe[5]), sData_File);
sData_File = ā€œfile:w,N:<ShareDrivePath>\Run Dataā€+sData_File + ā€œData.txtā€;

Where sData_File is a string with a length of 50 ? and N is a shared drive over the network.

50 characters is a very long file nameā€¦ But should be Ok.
Review the rules for the file name here:
https://www.cyberciti.biz/faq/linuxunix-rules-for-naming-file-and-directory-names/

As far as writing it to a shared drive. No.
Linux can not map to a network drive unless you have done something very sneaky in the shell, and if you have, please share it as I would LOVE to know how to connect to a shared drive from PAC Control.

1 Like

Hmmmm,

I have an another older machine that utilizes a snap pac controller, that strategy was not setup by me but it does write to the same share drive.

Now I am really curious to dig into that older strategy to see how does it do that.

Let me check and I will provide an update with some information.

That is interestingā€¦ SNAP PAC Controllers have even less than zero chance of writing to a network drive. They donā€™t have Linux or shell or anything sneaky to enable any network mapping of drives.
I am really wondering what is going on here.

I have checked the older software, and they way it was setup based on my limited understanding I believe the previous engineer used Pac display configurator to save the logs in a form of recipe files (.rcp) in a network location.

How they manged to do that? I honestly dont know. Based on what I have read in the forums, Groov doesnā€™t have such capability. Am I correct to assume that?

These same files were used to be called later in the software again to read their content, and used for calculations which they were written into the same files.

Ah, PAC Display, Ok, things are sort of falling into place nowā€¦
As you know PAC Display runs on Windows and that same computer has the mapped network drive on it, so it can read and write to the ā€˜Nā€™ drive with no problem.

There is a whole chapter in the PAC Display users guide as well as many posts here on the forums about using Recipe files. Its a very common way of moving data in and out of a controller to the computer hard drive.

Yes. groov EPIC can use recipes. No problem. The groov EPIC runs the PAC Control engine, so all the tags can be saved to your network drive on your Windows PC via the PAC Display recipe file.
When you say it canā€™t do it, I think you are thinking of groov View. It does not have the recipe function. But I can assure you, that using the EPIC controller can use PAC Display recipe files no problem.

Here is the one thing I canā€™t quite figure outā€¦ you mentioned the PAC Control comm file handle:

sData_File = ā€œfile:w,N:<ShareDrivePath>\Run Dataā€+sData_File + ā€œData.txtā€;

That does not make sense.
The mapped drive ā€˜Nā€™ is on the Windows PC, thatā€™s where the recipe file is being written, in the recipe command, not the comm handleā€¦

Is there any chance you guys are running (were running) SoftPAC?
Thatā€™s the PAC Control engine that runs on Windows.
Since its running on the same Windows PC it has access to the mapped drives and thatā€™s the only way I can think that comm file handle you show will work.
(Related trivia, I had to run SoftPAC on a PC that I needed to log some data to Dropbox).

Thank you for pointing this out, I will need to review this to get more familiar with the process.

Oh, that was something I thought is feasible to do with the epic (not on the older machine) but i have revised it since you pointed that out it cant be done that way.
Now I am writing to the unsecured storage:

sData_File = ā€œfile:w,/home/dev/unsecured/Perf_Data/ā€+sData_File + ā€œ.txtā€;
SetCommunicationHandleValue(sData_File,Save_Post_Run);
Com_Status = OpenOutgoingCommunication(Save_Post_Run);

I just wanted to say thank you for your continuous support on this.