Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
d95cf5d4
Commit
d95cf5d4
authored
Oct 22, 2011
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(uniset-codegen): Добавил поддержку списка переменных (<variables>)
parent
a538d602
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
1 deletion
+59
-1
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+37
-0
testgen.src.xml
Utilities/codegen/tests/testgen.src.xml
+18
-0
libuniset.spec
conf/libuniset.spec
+4
-1
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
d95cf5d4
...
...
@@ -581,6 +581,43 @@ askPause(conf->getPIntProp(cnode,"askPause",2000))
int msec = conf->getArgPInt("--startup-timeout", 10000);
ptStartUpTimeout.setTiming(msec);
// =====================
<
variables
>
=====================
<xsl:for-each
select=
"//variables/item"
>
std::string tmp_
<xsl:value-of
select=
"@name"
/>
( conf->getArgParam("--
<xsl:value-of
select=
"../@arg_prefix"
/><xsl:value-of
select=
"@name"
/>
",it.getProp("
<xsl:value-of
select=
"@name"
/>
")) );
<xsl:if
test=
"normalize-space(@default)!=''"
>
if( tmp_
<xsl:value-of
select=
"@name"
/>
.empty() )
tmp_
<xsl:value-of
select=
"@name"
/>
= "
<xsl:value-of
select=
"@default"
/>
";
</xsl:if>
<xsl:if
test=
"normalize-space(@type)='int'"
>
<xsl:value-of
select=
"@name"
/>
= uni_atoi(tmp_
<xsl:value-of
select=
"@name"
/>
);
</xsl:if>
<xsl:if
test=
"normalize-space(@type)='float'"
>
<xsl:value-of
select=
"@name"
/>
= atof(tmp_
<xsl:value-of
select=
"@name"
/>
.c_str());
</xsl:if>
<xsl:if
test=
"normalize-space(@type)='bool'"
>
<xsl:value-of
select=
"@name"
/>
= uni_atoi(tmp_
<xsl:value-of
select=
"@name"
/>
);
</xsl:if>
<xsl:if
test=
"normalize-space(@type)='str'"
>
<xsl:value-of
select=
"@name"
/>
= tmp_
<xsl:value-of
select=
"@name"
/>
;
</xsl:if>
<xsl:if
test=
"normalize-space(@min)!=''"
>
if(
<xsl:value-of
select=
"@name"
/>
<
<xsl:value-of
select=
"@min"
/>
)
{
unideb[Debug::WARN]
<<
myname
<<
": RANGE WARNING:
<xsl:value-of
select=
"@name"
/>
="
<<
<xsl:value-of
select=
"@name"
/>
<<
"
<
<xsl:value-of
select=
"@min"
/>
"
<<
endl;
<xsl:if
test=
"normalize-space(@no_range_exception)=''"
>
throw UniSetTypes::SystemError(myname+"(init):
<xsl:value-of
select=
"@name"
/>
<
<xsl:value-of
select=
"@min"
/>
");
</xsl:if>
}
</xsl:if>
<xsl:if
test=
"normalize-space(@max)!=''"
>
if(
<xsl:value-of
select=
"@name"
/>
>
<xsl:value-of
select=
"@max"
/>
)
{
unideb[Debug::WARN]
<<
myname
<<
": RANGE WARNING:
<xsl:value-of
select=
"@name"
/>
="
<<
<xsl:value-of
select=
"@name"
/>
<<
"
>
<xsl:value-of
select=
"@max"
/>
"
<<
endl;
<xsl:if
test=
"normalize-space(@no_range_exception)=''"
>
throw UniSetTypes::SystemError(myname+"(init):
<xsl:value-of
select=
"@name"
/>
>
<xsl:value-of
select=
"@max"
/>
");
</xsl:if>
}
</xsl:if>
// ----------
</xsl:for-each>
// ===================== end of
<
variables
>
=====================
}
// -----------------------------------------------------------------------------
...
...
Utilities/codegen/tests/testgen.src.xml
View file @
d95cf5d4
...
...
@@ -16,6 +16,24 @@
<set
name=
"msg-count"
val=
"20"
/>
<set
name=
"sleep-msec"
val=
"150"
/>
</settings>
<variables
arg_prefix=
"test-"
>
<!-- type = [int,str,bool,float]
int: max,min,no_range_exception=[0,1]
str:
float: max,min,no_range_exception=[0,1]
bool:
min - минимальное значение (может быть не задано)
max - максимальное значение (может быть не задано)
default - значение по умолчанию (может быть не задано)
no_range_exception=1 - при выходе за границы min или max только писать unideb[WARN].
-->
<item
name=
"test_int"
type=
"int"
min=
"0"
comment=
"test int variable"
/>
<item
name=
"test_int2"
type=
"int"
max=
"100"
default=
"110"
no_range_exception=
"1"
/>
<item
name=
"test_float"
type=
"float"
max=
"100.0"
default=
"50.0"
/>
<item
name=
"test_bool"
type=
"bool"
/>
<item
name=
"test_str"
type=
"str"
default1=
"ddd"
/>
</variables>
<smap>
<!-- name - название переменной в конф. файле -->
<item
name=
"input1_s"
vartype=
"in"
iotype=
"DI"
comment=
"comment for input1"
/>
...
...
conf/libuniset.spec
View file @
d95cf5d4
...
...
@@ -3,7 +3,7 @@
Name: libuniset
Version: 1.0
Release: alt4
6
Release: alt4
8
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
...
...
@@ -212,6 +212,9 @@ rm -f %buildroot%_libdir/*.la
%changelog
* Sat Oct 22 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt48
- added support for list of variables (<variables>) in uniset-codegen
* Tue Oct 11 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt47
- new build
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment