RobotStudio event

How to define IOConnection is smartcomponent?

Hello,

I need create a smartcomponent with "system name" and "system function" as input property. The smart component can make the IOConnection inside itself with the input system name. I wonder if it's possible to do this? Is any one have experience with this?

Thanks
Br/Wind

Comments

  • Hi DenisFR,

    I saw there are class "IOConnection" in robotstuido SDK,  

    public IOConnection(
    	ProjectObject sourceObject,
    	string sourceSignal,
    	ProjectObject targetObject,
    	string targetSignal
    )
    
    I don't know how to define sourceObject. Do you have some experience?
    
    Thanks a lot
  • Hi ,

    I have add a function to create connection of signals between two objects. As the following example, the signal will be connected from a.dotest1 to b.ditest1. But I have tested the code, it's not work. I have check the code have been executed. What's the reason the signal can't be connected with each other.

     public void ConnectIO(SmartComponent component)
            {
                ProjectObject a = (ProjectObject)component.Properties["ObjectA"].Value;
                ProjectObject b = (ProjectObject)component.Properties["ObjectB"].Value;
                

                IOConnection IOConn1 = new IOConnection(a, "dotest1", b, "ditest1");
                IOConn1.Update();
                
            }

    Thanks
    Br/Wind
  • DenisFR
    DenisFR ✭✭✭
    Hello,
    I don't understand what you want to do.
    I thought you want your component can get Robot Controller IO status.

    In you last example, you use this Constructor.
    In remarks, you can found that line:
    The object should be either a IHasIOSignals or an RsIrc5Controller.
    SmartComponent is IHasIOSignals.

    In Update() method, you get this remark too:
    There is normally no need to call this method since the connection is updated automatically whenever the source signal changes.

  • Hi Denis,

    We have simulation station with many robot controllers. Their have many communication between them. Normally we manually map the connection with station logic "IO Connection" page. The robot IO signals is standard. To make simulation easier, I want make a smart component to do this job. You just need define the system name and the smart component can map the connection automatically. I have tried with and without Update() method, both doesn't work. I don't know what's the problem actually.

    Thanks
    Br/Wind
  • DenisFR
    DenisFR ✭✭✭
    So, can you test to add these lines?
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Station station = component.ContainingProject as Station;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; station.IOSignals.Add(IOConn1);<br>
    PS: you should rename IOConn1 to ioConn1 to respect case naming.
    Variable start with lower and Class with upper.


  • Hi Denis,

     public void ConnectIO(SmartComponent component)
            {
                ProjectObject a = (ProjectObject)component.Properties["ObjectA"].Value;
                ProjectObject b = (ProjectObject)component.Properties["ObjectB"].Value;
                

                IOConnection ioConn1 = new IOConnection(a, "dotest1", b, "ditest1");
                Station station = component.ContainingProject as Station;         
                station.Connections.Add(ioConn1);
                station.Connections.Clear();
                
            }
    Thanks your support, now the connection auto map is OK. I also test the connections.Clear(), but found the clear can't clear the connection. Any mistake I made?

    Thanks
    Br/Wind
  • DenisFR
    DenisFR ✭✭✭
    Hello,
    I don't know why Clear doesn't work. You may send an issue.
    Did you test by using Remove(each item) ?
  • Hi Denis,

    Remove is OK. But there have other small problem with remove also. Thanks for your great help.

    Br/Wind