Skip to content
This repository has been archived by the owner on Sep 28, 2019. It is now read-only.

Multiple server-instances in a single application #2

Open
L4S1L0 opened this issue Mar 28, 2017 · 1 comment
Open

Multiple server-instances in a single application #2

L4S1L0 opened this issue Mar 28, 2017 · 1 comment

Comments

@L4S1L0
Copy link

L4S1L0 commented Mar 28, 2017

I tried to use this library to simulate multiple battery storage power plants in a single application and provide their data via IEC 60870-5-104 protocol. The architecture / the server items of each battery should be exactly the same in order to simply integrate them into an existing plc. Each server listens to another port.

The problem is that every server-instance sends data via their own port and also via each other port defined in the other servers.

To make it easy to reproduce this behavior, I prepared a short example with two servers. server1 on port 2404 should only provide data on IOA 1 and server2 on port 2405 should only provide data on IOA 2. I receive both items on both ports.

Here’s my sample:

private ServerSAP server1;
private ServerSAP server2;
private void Start()
{
    try
    {
        server1 = new ServerSAP("127.0.0.1", 2404);
        server2 = new ServerSAP("127.0.0.1", 2405);

        server1.StartListen(100);
        server2.StartListen(101);
        
        timer.Enabled = true;
    }
    catch(Exception e)
    {
        Console.WriteLine(e);
    }
}

private int cnt = 0;
void TimerTick(object sender, EventArgs e)
{
    InformationElement ielem_value1 = new IeShortFloat(cnt);
    InformationElement ielem_quality1 = new IeQuality(false,false,false,false,false);
    InformationElement[][] ielem1 = new InformationElement[1][] { new InformationElement[2] { ielem_value1,ielem_quality1 } };
    InformationObject[] iobj1 = new InformationObject[1] { new InformationObject(1, ielem1) };
    ASdu asdu1 = new ASdu(TypeId.M_ME_NC_1, false, CauseOfTransmission.SPONTANEOUS, false, false, 1, 1, iobj1);
    
    InformationElement ielem_value2 = new IeShortFloat(cnt*2);
    InformationElement ielem_quality2 = new IeQuality(true,true,true,false,false);
    InformationElement[][] ielem2 = new InformationElement[1][] { new InformationElement[2] { ielem_value2,ielem_quality2 } };
    InformationObject[] iobj2 = new InformationObject[1] { new InformationObject(2, ielem2) };
    ASdu asdu2 = new ASdu(TypeId.M_ME_NC_1, false, CauseOfTransmission.SPONTANEOUS, false, false, 1, 1, iobj2);
    
    server1.SendASdu(asdu1);
    server2.SendASdu(asdu2);
    cnt++;
}

Do I use the library the wrong way or is it a bug?

Thanks in advance for any suggestion.

@minhdtb83
Copy link
Collaborator

Yes, it is a bug. I will fix it soon. Thank you for your informations

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants