Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
a132267b
Commit
a132267b
authored
Oct 27, 2011
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sev, deadband for other types than float
parent
7c5b1249
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
12 deletions
+113
-12
sev/lib/sev/src/sev_dbms.cpp
sev/lib/sev/src/sev_dbms.cpp
+113
-12
No files found.
sev/lib/sev/src/sev_dbms.cpp
View file @
a132267b
...
...
@@ -866,7 +866,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
// Compare current value to old value
switch
(
m_items
[
item_idx
].
attr
[
attr_idx
].
type
)
{
case
pwr_eType_Float32
:
if
(
fabsf
(
*
(
pwr_tFloat32
*
)
buf
-
*
(
pwr_tFloat32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tFloat32
)))
||
(
fabsf
(
*
(
pwr_tFloat32
*
)
buf
-
*
(
pwr_tFloat32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -875,7 +876,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
}
break
;
case
pwr_eType_Float64
:
if
(
fabsf
(
*
(
pwr_tFloat64
*
)
buf
-
*
(
pwr_tFloat64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tFloat64
)))
||
(
fabsf
(
*
(
pwr_tFloat64
*
)
buf
-
*
(
pwr_tFloat64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -884,7 +886,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
}
break
;
case
pwr_eType_Int64
:
if
(
fabsf
(
*
(
pwr_tInt64
*
)
buf
-
*
(
pwr_tInt64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tInt64
)))
||
(
fabsf
(
*
(
pwr_tInt64
*
)
buf
-
*
(
pwr_tInt64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -893,7 +896,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
}
break
;
case
pwr_eType_Int32
:
if
(
fabsf
(
*
(
pwr_tInt32
*
)
buf
-
*
(
pwr_tInt32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tInt32
)))
||
(
fabsf
(
*
(
pwr_tInt32
*
)
buf
-
*
(
pwr_tInt32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -902,7 +906,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
}
break
;
case
pwr_eType_Int16
:
if
(
fabsf
(
*
(
pwr_tInt16
*
)
buf
-
*
(
pwr_tInt16
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tInt16
)))
||
(
fabsf
(
*
(
pwr_tInt16
*
)
buf
-
*
(
pwr_tInt16
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -912,7 +917,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
break
;
case
pwr_eType_Int8
:
case
pwr_eType_Char
:
if
(
fabsf
(
*
(
pwr_tInt8
*
)
buf
-
*
(
pwr_tInt8
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tInt8
)))
||
(
fabsf
(
*
(
pwr_tInt8
*
)
buf
-
*
(
pwr_tInt8
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -921,7 +927,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
}
break
;
case
pwr_eType_UInt64
:
if
(
fabsf
(
*
(
pwr_tUInt64
*
)
buf
-
*
(
pwr_tUInt64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tUInt64
)))
||
(
fabsf
(
*
(
pwr_tUInt64
*
)
buf
-
*
(
pwr_tUInt64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -931,7 +938,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
break
;
case
pwr_eType_UInt32
:
case
pwr_eType_Boolean
:
if
(
fabsf
(
*
(
pwr_tUInt32
*
)
buf
-
*
(
pwr_tUInt32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tUInt32
)))
||
(
fabsf
(
*
(
pwr_tUInt32
*
)
buf
-
*
(
pwr_tUInt32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -940,7 +948,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
}
break
;
case
pwr_eType_UInt16
:
if
(
fabsf
(
*
(
pwr_tUInt16
*
)
buf
-
*
(
pwr_tUInt16
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tUInt16
)))
||
(
fabsf
(
*
(
pwr_tUInt16
*
)
buf
-
*
(
pwr_tUInt16
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -949,7 +958,8 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
}
break
;
case
pwr_eType_UInt8
:
if
(
fabsf
(
*
(
pwr_tUInt8
*
)
buf
-
*
(
pwr_tUInt8
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tUInt8
)))
||
(
fabsf
(
*
(
pwr_tUInt8
*
)
buf
-
*
(
pwr_tUInt8
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
update_time_only
=
1
;
}
else
{
...
...
@@ -957,6 +967,15 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
*
(
pwr_tUInt8
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tUInt8
*
)
buf
;
}
break
;
case
pwr_eType_String
:
if
(
!
strncmp
(
(
char
*
)
buf
,
(
char
*
)
m_items
[
item_idx
].
old_value
,
m_items
[
item_idx
].
value_size
))
{
update_time_only
=
1
;
}
else
{
m_items
[
item_idx
].
deadband_active
=
0
;
strncpy
(
(
char
*
)
m_items
[
item_idx
].
old_value
,
(
char
*
)
buf
,
m_items
[
item_idx
].
value_size
);
}
break
;
default:
;
}
}
...
...
@@ -964,12 +983,94 @@ int sev_dbms::store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
// Compare current value to old value
switch
(
m_items
[
item_idx
].
attr
[
attr_idx
].
type
)
{
case
pwr_eType_Float32
:
if
(
fabsf
(
*
(
pwr_tFloat32
*
)
buf
-
*
(
pwr_tFloat32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
)
{
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tFloat32
)))
||
(
fabsf
(
*
(
pwr_tFloat32
*
)
buf
-
*
(
pwr_tFloat32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tFloat32
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tFloat32
*
)
buf
;
break
;
case
pwr_eType_Float64
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tFloat64
)))
||
(
fabsf
(
*
(
pwr_tFloat64
*
)
buf
-
*
(
pwr_tFloat64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tFloat64
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tFloat64
*
)
buf
;
break
;
case
pwr_eType_Int64
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tInt64
)))
||
(
fabsf
(
*
(
pwr_tInt64
*
)
buf
-
*
(
pwr_tInt64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tInt64
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tInt64
*
)
buf
;
break
;
case
pwr_eType_Int32
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tInt32
)))
||
(
fabsf
(
*
(
pwr_tInt32
*
)
buf
-
*
(
pwr_tInt32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tInt32
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tInt32
*
)
buf
;
break
;
case
pwr_eType_Int16
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tInt16
)))
||
(
fabsf
(
*
(
pwr_tInt16
*
)
buf
-
*
(
pwr_tInt16
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tInt16
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tInt16
*
)
buf
;
break
;
case
pwr_eType_Int8
:
case
pwr_eType_Char
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tInt8
)))
||
(
fabsf
(
*
(
pwr_tInt8
*
)
buf
-
*
(
pwr_tInt8
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tInt8
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tInt8
*
)
buf
;
break
;
case
pwr_eType_UInt64
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tUInt64
)))
||
(
fabsf
(
*
(
pwr_tUInt64
*
)
buf
-
*
(
pwr_tUInt64
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tUInt64
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tUInt64
*
)
buf
;
break
;
case
pwr_eType_UInt32
:
case
pwr_eType_Boolean
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tUInt32
)))
||
(
fabsf
(
*
(
pwr_tUInt32
*
)
buf
-
*
(
pwr_tUInt32
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tUInt32
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tUInt32
*
)
buf
;
break
;
case
pwr_eType_UInt16
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tUInt16
)))
||
(
fabsf
(
*
(
pwr_tUInt16
*
)
buf
-
*
(
pwr_tUInt16
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tUInt16
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tUInt16
*
)
buf
;
break
;
case
pwr_eType_UInt8
:
if
(
(
m_items
[
item_idx
].
deadband
==
0
&&
!
memcmp
(
buf
,
m_items
[
item_idx
].
old_value
,
sizeof
(
pwr_tUInt8
)))
||
(
fabsf
(
*
(
pwr_tUInt8
*
)
buf
-
*
(
pwr_tUInt8
*
)
m_items
[
item_idx
].
old_value
)
<
m_items
[
item_idx
].
deadband
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
*
(
pwr_tUInt8
*
)
m_items
[
item_idx
].
old_value
=
*
(
pwr_tUInt8
*
)
buf
;
break
;
case
pwr_eType_String
:
if
(
!
strncmp
(
(
char
*
)
buf
,
(
char
*
)
m_items
[
item_idx
].
old_value
,
m_items
[
item_idx
].
value_size
))
{
m_items
[
item_idx
].
deadband_active
=
1
;
set_jump
=
1
;
}
strncpy
(
(
char
*
)
m_items
[
item_idx
].
old_value
,
(
char
*
)
buf
,
m_items
[
item_idx
].
value_size
);
break
;
default:
;
}
}
...
...
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