Author Topic: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw  (Read 4307 times)

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #15 on: June 08, 2018, 08:32:10 AM »
Archie,

I still get a various Object..  error, when I wrote with the serial cable unplugged I got a Failed To Write To PLC popup window, and then the displays started showing loss of comm's errors - only get the Object error when it is communicating.

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #16 on: June 08, 2018, 12:06:41 PM »
Archie,

I added the steps1.txt and changed the properties as instructed, but still get the same error - it was put in the debug folder - I checked after the rebuild.

I tried to write a value with the serial cable unplugged and got a popup about PLC comm's loss not the Object..., and while testing the Object .. error does show occasionally on other screens.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #17 on: June 08, 2018, 04:39:24 PM »
Besides for the MainForm, no other form has a section of code to reduce communication when the form is not visible:

Code: [Select]
    '*******************************************************************************
    '* Stop polling when the form is not visible in order to reduce communications
    '* Copy this section of code to every new form created
    '*******************************************************************************
    Private NotFirstShow As Boolean

    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
    End Sub

Have you considered that or do you need all the activated drivers to continuously poll?
 

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #18 on: June 08, 2018, 05:47:33 PM »
Good catch, Godra.
I thought he's been around enough to know this
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #19 on: June 08, 2018, 06:25:47 PM »
Godra,

No, that's something I have never added to any form - I presumed that a closed form shut down completely.

I will add it to all the forms, and on other projects too.


AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #20 on: June 09, 2018, 07:02:14 AM »
When I went to MainForm and copied the code to shut down the driver I noticed the following section that warns .NET does not close windows - so I copied that to all other pages with the driver shut-down code.

Code: [Select]

    '***************************************************************
    '* .NET does not close hidden forms, so do it here
    '* to make sure forms are disposed and drivers close
    '***************************************************************
    Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        Dim index As Integer
        While index < My.Application.OpenForms.Count
            If My.Application.OpenForms(index) IsNot Me Then
                My.Application.OpenForms(index).Close()
            End If
            index += 1
        End While
    End Sub

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #21 on: June 09, 2018, 08:42:50 AM »
You should avoid that since it will create recursive loop.

Besides for your MainForm, all other forms are designed as borderless and have the "Home" button to return to the MainForm (which is designed to close the application).
The only way to close these other forms would be to press Alt+F4 on the keyboard.
If it is ever done then each form, while closing, will try to close the other open forms.

Instead, for all other forms, you should just have MainForm.Show() line:

Code: [Select]
    Private Sub Me_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        MainForm.Show()
    End Sub
« Last Edit: June 09, 2018, 08:46:54 AM by Godra »

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #22 on: June 09, 2018, 11:36:33 AM »
Godra,

First - shutting down the drivers fixed all those errors. Thanks for that one.

I will go through and remove all the form close code.

I still have problem with MainForm displaying the Steps1.txt. It is looking at the right PLC integer, the value of the integer is 21, which should show "Not Ready" but it still shows "Can't find part of..."

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #23 on: June 09, 2018, 12:45:19 PM »
You need to set IniFileName to Steps1.txt, as in the attached picture.

It works for me.

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Object Reference Nor Set o An Inistance.." Using AB DF1 & 399Vw
« Reply #24 on: June 09, 2018, 01:03:25 PM »
Godra,

Again, Thanks.

When I put it in it added it with the full path name, not just the file name - obviously it was looking in the wrong place as the HMI computer doesn't have a second hard drive..