Can i save data to csv file using ec4p controller? - plc

I want to save some data to csv file using eaton ec4p controller. I found tutorials that i can do this by using syslibfile library but i can't find it in my libraries. Is it possible that this controller doesn't have this library and can't write data?

Have you try EC_File.lib library? I found this definition:
Data access on the memory card Functions such as FileOpen or FileRead allow you to access the files of the memory card from the user program. These functions are provided in the library EC_File.lib and are described in the Function Blocks manual (MN05010002Z-EN; previously AWB2786-1456GB).
MN05003003Z_EN - User Manual for Eaton EasyControl EC4-200

I believe the library you are looking for is SysFile (or SysFile23 for CODESYS 2)

Related

Matlab converting library to model

I'm working on a script to convert a Simulink library to a plain model, meaning it can be simulated, it does not auto-lock etc.
Is there a way to do this with code aside from basically copy-pasting every single block into a new model? And if it isn't, what is the most efficient way to do the "copy-paste".
I was not able to find any clues as how to approach this problem here, or on Google, or on the official documentation or on the MathWorks forum so I'm at a loss on how to proceed.
Thank you in advance!
I don't think it's possible to convert a library to a model, but you can programmatically add library blocks to models like so:
sys = 'testModel';
new_system(sys);
open_system(sys);
add_block('Simulink/Sources/Sine Wave', [sys, '/MySineWave']);
save_system(sys);
close_system(sys);
sim(sys);
You could even use the find_system command to list all the blocks in a library and then loop through them all and create a new model for each using the above code.

changing the properties (details) of a file in matlab

How can I change the properties (details) of a file in Matlab?
by details I mean things like "album", "track#", "artist", etc. (for an audio file).
Thanks.
The properties that you mention are not general file properties, but specific properties supported by specific file formats. For MP3 files for instance, that information is normally stored using an extension called ID3. To modify the information, you either need to use a library for that purpose or implement it yourself. According to id3.org there is no Matlab implementation. However, it might be possible to get the Java implementation working using Matlab's built-in Java support.

Suggestion to consider improving MatFile support by using code from csmatio to read and write .mat files

is anyone using MatFile classes in ilnumerics?
I just tried to open a MAT file created using csmatio and found I could not import it into ilnumerics application.
Hit throw new Exception("element data type is not supported");
as there is no support for mxSTRUCT_CLASS in the method
private ILBaseArray read_miMATRIX(BinaryReader br).
Is it a lot of work to add support for mxSTRUCT_CLASS?
ILNumerics will add support for HDF5 soon. This will also provide access to recent Matlab mat files. There are no plans to improve the old ILMatFile interface currently.

What is the correct way to embed a resource in a reusable MFC class?

I am writing a C++ (MFC in particular) class which uses an external .gif image file and produces another image file after some processing. It would be nice if the initial image could be embedded in the code somehow. I have read in MSDN about using multiple .rc files and the whole thing seems quite complicated.
I would like to know from people who have gone through this before how to handle this problem.
EDIT : Sorry I was not clear. The class I am writing should be standalone, so I could use it again. If I put the image in a resource file, then the class will not compile if used in a fresh project.
You cannot embedd MFC resources inside a class or similar C++ container. They can only be embedded in DLL or EXE files - in a separate section of the produced binary. Since you want your class to be reusable, you must put it in a DLL. Hence, you must tag your class with the AFX_EXT_CLASS keyword.
There are two solutions.
Solution #1:
Create an MFC DLL project (MFC Extension DLL). Call it MyLibrary or whatever.
Put all your standalone classes in this DLL.
Embed all necessary resources.
Let your classes load resources from the HINSTANCE of your DLL as described below.
There are several ways to retrieve the HINSTANCE of your DLL. If you ask me, the best solution is to grab it in DllMain. This is done automatically if you choose the MFC Extension DLL configuration:
static AFX_EXTENSION_MODULE MyLibDLL = { NULL, NULL }; // Make this variable global!
// Then access the hInstance as follows:
LoadResource(MyLibDLL.hModule, ...)
Solution #2:
Store your resource as a byte buffer. Or better, convert it to Base64 and store it as an ASCII string. But remember not to blow the stack! Keep your resources small or increase the stack size in your project settings. Example:
const char *encodedResource = "SGVsbG8gd29ybGQh";
char *data = decode(encodedResource);
foo(data);
In the solution explorer go to resource view, Right click and click Add Resource then click Import and add the gif file. Now you can use your Resource ID to access the gif file in your code.
Just adding the file to a resource doesn't embed the file in the actual resource file it just links to the file. If you open your .rc file you'll see it says something like:
IDB_GIF_MYIMAGE GIF "artwork\\mygif.gif"
During the compilation face the resource will be included in the EXE, which you reference using the resource id IDB_GIF_MYIMAGE. You can reference the same file in other projects without having to duplicate the file.
To embed an image (or any other type of binary data) into your class without using resource files, use the bin2c utility, for example you can download it from here: http://www.opensource.apple.com/source/libpcap/libpcap-16/libpcap/msdos/bin2c.c . Running this on a file will produce what is basically a static array with the bytes of the file as members of that array. Stuff this array into a .h file (or put it in the header of your class, or make it a static member...) and then you will have that file available in-memory without having to use LoadResource() and its brethren.
If you want to use this with CImage::Load(), you will have to write your own class that derives from IStream, and implement a few of the methods in a way so that they 'read' from memory. I don't know of any ways to let CImage decode an image from an in-memory representation of a gif file.
I think the best solution is just to document that to use the class you must also import to your project a certain .gif file and give it a certain expected identifier (e.g. IDB_MYCLASS_MYGIF). You can then use the preprocessor to detect if the resource has been correctly added, e.g.:
#ifndef IDB_MYCLASS_MYGIF
#error Make sure you import mygif.gif to the project. See docs for more info.
#endif
This will prevent the class compiling until the user imports the image properly. Alternatively you could just use #ifdefs to fall back to code which does not use the default image if it is not provided.
Have a look at the CRuntimeDialog class presented in http://www.codeproject.com/Articles/5371/ToDoList-6-5-4-Feature-Release-An-effective-and-fl . It provides a way to create a dialog from the string that makes up the resource definition.

Testing data generator for Intersystems Caché?

Are there any easy ways (i.e. libraries) to create testing data for Caché, similar to the Populator and Faker gems for Ruby/Rails?
** edit **
I am trying to create test data for an Epic implementation. In addition to the electronic-medical-record (EMR) application, the implementation includes a tool called 'Text'. I'm hoping that I can use the data-generator with Text.
The %Populate class has a bunch of methods designed to help you create test data for your persistent classes.
Do ##class(MyApp.MyClass).Populate()
Could also use %PopulateUtils class directly to get random data returns directly.
USER>w ##class(%PopulateUtils).Name()
Taylor,Kenny O.
.
USER>w ##class(%PopulateUtils).Street()
3012 Oak Drive
.
USER>w ##class(%PopulateUtils).SSN()
113-89-3577
mccrackend is right. The docs on this can be found here:
http://docs.intersystems.com/cache20102/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_populate