opendaq 0.1.1

Safe Rust bindings for openDAQ, the open-source data acquisition SDK
Documentation
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
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
// Generated by tools/generate_bindings.py -- do not edit by hand.

// Mechanical output: lint findings here are the generator's business.
#![allow(clippy::all, unused_imports, rustdoc::bare_urls)]

use crate::error::{check, Error, Result};
use crate::object::{BaseObject, Interface, Ref};
use crate::sys;
use crate::value::{Complex, Ratio, Value};
use crate::generated::*;
use std::ffi::c_char;

/// IBlockReaderStatus inherits from IReaderStatus to expand information returned read function
/// Wrapper over the openDAQ `daqBlockReaderStatus` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct BlockReaderStatus(pub(crate) ReaderStatus);

impl std::ops::Deref for BlockReaderStatus {
    type Target = ReaderStatus;
    fn deref(&self) -> &ReaderStatus { &self.0 }
}
impl crate::sealed::Sealed for BlockReaderStatus {}
unsafe impl Interface for BlockReaderStatus {
    const NAME: &'static str = "daqBlockReaderStatus";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqBlockReaderStatus_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl BlockReaderStatus {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { BlockReaderStatus(ReaderStatus::__from_ref(r)) }
}
impl std::fmt::Display for BlockReaderStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&BlockReaderStatus> for Value {
    fn from(value: &BlockReaderStatus) -> Value { Value::Object(value.to_base_object()) }
}
impl From<BlockReaderStatus> for Value {
    fn from(value: BlockReaderStatus) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for BlockReaderStatus {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// As with Data packets, Event packets travel along the signal paths. They are used to notify recipients of any relevant changes to the signal sending the packet.
/// Wrapper over the openDAQ `daqEventPacket` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct EventPacket(pub(crate) Packet);

impl std::ops::Deref for EventPacket {
    type Target = Packet;
    fn deref(&self) -> &Packet { &self.0 }
}
impl crate::sealed::Sealed for EventPacket {}
unsafe impl Interface for EventPacket {
    const NAME: &'static str = "daqEventPacket";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqEventPacket_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl EventPacket {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { EventPacket(Packet::__from_ref(r)) }
}
impl std::fmt::Display for EventPacket {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&EventPacket> for Value {
    fn from(value: &EventPacket) -> Value { Value::Object(value.to_base_object()) }
}
impl From<EventPacket> for Value {
    fn from(value: EventPacket) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for EventPacket {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// Signals accepted by input ports can be connected, forming a connection between the input port and signal, through which Packets can be sent.
/// Any openDAQ object which wishes to receive signal data must create an input port and connect it to said
/// signals. Such objects are for example function blocks, and readers.
/// An input port can filter out incompatible signals by returning false when such a signal is passed as argument
/// to `acceptsSignal`, and also rejects the signals when they are passed as argument to `connect`.
/// Depending on the configuration, an input port might not require a signal to be connected, returning false
/// when `requiresSignal` is called. Such input ports are usually a part of function blocks that do not require
/// a given signal to perform calculations.
/// Wrapper over the openDAQ `daqInputPort` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct InputPort(pub(crate) Component);

impl std::ops::Deref for InputPort {
    type Target = Component;
    fn deref(&self) -> &Component { &self.0 }
}
impl crate::sealed::Sealed for InputPort {}
unsafe impl Interface for InputPort {
    const NAME: &'static str = "daqInputPort";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqInputPort_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl InputPort {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { InputPort(Component::__from_ref(r)) }
}
impl std::fmt::Display for InputPort {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&InputPort> for Value {
    fn from(value: &InputPort) -> Value { Value::Object(value.to_base_object()) }
}
impl From<InputPort> for Value {
    fn from(value: InputPort) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for InputPort {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// The configuration component of input ports. Provides access to Input port owners to internal components of the input port.
/// Wrapper over the openDAQ `daqInputPortConfig` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct InputPortConfig(pub(crate) InputPort);

impl std::ops::Deref for InputPortConfig {
    type Target = InputPort;
    fn deref(&self) -> &InputPort { &self.0 }
}
impl crate::sealed::Sealed for InputPortConfig {}
unsafe impl Interface for InputPortConfig {
    const NAME: &'static str = "daqInputPortConfig";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqInputPortConfig_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl InputPortConfig {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { InputPortConfig(InputPort::__from_ref(r)) }
}
impl std::fmt::Display for InputPortConfig {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&InputPortConfig> for Value {
    fn from(value: &InputPortConfig) -> Value { Value::Object(value.to_base_object()) }
}
impl From<InputPortConfig> for Value {
    fn from(value: InputPortConfig) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for InputPortConfig {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// Notifications object passed to the input port on construction by its owner (listener).
/// Input ports invoke the notification functions within the Input port notifications object when corresponding
/// events occur. The listener can then react on those events.
/// Wrapper over the openDAQ `daqInputPortNotifications` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct InputPortNotifications(pub(crate) BaseObject);

impl std::ops::Deref for InputPortNotifications {
    type Target = BaseObject;
    fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for InputPortNotifications {}
unsafe impl Interface for InputPortNotifications {
    const NAME: &'static str = "daqInputPortNotifications";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqInputPortNotifications_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl InputPortNotifications {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { InputPortNotifications(BaseObject(r)) }
}
impl std::fmt::Display for InputPortNotifications {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&InputPortNotifications> for Value {
    fn from(value: &InputPortNotifications) -> Value { Value::Object(value.to_base_object()) }
}
impl From<InputPortNotifications> for Value {
    fn from(value: InputPortNotifications) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for InputPortNotifications {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// IMultiReaderStatus inherits from IReaderStatus to expand information returned read function
/// Wrapper over the openDAQ `daqMultiReaderStatus` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct MultiReaderStatus(pub(crate) ReaderStatus);

impl std::ops::Deref for MultiReaderStatus {
    type Target = ReaderStatus;
    fn deref(&self) -> &ReaderStatus { &self.0 }
}
impl crate::sealed::Sealed for MultiReaderStatus {}
unsafe impl Interface for MultiReaderStatus {
    const NAME: &'static str = "daqMultiReaderStatus";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqMultiReaderStatus_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl MultiReaderStatus {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { MultiReaderStatus(ReaderStatus::__from_ref(r)) }
}
impl std::fmt::Display for MultiReaderStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&MultiReaderStatus> for Value {
    fn from(value: &MultiReaderStatus) -> Value { Value::Object(value.to_base_object()) }
}
impl From<MultiReaderStatus> for Value {
    fn from(value: MultiReaderStatus) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for MultiReaderStatus {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// Base packet type. Data, Value, and Event packets are all also packets. Provides the packet's unique ID that is unique to a given device, as well as the packet type.
/// Wrapper over the openDAQ `daqPacket` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Packet(pub(crate) BaseObject);

impl std::ops::Deref for Packet {
    type Target = BaseObject;
    fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Packet {}
unsafe impl Interface for Packet {
    const NAME: &'static str = "daqPacket";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqPacket_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl Packet {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { Packet(BaseObject(r)) }
}
impl std::fmt::Display for Packet {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&Packet> for Value {
    fn from(value: &Packet) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Packet> for Value {
    fn from(value: Packet) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Packet {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// An interface providing access to a new reader in order to reuse the invalidated reader's settings and configuration.
/// Wrapper over the openDAQ `daqReaderConfig` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ReaderConfig(pub(crate) BaseObject);

impl std::ops::Deref for ReaderConfig {
    type Target = BaseObject;
    fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ReaderConfig {}
unsafe impl Interface for ReaderConfig {
    const NAME: &'static str = "daqReaderConfig";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqReaderConfig_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl ReaderConfig {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { ReaderConfig(BaseObject(r)) }
}
impl std::fmt::Display for ReaderConfig {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&ReaderConfig> for Value {
    fn from(value: &ReaderConfig) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ReaderConfig> for Value {
    fn from(value: ReaderConfig) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ReaderConfig {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// Represents the status of the reading process returned by the reader::read function.
/// The `IReaderStatus` class provides information about the outcome of the reading operation,
/// including the validity of the reader and the potential encounter of event packets during processing.
/// Objects of this class are typically returned as a result of the `read` function of the Readers,
/// allowing the client code to assess and respond to the status of the reading process.
/// Wrapper over the openDAQ `daqReaderStatus` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ReaderStatus(pub(crate) BaseObject);

impl std::ops::Deref for ReaderStatus {
    type Target = BaseObject;
    fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ReaderStatus {}
unsafe impl Interface for ReaderStatus {
    const NAME: &'static str = "daqReaderStatus";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqReaderStatus_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl ReaderStatus {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { ReaderStatus(BaseObject(r)) }
}
impl std::fmt::Display for ReaderStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&ReaderStatus> for Value {
    fn from(value: &ReaderStatus) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ReaderStatus> for Value {
    fn from(value: ReaderStatus) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ReaderStatus {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

/// ITailReaderStatus inherits from IReaderStatus to expand information returned read function
/// Wrapper over the openDAQ `daqTailReaderStatus` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct TailReaderStatus(pub(crate) ReaderStatus);

impl std::ops::Deref for TailReaderStatus {
    type Target = ReaderStatus;
    fn deref(&self) -> &ReaderStatus { &self.0 }
}
impl crate::sealed::Sealed for TailReaderStatus {}
unsafe impl Interface for TailReaderStatus {
    const NAME: &'static str = "daqTailReaderStatus";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqTailReaderStatus_getInterfaceId)(&mut id) };
        Some(id)
    }
    unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
        Ref::from_owned(ptr).map(Self::__from_ref)
    }
    fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl TailReaderStatus {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { TailReaderStatus(ReaderStatus::__from_ref(r)) }
}
impl std::fmt::Display for TailReaderStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&TailReaderStatus> for Value {
    fn from(value: &TailReaderStatus) -> Value { Value::Object(value.to_base_object()) }
}
impl From<TailReaderStatus> for Value {
    fn from(value: TailReaderStatus) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for TailReaderStatus {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

impl BlockReaderStatus {
    /// Calls the openDAQ C function `daqBlockReaderStatus_createBlockReaderStatus()`.
    pub fn new(event_packet: &EventPacket, valid: bool, offset: impl Into<Value>, read_samples: usize) -> Result<BlockReaderStatus> {
        let __offset = crate::value::to_daq_number(&offset.into())?;
        let mut __obj: *mut sys::daqBlockReaderStatus = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqBlockReaderStatus_createBlockReaderStatus)(&mut __obj, event_packet.as_raw() as *mut _, u8::from(valid), crate::value::opt_ref_ptr(&__offset) as *mut _, read_samples) };
        check(__code, "daqBlockReaderStatus_createBlockReaderStatus")?;
        Ok(unsafe { crate::marshal::require_object::<BlockReaderStatus>(__obj as *mut _, "daqBlockReaderStatus_createBlockReaderStatus") }?)
    }

    /// Returns the number of samples that were read. Sometimes, during the process of reading, an event packet may occur that stops the reading of remaining samples. Developers can use this function to determine how many samples were actually read.
    ///
    /// # Returns
    /// - `samples_count`: the amount of samples that were read.
    ///
    /// Calls the openDAQ C function `daqBlockReaderStatus_getReadSamples()`.
    pub fn read_samples(&self) -> Result<usize> {
        let mut __read_samples: usize = Default::default();
        let __code = unsafe { (crate::sys::api().daqBlockReaderStatus_getReadSamples)(self.as_raw() as *mut _, &mut __read_samples) };
        check(__code, "daqBlockReaderStatus_getReadSamples")?;
        Ok(__read_samples)
    }

}

impl EventPacket {
    /// Creates a DataDescriptorChanged Event packet.
    ///
    /// # Parameters
    /// - `data_descriptor`: The data descriptor of the value signal.
    /// - `domain_data_descriptor`: The data descriptor of the domain signal that carries domain data of the value signal. The ID of the packet is "DATA_DESCRIPTOR_CHANGED". Its parameters dictionary contains the keys "DataDescriptor" and "DomainDataDescriptor", carrying their respective Signal descriptor objects as values.
    ///
    /// Calls the openDAQ C function `daqEventPacket_createDataDescriptorChangedEventPacket()`.
    pub fn data_descriptor_changed(data_descriptor: &DataDescriptor, domain_data_descriptor: &DataDescriptor) -> Result<EventPacket> {
        let mut __obj: *mut sys::daqEventPacket = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqEventPacket_createDataDescriptorChangedEventPacket)(&mut __obj, data_descriptor.as_raw() as *mut _, domain_data_descriptor.as_raw() as *mut _) };
        check(__code, "daqEventPacket_createDataDescriptorChangedEventPacket")?;
        Ok(unsafe { crate::marshal::require_object::<EventPacket>(__obj as *mut _, "daqEventPacket_createDataDescriptorChangedEventPacket") }?)
    }

    /// Creates and Event packet with a given id and parameter dictionary.
    ///
    /// # Parameters
    /// - `id`: The ID of the event.
    /// - `params`: The \<String, BaseObject\> dictionary containing the event parameters.
    ///
    /// Calls the openDAQ C function `daqEventPacket_createEventPacket()`.
    pub fn new(id: &str, params: impl Into<Value>) -> Result<EventPacket> {
        let __id = crate::marshal::make_string(id)?;
        let __params = crate::value::to_daq(&params.into())?;
        let mut __obj: *mut sys::daqEventPacket = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqEventPacket_createEventPacket)(&mut __obj, __id.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__params) as *mut _) };
        check(__code, "daqEventPacket_createEventPacket")?;
        Ok(unsafe { crate::marshal::require_object::<EventPacket>(__obj as *mut _, "daqEventPacket_createEventPacket") }?)
    }

    /// Creates a ImplicitDomainGapDetected Event packet.
    ///
    /// # Parameters
    /// - `diff`: The size of the gap in ticks or value The ID of the packet is "IMPLICIT_DOMAIN_GAP_DETECTED". Its parameters dictionary contains the key "Diff", which holds the size of the gap. The size can be negative, in which case it is an overlap of samples.
    ///
    /// Calls the openDAQ C function `daqEventPacket_createImplicitDomainGapDetectedEventPacket()`.
    pub fn implicit_domain_gap_detected(diff: impl Into<Value>) -> Result<EventPacket> {
        let __diff = crate::value::to_daq_number(&diff.into())?;
        let mut __obj: *mut sys::daqEventPacket = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqEventPacket_createImplicitDomainGapDetectedEventPacket)(&mut __obj, crate::value::opt_ref_ptr(&__diff) as *mut _) };
        check(__code, "daqEventPacket_createImplicitDomainGapDetectedEventPacket")?;
        Ok(unsafe { crate::marshal::require_object::<EventPacket>(__obj as *mut _, "daqEventPacket_createImplicitDomainGapDetectedEventPacket") }?)
    }

    /// Gets the ID of the event as a string. In example "DATA_DESCRIPTOR_CHANGED".
    ///
    /// # Returns
    /// - `id`: The ID of the event.
    ///
    /// Calls the openDAQ C function `daqEventPacket_getEventId()`.
    pub fn event_id(&self) -> Result<String> {
        let mut __id: *mut sys::daqString = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqEventPacket_getEventId)(self.as_raw() as *mut _, &mut __id) };
        check(__code, "daqEventPacket_getEventId")?;
        Ok(unsafe { crate::marshal::take_string(__id) })
    }

    /// Dictionary containing parameters as \<String, BaseObject\> pairs relevant to the event signalized by the Event packet.
    ///
    /// # Returns
    /// - `parameters`: The event parameters dictionary.
    ///
    /// Calls the openDAQ C function `daqEventPacket_getParameters()`.
    pub fn parameters(&self) -> Result<std::collections::HashMap<String, Value>> {
        let mut __parameters: *mut sys::daqDict = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqEventPacket_getParameters)(self.as_raw() as *mut _, &mut __parameters) };
        check(__code, "daqEventPacket_getParameters")?;
        Ok(unsafe { crate::marshal::take_dict::<String, Value>(__parameters as *mut _, "daqEventPacket_getParameters") }?)
    }

}

impl InputPortConfig {
    /// Calls the openDAQ C function `daqInputPortConfig_createInputPort()`.
    pub fn input_port(context: &Context, parent: Option<&Component>, local_id: &str, gap_checking: bool) -> Result<InputPortConfig> {
        let __local_id = crate::marshal::make_string(local_id)?;
        let mut __obj: *mut sys::daqInputPortConfig = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_createInputPort)(&mut __obj, context.as_raw() as *mut _, parent.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _), __local_id.as_ptr() as *mut _, u8::from(gap_checking)) };
        check(__code, "daqInputPortConfig_createInputPort")?;
        Ok(unsafe { crate::marshal::require_object::<InputPortConfig>(__obj as *mut _, "daqInputPortConfig_createInputPort") }?)
    }

    /// Get a custom data attached to the object.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_getCustomData()`.
    pub fn custom_data(&self) -> Result<Value> {
        let mut __custom_data: *mut sys::daqBaseObject = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_getCustomData)(self.as_raw() as *mut _, &mut __custom_data) };
        check(__code, "daqInputPortConfig_getCustomData")?;
        Ok(unsafe { crate::value::take_value(__custom_data, "daqInputPortConfig_getCustomData") }?)
    }

    /// Returns the state of gap checking requested by the input port.
    ///
    /// # Parameters
    /// - `gap_checking_enabled`: true if gap checking is requested by the input port.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_getGapCheckingEnabled()`.
    pub fn gap_checking_enabled(&self) -> Result<bool> {
        let mut __gap_checking_enabled: u8 = 0;
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_getGapCheckingEnabled)(self.as_raw() as *mut _, &mut __gap_checking_enabled) };
        check(__code, "daqInputPortConfig_getGapCheckingEnabled")?;
        Ok(__gap_checking_enabled != 0)
    }

    /// Gets the object receiving input-port related events and notifications.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_getListener()`.
    pub fn listener(&self) -> Result<Option<InputPortNotifications>> {
        let mut __port: *mut sys::daqInputPortNotifications = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_getListener)(self.as_raw() as *mut _, &mut __port) };
        check(__code, "daqInputPortConfig_getListener")?;
        Ok(unsafe { crate::marshal::take_object::<InputPortNotifications>(__port as *mut _) })
    }

    /// Gets the input-ports response to the packet enqueued notification.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_getNotificationMethod()`.
    pub fn notification_method(&self) -> Result<PacketReadyNotification> {
        let mut __method: u32 = 0;
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_getNotificationMethod)(self.as_raw() as *mut _, &mut __method) };
        check(__code, "daqInputPortConfig_getNotificationMethod")?;
        Ok(crate::marshal::enum_out(PacketReadyNotification::from_raw(__method), "daqInputPortConfig_getNotificationMethod")?)
    }

    /// Gets called when a packet was enqueued in a connection.
    ///
    /// # Parameters
    /// - `queue_was_empty`: True if queue was empty before packet was enqueued.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_notifyPacketEnqueued()`.
    pub fn notify_packet_enqueued(&self, queue_was_empty: bool) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_notifyPacketEnqueued)(self.as_raw() as *mut _, u8::from(queue_was_empty)) };
        check(__code, "daqInputPortConfig_notifyPacketEnqueued")?;
        Ok(())
    }

    /// Gets called when a packet was enqueued in a connection.
    /// The notification is called on the same thread that enqueued the packet.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_notifyPacketEnqueuedOnThisThread()`.
    pub fn notify_packet_enqueued_on_this_thread(&self) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_notifyPacketEnqueuedOnThisThread)(self.as_raw() as *mut _) };
        check(__code, "daqInputPortConfig_notifyPacketEnqueuedOnThisThread")?;
        Ok(())
    }

    /// Gets called when a packet was enqueued in a connection.
    /// The notification is scheduled.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_notifyPacketEnqueuedWithScheduler()`.
    pub fn notify_packet_enqueued_with_scheduler(&self) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_notifyPacketEnqueuedWithScheduler)(self.as_raw() as *mut _) };
        check(__code, "daqInputPortConfig_notifyPacketEnqueuedWithScheduler")?;
        Ok(())
    }

    /// Set a custom data attached to the object.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_setCustomData()`.
    pub fn set_custom_data(&self, custom_data: impl Into<Value>) -> Result<()> {
        let __custom_data = crate::value::to_daq(&custom_data.into())?;
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_setCustomData)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__custom_data) as *mut _) };
        check(__code, "daqInputPortConfig_setCustomData")?;
        Ok(())
    }

    /// Set the object receiving input-port related events and notifications.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_setListener()`.
    pub fn set_listener(&self, port: &InputPortNotifications) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_setListener)(self.as_raw() as *mut _, port.as_raw() as *mut _) };
        check(__code, "daqInputPortConfig_setListener")?;
        Ok(())
    }

    /// Sets the input-ports response to the packet enqueued notification.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_setNotificationMethod()`.
    pub fn set_notification_method(&self, method: PacketReadyNotification) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_setNotificationMethod)(self.as_raw() as *mut _, method as u32) };
        check(__code, "daqInputPortConfig_setNotificationMethod")?;
        Ok(())
    }

    /// Sets requires signal flag of the input port.
    ///
    /// # Parameters
    /// - `requires_signal`: True if the input port requires a signal to be connected; false otherwise. If an input port requires a signal, then the input port must have a signal connected otherwise the owner of the input port (function block) should report an error.
    ///
    /// Calls the openDAQ C function `daqInputPortConfig_setRequiresSignal()`.
    pub fn set_requires_signal(&self, requires_signal: bool) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortConfig_setRequiresSignal)(self.as_raw() as *mut _, u8::from(requires_signal)) };
        check(__code, "daqInputPortConfig_setRequiresSignal")?;
        Ok(())
    }

}

impl InputPortNotifications {
    /// Called when the Input port method `acceptsSignal` is called. Should return true if the signal is accepted; false otherwise.
    ///
    /// # Parameters
    /// - `port`: The input port on which the method was called.
    /// - `signal`: The signal which is being checked for acceptance.
    ///
    /// # Returns
    /// - `accept`: True if the signal is accepted; false otherwise.
    ///
    /// Calls the openDAQ C function `daqInputPortNotifications_acceptsSignal()`.
    pub fn accepts_signal(&self, port: &InputPort, signal: &Signal) -> Result<bool> {
        let mut __accept: u8 = 0;
        let __code = unsafe { (crate::sys::api().daqInputPortNotifications_acceptsSignal)(self.as_raw() as *mut _, port.as_raw() as *mut _, signal.as_raw() as *mut _, &mut __accept) };
        check(__code, "daqInputPortNotifications_acceptsSignal")?;
        Ok(__accept != 0)
    }

    /// Called when a signal is connected to the input port.
    ///
    /// # Parameters
    /// - `port`: The port to which the signal was connected.
    ///
    /// Calls the openDAQ C function `daqInputPortNotifications_connected()`.
    pub fn connected(&self, port: &InputPort) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortNotifications_connected)(self.as_raw() as *mut _, port.as_raw() as *mut _) };
        check(__code, "daqInputPortNotifications_connected")?;
        Ok(())
    }

    /// Called when a signal is disconnected from the input port.
    ///
    /// # Parameters
    /// - `port`: The port from which a signal was disconnected.
    ///
    /// Calls the openDAQ C function `daqInputPortNotifications_disconnected()`.
    pub fn disconnected(&self, port: &InputPort) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortNotifications_disconnected)(self.as_raw() as *mut _, port.as_raw() as *mut _) };
        check(__code, "daqInputPortNotifications_disconnected")?;
        Ok(())
    }

    /// Notifies the listener of the newly received packet on the specified input-port.
    ///
    /// # Parameters
    /// - `port`: The port on which the new packet was received.
    ///
    /// Calls the openDAQ C function `daqInputPortNotifications_packetReceived()`.
    pub fn packet_received(&self, port: &InputPort) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPortNotifications_packetReceived)(self.as_raw() as *mut _, port.as_raw() as *mut _) };
        check(__code, "daqInputPortNotifications_packetReceived")?;
        Ok(())
    }

}

impl InputPort {
    /// Returns true if the signal can be connected to the input port; false otherwise.
    ///
    /// # Parameters
    /// - `signal`: The signal being evaluated for compatibility.
    ///
    /// # Returns
    /// - `accepts`: True if the signal can be connected; false otherwise.
    ///
    /// # Errors
    /// - `OPENDAQ_ERR_NOTASSIGNED`: if the accepted signal criteria is not defined by the input port.
    ///
    /// Calls the openDAQ C function `daqInputPort_acceptsSignal()`.
    pub fn accepts_signal(&self, signal: &Signal) -> Result<bool> {
        let mut __accepts: u8 = 0;
        let __code = unsafe { (crate::sys::api().daqInputPort_acceptsSignal)(self.as_raw() as *mut _, signal.as_raw() as *mut _, &mut __accepts) };
        check(__code, "daqInputPort_acceptsSignal")?;
        Ok(__accepts != 0)
    }

    /// Checks whether the given signals can be connected to the input port.
    ///
    /// # Parameters
    /// - `signals`: The signals to check.
    ///
    /// # Returns
    /// - `accepts`: Output list of boolean values matching `signals` by index. A value of `true` indicates that the corresponding signal can be connected; `false` otherwise.
    ///
    /// Calls the openDAQ C function `daqInputPort_acceptsSignals()`.
    pub fn accepts_signals(&self, signals: &[Signal]) -> Result<Vec<bool>> {
        let __signals = crate::marshal::list_from_interfaces(signals)?;
        let mut __accepts: *mut sys::daqList = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqInputPort_acceptsSignals)(self.as_raw() as *mut _, __signals.as_ptr() as *mut _, &mut __accepts) };
        check(__code, "daqInputPort_acceptsSignals")?;
        Ok(unsafe { crate::marshal::take_list::<bool>(__accepts as *mut _, "daqInputPort_acceptsSignals") }?)
    }

    /// Connects the signal to the input port, forming a Connection.
    ///
    /// # Parameters
    /// - `signal`: The signal to be connected to the input port.
    ///
    /// # Errors
    /// - `OPENDAQ_ERR_SIGNAL_NOT_ACCEPTED`: if the signal is not accepted.
    /// - `OPENDAQ_ERR_NOTASSIGNED`: if the accepted signal criteria is not defined by the input port. The signal is notified of the connection formed between it and the input port.
    ///
    /// Calls the openDAQ C function `daqInputPort_connect()`.
    pub fn connect(&self, signal: &Signal) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPort_connect)(self.as_raw() as *mut _, signal.as_raw() as *mut _) };
        check(__code, "daqInputPort_connect")?;
        Ok(())
    }

    /// Disconnects the signal from the input port.
    ///
    /// Calls the openDAQ C function `daqInputPort_disconnect()`.
    pub fn disconnect(&self) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPort_disconnect)(self.as_raw() as *mut _) };
        check(__code, "daqInputPort_disconnect")?;
        Ok(())
    }

    /// Gets the Connection object formed between the Signal and Input port.
    ///
    /// # Returns
    /// - `connection`: The Connection object.
    ///
    /// Calls the openDAQ C function `daqInputPort_getConnection()`.
    pub fn connection(&self) -> Result<Option<Connection>> {
        let mut __connection: *mut sys::daqConnection = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqInputPort_getConnection)(self.as_raw() as *mut _, &mut __connection) };
        check(__code, "daqInputPort_getConnection")?;
        Ok(unsafe { crate::marshal::take_object::<Connection>(__connection as *mut _) })
    }

    /// Returns true if the port is public; false otherwise.
    ///
    /// # Returns
    /// - `is_public`: True if the port is public; false otherwise.
    ///
    /// Calls the openDAQ C function `daqInputPort_getPublic()`.
    pub fn public(&self) -> Result<bool> {
        let mut __is_public: u8 = 0;
        let __code = unsafe { (crate::sys::api().daqInputPort_getPublic)(self.as_raw() as *mut _, &mut __is_public) };
        check(__code, "daqInputPort_getPublic")?;
        Ok(__is_public != 0)
    }

    /// Returns true if the input port requires a signal to be connected; false otherwise.
    ///
    /// # Returns
    /// - `requires_signal`: True if the input port requires a signal to be connected; false otherwise.
    ///
    /// Calls the openDAQ C function `daqInputPort_getRequiresSignal()`.
    pub fn requires_signal(&self) -> Result<bool> {
        let mut __requires_signal: u8 = 0;
        let __code = unsafe { (crate::sys::api().daqInputPort_getRequiresSignal)(self.as_raw() as *mut _, &mut __requires_signal) };
        check(__code, "daqInputPort_getRequiresSignal")?;
        Ok(__requires_signal != 0)
    }

    /// Gets the signal connected to the input port.
    ///
    /// # Returns
    /// - `signal`: The signal connected to the input port.
    ///
    /// Calls the openDAQ C function `daqInputPort_getSignal()`.
    pub fn signal(&self) -> Result<Option<Signal>> {
        let mut __signal: *mut sys::daqSignal = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqInputPort_getSignal)(self.as_raw() as *mut _, &mut __signal) };
        check(__code, "daqInputPort_getSignal")?;
        Ok(unsafe { crate::marshal::take_object::<Signal>(__signal as *mut _) })
    }

    /// Sets the port to be either public or private.
    ///
    /// # Parameters
    /// - `is_public`: If false, the port is set to private; if true, the port is set to be public.
    ///
    /// Calls the openDAQ C function `daqInputPort_setPublic()`.
    pub fn set_public(&self, is_public: bool) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqInputPort_setPublic)(self.as_raw() as *mut _, u8::from(is_public)) };
        check(__code, "daqInputPort_setPublic")?;
        Ok(())
    }

}

impl MultiReaderStatus {
    /// Calls the openDAQ C function `daqMultiReaderStatus_createMultiReaderStatus()`.
    pub fn new(main_descriptor: &EventPacket, event_packets: impl Into<Value>, valid: bool, offset: impl Into<Value>) -> Result<MultiReaderStatus> {
        let __event_packets = crate::value::to_daq(&event_packets.into())?;
        let __offset = crate::value::to_daq_number(&offset.into())?;
        let mut __obj: *mut sys::daqMultiReaderStatus = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqMultiReaderStatus_createMultiReaderStatus)(&mut __obj, main_descriptor.as_raw() as *mut _, crate::value::opt_ref_ptr(&__event_packets) as *mut _, u8::from(valid), crate::value::opt_ref_ptr(&__offset) as *mut _) };
        check(__code, "daqMultiReaderStatus_createMultiReaderStatus")?;
        Ok(unsafe { crate::marshal::require_object::<MultiReaderStatus>(__obj as *mut _, "daqMultiReaderStatus_createMultiReaderStatus") }?)
    }

    /// Retrieves the dictionary of event packets from the reading process, ordered by signals.
    ///
    /// # Returns
    /// - `event_packets`: The dictionary with global id of input port and the corresponding event packet.
    ///
    /// Calls the openDAQ C function `daqMultiReaderStatus_getEventPackets()`.
    pub fn event_packets(&self) -> Result<std::collections::HashMap<String, EventPacket>> {
        let mut __event_packets: *mut sys::daqDict = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqMultiReaderStatus_getEventPackets)(self.as_raw() as *mut _, &mut __event_packets) };
        check(__code, "daqMultiReaderStatus_getEventPackets")?;
        Ok(unsafe { crate::marshal::take_dict::<String, EventPacket>(__event_packets as *mut _, "daqMultiReaderStatus_getEventPackets") }?)
    }

    /// Retrieves the descriptor of main signal. The main signal is the first signal in the list of signals.
    ///
    /// # Returns
    /// - `descriptor`: The descriptor of the main signal.
    ///
    /// Calls the openDAQ C function `daqMultiReaderStatus_getMainDescriptor()`.
    pub fn main_descriptor(&self) -> Result<Option<EventPacket>> {
        let mut __descriptor: *mut sys::daqEventPacket = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqMultiReaderStatus_getMainDescriptor)(self.as_raw() as *mut _, &mut __descriptor) };
        check(__code, "daqMultiReaderStatus_getMainDescriptor")?;
        Ok(unsafe { crate::marshal::take_object::<EventPacket>(__descriptor as *mut _) })
    }

}

impl Packet {
    /// Gets the reference count of the packet.
    ///
    /// # Returns
    /// - `ref_count`: The reference count of the packet.
    ///
    /// Calls the openDAQ C function `daqPacket_getRefCount()`.
    pub fn ref_count(&self) -> Result<usize> {
        let mut __ref_count: usize = Default::default();
        let __code = unsafe { (crate::sys::api().daqPacket_getRefCount)(self.as_raw() as *mut _, &mut __ref_count) };
        check(__code, "daqPacket_getRefCount")?;
        Ok(__ref_count)
    }

    /// Gets the packet's type.
    ///
    /// # Returns
    /// - `type`: The packet type.
    ///
    /// Calls the openDAQ C function `daqPacket_getType()`.
    pub fn type_(&self) -> Result<PacketType> {
        let mut __type_: u32 = 0;
        let __code = unsafe { (crate::sys::api().daqPacket_getType)(self.as_raw() as *mut _, &mut __type_) };
        check(__code, "daqPacket_getType")?;
        Ok(crate::marshal::enum_out(PacketType::from_raw(__type_), "daqPacket_getType")?)
    }

    /// Subscribes for notification when the packet is destroyed.
    ///
    /// # Parameters
    /// - `packet_destruct_callback`: The callback that is called when the packet is destroyed.
    ///
    /// Calls the openDAQ C function `daqPacket_subscribeForDestructNotification()`.
    pub fn subscribe_for_destruct_notification(&self, packet_destruct_callback: &PacketDestructCallback) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqPacket_subscribeForDestructNotification)(self.as_raw() as *mut _, packet_destruct_callback.as_raw() as *mut _) };
        check(__code, "daqPacket_subscribeForDestructNotification")?;
        Ok(())
    }

}

impl ReaderConfig {
    /// Gets the transform function that will be called with the read domain-data and currently valid Signal-Descriptor giving the user the chance add a custom post-processing step.
    ///
    /// # Returns
    /// - `transform`: The function performing the post-processing or `nullptr` if not assigned.
    ///
    /// Calls the openDAQ C function `daqReaderConfig_getDomainTransformFunction()`.
    pub fn domain_transform_function(&self) -> Result<Option<FunctionObject>> {
        let mut __transform: *mut sys::daqFunction = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqReaderConfig_getDomainTransformFunction)(self.as_raw() as *mut _, &mut __transform) };
        check(__code, "daqReaderConfig_getDomainTransformFunction")?;
        Ok(unsafe { crate::marshal::take_object::<FunctionObject>(__transform as *mut _) })
    }

    /// Gets the internally created input-ports if used.
    ///
    /// # Returns
    /// - `ports`: The internal Input-Ports if used by the reader otherwise `nullptr.`
    ///
    /// Calls the openDAQ C function `daqReaderConfig_getInputPorts()`.
    pub fn input_ports(&self) -> Result<Vec<InputPortConfig>> {
        let mut __ports: *mut sys::daqList = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqReaderConfig_getInputPorts)(self.as_raw() as *mut _, &mut __ports) };
        check(__code, "daqReaderConfig_getInputPorts")?;
        Ok(unsafe { crate::marshal::take_list::<InputPortConfig>(__ports as *mut _, "daqReaderConfig_getInputPorts") }?)
    }

    /// Calls the openDAQ C function `daqReaderConfig_getIsValid()`.
    pub fn is_valid(&self) -> Result<bool> {
        let mut __is_valid: u8 = 0;
        let __code = unsafe { (crate::sys::api().daqReaderConfig_getIsValid)(self.as_raw() as *mut _, &mut __is_valid) };
        check(__code, "daqReaderConfig_getIsValid")?;
        Ok(__is_valid != 0)
    }

    /// Gets the type of time-out handling used by the reader.
    ///
    /// # Returns
    /// - `timeout_type`: How the reader handles time-outs.
    ///
    /// Calls the openDAQ C function `daqReaderConfig_getReadTimeoutType()`.
    pub fn read_timeout_type(&self) -> Result<ReadTimeoutType> {
        let mut __timeout_type: u32 = 0;
        let __code = unsafe { (crate::sys::api().daqReaderConfig_getReadTimeoutType)(self.as_raw() as *mut _, &mut __timeout_type) };
        check(__code, "daqReaderConfig_getReadTimeoutType")?;
        Ok(crate::marshal::enum_out(ReadTimeoutType::from_raw(__timeout_type), "daqReaderConfig_getReadTimeoutType")?)
    }

    /// Gets the transform function that will be called with the read value-data and currently valid Signal-Descriptor giving the user the chance add a custom post-processing step.
    ///
    /// # Returns
    /// - `transform`: The function performing the post-processing or `nullptr` if not assigned.
    ///
    /// Calls the openDAQ C function `daqReaderConfig_getValueTransformFunction()`.
    pub fn value_transform_function(&self) -> Result<Option<FunctionObject>> {
        let mut __transform: *mut sys::daqFunction = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqReaderConfig_getValueTransformFunction)(self.as_raw() as *mut _, &mut __transform) };
        check(__code, "daqReaderConfig_getValueTransformFunction")?;
        Ok(unsafe { crate::marshal::take_object::<FunctionObject>(__transform as *mut _) })
    }

    /// Marks the current reader as invalid preventing any additional operations to be performed on the reader except reusing its info and configuration in a new reader.
    ///
    /// Calls the openDAQ C function `daqReaderConfig_markAsInvalid()`.
    pub fn mark_as_invalid(&self) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqReaderConfig_markAsInvalid)(self.as_raw() as *mut _) };
        check(__code, "daqReaderConfig_markAsInvalid")?;
        Ok(())
    }

}

impl ReaderStatus {
    /// Calls the openDAQ C function `daqReaderStatus_createReaderStatus()`.
    pub fn new(event_packet: &EventPacket, valid: bool, offset: impl Into<Value>) -> Result<ReaderStatus> {
        let __offset = crate::value::to_daq_number(&offset.into())?;
        let mut __obj: *mut sys::daqReaderStatus = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqReaderStatus_createReaderStatus)(&mut __obj, event_packet.as_raw() as *mut _, u8::from(valid), crate::value::opt_ref_ptr(&__offset) as *mut _) };
        check(__code, "daqReaderStatus_createReaderStatus")?;
        Ok(unsafe { crate::marshal::require_object::<ReaderStatus>(__obj as *mut _, "daqReaderStatus_createReaderStatus") }?)
    }

    /// Retrieves the event packet from the reading process.
    ///
    /// # Returns
    /// - `packet`: The event packet from the reading process.
    ///
    /// Calls the openDAQ C function `daqReaderStatus_getEventPacket()`.
    pub fn event_packet(&self) -> Result<Option<EventPacket>> {
        let mut __packet: *mut sys::daqEventPacket = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqReaderStatus_getEventPacket)(self.as_raw() as *mut _, &mut __packet) };
        check(__code, "daqReaderStatus_getEventPacket")?;
        Ok(unsafe { crate::marshal::take_object::<EventPacket>(__packet as *mut _) })
    }

    /// Retrieves the offset of the the read values
    ///
    /// # Returns
    /// - `offset`: The offset of the read values
    ///
    /// Calls the openDAQ C function `daqReaderStatus_getOffset()`.
    pub fn offset(&self) -> Result<Option<f64>> {
        let mut __offset: *mut sys::daqNumber = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqReaderStatus_getOffset)(self.as_raw() as *mut _, &mut __offset) };
        check(__code, "daqReaderStatus_getOffset")?;
        Ok(unsafe { crate::value::take_number(__offset, "daqReaderStatus_getOffset") }?)
    }

    /// Retrieves the current reading status, indicating whether the reading process is in an "Ok" state, has encountered an Event, has failed, or is in an Unknown state.
    ///
    /// # Returns
    /// - `status`: a ReadStatus enum variable where the current reading status will be stored.
    ///
    /// Calls the openDAQ C function `daqReaderStatus_getReadStatus()`.
    pub fn read_status(&self) -> Result<ReadStatus> {
        let mut __status: u32 = 0;
        let __code = unsafe { (crate::sys::api().daqReaderStatus_getReadStatus)(self.as_raw() as *mut _, &mut __status) };
        check(__code, "daqReaderStatus_getReadStatus")?;
        Ok(crate::marshal::enum_out(ReadStatus::from_raw(__status), "daqReaderStatus_getReadStatus")?)
    }

    /// Checks the validity of the reader.
    ///
    /// # Returns
    /// - `valid`: Boolean value indicating the validity of the reader
    ///
    /// Calls the openDAQ C function `daqReaderStatus_getValid()`.
    pub fn valid(&self) -> Result<bool> {
        let mut __valid: u8 = 0;
        let __code = unsafe { (crate::sys::api().daqReaderStatus_getValid)(self.as_raw() as *mut _, &mut __valid) };
        check(__code, "daqReaderStatus_getValid")?;
        Ok(__valid != 0)
    }

}

impl TailReaderStatus {
    /// Calls the openDAQ C function `daqTailReaderStatus_createTailReaderStatus()`.
    pub fn new(event_packet: &EventPacket, valid: bool, offset: impl Into<Value>, sufficient_history: bool) -> Result<TailReaderStatus> {
        let __offset = crate::value::to_daq_number(&offset.into())?;
        let mut __obj: *mut sys::daqTailReaderStatus = std::ptr::null_mut();
        let __code = unsafe { (crate::sys::api().daqTailReaderStatus_createTailReaderStatus)(&mut __obj, event_packet.as_raw() as *mut _, u8::from(valid), crate::value::opt_ref_ptr(&__offset) as *mut _, u8::from(sufficient_history)) };
        check(__code, "daqTailReaderStatus_createTailReaderStatus")?;
        Ok(unsafe { crate::marshal::require_object::<TailReaderStatus>(__obj as *mut _, "daqTailReaderStatus_createTailReaderStatus") }?)
    }

    /// Calls the openDAQ C function `daqTailReaderStatus_getSufficientHistory()`.
    pub fn sufficient_history(&self) -> Result<bool> {
        let mut __status: u8 = 0;
        let __code = unsafe { (crate::sys::api().daqTailReaderStatus_getSufficientHistory)(self.as_raw() as *mut _, &mut __status) };
        check(__code, "daqTailReaderStatus_getSufficientHistory")?;
        Ok(__status != 0)
    }

}