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
eb38568f
Commit
eb38568f
authored
Apr 20, 2004
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New baseclass for applications
parent
4bec0202
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
170 additions
and
0 deletions
+170
-0
src/lib/rt/src/rt_appl.cpp
src/lib/rt/src/rt_appl.cpp
+130
-0
src/lib/rt/src/rt_appl.h
src/lib/rt/src/rt_appl.h
+40
-0
No files found.
src/lib/rt/src/rt_appl.cpp
0 → 100644
View file @
eb38568f
//
// Example of a proview application program
//
#include "rt_appl.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "rt_aproc.h"
#include "rt_pwr_msg.h"
#include "rt_qcom_msg.h"
#include "rt_ini_event.h"
#include "co_error.h"
void
rt_appl
::
init
()
{
qcom_sQid
qini
;
qcom_sQattr
qAttr
;
pwr_tStatus
sts
;
// Init error and status logger with a unic application index per node.
errh_Init
(
m_name
,
m_anix
);
errh_SetStatus
(
PWR__APPLSTARTUP
);
// Init database
sts
=
gdh_Init
(
"rs_appl"
);
if
(
EVEN
(
sts
))
{
errh_Fatal
(
"gdh_Init, %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
sts
);
}
// Create a queue to receive stop and restart events
if
(
!
qcom_Init
(
&
sts
,
0
,
"rs_appl"
))
{
errh_Fatal
(
"qcom_Init, %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
sts
);
}
qAttr
.
type
=
qcom_eQtype_private
;
qAttr
.
quota
=
100
;
if
(
!
qcom_CreateQ
(
&
sts
,
&
m_qid
,
&
qAttr
,
"events"
))
{
errh_Fatal
(
"qcom_CreateQ, %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
sts
);
}
qini
=
qcom_cQini
;
if
(
!
qcom_Bind
(
&
sts
,
&
m_qid
,
&
qini
))
{
errh_Fatal
(
"qcom_Bind(Qini), %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
-
1
);
}
}
void
rt_appl
::
register_appl
(
char
*
name
)
{
pwr_tOid
oid
;
pwr_tStatus
sts
;
// Get configuration object
sts
=
gdh_NameToObjid
(
name
,
&
oid
);
if
(
EVEN
(
sts
))
throw
co_error
(
sts
);
aproc_RegisterObject
(
oid
);
}
void
rt_appl
::
mainloop
()
{
pwr_tStatus
sts
;
int
tmo
;
char
mp
[
2000
];
qcom_sGet
get
;
int
swap
=
0
;
bool
first_scan
=
true
;
try
{
open
();
}
catch
(
co_error
&
e
)
{
errh_Error
(
(
char
*
)
e
.
what
().
c_str
());
errh_Fatal
(
"rs_appl aborting"
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
0
);
}
aproc_TimeStamp
();
errh_SetStatus
(
PWR__ARUN
);
first_scan
=
true
;
for
(;;)
{
if
(
first_scan
)
{
tmo
=
(
int
)
(
m_scantime
*
1000
-
1
);
}
get
.
maxSize
=
sizeof
(
mp
);
get
.
data
=
mp
;
qcom_Get
(
&
sts
,
&
m_qid
,
&
get
,
tmo
);
if
(
sts
==
QCOM__TMO
||
sts
==
QCOM__QEMPTY
)
{
if
(
!
swap
)
{
aproc_TimeStamp
();
scan
();
}
}
else
{
ini_mEvent
new_event
;
qcom_sEvent
*
ep
=
(
qcom_sEvent
*
)
get
.
data
;
new_event
.
m
=
ep
->
mask
;
if
(
new_event
.
b
.
oldPlcStop
&&
!
swap
)
{
errh_SetStatus
(
PWR__APPLRESTART
);
swap
=
1
;
close
();
}
else
if
(
new_event
.
b
.
swapDone
&&
swap
)
{
swap
=
0
;
open
();
errh_SetStatus
(
PWR__ARUN
);
}
else
if
(
new_event
.
b
.
terminate
)
{
exit
(
0
);
}
}
first_scan
=
false
;
}
}
src/lib/rt/src/rt_appl.h
0 → 100644
View file @
eb38568f
#ifndef rt_appl_h
#define rt_appl_h
#include "pwr.h"
#include "rt_qcom.h"
#include "rt_errh.h"
/*! \file rt_appl.h
\brief Contains the rt_appl class. */
/*! \addtogroup rt */
/*@{*/
//! Baseclass for applications.
/*! rt_appl is a baseclass for applications, where the subclasses should
implement the virtual functions open(), close() and scan().
*/
class
rt_appl
{
public:
rt_appl
(
char
*
name
,
errh_eAnix
anix
,
double
scantime
=
1.0
,
qcom_sQid
qid
=
qcom_cNQid
)
:
m_anix
(
anix
),
m_scantime
(
scantime
),
m_qid
(
qid
)
{
strcpy
(
m_name
,
name
);
}
void
init
();
virtual
void
open
()
{};
virtual
void
close
()
{};
virtual
void
scan
()
{};
void
register_appl
(
char
*
name
);
void
mainloop
();
double
scantime
()
{
return
m_scantime
;}
void
set_scantime
(
double
time
)
{
m_scantime
=
time
;}
private:
errh_eAnix
m_anix
;
double
m_scantime
;
qcom_sQid
m_qid
;
char
m_name
[
80
];
};
#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