Forum Home › Forums › Development and Integration › How to retrieve data from the Channels table in a custom module?
- This topic has 2 replies, 3 voices, and was last updated 4 weeks, 1 day ago by Mikhail.
-
AuthorPosts
-
September 14, 2024 at 7:21 am #15455showmustgoonParticipant
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.
- This topic was modified 1 month ago by showmustgoon.
September 14, 2024 at 12:07 pm #15457manjey73ParticipantCnl 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 needThere 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.
September 16, 2024 at 7:52 am #15472 -
AuthorPosts
- You must be logged in to reply to this topic.