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 import xdc.rov.ViewInfo;
37
38 import xdc.runtime.Error;
39 import ti.sdo.io.IConverter;
40
41 /*!
42 * Transformer module
43 *
44 * This module allows the user to create instances which modify a data stream
45 * by applying a function to each point produced or consumed by an underlying
46 * driver. The number of transformer instances in the system is limited only
47 * by the availability of memory;
48 *
49 * This module implements {@link ti.sdo.io.IConverter} interface and as such is
50 * only usable with {@link ti.sdo.io.Stream}. IConverter instances are added to
51 * a table within Stream and they can be linked together to form an IO
52 * stack/chain.
53 *
54 * For example, is "/scale" is a Transformer instance in the stream table
55 * and "/adc" is a driver in {@link ti.sdo.io.DriverTable} then the name
56 * "/scale/adc" can be used to create a Stream instance.
57 *
58 * For every Transformer instance the user can supply a tranfer function.
59 * Transformer provides three of these functions - {@link #multiply},
60 * {@link #fix2flt} and {@link #flt2fix}.
61 */
62
63 module Transformer inherits IConverter
64 {
65 /*! typedefs for transformer function
66 *
67 * Functions of this type get passed the buffer, buffer size and a
68 * function specific argument. The function should NOT act on the buffer
69 * if buffer is NULL or buffer size is zero.
70 */
71 typedef Void (*TransFunc)(Ptr, SizeT, UArg);
72
73 metaonly struct BasicView {
74 String label;
75 Ptr lowerConverter;
76 String mode;
77 String callbackFxn[];
78 UArg callbackArg;
79 String transformFxn[];
80 UArg transformArg;
81 }
82
83 @Facet
84 metaonly config ViewInfo.Instance rovViewInfo =
85 ViewInfo.create({
86 viewMap: [
87 ['Basic', {type: ViewInfo.INSTANCE, viewInitFxn: 'viewInitBasic', structName: 'BasicView'}],
88 ]
89 });
90
91 /*!
92 * ======== multiply ========
93 * multiply function mutiples each data point with a scale value
94 *
95 * This function casts the scaleFactor to a UInt before using it.
96 * If arg is NULL a scaleFactor of 1 is used.
97 */
98 Void multiply(Ptr addr, SizeT size, UArg scaleFactor);
99
100 /*!
101 * ======== fix2flt ========
102 * fix2flt converts each data point from fixed point to floating point
103 *
104 * This function ignores the scaleFactor.
105 */
106 Void fix2flt(Ptr addr, SizeT size, UArg scaleFactor);
107
108 /*!
109 * ======== flt2fix ========
110 * flt2fix converts each data point from floating point to fixed point
111 *
112 * This function ignores the scaleFactor.
113 */
114 Void flt2fix(Ptr addr, SizeT size, UArg scalePtr);
115
116 instance:
117 /*!
118 * Function can be {@link #multiply}, {@link #fix2flt}
119 * or {@link #flt2fix} or a user specific function.
120 */
121 config TransFunc fxn = null;
122
123 /*!
124 * Arg to be used with transform functions.
125 */
126 config UArg arg = null;
127
128 internal:
129
130 /*!
131 * ======== callback ========
132 * @_nodoc
133 * callback function for lower IConverter instance.
134 *
135 * @param(cbArg) callback argument
136 */
137 Void callback(UArg cbArg);
138
139
140 struct Instance_State {
141 IConverter.Handle convHandle;
142 Bool drvAdapHdl;
143 UInt mode;
144 IConverter.DoneFxn cbFxn;
145 UArg cbArg;
146 TransFunc fxn;
147 UArg arg;
148 };
149 }