Recent Posts

Pages: [1] 2 3 ... 10
1
UPDATE: I had to uncheck the debugger to not break when this exception was thrown 😅 my bad... Thank y'all it works perfectly!!
2
I tried it with the NativeMethods you attached but I am still getting this error:
Quote
Managed Debugging Assistant 'PInvokeStackImbalance'
  Message=Managed Debugging Assistant 'PInvokeStackImbalance' : 'A call to PInvoke function 'AdvancedHMI!MfgControl.AdvancedHMI.NativeMethods::OpenPrinter' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.'

Could this just be a formatting issue with the form I am using to create the string that will be placed on the label?
3
I did not realize I left off the NativeMethods.vb

I edited the post above to add the file. Try to use that one because it came from a working project
4
So I tried using the NativeMethods.VB from the link that was given which fixed the "Friend" issue. However now its throwing an exception saying:
Code: [Select]
MfgControl.AdvancedHMI.NativeMethods::OpenPrinter' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.'
Which I have no idea what that means...
6
I have plugged everything in, but I am getting an error for the NativeMethods portion.

It is showing that the method isn't accessible because it is a "Friend" though the whole sub is public and its namespace is being imported.

And is the .pDocName suppose to be the name of the format file?
7
Support Questions / Re: AdvancedHMI not correct .NET framework for nugget.
« Last post by Archie on May 09, 2024, 06:39:53 PM »
The RawPrinterHelper.vb file is added to the project by right clicking the AdancedHMI project and selecting Add->Existing Item.

You are correct, the printer name does not matter as long as it is default.
8
Support Questions / Re: AdvancedHMI not correct .NET framework for nugget.
« Last post by paintman on May 09, 2024, 02:24:29 PM »
Okay that seems fairly simple. The rawprinterhelper is a tad confusing for me.

Is the rawprinterhelper just placed in a separate module and called when needed? I am looking at the class and trying to understand some segments of the code. 
Would I just change this to what ever I name the ZPL file as, and the data type I assume would remain the same since its send a direct ZPL file?
Code: [Select]
        ' Set up the DOCINFO structure.
        With di
            .pDocName = "Mix Room Label Printer"
            .pDataType = "RAW"
        End With

And as far as the printer name goes, I figure it wouldn't really matter as long as it is the default.
9
Open Discussion / Wago Modbus
« Last post by smoreno on May 09, 2024, 12:26:47 PM »
Hello
I am new this software, I think it works good,
I have some isseu addressing modbus to wago plc, has some one done any communication on this brand
tha can help out,
thanks in advance
10
Support Questions / Re: AdvancedHMI not correct .NET framework for nugget.
« Last post by Archie on May 09, 2024, 10:01:40 AM »
After creating the file using the Zebra designer software, I manually edited with Notepad. Attached is the file.

The first thing my code does is to read data from the PLC and put it in a local variable:
Code: [Select]
        Dim RecipeName As String = ""
        Try
            RecipeName = EthernetIPforCLXCom1.Read("Batch1RecipeName")
        Catch ex As Exception
            MsgBox("Failed to read Batch1RecipeName from PLC. " & ex.Message)
            Exit Sub
        End Try

It then reads the file and stores it in a string:
Code: [Select]
        Dim s As String
        Using sw As New System.IO.StreamReader("BatchTicketLabelFormat.prn")
            s = sw.ReadToEnd()
        End Using

Using Regular Expression, the string is parsed looking for the brackets
Code: [Select]
        Dim x As System.Text.RegularExpressions.Match = System.Text.RegularExpressions.Regex.Match(s, "\[(.*?)\]")
        Dim Substitue As String
        While Not String.IsNullOrEmpty(x.Value)
            If x.Value.IndexOf("Batch1RecipeName") >= 0 Then
                Substitue = RecipeName
             Else
                Substitue = "ZZZZZZ"
            End If
            s = s.Substring(0, x.Index) & Substitue & s.Substring(x.Index + x.Length)
            x = System.Text.RegularExpressions.Regex.Match(s, "\[(.*?)\]")
        End While

And finally send the string directly to the printr:
Code: [Select]
        RawPrinterHelper.SendStringToPrinter(RawPrinterHelper.DefaultPrinterName(), s)
Pages: [1] 2 3 ... 10