Jump to content

Marco G

Members
  • Posts

    54
  • Joined

  • Last visited

Posts posted by Marco G

  1. 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. ;)

  2. 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
  3. 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. 

  4. 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.

  5. 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?
  6. There is no SD.WriteXml, since the communication driver doesn't care which file you write.

    the SdFolder is an enum that tells the PLC to write to the specific folder EXCEL\EXCEL1.

    The null in this case is a delegate you give it in order to get progress updates.

     

    If the WriteFile doesn't throw any exception, then the file transfer was a success. You can read back the file (if you want) using ReadFile and validate its content.

     

    The ReadFile and WriteFile also have an overload that accepts a path instead of an enum for the folder

     

    //EDIT:

    Btw, the filenames must be 8.3 compliant (meaning no more than 8 characters to the filenamee and 3 characters for the extension)

    Hello, Thanks. So with the null i need to declare what it should do? VB2010 sees the null as a byte and wants to change it to dbnull.value which doesn't work. 

  7. 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.  

  8. 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.)

  9. Hi, I have updated the SD Files DLL with a new version (I've updated the file in the post #7: http://forum.unitronics.com/index.php?/topic/2630-alarms-from-sd-card/#entry9134 )

    I have fixed some bugs with the UDT file opening.

    Thanks, i already looked into the driver documentation, but couldn't really find a answer there. 

    This is my current code:

     Dim sSelectedIP As String = cbPLCnaam.SelectedValue
            Dim sDateTimePicker As String = DateTimePicker1.Text
            Dim sCompleteDirectory As String = sSelectedIP & "\Secure Digital-opslagapparaat\EXCELL"
            'oud: Dim sCompleteDirectory As String = "C:\" & sSelectedIP & "\SDCard" slaat op in C:\"ipadres"\SDCard
            'Het feitelijke opslaan als xml
           
            ds.Tables.Add(dtverzenden)
            ds.Tables(0).TableName = "verzenden"
            ds.WriteXml(sCompleteDirectory & "\" & sDateTimePicker & ".xml"
    

    As you can see, right now it writes to xml. according to our PLC programmer thats no problem, he has a method of reading it into the program. For the writefile i reckon i need this:

    plc.SD.Writefile(SdFolder.EXCEL_EXCEL1, sDateTimePicker &".xml", null);
    
    

    Where does the SdFolder and null come from and how can i make sure it writes the contents of the ds "verzenden" ? 

    I tried some things like plc.SD.Writexml but that (ofcourse) doesn't work.

  10. 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. 

  11. Typed a long text but pressed the wrong button.  :ph34r:

    Anyways, i have found out that in the DLL zip there's a example programm wich looks like it does what i want. Only it writes directly to the plc for as far as i can see. (writes to operands)

    I figure that if i have the same, but then in a way that writes it to the datatable my problems will be solved. I think that the PLC can read the datatable to chech if there's any row with a date/time that correspondents to his internal clock. It collects all the corresponding rows and then execute it. 

     

    So: Datatable with rows: Datetime(+id?), location, weight, location where the mix has to go. 

    PLC checks the date, sees 5 rows with a corresponding date, gets the weight from each location(5 kg of hay, 10 kg of grass for example) and then brings it to the location where the mix has to go. 

  12. Hello,

     

    Thanks :) I havn't looked into your example yet, but reading your previous post i get the feeling that it's too complicated for the end users. 

    That the Save as XML part is only to save to the PC wasn't very clear to me. Thanks for making that clear. 

    The .net datatables work well when used to save as xml or .csv.

     

     

    Basically, what i'm trying to accomplish is having a piece of software where someone can enter some food data, add diets and then calculate how much of each foodtype is needed for a diet. Then he(or she) can set a location where the foodmix has to go to and a execution date/time(on wich time does the diet has to be mixed and send to the location).

    I'm still working on the PLC part, but i wanted to have the pc software either send the data to the plc or let the plc check for new files(so date/time in filename).

    The PLC has to execute the orders at the right time, so when using the first method i think the date/time needs to be saved in the datatable, while in the second method it has to be used as filename.

    I want to have to use as little additional software as possible to make the software as userfriendly as possible.  

  13. Ah yes, i saw that. 

    This is part of my current code:

     Dim ds As New DataSet
            dtverzenden = New DataTable()
            dtverzenden.Columns.Add(New DataColumn("Voerlocatie", Type.GetType("System.String")))
            dtverzenden.Columns.Add(New DataColumn("Gewicht", Type.GetType("System.String")))
            dtverzenden.Columns.Add(New DataColumn("Voerbak", Type.GetType("System.String"))) 'was Int32 m.u.v. Voerlocatie, die was al string. bij Int32: cannot convert to int32 datatype
            fillRows(lblVoerzend.Text, lblzendgewicht.Text, lblvoerbaknr.Text)
            If lblzendgewicht1.Text <> "" Then
                fillRows(lblvoerzend1.Text, lblzendgewicht1.Text, lblvoerbaknr.Text)
                If lblzendgewicht2.Text <> "" Then
                    fillRows(lblVoerzend2.Text, lblzendgewicht2.Text, lblvoerbaknr.Text)
                    If lblzendgewicht3.Text <> "" Then
    
    
      ds.Tables.Add(dtverzenden)
            ds.Tables(0).TableName = "verzenden"
            ds.WriteXml("C:\Verzendenxml.xml")
            MsgBox("Done")
    It needs to have some data that occurs only one time(execution date/time and location) but i got that already figured out. :) 
    If i understand correctly, for the saving part i have to use:
    • public void SaveToUDT(string filePath, int datetime) (where datetime is a time and date specified by the user in a datetimepicker, will be saved as first colomn in the datatable)
    • public void SaveToUDT(string filePath, string verzenden)

     

    For the filepath: do i have to specify that it is a .udt? (so SD/filename.udt) 

     

    Co-workers say that it is possible for the PLC to read from CSV or XML, but i don't want to have to find out the hard way if it isn't so i'm working on building a save to .udt button right now. 

    It's easier to delete 1 or 2 buttons then to add buttons + code ;)

  14. Also, i found out that there are .net drivers availible, but it looks like they don't do what i want. 

    I want the user to be able to just enter some names etc and as it is now, the needed information for the PLC(Some numbers that are locations and weights in INT32) will be saved to a csv textfile. 

    Apparently that's not possible, although my collegues think that it should be no problem. 

     

    Alse, will it work if i save the data as a textfile? (with the comma's being used as seperator)? Because what basically needs to happen is that i need to be able to send some numbers(1-8 and weight) to the PLC, then the PLC can convert them to coordinates so it knows where it needs to take how much weight from and where the cart needs to drop it. (2 separate machines)

    And is it true that the Unitronics PLC(whe're going to use the V-models, i believe the 350) can also read from xml files? 

    That would be easier, then all i have to do is transform the textboxes into a dataset and save that. 

     

    All that remains then is the scheduling as in the first post. I think i got a way for that, but will that work? 

    My idea is saving the files(xml or UDT) with a datetime in the filename(picked using a datetimepicker) and then the plc will regulary check if there a file availible that has a datetime of within 5-10 minutes of the current date and time. 

    I think that this is the most flexible option for the user, because he can now set up multiple files and then the plc will automatically run them at the right time.

  15. Hello,

    I'm quite far with the software for my project. However, i got a few questions related to the PLC part now. (The PLC will probably be programmed by someone else.)

    The software allows the user to create a CSV of certain data, this csv has to be send to the PLC but there's some extra difficulty here. 

    I want the user to be able to create a scheduled task of it, so he can configure the assignments once and basically forget about it until the schedule runs out. 

    How can i do this?

    I recon the most easy way is to force the user to add a date/time to the csv filename and then let the plc check the pc(it's done remotely via TCP/IP) once in a while for the file that's up next.  But is that possible or are there other/better ways to do this? 

    I would like to have to install only the software i'm working on now(which is a relatively small vb.net application) on the users computer. 

     

    Also, i tried some googling but it seems that most questions are about importing to the user's pc. 

     

    The PLC that will be used will be a V130 that's controlling several sensors and engines(hydraulic and electric). Also, it needs to send some of the data(location of the items it needs to take and the weight.) to a other plc. 

×
×
  • Create New...