How to retrieve data from the Channels table in a custom module?

Forum Home Forums Development and Integration How to retrieve data from the Channels table in a custom module?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #15455
    showmustgoon
    Participant

    How can I retrieve data from the Channels table in a custom module’s View? I don’t need to modify it, I just want to read some of its properties to provide convenient configuration options for the user.

    #15457
    manjey73
    Participant

    Cnl CnlArc = ServerContext.Cnls.ArcCnls.Values.Where(x => x.CnlNum == cnlNum).FirstOrDefault();

    It is possible to get from the Scada Module in this way through the required channels.
    where is CnlNum the channel number you need

    There are 4 types of channel lists
    ArcCnls – all channels that can be saved in the database
    CnlOut – output channels only
    Calculated and another one where the input channels are

                // Каналы Archive - все Input, InputOutput, Calculated, CalculatedOutput
                try
                {
                    Cnl CnlArc = ServerContext.Cnls.ArcCnls.Values.Where(x => x.CnlNum == cnlNum).FirstOrDefault();
                    if (CnlArc != null)
                    {
                        if (!dictCnl.ContainsKey(Name)) // Сразу добавлять в словарь наверное не получится, так как неизвестен поток ??? Известна программа
                        {
                            dictCnl.Add(Name, CnlArc);
                        }
                    }
                }
                catch
                {
                    moduleLog.WriteLine($"НЕТ ArcCnls"); // TEST
                }
    
                // Каналы Output
                try
                {
                    Cnl CnlOut = ServerContext.Cnls.OutCnls.Values.Where(x => x.CnlNum == cnlNum).FirstOrDefault();
                    if (CnlOut != null)
                    {
                        if (!dictCnl.ContainsKey(Name))
                        {
                            dictCnl.Add(Name, CnlOut);
                        }
                    }
                }
                catch
                {
                    moduleLog.WriteLine($"НЕТ OutCnls"); // TEST
                }
            }
    

    So I add the channels I need to my dictionaries as an example.

    Next, you can study Cnl CnlArc and take the necessary actions depending on the Data Types, format, etc.

    • This reply was modified 1 month ago by manjey73.
    #15472
    Mikhail
    Moderator

    The configuration database is available for a module view. Check this source code.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.