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
2e9e4553
Commit
2e9e4553
authored
Aug 31, 2005
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ExternVolume implemented
parent
c51d2fbe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
177 additions
and
0 deletions
+177
-0
wb/exp/wb/src/wb_provider.cpp
wb/exp/wb/src/wb_provider.cpp
+135
-0
wb/exp/wb/src/wb_provider.h
wb/exp/wb/src/wb_provider.h
+42
-0
No files found.
wb/exp/wb/src/wb_provider.cpp
0 → 100644
View file @
2e9e4553
extern
"C"
{
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
}
extern
"C"
{
#include "pwr.h"
#include "pwr_class.h"
#include "co_cdh.h"
#include "wb_ldh_msg.h"
}
#include "wb_vext.h"
#include "wb_provider.h"
void
wb_procom
::
put
(
vext_sAMsg
*
msg
,
int
size
,
pwr_tStatus
*
sts
)
{
msg
->
Any
.
message_type
=
1
;
if
(
msgsnd
(
m_msgsndid
,
(
void
*
)
msg
,
size
,
0
)
==
-
1
)
{
*
sts
=
LDH__MSGSND
;
return
;
}
*
sts
=
LDH__SUCCESS
;
}
void
wb_procom
::
receive
(
vext_sQMsg
*
msg
,
int
size
,
pwr_tStatus
*
sts
)
{
if
(
!
m_connected
)
{
key_t
key
;
int
fd
=
-
1
;
fd
=
open
(
m_key
,
O_RDWR
|
O_CREAT
,
0777
);
if
(
fd
<
0
)
{
*
sts
=
LDH__NOPROV
;
return
;
}
close
(
fd
);
key
=
ftok
(
m_key
,
0
);
m_msgrcvid
=
msgget
(
(
key_t
)
key
,
0666
|
IPC_CREAT
);
if
(
m_msgrcvid
==
-
1
)
{
*
sts
=
LDH__MSGGET
;
return
;
}
m_msgsndid
=
msgget
(
(
key_t
)(
key
+
1
),
0666
|
IPC_CREAT
);
if
(
m_msgsndid
==
-
1
)
{
*
sts
=
LDH__MSGGET
;
return
;
}
m_connected
=
1
;
}
if
(
msgrcv
(
m_msgrcvid
,
(
void
*
)
msg
,
size
,
0
,
0
)
==
-
1
)
{
*
sts
=
LDH__MSGRCV
;
return
;
}
*
sts
=
LDH__SUCCESS
;
}
void
wb_procom
::
provideObject
(
pwr_tStatus
sts
,
pwr_tOix
oix
,
pwr_tOix
fthoix
,
pwr_tOix
bwsoix
,
pwr_tOix
fwsoix
,
pwr_tOix
fchoix
,
pwr_tOix
lchoix
,
pwr_tCid
cid
,
char
*
name
,
char
*
longname
)
{
vext_sAMsg
amsg
;
pwr_tStatus
asts
;
amsg
.
Object
.
Type
=
vext_eMsgType_Object
;
amsg
.
Object
.
Status
=
sts
;
amsg
.
Object
.
oix
=
oix
;
amsg
.
Object
.
fthoix
=
fthoix
;
amsg
.
Object
.
bwsoix
=
bwsoix
;
amsg
.
Object
.
fwsoix
=
fwsoix
;
amsg
.
Object
.
fchoix
=
fchoix
;
amsg
.
Object
.
lchoix
=
lchoix
;
amsg
.
Object
.
cid
=
cid
;
if
(
ODD
(
sts
))
{
strcpy
(
amsg
.
Object
.
name
,
name
);
strcpy
(
amsg
.
Object
.
longname
,
longname
);
}
put
(
&
amsg
,
sizeof
(
amsg
),
&
asts
);
}
void
wb_procom
::
provideBody
(
pwr_tStatus
sts
,
pwr_tOix
oix
,
int
size
,
void
*
body
)
{
vext_sAMsg
amsg
;
pwr_tStatus
asts
;
amsg
.
ObjectBody
.
Status
=
sts
;
amsg
.
ObjectBody
.
oix
=
oix
;
if
(
(
int
)
sizeof
(
amsg
.
ObjectBody
.
body
)
<
size
)
size
=
sizeof
(
amsg
.
ObjectBody
.
body
);
amsg
.
ObjectBody
.
size
=
size
;
if
(
ODD
(
sts
))
memcpy
(
amsg
.
ObjectBody
.
body
,
body
,
size
);
put
(
&
amsg
,
sizeof
(
amsg
),
&
asts
);
}
void
wb_procom
::
mainloop
()
{
vext_sQMsg
qmsg
;
pwr_tStatus
sts
;
for
(;;)
{
receive
(
&
qmsg
,
sizeof
(
qmsg
),
&
sts
);
switch
(
qmsg
.
Any
.
Type
)
{
case
vext_eMsgType_Object
:
printf
(
"Object
\n
"
);
m_provider
->
object
(
this
);
break
;
case
vext_eMsgType_ObjectOid
:
printf
(
"ObjectOid %d
\n
"
,
qmsg
.
Oid
.
Oix
);
m_provider
->
objectOid
(
this
,
qmsg
.
Oid
.
Oix
);
break
;
case
vext_eMsgType_ObjectBody
:
printf
(
"ObjectBody %d
\n
"
,
qmsg
.
Oid
.
Oix
);
m_provider
->
objectBody
(
this
,
qmsg
.
Oid
.
Oix
);
break
;
case
vext_eMsgType_ObjectName
:
printf
(
"ObjectName %s
\n
"
,
qmsg
.
ObjectName
.
Name
);
m_provider
->
objectName
(
this
,
qmsg
.
ObjectName
.
Name
);
break
;
default:
;
}
}
}
wb/exp/wb/src/wb_provider.h
0 → 100644
View file @
2e9e4553
#ifndef wb_provider_h
#define wb_provider_h
#include "wb_vext.h"
class
wb_procom
;
class
wb_provider
{
public:
virtual
void
object
(
wb_procom
*
pcom
)
{}
virtual
void
objectOid
(
wb_procom
*
pcom
,
pwr_tOix
oix
)
{}
virtual
void
objectName
(
wb_procom
*
pcom
,
char
*
name
)
{}
virtual
void
objectBody
(
wb_procom
*
pcom
,
pwr_tOix
oix
)
{}
};
class
wb_procom
{
char
m_key
[
200
];
int
m_connected
;
int
m_msgsndid
;
int
m_msgrcvid
;
wb_provider
*
m_provider
;
public:
wb_procom
(
char
*
key
,
wb_provider
*
p
)
:
m_connected
(
0
),
m_provider
(
p
)
{
strcpy
(
m_key
,
key
);
}
void
put
(
vext_sAMsg
*
msg
,
int
size
,
pwr_tStatus
*
sts
);
void
receive
(
vext_sQMsg
*
msg
,
int
size
,
pwr_tStatus
*
sts
);
void
mainloop
();
void
provideObject
(
pwr_tStatus
sts
,
pwr_tOix
oix
,
pwr_tOix
fthoix
,
pwr_tOix
bwsoix
,
pwr_tOix
fwsoix
,
pwr_tOix
fchoix
,
pwr_tOix
lchoix
,
pwr_tCid
cid
,
char
*
name
,
char
*
longname
);
void
provideBody
(
pwr_tStatus
sts
,
pwr_tOix
oix
,
int
size
,
void
*
body
);
};
#endif
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