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
eaf77a39
Commit
eaf77a39
authored
Jul 08, 2004
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handling of swap and terminate event from Qcom added
parent
20cd46d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
51 deletions
+106
-51
nmps/exe/rs_nmps_bck/src/rs_nmps_bck.c
nmps/exe/rs_nmps_bck/src/rs_nmps_bck.c
+106
-51
No files found.
nmps/exe/rs_nmps_bck/src/rs_nmps_bck.c
View file @
eaf77a39
...
...
@@ -56,6 +56,7 @@
#include "pwr_nmpsclasses.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "rt_gdh_msg.h"
...
...
@@ -63,6 +64,9 @@
#include "rs_nmps.h"
#include "rs_nmps_msg.h"
#include "rs_sutl.h"
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#include "rt_ini_event.h"
/*_Globala variabler______________________________________________________*/
...
...
@@ -286,6 +290,7 @@ int nmpsbck_get_filename(
*
s
=
0
;
strcat
(
outname
,
ext
);
}
dcli_translate_filename
(
outname
,
outname
);
return
NMPS__SUCCESS
;
}
...
...
@@ -1092,7 +1097,7 @@ static pwr_tStatus nmpsbck_open_file( bck_ctx bckctx)
{
nmpsbck_t_fileheader
fileheader
;
pwr_tUInt32
csts
;
char
filename
[
8
0
];
char
filename
[
20
0
];
float
reopen_time
=
10
;
int
first_time
;
int
wait_some_time
;
...
...
@@ -1555,7 +1560,7 @@ static pwr_tStatus nmpsbck_read( bck_ctx bckctx)
nmpsbck_t_data_list
*
data_ptr
;
nmpsbck_t_data_list
*
next_ptr
;
char
*
objectp
;
char
filename
[
8
0
];
char
filename
[
20
0
];
int
file_num
=
1
;
int
record_count
;
pwr_tUInt32
cellarea_start
[
NMPSBCK_MAX_RECORDS
];
...
...
@@ -2393,13 +2398,38 @@ int main()
int
count
;
int
first_scan
=
1
;
int
file_reopen
=
0
;
qcom_sQid
qid
=
qcom_cNQid
;
qcom_sQattr
qAttr
;
qcom_sQid
qini
;
int
tmo
;
int
swap
=
0
;
char
mp
[
2000
];
qcom_sGet
get
;
errh_Init
(
"rs_nmps_bck"
,
0
);
if
(
!
qcom_Init
(
&
sts
,
0
,
"rs_nmps_bck"
))
{
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
);
}
/* Init pams and gdh */
sts
=
gdh_Init
(
"rs_nmps_bck"
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
for
(;;)
{
for
(;;)
{
bckctx
=
calloc
(
1
,
sizeof
(
*
bckctx
));
if
(
bckctx
==
0
)
return
NMPS__NOMEMORY
;
...
...
@@ -2408,13 +2438,11 @@ int main()
sts
=
nmps_get_bckconfig
(
bckctx
);
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
if
(
!
bckctx
->
bckconfig
->
NoRead
)
{
if
(
!
bckctx
->
bckconfig
->
NoRead
)
{
/* Restore the old backup file */
sts
=
nmpsbck_read
(
bckctx
);
}
else
{
else
{
/* Release the cells by setting backup done flag */
sts
=
nmpsbck_set_cell_backup_done
();
if
(
EVEN
(
sts
))
LogAndExit
(
sts
);
...
...
@@ -2428,58 +2456,85 @@ int main()
scantime
=
bckctx
->
bckconfig
->
IncrementCycleTime
;
full_scan
=
bckctx
->
bckconfig
->
FullCycleTime
/
scantime
+
FLT_EPSILON
;
tmo
=
(
int
)
scantime
*
1000
;
count
=
0
;
for
(;;)
{
count
++
;
if
(
count
>
full_scan
||
first_scan
||
file_reopen
||
bckctx
->
record_count
>=
NMPSBCK_MAX_RECORDS
-
1
||
bckctx
->
bckconfig
->
ForceFullBackup
)
{
/* Time for full backup */
if
(
bckctx
->
bckconfig
->
ForceFullBackup
)
bckctx
->
bckconfig
->
ForceFullBackup
=
0
;
bckctx
->
increment
=
0
;
count
=
0
;
/* Toggle file */
if
(
!
file_reopen
)
{
if
(
bckctx
->
file_num
==
1
)
bckctx
->
file_num
=
2
;
else
bckctx
->
file_num
=
1
;
for
(;;)
{
get
.
maxSize
=
sizeof
(
mp
);
get
.
data
=
mp
;
qcom_Get
(
&
sts
,
&
qid
,
&
get
,
tmo
);
if
(
sts
==
QCOM__TMO
||
sts
==
QCOM__QEMPTY
)
{
if
(
swap
)
continue
;
if
(
bckctx
->
bckconfig
->
Initialize
)
{
bckctx
->
bckconfig
->
Initialize
=
0
;
nmpsbck_free
(
bckctx
);
break
;
}
file_reopen
=
0
;
}
else
/* Incremental backup */
bckctx
->
increment
=
1
;
sts
=
nmpsbck_cell_handler
(
bckctx
);
if
(
sts
==
NMPS__FILEREOPEN
)
{
/* New file is opened, write a full backup */
file_reopen
=
1
;
continue
;
}
if
(
ODD
(
sts
))
bckctx
->
bckconfig
->
LoopCount
++
;
count
++
;
if
(
count
>
full_scan
||
first_scan
||
file_reopen
||
bckctx
->
record_count
>=
NMPSBCK_MAX_RECORDS
-
1
||
bckctx
->
bckconfig
->
ForceFullBackup
)
{
/* Time for full backup */
if
(
bckctx
->
bckconfig
->
ForceFullBackup
)
bckctx
->
bckconfig
->
ForceFullBackup
=
0
;
bckctx
->
increment
=
0
;
count
=
0
;
/* Toggle file */
if
(
!
file_reopen
)
{
if
(
bckctx
->
file_num
==
1
)
bckctx
->
file_num
=
2
;
else
bckctx
->
file_num
=
1
;
}
file_reopen
=
0
;
}
else
/* Incremental backup */
bckctx
->
increment
=
1
;
sts
=
nmpsbck_cell_handler
(
bckctx
);
if
(
sts
==
NMPS__FILEREOPEN
)
{
/* New file is opened, write a full backup */
file_reopen
=
1
;
continue
;
}
if
(
ODD
(
sts
))
bckctx
->
bckconfig
->
LoopCount
++
;
#if 0
else if (EVEN(sts)) LogAndExit( sts);
else if (EVEN(sts)) LogAndExit( sts);
#endif
sutl_sleep
(
scantime
);
if
(
bckctx
->
bckconfig
->
Initialize
)
{
bckctx
->
bckconfig
->
Initialize
=
0
;
nmpsbck_free
(
bckctx
);
break
;
// sutl_sleep( scantime);
first_scan
=
0
;
}
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
;
nmpsbck_free
(
bckctx
);
break
;
}
else
if
(
new_event
.
b
.
swapDone
&&
swap
)
{
swap
=
0
;
}
else
if
(
new_event
.
b
.
terminate
)
{
exit
(
0
);
}
}
first_scan
=
0
;
}
}
}
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