Author Topic: Add AdvancedHMI.Controls but failed, can anyone find the problem?  (Read 1465 times)

halosome

  • Newbie
  • *
  • Posts: 31
    • View Profile
Add AdvancedHMI.Controls but failed, can anyone find the problem?
« on: September 29, 2019, 04:20:07 PM »
        SS10 = New AdvancedHMIControls.SevenSegment2
        SS11 = New AdvancedHMIControls.SevenSegment2
        SS12 = New AdvancedHMIControls.SevenSegment2

        SS10.Location = New Point(400, 160)
        SS11.Location = New Point(400, 220)
        SS12.Location = New Point(400, 280)

        SS10.ForeColorInLimits = SystemColors.Info
        SS11.ForeColorInLimits = SystemColors.Info
        SS12.ForeColorInLimits = SystemColors.Info

        SS10.BackColor = SystemColors.Window

        SS10.PLCAddressValue = New Drivers.PLCAddressItem("43006,1,,,0.1,0")
        SS11.PLCAddressValue = New Drivers.PLCAddressItem("43008,1,,,0.1,0")
        SS12.PLCAddressValue = New Drivers.PLCAddressItem("43010,1,,,0.1,0")

        Me.Controls.Add(SS10)
        Me.Controls.Add(SS11)
        Me.Controls.Add(SS12)

        Me.Refresh()

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Add AdvancedHMI.Controls but failed, can anyone find the problem?
« Reply #1 on: September 29, 2019, 05:40:27 PM »
It should be similar to this:

Code: [Select]
    Private SS10, SS11, SS12 As AdvancedHMIControls.SevenSegment2
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        SS10 = New AdvancedHMIControls.SevenSegment2
        SS11 = New AdvancedHMIControls.SevenSegment2
        SS12 = New AdvancedHMIControls.SevenSegment2

        SS10.Location = New Point(600, 160)
        SS11.Location = New Point(600, 320)
        SS12.Location = New Point(600, 480)

        SS10.Size = New Size(220, 88)
        SS11.Size = New Size(220, 88)
        SS12.Size = New Size(220, 88)

        SS10.ForeColorInLimits = SystemColors.Info
        SS11.ForeColorInLimits = SystemColors.Info
        SS12.ForeColorInLimits = SystemColors.Info

        SS10.BackColor = SystemColors.Window

        SS10.ComComponent = Me.ModbusTCPCom1
        SS11.ComComponent = Me.ModbusTCPCom1
        SS12.ComComponent = Me.ModbusTCPCom1

        SS10.PLCAddressValue = New Drivers.PLCAddressItem("43006", 1, "", "", 0.1, 0)
        SS11.PLCAddressValue = New Drivers.PLCAddressItem("43008", 1, "", "", 0.1, 0)
        SS12.PLCAddressValue = New Drivers.PLCAddressItem("43010", 1, "", "", 0.1, 0)

        Me.Controls.Add(SS10)
        Me.Controls.Add(SS11)
        Me.Controls.Add(SS12)

    End Sub

« Last Edit: September 29, 2019, 05:45:32 PM by Godra »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Add AdvancedHMI.Controls but failed, can anyone find the problem?
« Reply #2 on: September 29, 2019, 06:01:55 PM »
My guess is that you are missing to set the Size

halosome

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Add AdvancedHMI.Controls but failed, can anyone find the problem?
« Reply #3 on: September 29, 2019, 06:11:10 PM »
Thank you both.

Its right, I tried the code, it works.  But there is another problem now, the modbustcp.beginread which i call every 100mS pops up an exception:

MFgControls.advancedHMI.driver.comm.PLCDriverException: 'ModbusTCP SendData DLL Instance not Created.

The BeginRead is calling from the MainForm, the add controls code is in Form10. If I don't show form10, everything is OK, if I show Form10, the exception pops up right away.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Add AdvancedHMI.Controls but failed, can anyone find the problem?
« Reply #4 on: September 29, 2019, 06:49:46 PM »
Does it happen if you call Read instead of BeginRead ?

The error can happen if the IPAddress is left at 0.0.0.0
« Last Edit: September 29, 2019, 06:51:40 PM by Archie »

halosome

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Add AdvancedHMI.Controls but failed, can anyone find the problem?
« Reply #5 on: September 29, 2019, 07:03:44 PM »
You got it. I left form10's driver to 0.0.0.0.

Thanks Archie!