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
256a0a03
Commit
256a0a03
authored
Apr 19, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(IO): добавил поддержку precision < 0
parent
15492364
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
8 deletions
+25
-8
libuniset2.spec
conf/libuniset2.spec
+1
-1
IOBase.cc
extensions/lib/IOBase.cc
+5
-5
test_iobase_with_sm.cc
extensions/tests/test_iobase_with_sm.cc
+18
-2
tests_with_sm.xml
extensions/tests/tests_with_sm.xml
+1
-0
No files found.
conf/libuniset2.spec
View file @
256a0a03
...
...
@@ -16,7 +16,7 @@
Name: libuniset2
Version: 2.6
Release: alt1
2.1
Release: alt1
4
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
...
...
extensions/lib/IOBase.cc
View file @
256a0a03
...
...
@@ -246,8 +246,8 @@ namespace uniset
val
=
uniset
::
lcalibrate
(
val
,
cal
->
minRaw
,
cal
->
maxRaw
,
cal
->
minCal
,
cal
->
maxCal
,
it
->
calcrop
);
}
if
(
!
it
->
noprecision
&&
it
->
cal
.
precision
>
0
)
val
*=
lround
(
pow10
(
it
->
cal
.
precision
)
);
if
(
!
it
->
noprecision
&&
it
->
cal
.
precision
!=
0
)
val
=
lround
(
val
*
pow10
(
it
->
cal
.
precision
)
);
}
}
// end of 'check_depend'
...
...
@@ -282,7 +282,7 @@ namespace uniset
val
=
0
;
memcpy
(
&
val
,
&
fval
,
std
::
min
(
sizeof
(
val
),
sizeof
(
fval
)));
}
else
if
(
it
->
cal
.
precision
>
0
&&
!
it
->
noprecision
)
else
if
(
it
->
cal
.
precision
!=
0
&&
!
it
->
noprecision
)
val
=
lroundf
(
fval
*
pow10
(
it
->
cal
.
precision
)
);
// проверка на обрыв
...
...
@@ -394,7 +394,7 @@ namespace uniset
else
{
// сперва "убираем степень", потом калибруем.. (это обратная последовательность для AsAI)
if
(
!
it
->
noprecision
&&
it
->
cal
.
precision
>
0
)
if
(
!
it
->
noprecision
&&
it
->
cal
.
precision
!=
0
)
val
=
lroundf
(
(
float
)
it
->
value
/
pow10
(
it
->
cal
.
precision
)
);
IOController_i
::
CalibrateInfo
*
cal
(
&
(
it
->
cal
)
);
...
...
@@ -460,7 +460,7 @@ namespace uniset
fval
=
uniset
::
fcalibrate
(
fval
,
cal
->
minCal
,
cal
->
maxCal
,
cal
->
minRaw
,
cal
->
maxRaw
,
it
->
calcrop
);
}
if
(
!
it
->
noprecision
&&
it
->
cal
.
precision
>
0
)
if
(
!
it
->
noprecision
&&
it
->
cal
.
precision
!=
0
)
return
(
fval
/
pow10
(
it
->
cal
.
precision
)
);
}
else
// if( it->stype == UniversalIO::DI || it->stype == UniversalIO::DO )
...
...
extensions/tests/test_iobase_with_sm.cc
View file @
256a0a03
...
...
@@ -330,10 +330,10 @@ TEST_CASE("[IOBase::calibration]: AI calibration (precision)", "[iobase][calibra
init_test
();
ObjectId
ai
=
conf
->
getSensorID
(
"CalibrationTest_AI2_AS"
);
CHECK
(
ai
!=
DefaultObjectId
);
REQUIRE
(
ai
!=
DefaultObjectId
);
IOBase
ib
;
CHECK
(
init_iobase
(
&
ib
,
"CalibrationTest_AI2_AS"
)
);
REQUIRE
(
init_iobase
(
&
ib
,
"CalibrationTest_AI2_AS"
)
);
SECTION
(
"AI calibration with precision (asAI)"
)
{
...
...
@@ -435,6 +435,22 @@ TEST_CASE("[IOBase::calibration]: AI calibration (precision)", "[iobase][calibra
ib
.
noprecision
=
false
;
}
ai
=
conf
->
getSensorID
(
"CalibrationTest_AI3_AS"
);
REQUIRE
(
ai
!=
DefaultObjectId
);
REQUIRE
(
init_iobase
(
&
ib
,
"CalibrationTest_AI3_AS"
)
);
SECTION
(
"AI calibration with precision < 0 (asAI)"
)
{
IOBase
::
processingAsAI
(
&
ib
,
0
,
shm
,
true
);
REQUIRE
(
shm
->
getValue
(
ai
)
==
0
);
IOBase
::
processingAsAI
(
&
ib
,
1000
,
shm
,
true
);
REQUIRE
(
shm
->
getValue
(
ai
)
==
1
);
IOBase
::
processingAsAI
(
&
ib
,
-
10
,
shm
,
true
);
REQUIRE
(
shm
->
getValue
(
ai
)
==
0
);
}
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"[IOBase::calibration]: asDI, asDO"
,
"[iobase][di][do][extensions]"
)
...
...
extensions/tests/tests_with_sm.xml
View file @
256a0a03
...
...
@@ -261,6 +261,7 @@
<!-- calibration test -->
<item
id=
"114"
iotype=
"AI"
name=
"CalibrationTest_AI1_AS"
textname=
"Calibration test: AI1"
rmin=
"-100"
rmax=
"100"
cmin=
"-1000"
cmax=
"1000"
/>
<item
id=
"115"
iotype=
"AI"
name=
"CalibrationTest_AI2_AS"
textname=
"Calibration test: AI2"
rmin=
"-100"
rmax=
"100"
cmin=
"-1000"
cmax=
"1000"
precision=
"2"
/>
<item
id=
"123"
iotype=
"AI"
name=
"CalibrationTest_AI3_AS"
textname=
"Calibration test: AI3"
precision=
"-3"
/>
<!-- asDI, asDO -->
<item
id=
"116"
iotype=
"AI"
name=
"AsDI1_AS"
textname=
"AsDI1"
/>
...
...
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