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
19383fbd
Commit
19383fbd
authored
Jun 03, 2020
by
Claes
Committed by
Esteban Blanc
Dec 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test log functions added
parent
273df1b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
235 additions
and
0 deletions
+235
-0
src/lib/co/src/co_tst_log.cpp
src/lib/co/src/co_tst_log.cpp
+121
-0
src/lib/co/src/co_tst_log.h
src/lib/co/src/co_tst_log.h
+73
-0
src/msg/co/src/co_tst_msg.msg
src/msg/co/src/co_tst_msg.msg
+40
-0
src/msg/used_facility_numbers.txt
src/msg/used_facility_numbers.txt
+1
-0
No files found.
src/lib/co/src/co_tst_log.cpp
0 → 100644
View file @
19383fbd
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2020 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include <stdio.h>
#include <stdarg.h>
#include "co_msg.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_tst_log.h"
void
tst_log
::
log
(
const
char
severity
,
const
char
*
text
,
pwr_tStatus
status
)
{
if
(
!
m_fp
)
return
;
char
msg
[
200
]
=
""
;
char
timstr
[
40
];
time_AtoAscii
(
0
,
time_eFormat_DateAndTime
,
timstr
,
sizeof
(
timstr
));
if
(
status
!=
0xffffffff
)
msg_GetMsg
(
status
,
msg
,
sizeof
(
msg
));
if
(
text
&&
strcmp
(
msg
,
""
)
!=
0
)
fprintf
(
m_fp
,
"%c %s %s, %s: %s
\n
"
,
severity
,
timstr
,
m_category
,
text
,
msg
);
else
if
(
text
)
fprintf
(
m_fp
,
"%c %s %s, %s
\n
"
,
severity
,
timstr
,
m_category
,
text
);
else
if
(
strcmp
(
msg
,
""
)
!=
0
)
fprintf
(
m_fp
,
"%c %s %s, %s
\n
"
,
severity
,
timstr
,
m_category
,
msg
);
else
fprintf
(
m_fp
,
"%c %s %s
\n
"
,
severity
,
timstr
,
m_category
);
}
void
tst_log
::
log
(
const
char
severity
,
const
char
*
text1
,
const
char
*
text2
,
pwr_tStatus
status
)
{
if
(
!
m_fp
)
return
;
char
msg
[
200
]
=
""
;
char
timstr
[
40
];
time_AtoAscii
(
0
,
time_eFormat_DateAndTime
,
timstr
,
sizeof
(
timstr
));
if
(
status
!=
0xffffffff
)
msg_GetMsg
(
status
,
msg
,
sizeof
(
msg
));
if
(
strcmp
(
msg
,
""
)
!=
0
)
fprintf
(
m_fp
,
"%c %s %s, %s, %s: %s
\n
"
,
severity
,
timstr
,
m_category
,
text1
,
text2
,
msg
);
else
fprintf
(
m_fp
,
"%c %s %s, %s, %s
\n
"
,
severity
,
timstr
,
m_category
,
text1
,
text2
);
}
void
tst_log
::
vlog
(
const
char
severity
,
const
char
*
format
,
...)
{
if
(
!
m_fp
)
return
;
va_list
ap
;
char
msg
[
200
];
char
timstr
[
40
];
time_AtoAscii
(
0
,
time_eFormat_DateAndTime
,
timstr
,
sizeof
(
timstr
));
va_start
(
ap
,
format
);
vsnprintf
(
msg
,
sizeof
(
msg
),
format
,
ap
);
va_end
(
ap
);
fprintf
(
m_fp
,
"%c %s %s, %s
\n
"
,
severity
,
timstr
,
m_category
,
msg
);
}
tst_log
::
tst_log
(
pwr_tStatus
*
sts
,
const
char
*
category
,
const
char
*
filename
)
{
*
sts
=
TST__SUCCESS
;
strncpy
(
m_category
,
category
,
sizeof
(
m_category
));
dcli_translate_filename
(
m_filename
,
filename
);
m_fp
=
fopen
(
m_filename
,
"w"
);
if
(
!
m_fp
)
*
sts
=
TST__OPENFILE
;
}
tst_log
::~
tst_log
()
{
if
(
m_fp
)
fclose
(
m_fp
);
}
src/lib/co/src/co_tst_log.h
0 → 100644
View file @
19383fbd
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2020 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef co_tst_log_h
#define co_tst_log_h
/* co_tst_log.h -- Log test results */
#if defined __cplusplus
extern
"C"
{
#endif
#include <string.h>
#include <stdio.h>
#include "pwr.h"
#include "co_cdh.h"
#include "co_tst_msg.h"
class
tst_log
{
pwr_tStatus
m_sts
;
pwr_tFileName
m_filename
;
char
m_category
[
80
];
FILE
*
m_fp
;
public:
tst_log
(
pwr_tStatus
*
sts
,
const
char
*
category
,
const
char
*
filename
);
~
tst_log
();
void
log
(
const
char
severity
,
const
char
*
text
,
pwr_tStatus
status
=
0xffffffff
);
void
log
(
const
char
severity
,
const
char
*
text1
,
const
char
*
text2
,
pwr_tStatus
status
=
0xffffffff
);
void
vlog
(
const
char
severity
,
const
char
*
format
,
...);
};
#if defined __cplusplus
}
#endif
#endif
src/msg/co/src/co_tst_msg.msg
0 → 100644
View file @
19383fbd
!
! ProviewR Open Source Process Control.
! Copyright (C) 2005-2020 SSAB EMEA AB.
!
! This file is part of ProviewR.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with ProviewR. If not, see <http://www.gnu.org/licenses/>
!
! Linking ProviewR statically or dynamically with other modules is
! making a combined work based on ProviewR. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! ProviewR give you permission to, from the build function in the
! ProviewR Configurator, combine ProviewR with modules generated by the
! ProviewR PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of ProviewR (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
.facility TST,29 /prefix = TST__ !
success <Successful completion> /succ
openfile <Unable to open file> /error
src/msg/used_facility_numbers.txt
View file @
19383fbd
...
...
@@ -18,6 +18,7 @@
26 SIM
27 REDU
28 MVA
29 TST
50 HD
100 CDH
101 TIME
...
...
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