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
13ea20be
Commit
13ea20be
authored
Nov 17, 2009
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sev_server: map changed to co_tree
parent
5541f8e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
28 deletions
+74
-28
sev/exe/sev_server/src/sev_server.cpp
sev/exe/sev_server/src/sev_server.cpp
+62
-9
sev/exe/sev_server/src/sev_server.h
sev/exe/sev_server/src/sev_server.h
+12
-19
No files found.
sev/exe/sev_server/src/sev_server.cpp
View file @
13ea20be
...
...
@@ -26,6 +26,7 @@
#include "co_time.h"
#include "co_error.h"
#include "co_cnf.h"
#include "co_tree.h"
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#include "rt_ini_event.h"
...
...
@@ -41,6 +42,32 @@
#define sev_cGarbageInterval 120
static
int
sev_comp_item
(
tree_sTable
*
tp
,
tree_sNode
*
x
,
tree_sNode
*
y
)
{
sev_sItem
*
xp
=
(
sev_sItem
*
)
x
;
sev_sItem
*
yp
=
(
sev_sItem
*
)
y
;
if
(
xp
->
key
.
oid
.
vid
>
yp
->
key
.
oid
.
vid
)
return
1
;
if
(
xp
->
key
.
oid
.
vid
<
yp
->
key
.
oid
.
vid
)
return
-
1
;
if
(
xp
->
key
.
oid
.
oix
>
yp
->
key
.
oid
.
oix
)
return
1
;
if
(
xp
->
key
.
oid
.
oix
<
yp
->
key
.
oid
.
oix
)
return
-
1
;
if
(
strcmp
(
xp
->
key
.
aname
,
yp
->
key
.
aname
)
>
0
)
return
1
;
if
(
strcmp
(
xp
->
key
.
aname
,
yp
->
key
.
aname
)
<
0
)
return
-
1
;
return
0
;
}
int
sev_server
::
init
(
int
noneth
)
{
qcom_sNode
node
;
...
...
@@ -104,9 +131,16 @@ int sev_server::init( int noneth)
m_db
->
get_items
(
&
m_sts
);
m_item_key
=
tree_CreateTable
(
&
sts
,
sizeof
(
sev_sItemKey
),
offsetof
(
sev_sItem
,
key
),
sizeof
(
sev_sItem
),
100
,
sev_comp_item
);
for
(
unsigned
int
i
=
0
;
i
<
m_db
->
m_items
.
size
();
i
++
)
{
sev_item_key
items_key
(
m_db
->
m_items
[
i
].
oid
,
m_db
->
m_items
[
i
].
attr
[
0
].
aname
);
m_item_key
[
items_key
]
=
i
;
sev_sItemKey
ik
;
sev_sItem
*
ip
;
ik
.
oid
=
m_db
->
m_items
[
i
].
oid
;
strcpy
(
ik
.
aname
,
m_db
->
m_items
[
i
].
attr
[
0
].
aname
);
ip
=
(
sev_sItem
*
)
tree_Insert
(
&
sts
,
m_item_key
,
&
ik
);
ip
->
idx
=
i
;
}
// Create a queue to server
...
...
@@ -429,6 +463,7 @@ int sev_server::mainloop()
int
sev_server
::
check_histitems
(
sev_sMsgHistItems
*
msg
,
unsigned
int
size
)
{
pwr_tStatus
sts
;
unsigned
int
idx
;
pwr_tDeltaTime
storagetime
;
int
item_cnt
=
(
size
-
sizeof
(
sev_sMsgHistItems
))
/
sizeof
(
sev_sHistItem
)
+
1
;
...
...
@@ -462,8 +497,13 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
msg
->
Items
[
i
].
deadband
,
msg
->
Items
[
i
].
options
,
&
idx
);
if
(
EVEN
(
m_sts
))
return
m_sts
;
sev_item_key
item_key
(
msg
->
Items
[
i
].
oid
,
msg
->
Items
[
i
].
attr
[
0
].
aname
);
m_item_key
[
item_key
]
=
idx
;
sev_sItemKey
ik
;
sev_sItem
*
ip
;
ik
.
oid
=
msg
->
Items
[
i
].
oid
;
strcpy
(
ik
.
aname
,
msg
->
Items
[
i
].
attr
[
0
].
aname
);
ip
=
(
sev_sItem
*
)
tree_Insert
(
&
sts
,
m_item_key
,
&
ik
);
ip
->
idx
=
idx
;
}
m_db
->
m_items
[
idx
].
sevid
=
msg
->
Items
[
i
].
sevid
;
...
...
@@ -471,7 +511,15 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
m_refid
[
sevid
]
=
idx
;
}
printf
(
"---- Node up ----
\n
"
);
#if 0
sev_sItem *ip = (sev_sItem *)tree_Minimum(&sts, m_item_key);
while ( ip) {
printf( "ItemKey: %d,%d Name %s idx: %d\n", ip->key.oid.vid, ip->key.oid.oix, ip->key.aname, ip->idx);
ip = (sev_sItem *)tree_Successor(&sts, m_item_key, ip);
}
#endif
printf
(
"---- Node up (%d) ----
\n
"
,
nid
);
// for ( iterator_refid it = m_refid.begin(); it != m_refid.end(); it++)
// printf( "Refid: %d,%d Name %s\n", it->first.id.nid, it->first.id.rix, m_db->m_items[it->second].oname);
...
...
@@ -512,16 +560,21 @@ int sev_server::send_histdata( qcom_sQid tgt, sev_sMsgHistDataGetRequest *rmsg,
pwr_tStatus
sts
,
lsts
;
pwr_tTime
starttime
,
endtime
;
sev_item_key
item_key
(
rmsg
->
Oid
,
rmsg
->
AName
);
iterator_item_key
it
=
m_item_key
.
find
(
item_key
);
if
(
it
==
m_item_key
.
end
())
sev_sItemKey
ik
;
sev_sItem
*
ip
;
ik
.
oid
=
rmsg
->
Oid
;
strcpy
(
ik
.
aname
,
rmsg
->
AName
);
ip
=
(
sev_sItem
*
)
tree_Find
(
&
sts
,
m_item_key
,
&
ik
);
if
(
!
ip
)
m_sts
=
SEV__NOSUCHITEM
;
else
m_sts
=
SEV__SUCCESS
;
int
idx
=
0
;
if
(
ODD
(
m_sts
))
{
idx
=
i
t
->
second
;
idx
=
i
p
->
idx
;
starttime
=
net_NetTimeToTime
(
&
rmsg
->
StartTime
);
endtime
=
net_NetTimeToTime
(
&
rmsg
->
EndTime
);
...
...
sev/exe/sev_server/src/sev_server.h
View file @
13ea20be
...
...
@@ -47,37 +47,30 @@ class sev_refid {
pwr_tRefId
id
;
};
class
sev_item_key
{
public:
sev_item_key
(
pwr_tOid
oid
,
char
*
aname
)
:
m_oid
(
oid
)
{
strncpy
(
m_aname
,
aname
,
sizeof
(
m_aname
));
}
// Struct for binary tree item
typedef
struct
{
pwr_tOid
oid
;
pwr_tAName
aname
;
}
sev_sItemKey
;
bool
operator
<
(
const
sev_item_key
&
x
)
const
{
if
(
m_oid
.
vid
<
x
.
m_oid
.
vid
)
return
true
;
if
(
m_oid
.
oix
<
x
.
m_oid
.
oix
)
return
true
;
return
strcmp
(
m_aname
,
x
.
m_aname
);
}
pwr_tOid
m_oid
;
pwr_tAName
m_aname
;
};
typedef
struct
{
tree_sNode
node
;
sev_sItemKey
key
;
int
idx
;
}
sev_sItem
;
class
sev_server
{
public:
sev_server
()
:
m_server_status
(
0
),
m_msg_id
(
0
)
{}
sev_server
()
:
m_server_status
(
0
),
m_
item_key
(
0
),
m_
msg_id
(
0
)
{}
typedef
map
<
sev_refid
,
unsigned
int
>::
iterator
iterator_refid
;
typedef
map
<
sev_item_key
,
unsigned
int
>::
iterator
iterator_item_key
;
pwr_tStatus
m_sts
;
pwr_tStatus
m_server_status
;
vector
<
sev_node
>
m_nodes
;
map
<
sev_refid
,
unsigned
int
>
m_refid
;
map
<
sev_item_key
,
unsigned
int
>
m_item_key
;
tree_sTable
*
m_item_key
;
unsigned
int
m_msg_id
;
sev_db
*
m_db
;
int
m_noneth
;
...
...
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