RobotStudio event

View Windows

I have a number of windows each are displayed based on a state of a number of digital signals. This works for the 1st couple of signal changes it the stop changing, this occurs when windows are to return to main window. The windows freeze and only navigate amongst themselves, the samplame code is given below:
 

public view1()
{
InitializeComponent();
a1Controller =
new Controller();
sWindow = a1Controller.IOSystem.GetSignal(
"diP1");
diWnd = (
DigitalSignal)sWindow;
this.diWnd.Changed += new SignalChangedEventHandler(diWnd_Changed);
}
void diWnd_Changed(object sender, SignalChangedEventArgs e)
{
this.Invoke(new ABB.Robotics.Controllers.IOSystemDomain.SignalChangedEventHandler(this.UpdateUIw), new Object[] { sender, e });
}
private void UpdateUIw(object sender, SignalChangedEventArgs e)
{

SignalState wState = e.NewSignalState;
float wVal = wState.Value;
if (wVal == 0)
{
this.CloseMe();
}
}
/// <summary>
/// Clean up any resources used by this class
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (!IsDisposed)
{
try
{
if (disposing)
{
//ToDo: Call the Dispose method of all FP SDK instances that may otherwise cause memory leak
if (components != null)
{
components.Dispose();
}
if (a1Controller != null)
{
a1Controller =
null;
a1Controller.Dispose();
}
}
}
finally
{
base.Dispose(disposing);
}
}
}

I am using VisualStudio 2008, RAB5.11, and RobotStudio 5.11.


Please assist!
Thanks'

Comments

  • Hi,
     

    try to create a Controller instance which is alive all the time. In this case, create the Controller instance in the main windows, then you can pass it through all the sub-windows.

     

    Also, make sure to dispose the signal in the dispose method of the subwindow.

     

    Let us know how this goes.

     

    BR
    Carlos Martinez
    ABB
  • Hi'
     

    How do I pass the controller instance in the main Window through to the sub-windows?

     

    I have have tried disposing the signal but the problem still exists'

     

    Many Thanks 
  • This is a simple pseudo-code
     


    class SubForm : TpsForm

    {

        Controller _ctrl;

        internal Init(Controller ctrl)

       {

            _ctrl = ctrl;

       }

    }

     

    class MainForm : TpsForm

    {

        Controller _ctrl;

        MainForm()


       {


          _ctrl = new Controller();

       }
     

        void Test()


       {

            SubForm f = new SubForm();

            f.Init(_ctrl);

            t.ShowMe(this);

       }

    }
    Carlos Martinez
    ABB