File: archive_event.cpp

package info (click to toggle)
tango 10.0.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 89,936 kB
  • sloc: cpp: 201,786; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 272; sql: 72; ruby: 24
file content (796 lines) | stat: -rw-r--r-- 23,135 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
// NOLINTBEGIN(*)

#include "old_common.h"

class EventCallBack : public Tango::CallBack
{
    void push_event(Tango::EventData *);

  public:
    int cb_executed;
    int cb_err;
    int old_sec, old_usec;
    long val;
    long val_size;
};

void EventCallBack::push_event(Tango::EventData *event_data)
{
    std::vector<DevLong> value;
    struct timeval now_timeval = Tango::make_timeval(std::chrono::system_clock::now());

    TEST_LOG << "date : tv_sec = " << now_timeval.tv_sec;
    TEST_LOG << ", tv_usec = " << now_timeval.tv_usec << std::endl;

    auto delta_msec = ((now_timeval.tv_sec - old_sec) * 1000) + ((now_timeval.tv_usec - old_usec) / 1000);

    old_sec = now_timeval.tv_sec;
    old_usec = now_timeval.tv_usec;

    TEST_LOG << "delta_msec = " << delta_msec << std::endl;

    cb_executed++;

    try
    {
        TEST_LOG << "StateEventCallBack::push_event(): called attribute " << event_data->attr_name << " event "
                 << event_data->event << "\n";
        if(!event_data->err)
        {
            *(event_data->attr_value) >> value;
            TEST_LOG << "CallBack value size " << value.size() << std::endl;
            val = value[2];
            val_size = value.size();
            TEST_LOG << "Callback value " << val << std::endl;
        }
        else
        {
            TEST_LOG << "Error send to callback" << std::endl;
            //            Tango::Except::print_error_stack(event_data->errors);
            if(strcmp(event_data->errors[0].reason.in(), "bbb") == 0)
            {
                cb_err++;
            }
        }
    }
    catch(Tango::DevFailed &e)
    {
        Tango::Except::print_exception(e);
    }
    catch(...)
    {
        TEST_LOG << "EventCallBack::push_event(): could not extract data !\n";
    }
}

int main(int argc, char **argv)
{
    DeviceProxy *device;

    if(argc == 1)
    {
        TEST_LOG << "usage: %s device" << std::endl;
        exit(-1);
    }

    std::string device_name = argv[1];

    try
    {
        device = new DeviceProxy(device_name);
    }
    catch(CORBA::Exception &e)
    {
        Except::print_exception(e);
        exit(1);
    }

    TEST_LOG << std::endl << "new DeviceProxy(" << device->name() << ") returned" << std::endl << std::endl;

    try
    {
        std::string att_name("Event_change_tst");

        //
        // Test set up (stop polling and clear abs_change and rel_change attribute
        // properties but restart device to take this into account)
        // Set the abs_change to 1
        //

        if(device->is_attribute_polled(att_name))
        {
            device->stop_poll_attribute(att_name);
        }
        DbAttribute dba(att_name, device_name);
        DbData dbd;
        DbDatum a(att_name);
        a << (short) 3;
        dbd.push_back(a);
        dbd.push_back(DbDatum("archive_abs_change"));
        dbd.push_back(DbDatum("archive_rel_change"));
        dbd.push_back(DbDatum("archive_period"));
        dba.delete_property(dbd);

        dbd.clear();
        a << (short) 2;
        dbd.push_back(a);
        DbDatum ch("archive_abs_change");
        ch << (short) 1;
        dbd.push_back(ch);
        DbDatum p("archive_period");
        p << (short) 10000;
        dbd.push_back(p);
        dba.put_property(dbd);

        DeviceProxy adm_dev(device->adm_name().c_str());
        DeviceData di;
        di << device_name;
        adm_dev.command_inout("DevRestart", di);

        delete device;
        device = new DeviceProxy(device_name);
        std::this_thread::sleep_for(std::chrono::seconds(1));

        //
        // subscribe to a archive event
        //

        int eve_id;
        std::vector<std::string> filters;
        EventCallBack cb;
        cb.cb_executed = 0;
        cb.cb_err = 0;
        cb.old_sec = cb.old_usec = 0;

        bool po;
        int poll_period;

        // start the polling first!
        device->poll_attribute(att_name, 1000);

        eve_id = device->subscribe_event(att_name, Tango::ARCHIVE_EVENT, &cb, filters);

        //
        // Check that the attribute is now polled at 1000 mS
        //

        po = device->is_attribute_polled(att_name);
        TEST_LOG << "attribute polled : " << po << std::endl;
        assert(po == true);

        poll_period = device->get_attribute_poll_period(att_name);
        TEST_LOG << "att polling period : " << poll_period << std::endl;
        assert(poll_period == 1000);

        TEST_LOG << "   subscribe_event --> OK" << std::endl;

        //
        // Check that first point has been received
        //

        assert(cb.cb_executed == 1);
        assert(cb.val == 30);
        assert(cb.val_size == 4);
        TEST_LOG << "   first point received --> OK" << std::endl;

        //
        // Check that callback was called after a positive value change
        //

        // A trick for gdb. The thread created by omniORB for the callback execution
        // is just started during the sleep. Gdb has a breakpoint reached at each thread
        // creation to display message on the console. This breakpoint is a software
        // signal which interrupts the sleep.....
        //

        std::this_thread::sleep_for(std::chrono::seconds(1));

        device->command_inout("IOIncValue");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 3);
        assert(cb.val == 31);
        assert(cb.val_size == 4);

        TEST_LOG << "   CallBack executed for positive absolute delta --> OK" << std::endl;

        //
        // Check that callback was called after a negative value change
        //

        device->command_inout("IODecValue");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 4);
        assert(cb.val == 30);
        assert(cb.val_size == 4);

        TEST_LOG << "   CallBack executed for negative absolute delta --> OK" << std::endl;

        //
        // Check that callback was called after adding one elt to the spectrum
        //

        device->command_inout("IOAddOneElt");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 5);
        assert(cb.val == 30);
        assert(cb.val_size == 5);

        TEST_LOG << "   CallBack executed when spectrum size increases --> OK" << std::endl;

        //
        // Check that callback was called after removing one elt to the spectrum
        //

        device->command_inout("IORemoveOneElt");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 6);
        assert(cb.val == 30);
        assert(cb.val_size == 4);

        TEST_LOG << "   CallBack executed when spectrum size decreases --> OK" << std::endl;

        //
        // Force the attribute to throw exception
        //

        std::vector<short> data_in(2);
        data_in[0] = 1;
        data_in[1] = 1;
        di << data_in;

        device->command_inout("IOAttrThrowEx", di);

        //
        // Check that callback was called with error
        // two times: one for error detection and the other one due to the
        // periodic call
        //

        std::this_thread::sleep_for(std::chrono::seconds(3));
        TEST_LOG << "Callback cb_err = " << cb.cb_err << std::endl;
        assert((cb.cb_err == 1) || (cb.cb_err == 2));

        TEST_LOG << "   CallBack executed when attribute throw exception only once --> OK" << std::endl;

        //
        // Attribute does not send exception any more
        //

        data_in[1] = 0;
        di << data_in;

        device->command_inout("IOAttrThrowEx", di);

        //
        // Wait for the periodic part of the event (default = 10 sec)
        // Wait one second for the callback sent because exception not thrown any more
        //

        std::this_thread::sleep_for(std::chrono::seconds(1));
        long nb_cb = cb.cb_executed;
        std::this_thread::sleep_for(std::chrono::seconds(12));

        assert(cb.cb_executed == (nb_cb + 1));
        TEST_LOG << "   CallBack executed for the periodic part of the event --> OK" << std::endl;

        //
        // unsubscribe to the event
        //

        device->unsubscribe_event(eve_id);

        TEST_LOG << "   unsubscribe_event --> OK" << std::endl;
        //
        // Change the event parameters. This means restart the device to take
        // this into account
        //

        if(device->is_attribute_polled(att_name))
        {
            device->stop_poll_attribute(att_name);
        }
        dbd.clear();
        a << (short) 3;
        dbd.push_back(a);
        dbd.push_back(DbDatum("archive_abs_change"));
        dbd.push_back(DbDatum("archive_rel_change"));
        dbd.push_back(DbDatum("archive_period"));
        dba.delete_property(dbd);
        exit(0);
        dbd.clear();
        a << (short) 2;
        dbd.push_back(a);
        DbDatum drel("archive_rel_change");
        drel << (short) 10;
        dbd.push_back(drel);
        DbDatum drel1("archive_period");
        drel1 << (short) 5000;
        dbd.push_back(drel1);
        dba.put_property(dbd);

        DeviceProxy adm_dev_1 = device->adm_name().c_str();
        di << device_name;
        adm_dev_1.command_inout("DevRestart", di);

        delete device;
        device = new DeviceProxy(device_name);
        std::this_thread::sleep_for(std::chrono::seconds(1));

        //
        // Poll attribute at 500 mS
        //

        device->poll_attribute(att_name, 500);

        //
        // subscribe to an archive event
        //

        cb.cb_executed = 0;
        cb.cb_err = 0;
        cb.old_sec = cb.old_usec = 0;

        eve_id = device->subscribe_event(att_name, Tango::ARCHIVE_EVENT, &cb, filters);

        //
        // Check that the attribute is still polled at 500 mS
        //

        po = device->is_attribute_polled(att_name);
        TEST_LOG << "attribute polled : " << po << std::endl;
        assert(po == true);

        poll_period = device->get_attribute_poll_period(att_name);
        TEST_LOG << "att polling period : " << poll_period << std::endl;
        assert(poll_period == 500);

        TEST_LOG << "   subscribe_event (with relative change) --> OK" << std::endl;

        //
        // Check that first point has been received
        //

        assert(cb.cb_executed == 1);
        assert(cb.val == 30);
        assert(cb.val_size == 4);
        TEST_LOG << "   first point received (with relative change) --> OK" << std::endl;

        //
        // Generates a positive change
        //

        std::this_thread::sleep_for(std::chrono::seconds(1));

        device->command_inout("IOIncValue");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 1);

        device->command_inout("IOIncValue");
        device->command_inout("IOIncValue");

        std::this_thread::sleep_for(std::chrono::seconds(1));

        assert(cb.cb_executed == 2);
        assert(cb.val == 33);
        assert(cb.val_size == 4);

        TEST_LOG << "   CallBack executed for positive relative delta --> OK" << std::endl;

        //
        // Generates a negative change (10 % of 33 is 3.3)
        // Note that like archive_period is set to 5 seconds, we should have received
        // an archive periodic callback
        //

        device->command_inout("IODecValue");

        std::this_thread::sleep_for(std::chrono::seconds(3));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;

        // 3 instead of 2 due to the archive_period property

        assert(cb.cb_executed == 3);

        device->command_inout("IODecValue");
        device->command_inout("IODecValue");

        std::this_thread::sleep_for(std::chrono::seconds(1));

        assert(cb.cb_executed == 3);

        device->command_inout("IODecValue");
        device->command_inout("IODecValue");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        assert(cb.cb_executed == 4);
        assert(cb.val == 28);
        assert(cb.val_size == 4);

        TEST_LOG << "   CallBack executed for negative relative delta --> OK" << std::endl;

        //
        // Force the attribute to throw exception
        //

        data_in[0] = 1;
        data_in[1] = 1;
        di << data_in;

        device->command_inout("IOAttrThrowEx", di);

        //
        // Check that callback was called
        //

        std::this_thread::sleep_for(std::chrono::seconds(2));
        TEST_LOG << "Callback cb_err = " << cb.cb_err << std::endl;
        assert(cb.cb_err == 1);

        TEST_LOG << "   CallBack executed when attribute throw exception only once --> OK" << std::endl;

        //
        // Attribute does not send exception any more
        //

        data_in[1] = 0;
        di << data_in;

        device->command_inout("IOAttrThrowEx", di);

        //
        // Wait for the periodic part of the event (is now set to 5 sec)
        //

        std::this_thread::sleep_for(std::chrono::seconds(1));
        nb_cb = cb.cb_executed;
        std::this_thread::sleep_for(std::chrono::seconds(7));

        assert(cb.cb_executed >= (nb_cb + 1));
        TEST_LOG << "   CallBack executed for the periodic part of the event (archive_period set) --> OK" << std::endl;

        //
        // unsubscribe to the event
        //

        device->unsubscribe_event(eve_id);

        TEST_LOG << "   unsubscribe_event --> OK" << std::endl;

        //
        // Change the event parameters. This means restart the device to take
        // this into account
        //

        if(device->is_attribute_polled(att_name))
        {
            device->stop_poll_attribute(att_name);
        }
        dbd.clear();
        a << (short) 3;
        dbd.push_back(a);
        dbd.push_back(DbDatum("archive_abs_change"));
        dbd.push_back(DbDatum("archive_rel_change"));
        dbd.push_back(DbDatum("archive_period"));
        dba.delete_property(dbd);

        dbd.clear();
        a << (short) 1;
        dbd.push_back(a);
        dbd.push_back(ch);
        dba.put_property(dbd);

        DeviceProxy adm_dev_2 = device->adm_name().c_str();
        di << device_name;
        adm_dev_2.command_inout("DevRestart", di);

        delete device;
        device = new DeviceProxy(device_name);
        std::this_thread::sleep_for(std::chrono::seconds(1));

        //
        // subscribe to a archive event with a filter
        //

        cb.cb_executed = 0;
        cb.cb_err = 0;
        cb.old_sec = cb.old_usec = 0;
        filters.push_back("$delta_change_abs >= 2 or $delta_change_abs <= -2");

        // start the polling first!
        device->poll_attribute(att_name, 1000);
#ifdef NOTIFD
        eve_id = device->subscribe_event(att_name, Tango::ARCHIVE_EVENT, &cb, filters);

        //
        // Check that the attribute is still polled at 1000 mS
        //

        po = device->is_attribute_polled(att_name);
        TEST_LOG << "attribute polled : " << po << std::endl;
        assert(po == true);

        poll_period = device->get_attribute_poll_period(att_name);
        TEST_LOG << "att polling period : " << poll_period << std::endl;
        assert(poll_period == 1000);

        TEST_LOG << "   subscribe_event (with filter) --> OK" << std::endl;

        //
        // Check that first point has been received
        //

        assert(cb.cb_executed == 1);
        assert(cb.val == 30);
        assert(cb.val_size == 4);
        TEST_LOG << "   first point received (with filter) --> OK" << std::endl;

        //
        // Generates a positive change
        //

        std::this_thread::sleep_for(std::chrono::seconds(1));

        device->command_inout("IOIncValue");

        std::this_thread::sleep_for(std::chrono::seconds(1));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 1);

        // Let's hope the polling thread will not start just between the two command_inout

        device->command_inout("IOIncValue");
        device->command_inout("IOIncValue");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        assert(cb.cb_executed == 2);
        assert(cb.val == 33);
        assert(cb.val_size == 4);

        TEST_LOG << "   CallBack executed for positive delta (with filter) --> OK" << std::endl;

        //
        // Generates a negative change
        //

        device->command_inout("IODecValue");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 2);

        device->command_inout("IODecValue");
        device->command_inout("IODecValue");
        device->command_inout("IODecValue");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        assert(cb.cb_executed == 3);
        assert(cb.val == 29);
        assert(cb.val_size == 4);

        TEST_LOG << "   CallBack executed for negative delta (with filter) --> OK" << std::endl;

        //
        // Check that callback was called after adding one elt to the spectrum
        //

        device->command_inout("IOAddOneElt");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 4);
        assert(cb.val == 29);
        assert(cb.val_size == 5);

        TEST_LOG << "   CallBack executed when spectrum size increases (with filter) --> OK" << std::endl;

        //
        // Check that callback was called after removing one elt to the spectrum
        //

        device->command_inout("IORemoveOneElt");

        std::this_thread::sleep_for(std::chrono::seconds(2));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 5);
        assert(cb.val == 29);
        assert(cb.val_size == 4);

        TEST_LOG << "   CallBack executed when spectrum size decreases (with filter) --> OK" << std::endl;

        //
        // Force the attribute to throw exception
        //

        data_in[0] = 1;
        data_in[1] = 1;
        di << data_in;

        device->command_inout("IOAttrThrowEx", di);

        //
        // Check that callback was called
        //

        std::this_thread::sleep_for(std::chrono::seconds(3));
        TEST_LOG << "Callback cb_err = " << cb.cb_err << std::endl;
        assert(cb.cb_err == 1);

        TEST_LOG << "   CallBack executed when attribute throw exception only once (with filter) --> OK" << std::endl;

        //
        // Attribute does not send exception any more
        //

        data_in[0] = 1;
        data_in[1] = 0;
        di << data_in;

        device->command_inout("IOAttrThrowEx", di);

        //
        // unsubscribe to the event
        //

        device->unsubscribe_event(eve_id);
        TEST_LOG << "   unsubscribe_event --> OK" << std::endl;
#endif

        //
        // Change the event parameters. This means restart the device to take
        // this into account
        //

        if(device->is_attribute_polled(att_name))
        {
            device->stop_poll_attribute(att_name);
        }
        dbd.clear();
        a << (short) 3;
        dbd.push_back(a);
        dbd.push_back(DbDatum("archive_abs_change"));
        dbd.push_back(DbDatum("archive_rel_change"));
        dbd.push_back(DbDatum("archive_period"));
        dba.delete_property(dbd);

        dbd.clear();
        a << (short) 1;
        dbd.push_back(a);
        dbd.push_back(ch);
        dba.put_property(dbd);

        DeviceProxy adm_dev_3(device->adm_name().c_str());
        di << device_name;
        adm_dev_3.command_inout("DevRestart", di);

        delete device;
        device = new DeviceProxy(device_name);
        std::this_thread::sleep_for(std::chrono::seconds(1));

        //
        // subscribe to a archive event with a filter on delta_event
        //

        cb.cb_executed = 0;
        cb.cb_err = 0;
        cb.old_sec = cb.old_usec = 0;
        filters.clear();
        filters.push_back("$delta_event >= 500.0 ");

        // start the polling first!
        device->poll_attribute(att_name, 250);
#ifdef NOTIFD
        eve_id = device->subscribe_event(att_name, Tango::ARCHIVE_EVENT, &cb, filters);

        //
        // Check that the attribute is still polled at 1000 mS
        //

        po = device->is_attribute_polled(att_name);
        TEST_LOG << "attribute polled : " << po << std::endl;
        assert(po == true);

        poll_period = device->get_attribute_poll_period(att_name);
        TEST_LOG << "att polling period : " << poll_period << std::endl;
        assert(poll_period == 250);

        TEST_LOG << "   subscribe_event (with filter on delta_event) --> OK" << std::endl;

        //
        // Check that first point has been received
        //

        assert(cb.cb_executed == 1);
        assert(cb.val == 30);
        assert(cb.val_size == 4);
        TEST_LOG << "   first point received (with delta_event filter) --> OK" << std::endl;

        device->command_inout("IOIncValue");

        std::this_thread::sleep_for(std::chrono::milliseconds(100));

        //
        // Generates a positive change
        //

        device->command_inout("IOIncValue");
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        device->command_inout("IOIncValue");
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        device->command_inout("IOIncValue");
        std::this_thread::sleep_for(std::chrono::milliseconds(700));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 1);
        assert(cb.val == 30);
        assert(cb.val_size == 4);

        TEST_LOG << "   Event filtered with delta_event filter set --> OK" << std::endl;

        //
        // Change once more the value and wait for the event

        device->command_inout("IOIncValue");

        std::this_thread::sleep_for(std::chrono::seconds(1));

        TEST_LOG << "cb excuted = " << cb.cb_executed << std::endl;
        assert(cb.cb_executed == 2);
        assert(cb.val == 35);
        assert(cb.val_size == 4);

        TEST_LOG << "   Event received with delta_event filter set --> OK" << std::endl;

        //
        // unsubscribe to the event
        //

        device->unsubscribe_event(eve_id);
        TEST_LOG << "   unsubscribe_event --> OK" << std::endl;
#endif

        //
        // Stop polling
        //

        device->stop_poll_attribute(att_name);
    }
    catch(Tango::DevFailed &e)
    {
        Except::print_exception(e);
        exit(-1);
    }
    catch(CORBA::Exception &ex)
    {
        Except::print_exception(ex);
        exit(-1);
    }

    delete device;

    return 0;
}

// NOLINTEND(*)