-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathput_single.xsl
More file actions
158 lines (145 loc) · 7.15 KB
/
put_single.xsl
File metadata and controls
158 lines (145 loc) · 7.15 KB
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
<?xml version="1.0" encoding="UTF-8"?>
<?modxslt-stylesheet type="text/xsl" media="fuffa, screen and $GET[stylesheet]" href="./%24GET%5Bstylesheet%5D" alternate="no" title="Translation using provided stylesheet" charset="ISO-8859-1" ?>
<?modxslt-stylesheet type="text/xsl" media="screen" alternate="no" title="Show raw source of the XML file" charset="ISO-8859-1" ?>
<!-- Generating MEX access layer code from Data Dictionary IDSDef.xml -->
<!-- -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:my="dummy"
version="2.0">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
<!--=================================================-->
<!-- put field of a time-dependent IDS -->
<!--=================================================-->
<xsl:template match="field" mode="PUT_SINGLE">
<xsl:param name="dynamic_only"/>
<xsl:param name="ids_type"/>
<xsl:variable name="methodName">
<xsl:choose>
<xsl:when test="$dynamic_only !='yes'" >
<xsl:value-of select="'put'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'put_slice'" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$dynamic_only !='yes' or descendant-or-self::field[@type='dynamic'] or ancestor::field[@type='dynamic' and @data_type='struct_array']">
<xsl:call-template name="COMMENT_FIELD"/>
<xsl:choose>
<!--========== Array of structure ===========-->
<!-- Type 1 arrays of structure, with potentially multiple time bases -->
<!-- Type 2 arrays of structure -->
<!-- Type 3 arrays of structure, with a unique time base -->
<xsl:when test = "@data_type = 'struct_array'">
<xsl:if test="$dynamic_only !='yes' and @type='dynamic'"> <!-- This could be put in the same statement as aosArraySize>0 -->
if (homogeneousTime != IDS_TIME_MODE_INDEPENDENT) {
</xsl:if>
<xsl:call-template name="generateNodePath">
<xsl:with-param name="ignore_nbc_change">1</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="generateTimebasePath">
<xsl:with-param name="ignore_nbc_change">1</xsl:with-param>
<xsl:with-param name="ids_type"><xsl:value-of select="$ids_type"/></xsl:with-param>
</xsl:call-template>
aosCtx = aosArraySize = 0; /* Initialize to avoid reusing old values in case of errors */
status = begin_dataTree_array_write("<xsl:value-of select="@name"/>", &aosArraySize);
hliAosArraySize = aosArraySize;
if (status.code >= 0) {
status = al_begin_arraystruct_action(ctx, field.fieldPath, field.timebasePath, &aosArraySize, &aosCtx);
if(aosCtx>0 && aosArraySize>0 && hliAosArraySize == 0)
status = begin_dataTree_array_write("<xsl:value-of select="@name"/>", &aosArraySize);
}
if (status.code >= 0) {
for (int i=0; i<aosArraySize; i++) {
if (status.code >= 0) status = iterate_dataTree_array(i);
if (status.code >= 0) status = <xsl:value-of select="concat($methodName,'_',@name,'_',generate-id(.))"/>(aosCtx, homogeneousTime, idsFullName);
if (status.code >= 0) status = al_iterate_over_arraystruct(aosCtx, 1);
}
/* Finished processing array of structure <xsl:value-of select="@name"/> */
if (aosCtx > 0) {
status_end = al_end_action(aosCtx);
if (status.code >= 0) status = status_end; /* Result of al_end_action is only relevant if there was no error before */
}
}
if (status.code >= 0) end_dataTree_array_action();
/* Error handling */
if (status.code < 0) {
addIdsPathInfoToErrMsg("\n ... in aos <xsl:value-of select="@path"/>",0);
return status;
}
<xsl:if test="$dynamic_only !='yes' and @type='dynamic'"> <!-- homogeneous_time != IDS_TIME_MODE_INDEPENDENT -->
}
</xsl:if>
</xsl:when>
<!--========== Regular structure ===========-->
<xsl:when test="@data_type='structure'">
status = begin_dataTree_write("<xsl:value-of select="@name"/>", &isEmpty);
if (!isEmpty && status.code >= 0) status = <xsl:value-of select="concat($methodName,'_',@name,'_',generate-id(.))"/>(ctx, homogeneousTime, idsFullName);
/* Finished processing structure <xsl:value-of select="@name"/> */
if (status.code >= 0) status = end_dataTree_action();
/* Error handling */
if (status.code < 0) {
addIdsPathInfoToErrMsg("\n ... in structure <xsl:value-of select="@path"/>",0);
return status;
}
</xsl:when>
<!--========== Simple types ===========-->
<xsl:when test="my:get_datatype(@data_type)='CHAR_DATA' or
my:get_datatype(@data_type)='INTEGER_DATA' or
my:get_datatype(@data_type)='DOUBLE_DATA' or
my:get_datatype(@data_type)='COMPLEX_DATA'">
<xsl:if test="$dynamic_only !='yes' and @type='dynamic' and not(ancestor::field[@type='dynamic' and @data_type='struct_array'])"> <!-- This could be put in the same statement as is_field_valid -->
if (homogeneousTime != IDS_TIME_MODE_INDEPENDENT) {
</xsl:if>
<xsl:choose>
<xsl:when test="@path='ids_properties/version_put/data_dictionary'">
data = mxCreateString("<xsl:value-of select="$DD_GIT_DESCRIBE"/>");
status.code = 0;
</xsl:when>
<xsl:when test="@path='ids_properties/version_put/access_layer'">
data = mxCreateString(getALVersion());
status.code = 0;
</xsl:when>
<xsl:when test="@path='ids_properties/version_put/access_layer_language'">
data = mxCreateString("<xsl:value-of select="concat('matlab (mex) - ', $AL_GIT_DESCRIBE)"/>");
status.code = 0;
</xsl:when>
<xsl:otherwise>
status = get_data_from_dataTree("<xsl:value-of select="@name"/>", (mxArray **) &data);
</xsl:otherwise>
</xsl:choose>
if (status.code >= 0) {
<xsl:call-template name="generateNodePath">
<xsl:with-param name="ignore_nbc_change">1</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="generateTimebasePath">
<xsl:with-param name="ignore_nbc_change">1</xsl:with-param>
<xsl:with-param name="ids_type"><xsl:value-of select="$ids_type"/></xsl:with-param>
</xsl:call-template>
field.datatype = <xsl:value-of select="my:get_datatype(@data_type)"/>;
field.dim = <xsl:value-of select="my:get_dim(@data_type)"/>;
status = my_al_write_data(&action, &field, data, idsFullName, "<xsl:value-of select="@lifecycle_status"/>");
}
<xsl:if test="starts-with(@path,'ids_properties/version_put/')">
mxDestroyArray((mxArray *) data);
</xsl:if>
<xsl:if test="$dynamic_only !='yes' and @type='dynamic' and not(ancestor::field[@type='dynamic' and @data_type='struct_array'])"> <!-- homogeneous_time != IDS_TIME_MODE_INDEPENDENT -->
}
</xsl:if>
/* Error handling */
if (status.code < 0) {
addIdsPathInfoToErrMsg("\n ... in field <xsl:value-of select="@path"/>",0);
return status;
}
</xsl:when>
<!--========== Unknown type ===========-->
<xsl:otherwise>
<xsl:message terminate="yes">ERROR: Unidentified type: <xsl:value-of select="@data_type"/> !</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>