External Moderators Nacho Posted July 9, 2012 External Moderators Report Share Posted July 9, 2012 I know it's possible with the Advanced Web Server to download a file from the SD to the PC via web explorer. Now I have a finished application where the customer needs to download the CSV without use the SD Card Explorer. Copy and paste all the application to the .vlp with the embedded webserver is a task for titans but I don't know how to start to make a simple application to download a CSV. It will be about chunks... Anyone can help me? Project: A PLC with IP 192.168.1.201 and a CSV called test. Download from internet explorer: http://192.168.1.201/EXCEL/TEST.CSV Link to comment Share on other sites More sharing options...
Saragani Posted July 23, 2012 Report Share Posted July 23, 2012 Do you want to write a .Net application that reads the CSV file? Link to comment Share on other sites More sharing options...
External Moderators Nacho Posted July 24, 2012 Author External Moderators Report Share Posted July 24, 2012 No, I want to write a .vlp application and a HTML with only a link to the CSV file. Link to comment Share on other sites More sharing options...
Marco G Posted November 13, 2014 Report Share Posted November 13, 2014 Small kick, cause i'm investigating the same issue, but then with the use of .net from a pc to a networked plc. Link to comment Share on other sites More sharing options...
Saragani Posted November 16, 2014 Report Share Posted November 16, 2014 You can use the .Net communication driver nad its SD Capabilities in order to read a file from the PLC. Link to comment Share on other sites More sharing options...
Marco G Posted November 17, 2014 Report Share Posted November 17, 2014 Yeah.. That's not what i want.. I have a file that needs to be written to the sdcard. Because the software needs to be flexible i have to use the ipadres as part of the saving path. 9so for example: 192.168.1.16\SDcard\Excel. For me that's the easiest way. The ip adres is selected by the user from a dropdown menu. If i need to use the .net driver, how could i do that? I didn't find anything in the documentation. Link to comment Share on other sites More sharing options...
Marco G Posted November 17, 2014 Report Share Posted November 17, 2014 Oh, and no, i dont want to use the Card reader software you made. I want it to be as userfriendly as possible. (meaning the less steps the better) Link to comment Share on other sites More sharing options...
Saragani Posted November 17, 2014 Report Share Posted November 17, 2014 I've mentioned the .Net communication driver and its SD capabilities, since it gives you the ability to read and write files to the SD.\ This is what the SD Card Explorer uses. The SD Card Explorer is just a UI wrapper that manages things (like listing the files, handling the transfers and showing progress bars). The true API is inside the driver. After you have a plc object (follow the .Net communication driver manual and examples, if you don't know how), that plc object has an SD property with a readfile and writefile methods, for example: plc.SD.ReadFile(..... Link to comment Share on other sites More sharing options...
Saragani Posted November 17, 2014 Report Share Posted November 17, 2014 I'm not able to find the documentation I wrote few years ago about the SD Class, but, I've found some old information on the forum: http://forum.unitronics.com/index.php?/topic/2630-alarms-from-sd-card/?hl=readfile#entry9117 Link to comment Share on other sites More sharing options...
Marco G Posted November 18, 2014 Report Share Posted November 18, 2014 Thanks, Will dig into the SD Card Explorer sample. Will let you know the result but it may take a while as the solution files are not compatible with my Visual Express 2010 so i'm downloading VS 2013 first. Link to comment Share on other sites More sharing options...
Marco G Posted November 18, 2014 Report Share Posted November 18, 2014 1 more question: Right now i got this code: plc.SD.WriteFile(Sdfolder.EXCEL_EXCEL1, sDateTimePicker & ".xml", null) I want to transfer the xml file to that folder on the sdCard. However, i notice that writefile can only write 1 byte? (my collegue is working on something to let the plc read .xml file's, if he doesnt succeed i'll try .udt.) Link to comment Share on other sites More sharing options...
Saragani Posted November 18, 2014 Report Share Posted November 18, 2014 Hi, it can write more than 1 byte. The function signature is: public void WriteFile(SdFolder sdFolder, string fileName, byte[] fileContent, ProgressStatusChangedDelegate del) The first parameter is the folder the second one is the filename inside the plc (the target filename) the third parameter is the content of the file (byte array... You should read the content of the original file) The 4th parameter is the progress delegate. Link to comment Share on other sites More sharing options...
Marco G Posted November 18, 2014 Report Share Posted November 18, 2014 Ah okay. Thanks. Hmm, It looks like it's quite easy to save to UDT then as wel isn't it? Something like Public Void SaveToUDT(Sdfolder.EXCEL_EXCEL1, sDateTimePicker, dtverzenden) ? dtverzenden is the datatable that contains the data that needs to be send to the plc. DatetimePicker contains the value used for the filename(so for example 10-10-1730 to indicate that it should be executed at 10 october at 30 minutes past 5. ) That way it's 2 flys in 1 hit(dutch proverb) because then it will save it on the plc's SD card and as the recommended UDT file. Link to comment Share on other sites More sharing options...
Saragani Posted November 18, 2014 Report Share Posted November 18, 2014 Yes, it doesn't care what file is it, as long it follows the 8.3 filename standard. You can write your own SaveToUDT that will save to file and then upload it the SD. You might also be able to write an extension method. This will allow you to do (where dtverzenden is the Unitronics Data Table object): dtverzenden.UploadToSD(Sdfolder.EXCEL_EXCEL1, sDateTimePicker) Link to comment Share on other sites More sharing options...
Marco G Posted November 25, 2014 Report Share Posted November 25, 2014 Thanks, Right now i got this: first saving the UDT to the pc Then uploading it to the plc. Dim fileContent As Byte() fileContent = System.IO.File.ReadAllBytes("c:\Voerkar\" & sDateTimePicker & ".udt") SaveToUDT("C:\Voerkar\", sDateTimePicker, dtverzenden) plc.SD.WriteFile(Sdfolder.EXCEL_EXCEL1, sDateTimePicker & ".udt", fileContent, Nothing) The savetoUDT is a C code i believe, and the dll documentation i have isn't saying anything about how it works in .net. I know(or atleast i think) i need the change the public void to a DIM, but as i need to declare it, can you help me further? Link to comment Share on other sites More sharing options...
Saragani Posted November 25, 2014 Report Share Posted November 25, 2014 Is the SaveToUDT a function you wrote? (Because the only SaveToUDT function I know, accepts one parameter, which is a file path). The SaveToUDT I know is written in C#, which is a .Net languages (the whole .Net communication driver and then Data Tables DLLs are written in .Net), and it compiles to IL code (So it doesn't matter if you use C# or VB.Net... You can use those DLLs). I'm not sure I understand the question. Link to comment Share on other sites More sharing options...
Marco G Posted November 26, 2014 Report Share Posted November 26, 2014 Is the SaveToUDT a function you wrote? (Because the only SaveToUDT function I know, accepts one parameter, which is a file path). The SaveToUDT I know is written in C#, which is a .Net languages (the whole .Net communication driver and then Data Tables DLLs are written in .Net), and it compiles to IL code (So it doesn't matter if you use C# or VB.Net... You can use those DLLs). I'm not sure I understand the question. No, i took it from the documentation. But in there it uses public void. If i use it in front of the savetoudt part, i get the the error "End of statement expected" after the void. Link to comment Share on other sites More sharing options...
Saragani Posted November 26, 2014 Report Share Posted November 26, 2014 The documentation is outdated. The SaveToUDT accepts only 1 paremeter, which is the filename (it takes all the tables and saves them to a UDT file). void in c# means that the function does not return anything. In VB.net there is Function and there is Sub (where Sub is a function that does not return any result). You should just call it like: SaveToUDT("c:\hello.udt") No need for Public or void... Link to comment Share on other sites More sharing options...
Marco G Posted November 26, 2014 Report Share Posted November 26, 2014 The documentation is outdated. The SaveToUDT accepts only 1 paremeter, which is the filename (it takes all the tables and saves them to a UDT file). void in c# means that the function does not return anything. In VB.net there is Function and there is Sub (where Sub is a function that does not return any result). You should just call it like: SaveToUDT("c:\hello.udt") No need for Public or void... Ah thanks That solved part of the problem. So i need to declare a function where the datatable will be saved to the pc and then call that function inside the part where the user actually presses Save? I loaded the Unitronics COM driver dll but that doesnt help recognize the SaveToUDT. Link to comment Share on other sites More sharing options...
Marco G Posted November 26, 2014 Report Share Posted November 26, 2014 Update: Imported the data tables dll(thought i already did this but nope.) and now i stil lget the same error but it wants to gnerate a method stub for me: Private Sub SaveToUDT(ByVal p1 As String) Throw New NotImplementedException End Sub Link to comment Share on other sites More sharing options...
Saragani Posted November 26, 2014 Report Share Posted November 26, 2014 Can you please attach your solution? I'm hoping this forum will not block the Zip file. Link to comment Share on other sites More sharing options...
Marco G Posted November 26, 2014 Report Share Posted November 26, 2014 Hello, Sure. I changed a couple of things and removed some specific forms for privacy reasons. but here it is. The saving functions are in the homescreens, the 2 buttons to the right. Right now im working with the save as xml button(the left one of the two). Code is a bit messy, but it is still a work in progress. I usually clean up the code after i'm done and leave the old code or info in commented lines so i can refer to it if something screws up. Edit: Filesize of total project is 1406 kb. So too much for the forum. The solution file is 1 kb, so i don't think you can work from only that file. Link to comment Share on other sites More sharing options...
Saragani Posted November 27, 2014 Report Share Posted November 27, 2014 Ok, I've saw the project you've send me using dropbox. I'll look into it. Link to comment Share on other sites More sharing options...
Saragani Posted November 27, 2014 Report Share Posted November 27, 2014 Hi, I wrote a little example. Look for the subroutine ExampleCode Voerkar.rar Link to comment Share on other sites More sharing options...
Marco G Posted December 1, 2014 Report Share Posted December 1, 2014 Awesome, thanks! This i can work with. I will ask my collegues to see what they prefer, but i think that we'll be going for the save and then write way. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now