Author Topic: Numbering Screens  (Read 2575 times)

pal

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Numbering Screens
« on: April 07, 2016, 03:13:57 PM »
I'm missing something . Is there a way of numbering screens so that the number can be sent to the PLC and  also the PLC can call a screen by number ?
Paul

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: Numbering Screens
« Reply #1 on: April 07, 2016, 06:20:27 PM »
The technique I use for sending the current screen to the PLC is this:

- Each form has a Tag property. I set that property for each form to the number I want to go to the PLC
- In the code behind the MainForm is a default piece of code. Modify the code like this:
Code: [Select]
    Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        '* Do not start comms on first show in case it was set to disable in design mode
        If NotFirstShow Then
            AdvancedHMIDrivers.Utilities.StopComsOnHidden(components, Me)
        Else
            NotFirstShow = True
        End If

        Try
            If Me.Tag IsNot Nothing AndAlso Me.Tag <> "" Then
                EthernetIPforCLXCom1.Write("ScreenNuberTag", Me.Tag)
            End If
        Catch ex As Exception
        End Try
    End Sub

pal

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Numbering Screens
« Reply #2 on: April 08, 2016, 06:23:17 PM »
Thank you Archie for the quick reply . How do I get The PLC to select a screen ? - I'm developing a help system for faults and would like bring up related text screens with detailed descriptions if the operator presses a "More Button "

Thanks , Paul

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: Numbering Screens
« Reply #3 on: April 08, 2016, 07:13:15 PM »
One method is to use a DataSubscriber.

- Add a DataSubscriber to the MainForm
- Set PLCAddressValue
- Double Click the DataSubscriber to get back to the code
- Enter code like this:
Code: [Select]
    Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        Dim SelectedScreen As Integer=e.values(0)
        Select Case SelectedScreen
            Case 1
                Page2.Show()
            Case 2
                Page3.show()
        End Select
    End Sub


You will have to comment out this default line of code in MainForm:

            AdvancedHMIDrivers.Utilities.StopComsOnHidden(components, Me)



pal

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Numbering Screens
« Reply #4 on: April 09, 2016, 04:48:37 PM »
Thank you yet again Archie .
Paul

bachphi

  • Hero Member
  • *****
  • Posts: 674
    • View Profile
Re: Numbering Screens
« Reply #5 on: April 14, 2016, 05:19:55 PM »
If each form has its own E-net driver, do I  still need to comment out the StopComsOnHidden in the Mainform?
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: Numbering Screens
« Reply #6 on: April 14, 2016, 05:26:09 PM »
If each form has its own E-net driver, do I  still need to comment out the StopComsOnHidden in the Mainform?
The reason that line of code needs commented out (only on the MainForm) is so it will continue to monitor the screen requests even when the MainForm is hidden.