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
8b38d961
Commit
8b38d961
authored
Nov 23, 2012
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Calibration): добавил функции getLeftRaw(),getRightRaw(),getLeftVal(),getRightVal()
исправил ошибки в реализации getRawValue().
parent
e5bc267e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
47 deletions
+62
-47
libuniset.spec
conf/libuniset.spec
+5
-1
Calibration.h
extensions/include/Calibration.h
+12
-6
Calibration.cc
extensions/lib/Calibration.cc
+45
-40
No files found.
conf/libuniset.spec
View file @
8b38d961
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
Name: libuniset
Name: libuniset
Version: 1.5
Version: 1.5
Release: alt
4
Release: alt
5
Summary: UniSet - library for building distributed industrial control systems
Summary: UniSet - library for building distributed industrial control systems
License: GPL
License: GPL
Group: Development/C++
Group: Development/C++
...
@@ -211,6 +211,10 @@ rm -f %buildroot%_libdir/*.la
...
@@ -211,6 +211,10 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
%changelog
* Fri Nov 23 2012 Pavel Vainerman <pv@altlinux.ru> 1.5-alt5
- (Calibration): add getLeftRaw(),getRightRaw(),getLeftVal(),getRightVal()
- (Calibration): fixed bugs
* Fri Nov 23 2012 Pavel Vainerman <pv@altlinux.ru> 1.5-alt4
* Fri Nov 23 2012 Pavel Vainerman <pv@altlinux.ru> 1.5-alt4
- (uniset-codegen): fixed minor bug
- (uniset-codegen): fixed minor bug
...
...
extensions/include/Calibration.h
View file @
8b38d961
...
@@ -43,18 +43,24 @@ class Calibration
...
@@ -43,18 +43,24 @@ class Calibration
inline
long
getMinVal
(){
return
minVal
;
}
inline
long
getMinVal
(){
return
minVal
;
}
inline
long
getMaxVal
(){
return
maxVal
;
}
inline
long
getMaxVal
(){
return
maxVal
;
}
inline
long
getLeftVal
(){
return
leftVal
;
}
inline
long
getRightVal
(){
return
rightVal
;
}
/*!
/*!
Получение сырого значения по калиброванному
Получение сырого значения по калиброванному
\param
crop_cal - обрезать значение по крайним точкам,
\param
range=true вернуть крайнее значение в диаграмме
если оно < minVal или > max
Val (т.е. выходит за диапазон)
если оно cal<leftVal или cal>right
Val (т.е. выходит за диапазон)
Если
crop_cal
=false, то может быть возвращено значение outOfRange.
Если
range
=false, то может быть возвращено значение outOfRange.
*/
*/
long
getRawValue
(
long
cal
,
bool
crop_cal
=
false
);
long
getRawValue
(
long
cal
,
bool
range
=
false
);
inline
long
getMinRaw
(){
return
minRaw
;
}
inline
long
getMinRaw
(){
return
minRaw
;
}
inline
long
getMaxRaw
(){
return
maxRaw
;
}
inline
long
getMaxRaw
(){
return
maxRaw
;
}
inline
long
getLeftRaw
(){
return
leftRaw
;
}
inline
long
getRightRaw
(){
return
rightRaw
;
}
/*! построение характеристрики из конф. файла
/*! построение характеристрики из конф. файла
\param name - название характеристики в файле
\param name - название характеристики в файле
...
@@ -140,7 +146,7 @@ class Calibration
...
@@ -140,7 +146,7 @@ class Calibration
// список надо отсортировать по x!
// список надо отсортировать по x!
typedef
std
::
list
<
Part
>
PartsList
;
typedef
std
::
list
<
Part
>
PartsList
;
long
minRaw
,
maxRaw
,
minVal
,
maxVal
;
long
minRaw
,
maxRaw
,
minVal
,
maxVal
,
rightVal
,
leftVal
,
rightRaw
,
leftRaw
;
private
:
private
:
PartsList
plist
;
PartsList
plist
;
...
...
extensions/lib/Calibration.cc
View file @
8b38d961
...
@@ -94,7 +94,7 @@ Calibration::TypeOfValue Calibration::Part::calcX( TypeOfValue y )
...
@@ -94,7 +94,7 @@ Calibration::TypeOfValue Calibration::Part::calcX( TypeOfValue y )
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
Calibration
::
Calibration
()
:
Calibration
::
Calibration
()
:
minRaw
(
0
),
maxRaw
(
0
),
minVal
(
0
),
maxVal
(
0
),
minRaw
(
0
),
maxRaw
(
0
),
minVal
(
0
),
maxVal
(
0
),
rightVal
(
0
),
leftVal
(
0
),
rightRaw
(
0
),
leftRaw
(
0
),
myname
(
""
)
myname
(
""
)
{
{
}
}
...
@@ -102,7 +102,7 @@ myname("")
...
@@ -102,7 +102,7 @@ myname("")
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
Calibration
::
Calibration
(
const
string
name
,
const
string
confile
)
:
Calibration
::
Calibration
(
const
string
name
,
const
string
confile
)
:
minRaw
(
0
),
maxRaw
(
0
),
minVal
(
0
),
maxVal
(
0
),
minRaw
(
0
),
maxRaw
(
0
),
minVal
(
0
),
maxVal
(
0
),
rightVal
(
0
),
leftVal
(
0
),
rightRaw
(
0
),
leftRaw
(
0
),
myname
(
name
)
myname
(
name
)
{
{
build
(
name
,
confile
,
0
);
build
(
name
,
confile
,
0
);
...
@@ -110,7 +110,7 @@ myname(name)
...
@@ -110,7 +110,7 @@ myname(name)
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
Calibration
::
Calibration
(
xmlNode
*
node
)
:
Calibration
::
Calibration
(
xmlNode
*
node
)
:
minRaw
(
0
),
maxRaw
(
0
),
minVal
(
0
),
maxVal
(
0
)
minRaw
(
0
),
maxRaw
(
0
),
minVal
(
0
),
maxVal
(
0
)
,
rightVal
(
0
),
leftVal
(
0
),
rightRaw
(
0
),
leftRaw
(
0
)
{
{
UniXML_iterator
it
(
node
);
UniXML_iterator
it
(
node
);
myname
=
it
.
getProp
(
"name"
);
myname
=
it
.
getProp
(
"name"
);
...
@@ -171,15 +171,15 @@ void Calibration::build( const string name, const string confile, xmlNode* root
...
@@ -171,15 +171,15 @@ void Calibration::build( const string name, const string confile, xmlNode* root
// cout << myname << "(Calibration::build):"
// cout << myname << "(Calibration::build):"
// << "\tadd x=" << p.x << " y=" << p.y << endl;
// << "\tadd x=" << p.x << " y=" << p.y << endl;
if
(
p
.
y
>
maxRaw
)
if
(
p
.
x
>
maxRaw
)
maxRaw
=
p
.
y
;
maxRaw
=
p
.
x
;
else
if
(
p
.
y
<
minRaw
)
else
if
(
p
.
x
<
minRaw
)
minRaw
=
p
.
y
;
minRaw
=
p
.
x
;
if
(
p
.
x
>
maxVal
)
if
(
p
.
y
>
maxVal
)
maxVal
=
p
.
x
;
maxVal
=
p
.
y
;
else
if
(
p
.
x
<
minVal
)
else
if
(
p
.
y
<
minVal
)
minVal
=
p
.
x
;
minVal
=
p
.
y
;
if
(
prev
)
if
(
prev
)
{
{
...
@@ -198,8 +198,20 @@ void Calibration::build( const string name, const string confile, xmlNode* root
...
@@ -198,8 +198,20 @@ void Calibration::build( const string name, const string confile, xmlNode* root
}
}
plist
.
sort
();
plist
.
sort
();
PartsList
::
iterator
beg
=
plist
.
begin
();
PartsList
::
iterator
end
=
plist
.
end
();
if
(
plist
.
size
()
>
0
)
{
leftRaw
=
beg
->
left_x
();
leftVal
=
beg
->
left_y
();
end
--
;
rightRaw
=
end
->
right_x
();
rightVal
=
end
->
right_y
();
}
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
cerr
<<
myname
<<
"(Calibration::build): Failed open "
<<
confile
<<
endl
;
cerr
<<
myname
<<
"(Calibration::build): Failed open "
<<
confile
<<
endl
;
throw
;
throw
;
...
@@ -208,51 +220,44 @@ void Calibration::build( const string name, const string confile, xmlNode* root
...
@@ -208,51 +220,44 @@ void Calibration::build( const string name, const string confile, xmlNode* root
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
long
Calibration
::
getValue
(
long
raw
,
bool
crop_raw
)
long
Calibration
::
getValue
(
long
raw
,
bool
crop_raw
)
{
{
PartsList
::
iterator
it
=
plist
.
begin
();
if
(
crop_raw
)
// если x левее первого отрезка то берём первую точку...
if
(
raw
<=
it
->
left_x
()
)
{
{
if
(
crop_raw
)
// если x левее первого отрезка то берём первую точку...
return
it
->
left_y
();
if
(
raw
<
leftRaw
)
return
leftVal
;
return
it
->
calcY
(
raw
);
// если x правее последнего то берём крайнюю точку...
if
(
raw
>
rightRaw
)
return
rightVal
;
}
}
for
(
;
it
!=
plist
.
end
();
++
it
)
for
(
PartsList
::
iterator
it
=
plist
.
begin
()
;
it
!=
plist
.
end
();
++
it
)
{
{
TypeOfValue
q
(
it
->
getY
(
raw
)
);
TypeOfValue
q
=
it
->
getY
(
raw
);
if
(
q
!=
outOfRange
)
if
(
q
!=
outOfRange
)
return
tRound
(
q
);
return
tRound
(
q
);
}
}
// берём последний отрезок и вычисляем по нему...
return
outOfRange
;
it
=
plist
.
end
();
it
--
;
if
(
crop_raw
&&
raw
>=
it
->
right_x
()
)
return
it
->
right_y
();
return
it
->
calcY
(
raw
);
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
long
Calibration
::
getRawValue
(
long
cal
,
bool
crop_cal
)
long
Calibration
::
getRawValue
(
long
cal
,
bool
range
)
{
{
if
(
crop_cal
)
{
if
(
cal
<
minVal
)
cal
=
minVal
;
else
if
(
cal
>
maxVal
)
cal
=
maxVal
;
}
for
(
PartsList
::
iterator
it
=
plist
.
begin
();
it
!=
plist
.
end
();
++
it
)
for
(
PartsList
::
iterator
it
=
plist
.
begin
();
it
!=
plist
.
end
();
++
it
)
{
{
TypeOfValue
q
(
it
->
getX
(
cal
)
);
TypeOfValue
q
=
it
->
getX
(
cal
);
if
(
q
!=
outOfRange
)
if
(
q
!=
outOfRange
)
return
tRound
(
q
);
return
tRound
(
q
);
}
}
if
(
range
)
{
if
(
cal
<
leftVal
)
return
leftRaw
;
if
(
cal
>
rightVal
)
return
rightRaw
;
}
return
outOfRange
;
return
outOfRange
;
}
}
...
...
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