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
b497960f
Commit
b497960f
authored
Mar 22, 2004
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Soft restart
parent
06a43bd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
270 additions
and
132 deletions
+270
-132
nmps/exe/rs_nmps_trans/src/rs_nmps_trans.c
nmps/exe/rs_nmps_trans/src/rs_nmps_trans.c
+193
-61
src/exe/rt_trend/src/rt_trend.c
src/exe/rt_trend/src/rt_trend.c
+77
-71
No files found.
nmps/exe/rs_nmps_trans/src/rs_nmps_trans.c
View file @
b497960f
...
...
@@ -58,6 +58,9 @@
#include "co_time.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "rt_qcom.h"
#include "rt_ini_event.h"
#include "rt_qcom_msg.h"
#include "rt_mh_msg.h"
#include "rt_mh_net.h"
#include "rt_mh_appl.h"
...
...
@@ -274,6 +277,9 @@ static int nmpstrans_request_data( trans_ctx transctx,
int
position
,
translist_t_entry
**
translist_list
,
nmpstrans_t_req_list
*
req_ptr
);
static
void
nmpstrans_reqlist_close
(
trans_ctx
transctx
);
static
void
nmpstrans_rcvlist_close
(
trans_ctx
transctx
);
static
void
nmpstrans_sndlist_close
(
trans_ctx
transctx
);
static
pwr_tStatus
nmpstrans_reqlist_add
(
trans_ctx
transctx
,
pwr_tObjid
objid
,
...
...
@@ -298,7 +304,6 @@ static int nmpstrans_send_datasend( trans_ctx transctx,
translist_t_entry
**
translist_list
,
nmpstrans_t_snd_list
*
snd_ptr
);
static
pwr_tStatus
nmpstrans_trans_handler
(
trans_ctx
transctx
);
static
pwr_tStatus
nmpstrans_free
(
trans_ctx
transctx
);
static
int
nmpstrans_connect_alarm
();
static
int
nmpstrans_alarm_send
(
char
*
alarm_text
,
...
...
@@ -1534,6 +1539,43 @@ static int nmpstrans_rcv_reset_detected( trans_ctx transctx,
/****************************************************************************
* Name: nmpstrans_reqlist_close()
*
* Type void
*
* Type Parameter IOGF Description
*
* Description:
* Unref and free reqlist.
*
**************************************************************************/
static
void
nmpstrans_reqlist_close
(
trans_ctx
transctx
)
{
nmpstrans_t_req_list
*
reqlist_ptr
;
int
i
;
pwr_tStatus
sts
;
reqlist_ptr
=
transctx
->
reqlist
;
for
(
i
=
0
;
i
<
transctx
->
req_count
;
i
++
)
{
sts
=
gdh_DLUnrefObjectInfo
(
reqlist_ptr
->
subid
);
if
(
reqlist_ptr
->
req
->
Function
&
NMPS_REQUESTFUNC_DISPLAYOBJECT
)
sts
=
gdh_DLUnrefObjectInfo
(
reqlist_ptr
->
display_object_subid
);
sts
=
gdh_DLUnrefObjectInfo
(
reqlist_ptr
->
send_remtrans_subid
);
sts
=
gdh_DLUnrefObjectInfo
(
reqlist_ptr
->
send_remtransbuff_subid
);
sts
=
gdh_DLUnrefObjectInfo
(
reqlist_ptr
->
rcv_remtrans_subid
);
sts
=
gdh_DLUnrefObjectInfo
(
reqlist_ptr
->
rcv_remtransbuff_subid
);
if
(
reqlist_ptr
->
req
->
Function
&
NMPS_REQUESTFUNC_CELLINSERT
)
sts
=
gdh_DLUnrefObjectInfo
(
reqlist_ptr
->
cell_subid
);
free
(
reqlist_ptr
->
conv_table
);
reqlist_ptr
->
conv_table
=
0
;
reqlist_ptr
++
;
}
free
(
transctx
->
reqlist
);
transctx
->
reqlist
=
0
;
transctx
->
req_count
=
0
;
}
/****************************************************************************
* Name: nmpstrans_reqlist_add()
...
...
@@ -1724,6 +1766,46 @@ static pwr_tStatus nmpstrans_reqlist_add(
return
NMPS__SUCCESS
;
}
/****************************************************************************
* Name: nmpstrans_rcvlist_close()
*
* Type pwr_tStatus
*
* Type Parameter IOGF Description
*
* Description:
* Unref and free the rcvlist.
*
**************************************************************************/
static
void
nmpstrans_rcvlist_close
(
trans_ctx
transctx
)
{
nmpstrans_t_rcv_list
*
rcvlist_ptr
;
int
i
;
pwr_tStatus
sts
;
rcvlist_ptr
=
transctx
->
rcvlist
;
for
(
i
=
0
;
i
<
transctx
->
rcv_count
;
i
++
)
{
sts
=
gdh_DLUnrefObjectInfo
(
rcvlist_ptr
->
subid
);
if
(
rcvlist_ptr
->
rcv
->
Function
&
NMPS_DATARCVFUNC_DISPLAYOBJECT
)
sts
=
gdh_DLUnrefObjectInfo
(
rcvlist_ptr
->
display_object_subid
);
if
(
rcvlist_ptr
->
rcv
->
Function
&
NMPS_DATARCVFUNC_ACK
)
{
sts
=
gdh_DLUnrefObjectInfo
(
rcvlist_ptr
->
send_remtrans_subid
);
sts
=
gdh_DLUnrefObjectInfo
(
rcvlist_ptr
->
send_remtransbuff_subid
);
}
sts
=
gdh_DLUnrefObjectInfo
(
rcvlist_ptr
->
rcv_remtrans_subid
);
sts
=
gdh_DLUnrefObjectInfo
(
rcvlist_ptr
->
rcv_remtransbuff_subid
);
if
(
rcvlist_ptr
->
rcv
->
Function
&
NMPS_DATARCVFUNC_CELLINSERT
)
sts
=
gdh_DLUnrefObjectInfo
(
rcvlist_ptr
->
cell_subid
);
free
(
rcvlist_ptr
->
conv_table
);
rcvlist_ptr
->
conv_table
=
0
;
rcvlist_ptr
++
;
}
free
(
transctx
->
rcvlist
);
transctx
->
rcvlist
=
0
;
transctx
->
rcv_count
=
0
;
}
/****************************************************************************
* Name: nmpstrans_rcvlist_add()
...
...
@@ -1912,6 +1994,42 @@ static pwr_tStatus nmpstrans_rcvlist_add(
return
NMPS__SUCCESS
;
}
/****************************************************************************
* Name: nmpstrans_sndlist_close()
*
* Type void
*
* Type Parameter IOGF Description
*
* Description:
* Unref and free the sndlist.
*
**************************************************************************/
static
void
nmpstrans_sndlist_close
(
trans_ctx
transctx
)
{
nmpstrans_t_snd_list
*
sndlist_ptr
;
int
i
;
pwr_tStatus
sts
;
sndlist_ptr
=
transctx
->
sndlist
;
for
(
i
=
0
;
i
<
transctx
->
snd_count
;
i
++
)
{
sts
=
gdh_DLUnrefObjectInfo
(
sndlist_ptr
->
subid
);
sts
=
gdh_DLUnrefObjectInfo
(
sndlist_ptr
->
send_remtrans_subid
);
sts
=
gdh_DLUnrefObjectInfo
(
sndlist_ptr
->
send_remtransbuff_subid
);
if
(
sndlist_ptr
->
snd
->
Function
&
NMPS_DATASENDFUNC_ACK
)
{
sts
=
gdh_DLUnrefObjectInfo
(
sndlist_ptr
->
rcv_remtrans_subid
);
sts
=
gdh_DLUnrefObjectInfo
(
sndlist_ptr
->
rcv_remtransbuff_subid
);
}
free
(
sndlist_ptr
->
conv_table
);
sndlist_ptr
++
;
}
free
(
transctx
->
sndlist
);
transctx
->
sndlist
=
0
;
transctx
->
snd_count
=
0
;
}
/****************************************************************************
* Name: nmpstrans_sndlist_add()
...
...
@@ -2611,83 +2729,97 @@ static pwr_tStatus nmpstrans_trans_handler( trans_ctx transctx)
return
NMPS__SUCCESS
;
}
/****************************************************************************
* Name: nmpstrans_free()
*
* Type pwr_tStatus
*
* Type Parameter IOGF Description
*
* Description:
* Free the nmpstrans context.
*
**************************************************************************/
static
pwr_tStatus
nmpstrans_free
(
trans_ctx
transctx
)
{
nmpstrans_t_req_list
*
req_ptr
;
int
i
;
/* Loop through the req objects */
req_ptr
=
transctx
->
reqlist
;
for
(
i
=
0
;
i
<
transctx
->
req_count
;
i
++
)
{
free
(
req_ptr
->
conv_table
);
req_ptr
++
;
}
free
(
transctx
->
reqlist
);
free
(
transctx
);
return
NMPS__SUCCESS
;
}
int
main
()
{
trans_ctx
transctx
;
pwr_tStatus
sts
;
float
scantime
;
qcom_sQid
qini
;
qcom_sQattr
qAttr
;
int
tmo
;
char
mp
[
2000
];
qcom_sQid
qid
=
qcom_cNQid
;
qcom_sGet
get
;
int
swap
=
0
;
/* Init pams and gdh */
sts
=
gdh_Init
(
"rt_nmps_trans"
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
)
sts
=
gdh_Init
(
"rs_nmps_trans"
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
/* Init qcom and bind event que */
if
(
!
qcom_Init
(
&
sts
,
0
,
"rs_nmps_trans"
))
{
errh_Fatal
(
"qcom_Init, %m"
,
sts
);
exit
(
sts
);
}
qAttr
.
type
=
qcom_eQtype_private
;
qAttr
.
quota
=
100
;
if
(
!
qcom_CreateQ
(
&
sts
,
&
qid
,
&
qAttr
,
"events"
))
{
errh_Fatal
(
"qcom_CreateQ, %m"
,
sts
);
exit
(
sts
);
}
qini
=
qcom_cQini
;
if
(
!
qcom_Bind
(
&
sts
,
&
qid
,
&
qini
))
{
errh_Fatal
(
"qcom_Bind(Qini), %m"
,
sts
);
exit
(
-
1
);
}
/* Wait for the plcpgm has flagged initizated */
plc_UtlWaitForPlc
();
for
(;;)
{
transctx
=
calloc
(
1
,
sizeof
(
*
transctx
));
if
(
transctx
==
0
)
LogAndExit
(
NMPS__NOMEMORY
)
transctx
=
calloc
(
1
,
sizeof
(
*
transctx
));
if
(
transctx
==
0
)
LogAndExit
(
NMPS__NOMEMORY
);
sts
=
nmps_get_transconfig
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmps_get_transconfig
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmpstrans_datareq_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmpstrans_datareq_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmpstrans_datarcv_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmpstrans_datarcv_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmpstrans_datasend_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
for
(;;)
{
scantime
=
transctx
->
transconfig
->
CycleTime
;
sts
=
nmpstrans_datasend_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmpstrans_trans_handler
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sutl_sleep
(
scantime
);
if
(
transctx
->
transconfig
->
Initialize
)
{
transctx
->
transconfig
->
Initialize
=
0
;
nmpstrans_free
(
transctx
);
break
;
tmo
=
1000
*
transctx
->
transconfig
->
CycleTime
-
1
;
for
(;;)
{
get
.
maxSize
=
sizeof
(
mp
);
get
.
data
=
mp
;
qcom_Get
(
&
sts
,
&
qid
,
&
get
,
tmo
);
if
(
sts
==
QCOM__TMO
||
sts
==
QCOM__QEMPTY
)
{
if
(
!
swap
)
{
sts
=
nmpstrans_trans_handler
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
transctx
->
transconfig
->
LoopCount
++
;
}
}
else
{
ini_mEvent
new_event
;
qcom_sEvent
*
ep
=
(
qcom_sEvent
*
)
get
.
data
;
new_event
.
m
=
ep
->
mask
;
if
(
new_event
.
b
.
oldPlcStop
&&
!
swap
)
{
swap
=
1
;
nmpstrans_reqlist_close
(
transctx
);
nmpstrans_rcvlist_close
(
transctx
);
nmpstrans_sndlist_close
(
transctx
);
}
else
if
(
new_event
.
b
.
swapDone
&&
swap
)
{
swap
=
0
;
sts
=
nmpstrans_datareq_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmpstrans_datarcv_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
sts
=
nmpstrans_datasend_init
(
transctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
errh_Info
(
"Warm restart completed"
);
}
transctx
->
transconfig
->
LoopCount
++
;
}
}
}
src/exe/rt_trend/src/rt_trend.c
View file @
b497960f
...
...
@@ -6,18 +6,9 @@
This file contains the access routines to the datastorage
of data to trendplot. */
#if defined OS_ELN
# include stdio
# include stdlib
# include signal
# include "rt_plc_loop.h"
#elif defined OS_VMS
#if defined OS_VMS
# include <stdio.h>
# include <stdlib.h>
# include <signal.h>
# include <descrip.h>
# include <starlet.h>
# include "rt_plc_loop.h"
#elif defined OS_LYNX || defined OS_LINUX
# include <stdio.h>
# include <stdlib.h>
...
...
@@ -37,6 +28,9 @@
#include "rt_gdh.h"
#include "rt_ds_msg.h"
#include "rt_gdh_msg.h"
#include "rt_qcom_msg.h"
#include "rt_qcom.h"
#include "rt_ini_event.h"
#define Log_Error(a, b) errh_CErrLog(DS__ERROR, errh_ErrArgAF(b), errh_ErrArgMsg(a), NULL)
#define Log(b) errh_CErrLog(DS__LOG, errh_ErrArgAF(b), NULL)
...
...
@@ -56,6 +50,7 @@ struct s_LstNode
static
sLstNode
*
LstHead
=
NULL
;
static
pwr_tStatus
InitTrendList
();
static
void
CloseTrendList
();
static
pwr_tBoolean
IsValidType
(
pwr_eTix
Type
);
static
void
StoreData
();
...
...
@@ -66,27 +61,39 @@ int main (int argc, char **argv)
pwr_tObjid
ObjId
;
pwr_sClass_DsTrendConf
*
TConfP
;
pwr_tBoolean
InitOK
;
pwr_tInt32
ScanTime
=
1
;
/* Later it will be fetched from a
* configuration object.
*/
#ifdef OS_VMS
extern
int
plc_ConvMSToLI
(
pwr_tUInt32
Time
,
pwr_tVaxTime
*
TimeLI
);
unsigned
int
TimerFlag
;
pwr_tVaxTime
DeltaTime
;
#elif defined OS_ELN
pwr_tVaxTime
NextTime
;
pwr_tVaxTime
DeltaTime
;
#elif defined OS_LYNX || defined OS_LINUX
pwr_tInt32
ScanTime
=
1
;
pwr_tTime
CurrentTime
,
LastScan
,
NextScan
;
pwr_tDeltaTime
ScanDeltaTime
,
WaitTime
;
#endif
qcom_sQid
qini
;
qcom_sQattr
qAttr
;
int
tmo
;
char
mp
[
2000
];
qcom_sQid
qid
=
qcom_cNQid
;
qcom_sGet
get
;
int
swap
=
0
;
errh_Init
(
"pwr_trend"
);
sts
=
gdh_Init
(
"
pwr
_trend"
);
sts
=
gdh_Init
(
"
ds
_trend"
);
If_Error_Log_Exit
(
sts
,
"gdh_Init"
);
if
(
!
qcom_Init
(
&
sts
,
0
,
"pwr_trend"
))
{
errh_Fatal
(
"qcom_Init, %m"
,
sts
);
exit
(
sts
);
}
qAttr
.
type
=
qcom_eQtype_private
;
qAttr
.
quota
=
100
;
if
(
!
qcom_CreateQ
(
&
sts
,
&
qid
,
&
qAttr
,
"events"
))
{
errh_Fatal
(
"qcom_CreateQ, %m"
,
sts
);
exit
(
sts
);
}
qini
=
qcom_cQini
;
if
(
!
qcom_Bind
(
&
sts
,
&
qid
,
&
qini
))
{
errh_Fatal
(
"qcom_Bind(Qini), %m"
,
sts
);
exit
(
-
1
);
}
/* Wait until local nethandler has started */
while
(
EVEN
(
gdh_NethandlerRunning
()))
sleep
(
1
);
...
...
@@ -117,53 +124,45 @@ int main (int argc, char **argv)
/* If even sts, just wait for init message */
#if defined OS_VMS
plc_ConvMSToLI
(
ScanTime
*
1000
,
&
DeltaTime
);
sts
=
lib
$
get_ef
(
&
TimerFlag
);
if
(
EVEN
(
sts
))
{
Log_Error_Exit
(
sts
,
"Couldn't allocate event flag for timer"
);
}
#elif defined OS_ELN
plc_ConvMSToLI
(
ScanTime
*
1000
,
&
DeltaTime
);
sts
=
plc_LoopInit
(
&
NextTime
);
if
(
EVEN
(
sts
))
{
Log_Error_Exit
(
sts
,
"Couldn't initialize timer loop"
);
}
#elif defined OS_LYNX || defined OS_LINUX
clock_gettime
(
CLOCK_REALTIME
,
&
LastScan
);
ScanDeltaTime
.
tv_sec
=
ScanTime
;
ScanDeltaTime
.
tv_nsec
=
0
;
#endif
while
(
InitOK
)
{
/* We cannot do anything if there is a slip */
#if defined OS_VMS
sys
$
clref
(
TimerFlag
);
sys
$
setimr
(
TimerFlag
,
&
DeltaTime
,
0
,
2
,
0
);
StoreData
(
LstHead
);
sys
$
waitfr
(
TimerFlag
);
#elif defined OS_ELN
StoreData
(
LstHead
);
sts
=
plc_LoopWait
(
NULL
,
&
DeltaTime
,
&
NextTime
,
NULL
);
#else
StoreData
(
LstHead
);
for
(;;)
{
clock_gettime
(
CLOCK_REALTIME
,
&
CurrentTime
);
time_Aadd
(
&
NextScan
,
&
LastScan
,
&
ScanDeltaTime
);
if
(
time_Acomp
(
&
CurrentTime
,
&
NextScan
)
<
0
)
{
time_Adiff
(
&
WaitTime
,
&
NextScan
,
&
CurrentTime
);
nanosleep
((
struct
timespec
*
)
&
WaitTime
,
NULL
);
tmo
=
1000
*
time_DToFloat
(
0
,
&
WaitTime
);
get
.
maxSize
=
sizeof
(
mp
);
get
.
data
=
mp
;
qcom_Get
(
&
sts
,
&
qid
,
&
get
,
tmo
);
if
(
sts
==
QCOM__TMO
||
sts
==
QCOM__QEMPTY
)
{
if
(
!
swap
)
StoreData
(
LstHead
);
}
else
{
ini_mEvent
new_event
;
qcom_sEvent
*
ep
=
(
qcom_sEvent
*
)
get
.
data
;
new_event
.
m
=
ep
->
mask
;
if
(
new_event
.
b
.
oldPlcStop
&&
!
swap
)
{
swap
=
1
;
CloseTrendList
(
&
LstHead
);
}
else
if
(
new_event
.
b
.
swapDone
&&
swap
)
{
swap
=
0
;
sts
=
InitTrendList
(
ScanTime
,
&
LstHead
);
errh_Info
(
"Warm restart completed"
);
}
}
}
else
if
(
!
swap
)
StoreData
(
LstHead
);
LastScan
=
NextScan
;
#endif
}
return
1
;
...
...
@@ -172,21 +171,12 @@ int main (int argc, char **argv)
/* Set up subscriptions for every local DsTrend object and
initialize the DsTrend objects. */
static
pwr_tStatus
InitTrendList
(
pwr_tInt32
ScanTime
,
static
void
CloseTrendList
(
sLstNode
**
LstHead
)
{
sLstNode
*
LstNode
,
*
TmpNode
;
pwr_tStatus
sts
;
pwr_tUInt32
Dummy
;
pwr_tTypeId
Type
;
int
Tix
;
pwr_tObjid
ObjId
;
char
Name
[
81
];
pwr_sClass_DsTrend
*
Trend
;
/* Free old list */
...
...
@@ -199,6 +189,22 @@ InitTrendList (
free
(
TmpNode
);
}
*
LstHead
=
NULL
;
}
static
pwr_tStatus
InitTrendList
(
pwr_tInt32
ScanTime
,
sLstNode
**
LstHead
)
{
sLstNode
*
LstNode
;
pwr_tStatus
sts
;
pwr_tUInt32
Dummy
;
pwr_tTypeId
Type
;
int
Tix
;
pwr_tObjid
ObjId
;
char
Name
[
81
];
pwr_sClass_DsTrend
*
Trend
;
sts
=
gdh_GetClassList
(
pwr_cClass_DsTrend
,
&
ObjId
);
if
(
EVEN
(
sts
))
{
...
...
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