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
5fc045ca
Commit
5fc045ca
authored
Dec 06, 2016
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sev mysql, policy when selecting values with deadband changed
parent
6618e0c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
87 deletions
+103
-87
sev/lib/sev/src/sev_dbms.cpp
sev/lib/sev/src/sev_dbms.cpp
+103
-87
No files found.
sev/lib/sev/src/sev_dbms.cpp
View file @
5fc045ca
...
@@ -1482,6 +1482,7 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
...
@@ -1482,6 +1482,7 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
char
orderby_part
[
80
];
char
orderby_part
[
80
];
char
jumpstr
[
40
];
char
jumpstr
[
40
];
char
where_part
[
200
];
char
where_part
[
200
];
int
rows
;
if
(
starttime
&&
starttime
->
tv_sec
==
0
&&
starttime
->
tv_nsec
==
0
)
if
(
starttime
&&
starttime
->
tv_sec
==
0
&&
starttime
->
tv_nsec
==
0
)
starttime
=
0
;
starttime
=
0
;
...
@@ -1620,7 +1621,7 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
...
@@ -1620,7 +1621,7 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
strcpy
(
column_part
,
"time,value"
);
strcpy
(
column_part
,
"time,value"
);
if
(
options
&
pwr_mSevOptionsMask_UseDeadBand
)
if
(
options
&
pwr_mSevOptionsMask_UseDeadBand
)
strcpy
(
jumpstr
,
"
or jump = 1"
);
strcpy
(
jumpstr
,
"
"
);
// "or jump = 1" removed
else
else
strcpy
(
jumpstr
,
""
);
strcpy
(
jumpstr
,
""
);
...
@@ -1634,6 +1635,7 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
...
@@ -1634,6 +1635,7 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
strcpy
(
orderby_part
,
"time"
);
strcpy
(
orderby_part
,
"time"
);
}
}
for
(
int
k
=
0
;
k
<
2
;
k
++
)
{
// 'where' part
// 'where' part
if
(
options
&
pwr_mSevOptionsMask_ReadOptimized
)
{
if
(
options
&
pwr_mSevOptionsMask_ReadOptimized
)
{
if
(
starttime
&&
endtime
)
{
if
(
starttime
&&
endtime
)
{
...
@@ -1711,8 +1713,8 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
...
@@ -1711,8 +1713,8 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
strcpy
(
where_part
,
""
);
strcpy
(
where_part
,
""
);
}
}
sprintf
(
query
,
"select %s from %s %s order by %s
"
,
sprintf
(
query
,
"select %s from %s %s order by %s limit %d
"
,
column_part
,
item
.
tablename
,
where_part
,
orderby_part
);
column_part
,
item
.
tablename
,
where_part
,
orderby_part
,
maxsize
*
2
);
rc
=
mysql_query
(
m_env
->
con
(),
query
);
rc
=
mysql_query
(
m_env
->
con
(),
query
);
if
(
rc
)
{
if
(
rc
)
{
...
@@ -1729,9 +1731,23 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
...
@@ -1729,9 +1731,23 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
*
sts
=
SEV__DBERROR
;
*
sts
=
SEV__DBERROR
;
return
0
;
return
0
;
}
}
int
rows
=
mysql_num_rows
(
result
);
rows
=
mysql_num_rows
(
result
);
int
bufrows
=
rows
;
if
(
k
==
0
&&
options
&
pwr_mSevOptionsMask_UseDeadBand
&&
rows
<
maxsize
/
3
&&
rows
!=
0
&&
div
!=
1
)
{
// Try another read with smaller div
printf
(
"Retry: %d old dev: %d, new div %d
\n
"
,
rows
,
div
,
div
*
rows
/
maxsize
+
1
);
if
(
div
==
div
*
rows
/
maxsize
+
1
)
break
;
div
=
div
*
rows
/
maxsize
+
1
;
mysql_free_result
(
result
);
}
else
break
;
}
int
bufrows
=
rows
;
if
(
options
&
pwr_mSevOptionsMask_ReadOptimized
)
{
if
(
options
&
pwr_mSevOptionsMask_ReadOptimized
)
{
...
@@ -4062,10 +4078,10 @@ void sev_dbms::add_cache( int item_idx)
...
@@ -4062,10 +4078,10 @@ void sev_dbms::add_cache( int item_idx)
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_DeadBandMeanValue
)
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_DeadBandMeanValue
)
m_items
[
item_idx
].
cache
=
new
sev_valuecache_double
(
sev_eCvType_Mean
,
m_items
[
item_idx
].
deadband
,
m_items
[
item_idx
].
cache
=
new
sev_valuecache_double
(
sev_eCvType_Mean
,
m_items
[
item_idx
].
deadband
,
m_items
[
item_idx
].
scantime
);
m_items
[
item_idx
].
scantime
/
2
);
else
else
m_items
[
item_idx
].
cache
=
new
sev_valuecache_double
(
sev_eCvType_Point
,
m_items
[
item_idx
].
deadband
,
m_items
[
item_idx
].
cache
=
new
sev_valuecache_double
(
sev_eCvType_Point
,
m_items
[
item_idx
].
deadband
,
m_items
[
item_idx
].
scantime
);
m_items
[
item_idx
].
scantime
/
2
);
m_items
[
item_idx
].
cache
->
set_write_cb
(
write_db_cb
,
this
,
item_idx
);
m_items
[
item_idx
].
cache
->
set_write_cb
(
write_db_cb
,
this
,
item_idx
);
break
;
break
;
case
pwr_eType_Boolean
:
case
pwr_eType_Boolean
:
...
...
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