-->

Sorting items in OPC Server

2019-09-17 09:36发布

问题:

We are trying to implement an OPC Server, with a specific objects structure, as you can see in the following example:

  • Node X
    • Item 1
    • Item 2
    • Item 3
    • Item 4
    • Item 5
    • Item 6
    • Item 7
    • ... (till 300)
  • Node Y
    • ...

But, for some strange reason, in several OPC clients the items are shown like this:

  • Node X
    • Item 3
    • Item 11
    • Item 22
    • Item 33
    • Item 44
    • Item 55
    • Item 4
    • ... (till 300)
  • Node Y
    • ...

Our main problem is about sorting the items in the list. As you can see in the screenshot the items are not shown sorted in the OPC client, and we have tried several OPC clients and some of them have a special option to show the items in a sorted way and some others no.

The thing is... if we are creating a generic OPC Server for all the existing OPC clients in the market... it is responsibility of the server to serve the items sorted, right? or... is it responsibility of the client?

Conceptually, which is the correct way?

My feeling is that the OPC Server should give all the items sorted anyway, but I'm not sure if it is possible and standard.

Otherwise, there are a lot of SCADA's in the world, for sure, that trying to show the list of items in a screen will show them not sorted, as in the sample provided, and this is a big problem when you have around 300 items in a list.

Thanks for your collaboration!

回答1:

The order of items has no significance in OPC specifications. In addition, OPC does not "tell" the servers in which order they should enumerate the items, and it does not "tell" the clients in which order they should display them.

If you want to see the items ordered in a specific way, the best you can do is to develop your OPC server so that it indeed enumerates them in that order. When done this way, the OPC clients that do NOT sort the incoming items in any way will list them in the order you have chosen. With OPC clients that decide to sort the items somehow, you are out of luck - they will always do it their way. I would argue that good OPC clients that present the items to the user should allow them to influence the ordering, but that's up to them.

Also, the example order you presented somewhat resembles what happens when strings are sorted using the "dumb" ordering, and not looking for the natural number order in them. This leads to number ordering where numbers with less digits are interspersed within numbers with more digits, instead of numbers being taken for their numerical value. But, if that was the case, you example would like more like this:

  • > - Node X

    -- Item 1 -- Item 10 -- Item 11 -- Item 12 -- ... -- Item 2 -- Item 20 -- Item 21 -- Item 22 -- ... -- Item 3 -- Item 30 -- ...

    • Node Y

    Isn't that what you are getting? (but regardless of it, the first part of the answer applies anyway).