Author Topic: VB.Net With Advanced HMI  (Read 3210 times)

lgrimm

  • Newbie
  • *
  • Posts: 22
    • View Profile
VB.Net With Advanced HMI
« on: March 02, 2017, 01:27:13 PM »
HI;

I am developing a program in VB.NET. Connecting to an Allen Bradley 1400 .EthernetIPforSLCMicroCom1.Read("B3:1/1")
and other addresses.

I need to detect a change in B3:1/1 as boolean and turn a pump on or off. Have no problem using mouse click.

Sending tank level to above address on PLC.

The problem is reading change in bit  outside the mouse click Private sub. The Sub That records data to database
and turns pump on and off.

This is my code so for and it works except being able to assign EthernetIPforSLCMicroCom1.Read("B3:1/1") to the values.

 Public Class myVar
        Private TankLevel As Boolean
        Public Event VariableChanged(ByVal TankLevel As Boolean)
        Public Property Variable() As Boolean
            Get
                Variable = TankLevel
            End Get
            Set(ByVal value As Boolean)
                TankLevel = value
                RaiseEvent VariableChanged(TankLevel)
            End Set
        End Property
    End Class


Private WithEvents TankChange As New myVar
    Private Sub VariableChanged(ByVal NewValue As Boolean) Handles TankChange.VariableChanged
        Me.BasicButton1.PerformClick()
    End Sub

_____________________-

The Perform click is the routine that turns pump on and off and records data to database.

Thanks
Lee

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: VB.Net With Advanced HMI
« Reply #1 on: March 02, 2017, 02:33:24 PM »
Either you are making this difficult for yourself or there is more there than just what you are showing.

This is how I would tackle the task:

- Add a DataSubscriber to the form
- Set PLCAddressValue to B3/1
- Double click the DataSubscriber to get to the Value changed event handler
- Add this code:

If e.Values IsNot Nothing AndAlso E.Values.Count>0 then
   If e.Values(0)="True" then
      '* Perform the task
       EthernetIPforSLCMicroCom1.Write("B3/10","1")
   End If
End If

Godra

  • Hero Member
  • *****
  • Posts: 1449
    • View Profile
Re: VB.Net With Advanced HMI
« Reply #2 on: March 02, 2017, 02:49:50 PM »
Or follow the steps Archie suggested and change the code to this (to automate the button click with every change):

If e.Values IsNot Nothing AndAlso E.Values.Count>0 then
   Me.BasicButton1.PerformClick()
End If

lgrimm

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: VB.Net With Advanced HMI
« Reply #3 on: March 02, 2017, 05:33:00 PM »
Hi:

Appreciate your reply:

However I have an issue with EthernetIPforSLCMicroCom1.Read("B3:1/1" in that it is a boolean and returns a true or false.

I think that is an issue with the solution you gave me.

Any Idea ?

Thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: VB.Net With Advanced HMI
« Reply #4 on: March 02, 2017, 05:45:38 PM »
Boolean value do return "True" or "False", hence the conditional line:

If e.Values(0)="True" then