Custom modbus driver

Forum Home Forums Development and Integration Custom modbus driver

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17573
    oley
    Participant

    Hi,

    I have successfully created a driver that is an extension of DrvModbus. Unfortunately, the generated events do not appear in the web application or in the server log.
    I can see them in the device, e.g.

    Recent Events
    +---------------------+-----+-------------------------------------+
    | Timestamp           | Tag | Description                         |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:18:54 |     | ODWZB. WE 31                        |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:18:54 |     | POB. WE 18                          |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:18:54 |     | ZAMKNIĘCIE OPERACYJNE ŁĄCZNIKA 1 
    7 |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:21:45 |     | POB. WE 31                          |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:21:45 |     | ODWZB. WE 18                        |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:21:45 |     | OTWARCIE OPERACYJNE ŁĄCZNIKA 1 7   |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:22:07 |     | ODWZB. WE 31                        |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:22:07 |     | POB. WE 18                          |
    +---------------------+-----+-------------------------------------+
    | 18/01/2026 19:22:07 |     | ZAMKNIĘCIE OPERACYJNE ŁĄCZNIKA 1 7 |
    +---------------------+-----+-------------------------------------+
    

    The code I use to generate the event is:

    DeviceEvent devEvent = new DeviceEvent
    {
        Timestamp = eventUtcTime,
        CnlVal = code,
        CnlStat = CnlStatusID.Defined,
        Descr = descr
    };
    
    DeviceData.EnqueueEvent(devEvent);
    • This topic was modified 2 months, 2 weeks ago by Mikhail.
    • This topic was modified 2 months, 2 weeks ago by Mikhail.
    #17580
    Mikhail
    Moderator

    Hi,
    An event generated from the driver should be bound to a device tag.
    A device tag should be bound to a channel.
    Check this example.

    #17584
    oley
    Participant

    Hi Mikhail,

    I tried to do this similar to DrvSimulator.

    internal static class TagCode
    {
        public const string TangoEventCode = nameof(TangoEventCode);
    }
    public static List<CnlPrototypeGroup> GetGroups()
    {
        List<CnlPrototypeGroup> groups = new List<CnlPrototypeGroup>();
    
        CnlPrototypeGroup group = new CnlPrototypeGroup("Events");
        group.AddCnlPrototype(TagCode.TangoEventCode, "TangoEvent");
        groups.Add(group);
    
        return groups;
    }
    DeviceTag eventTag = null;
    
    if (DeviceTags != null)
    {
        eventTag = DeviceTags[TagCode.TangoEventCode];
    }
    
    DeviceEvent devEvent = eventTag != null
        ? new DeviceEvent(eventTag)
        : new DeviceEvent();
    
    devEvent.Timestamp = eventUtcTime;
    devEvent.CnlVal = code;
    devEvent.CnlStat = CnlStatusID.Defined;
    devEvent.Descr = descr;
    
    DeviceData.EnqueueEvent(devEvent);

    I have created a channel in Scada bound to TangoEventCode tag.
    Now I become an event in web app, but this contains Defined, <code> not my description of the event.

    Do I need to create a channel in Scada? If I use this driver for all my devices I have to gave this tag unique name with device number coded or similar.

    I want to see my generated event with the description I created for it.

    #17588
    Mikhail
    Moderator

    A device tag is not null event if it is not bound to a channel.
    You should initialize device tags in the driver logic in the InitDeviceTags method.
    According to your first message, you already have device tags. For tests, try DeviceTags[0]

    #17590
    oley
    Participant

    My problem now is that now I become evens which looks like defined channel data event:

    21/01/2026 07:07:13	PV	TANGO	TangoEventCode	Defined, 311.000		
    21/01/2026 07:07:13	PV 	TANGO	TangoEventCode	Defined, 310.000		
    21/01/2026 07:07:13	PV 	TANGO	TangoEventCode	Defined, 271.000		
    21/01/2026 07:07:13	PV 	TANGO	TangoEventCode	Defined, 270.000		
    

    But I create a proper description for my device event in the driver (event is simple code, but has its meaning).

    Recent Events
    +---------------------+----------------+-------------------------------------+
    | Timestamp           | Tag            | Description                         |
    +---------------------+----------------+-------------------------------------+
    | 20/01/2026 19:08:04 | TangoEventCode | <strong>ODWZB. WE 31</strong>                        |
    +---------------------+----------------+-------------------------------------+
    | 20/01/2026 19:08:04 | TangoEventCode | POB. WE 18                          |
    +---------------------+----------------+-------------------------------------+
    | 20/01/2026 19:08:04 | TangoEventCode | ZAMKNIĘCIE OPERACYJNE ŁĄCZNIKA 1 
    7 |
    +---------------------+----------------+-------------------------------------+
    | 21/01/2026 07:07:13 | TangoEventCode | ODWZB. ZAB. f<2                     |
    +---------------------+----------------+-------------------------------------+
    | 21/01/2026 07:07:13 | TangoEventCode | POB. ZAB. f<2 
    0 -100270580 2       |
    +---------------------+----------------+-------------------------------------+
    | 21/01/2026 07:07:13 | TangoEventCode | ODWZB. ZAB. f>2                     |
    +---------------------+----------------+-------------------------------------+
    | 21/01/2026 07:07:13 | TangoEventCode | POB. ZAB. f>2 
    0 -8.214282E+11 2    |
    +---------------------+----------------+-------------------------------------+
    

    I want to see the description in rapid scada event table, in column description. Is this possible?

    #17594
    Mikhail
    Moderator

    Play with the TextFormat and Text properties of an event.
    Link

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