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
4313988b
Commit
4313988b
authored
May 31, 2016
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sev_server, read values adapted to deadband linear regr
parent
8aa690d0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
40 deletions
+140
-40
sev/lib/sev/src/sev_dbms.cpp
sev/lib/sev/src/sev_dbms.cpp
+139
-40
sev/lib/sev/src/sev_dbms.h
sev/lib/sev/src/sev_dbms.h
+1
-0
No files found.
sev/lib/sev/src/sev_dbms.cpp
View file @
4313988b
...
...
@@ -1514,8 +1514,33 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
}
if
(
item
.
options
&
pwr_mSevOptionsMask_Event
)
{
total_rows
=
atoi
(
row
[
4
]);
div
=
total_rows
/
maxsize
+
1
;
}
else
if
(
starttime
&&
endtime
)
{
else
if
(
item
.
options
&
pwr_mSevOptionsMask_UseDeadBand
&&
item
.
options
&
pwr_mSevOptionsMask_DeadBandLinearRegr
)
{
int
startid
;
int
endid
;
if
(
starttime
)
{
// Get id for starttime
*
sts
=
get_closest_time
(
item
.
tablename
,
item
.
options
,
starttime
,
1
,
&
startid
);
}
else
startid
=
0
;
if
(
endtime
)
{
// Get id for starttime
*
sts
=
get_closest_time
(
item
.
tablename
,
item
.
options
,
endtime
,
0
,
&
endid
);
if
(
endid
==
0
)
endid
=
atoi
(
row
[
4
]);
}
else
endid
=
atoi
(
row
[
4
]);
printf
(
"startid %d, endid %d
\n
"
,
startid
,
endid
);
div
=
(
endid
-
startid
+
1
)
/
maxsize
+
1
;
}
else
{
if
(
starttime
&&
endtime
)
{
pwr_tTime
update_time
;
if
(
row
[
12
])
timestr_to_time
(
row
[
12
],
&
update_time
);
...
...
@@ -1561,9 +1586,10 @@ int sev_dbms::get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, flo
else
{
total_rows
=
atoi
(
row
[
4
]);
}
div
=
total_rows
/
maxsize
+
1
;
}
mysql_free_result
(
result
);
div
=
total_rows
/
maxsize
+
1
;
if
(
starttime
)
{
*
sts
=
time_AtoAscii
(
&
stime
,
time_eFormat_NumDateAndTime
,
starttimstr
,
...
...
@@ -3169,6 +3195,58 @@ int sev_dbms::check_deadband(pwr_eType type, unsigned int size, pwr_tFloat32 dea
return
deadband_active
;
}
int
sev_dbms
::
get_closest_time
(
char
*
tablename
,
unsigned
int
options
,
pwr_tTime
*
time
,
int
before
,
int
*
id
)
{
char
query
[
200
];
pwr_tStatus
sts
;
char
timstr
[
20
];
sts
=
time_AtoAscii
(
time
,
time_eFormat_NumDateAndTime
,
timstr
,
sizeof
(
timstr
));
if
(
EVEN
(
sts
))
return
sts
;
timstr
[
19
]
=
0
;
if
(
options
&
pwr_mSevOptionsMask_PosixTime
)
{
if
(
before
)
sprintf
(
query
,
"select id from %s where time <= %ld order by time desc limit 1"
,
tablename
,
(
long
int
)
time
->
tv_sec
);
else
sprintf
(
query
,
"select id from %s where time >= %ld order by time asc limit 1"
,
tablename
,
(
long
int
)
time
->
tv_sec
);
}
else
{
if
(
before
)
sprintf
(
query
,
"select id from %s where time <= '%s' order by time desc limit 1"
,
tablename
,
timstr
);
else
sprintf
(
query
,
"select id from %s where time >= '%s' order by time asc limit 1"
,
tablename
,
timstr
);
}
int
rc
=
mysql_query
(
m_env
->
con
(),
query
);
if
(
rc
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
printf
(
"%s Query Error
\n
"
,
__FUNCTION__
);
return
SEV__DBERROR
;
}
MYSQL_ROW
row
;
MYSQL_RES
*
result
=
mysql_store_result
(
m_env
->
con
());
if
(
!
result
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
printf
(
"%s Status Result Error
\n
"
,
__FUNCTION__
);
return
SEV__DBERROR
;
}
row
=
mysql_fetch_row
(
result
);
if
(
!
row
)
{
*
id
=
0
;
}
else
*
id
=
atoi
(
row
[
0
]);
mysql_free_result
(
result
);
return
1
;
}
int
sev_dbms
::
get_objectvalues
(
pwr_tStatus
*
sts
,
sev_item
*
item
,
unsigned
int
size
,
pwr_tTime
*
starttime
,
pwr_tTime
*
endtime
,
int
maxsize
,
pwr_tTime
**
tbuf
,
void
**
vbuf
,
unsigned
int
*
bsize
)
...
...
@@ -3227,6 +3305,27 @@ int sev_dbms::get_objectvalues( pwr_tStatus *sts, sev_item *item,
if
(
item
->
options
&
pwr_mSevOptionsMask_Event
)
{
total_rows
=
atoi
(
row
[
4
]);
}
else
if
(
item
->
options
&
pwr_mSevOptionsMask_UseDeadBand
&&
item
->
options
&
pwr_mSevOptionsMask_DeadBandLinearRegr
)
{
int
startid
;
int
endid
;
if
(
starttime
)
{
// Get id for starttime
*
sts
=
get_closest_time
(
item
->
tablename
,
item
->
options
,
starttime
,
1
,
&
startid
);
}
else
startid
=
0
;
if
(
endtime
)
{
// Get id for starttime
*
sts
=
get_closest_time
(
item
->
tablename
,
item
->
options
,
endtime
,
0
,
&
endid
);
}
else
endid
=
atoi
(
row
[
4
]);
printf
(
"startid %d, endid %d
\n
"
,
startid
,
endid
);
div
=
(
endid
-
startid
+
1
)
/
maxsize
+
1
;
}
else
if
(
starttime
&&
endtime
)
{
pwr_tTime
update_time
;
if
(
row
[
12
])
...
...
sev/lib/sev/src/sev_dbms.h
View file @
4313988b
...
...
@@ -206,6 +206,7 @@ class sev_dbms : public sev_db {
void
add_cache
(
int
item_idx
);
int
begin_transaction
();
int
commit_transaction
();
int
get_closest_time
(
char
*
tablename
,
unsigned
int
options
,
pwr_tTime
*
time
,
int
before
,
int
*
id
);
inline
char
*
create_colName
(
unsigned
int
index
,
char
*
attributename
)
{
static
char
colName
[
constMaxColNameLength
];
strncpy
(
colName
,
attributename
,
constMaxColNameLength
);
...
...
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